aboutsummaryrefslogtreecommitdiff
path: root/fs/ext3/fsync.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3/fsync.c')
-rw-r--r--fs/ext3/fsync.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/fs/ext3/fsync.c b/fs/ext3/fsync.c
index 0bcf63adb80..1cb9c7e10c6 100644
--- a/fs/ext3/fsync.c
+++ b/fs/ext3/fsync.c
@@ -22,14 +22,9 @@
* we can depend on generic_block_fdatasync() to sync the data blocks.
*/
-#include <linux/time.h>
#include <linux/blkdev.h>
-#include <linux/fs.h>
-#include <linux/sched.h>
#include <linux/writeback.h>
-#include <linux/jbd.h>
-#include <linux/ext3_fs.h>
-#include <linux/ext3_jbd.h>
+#include "ext3.h"
/*
* akpm: A new design for ext3_sync_file().
@@ -51,19 +46,18 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
int ret, needs_barrier = 0;
tid_t commit_tid;
- if (inode->i_sb->s_flags & MS_RDONLY)
- return 0;
+ trace_ext3_sync_file_enter(file, datasync);
+ if (inode->i_sb->s_flags & MS_RDONLY) {
+ /* Make sure that we read updated state */
+ smp_rmb();
+ if (EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ERROR_FS)
+ return -EROFS;
+ return 0;
+ }
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (ret)
- return ret;
-
- /*
- * Taking the mutex here just to keep consistent with how fsync was
- * called previously, however it looks like we don't need to take
- * i_mutex at all.
- */
- mutex_lock(&inode->i_mutex);
+ goto out;
J_ASSERT(ext3_journal_current_handle() == NULL);
@@ -82,8 +76,8 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* safe in-journal, which is all fsync() needs to ensure.
*/
if (ext3_should_journal_data(inode)) {
- mutex_unlock(&inode->i_mutex);
- return ext3_force_commit(inode->i_sb);
+ ret = ext3_force_commit(inode->i_sb);
+ goto out;
}
if (datasync)
@@ -102,8 +96,14 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* disk caches manually so that data really is on persistent
* storage
*/
- if (needs_barrier)
- blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
- mutex_unlock(&inode->i_mutex);
+ if (needs_barrier) {
+ int err;
+
+ err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
+ if (!ret)
+ ret = err;
+ }
+out:
+ trace_ext3_sync_file_exit(inode, ret);
return ret;
}