diff options
Diffstat (limited to 'fs/nilfs2/file.c')
-rw-r--r-- | fs/nilfs2/file.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index d7eeca62febd..26601529dc17 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "nilfs.h" | 27 | #include "nilfs.h" |
28 | #include "segment.h" | 28 | #include "segment.h" |
29 | 29 | ||
30 | int nilfs_sync_file(struct file *file, int datasync) | 30 | int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) |
31 | { | 31 | { |
32 | /* | 32 | /* |
33 | * Called from fsync() system call | 33 | * Called from fsync() system call |
@@ -40,8 +40,15 @@ int nilfs_sync_file(struct file *file, int datasync) | |||
40 | struct inode *inode = file->f_mapping->host; | 40 | struct inode *inode = file->f_mapping->host; |
41 | int err; | 41 | int err; |
42 | 42 | ||
43 | if (!nilfs_inode_dirty(inode)) | 43 | err = filemap_write_and_wait_range(inode->i_mapping, start, end); |
44 | if (err) | ||
45 | return err; | ||
46 | mutex_lock(&inode->i_mutex); | ||
47 | |||
48 | if (!nilfs_inode_dirty(inode)) { | ||
49 | mutex_unlock(&inode->i_mutex); | ||
44 | return 0; | 50 | return 0; |
51 | } | ||
45 | 52 | ||
46 | if (datasync) | 53 | if (datasync) |
47 | err = nilfs_construct_dsync_segment(inode->i_sb, inode, 0, | 54 | err = nilfs_construct_dsync_segment(inode->i_sb, inode, 0, |
@@ -49,6 +56,7 @@ int nilfs_sync_file(struct file *file, int datasync) | |||
49 | else | 56 | else |
50 | err = nilfs_construct_segment(inode->i_sb); | 57 | err = nilfs_construct_segment(inode->i_sb); |
51 | 58 | ||
59 | mutex_unlock(&inode->i_mutex); | ||
52 | return err; | 60 | return err; |
53 | } | 61 | } |
54 | 62 | ||