diff options
Diffstat (limited to 'fs/nilfs2/file.c')
-rw-r--r-- | fs/nilfs2/file.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index 26601529dc17..62cebc8e1a1f 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c | |||
@@ -37,6 +37,7 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | |||
37 | * This function should be implemented when the writeback function | 37 | * This function should be implemented when the writeback function |
38 | * will be implemented. | 38 | * will be implemented. |
39 | */ | 39 | */ |
40 | struct the_nilfs *nilfs; | ||
40 | struct inode *inode = file->f_mapping->host; | 41 | struct inode *inode = file->f_mapping->host; |
41 | int err; | 42 | int err; |
42 | 43 | ||
@@ -45,18 +46,21 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | |||
45 | return err; | 46 | return err; |
46 | mutex_lock(&inode->i_mutex); | 47 | mutex_lock(&inode->i_mutex); |
47 | 48 | ||
48 | if (!nilfs_inode_dirty(inode)) { | 49 | if (nilfs_inode_dirty(inode)) { |
49 | mutex_unlock(&inode->i_mutex); | 50 | if (datasync) |
50 | return 0; | 51 | err = nilfs_construct_dsync_segment(inode->i_sb, inode, |
52 | 0, LLONG_MAX); | ||
53 | else | ||
54 | err = nilfs_construct_segment(inode->i_sb); | ||
51 | } | 55 | } |
52 | |||
53 | if (datasync) | ||
54 | err = nilfs_construct_dsync_segment(inode->i_sb, inode, 0, | ||
55 | LLONG_MAX); | ||
56 | else | ||
57 | err = nilfs_construct_segment(inode->i_sb); | ||
58 | |||
59 | mutex_unlock(&inode->i_mutex); | 56 | mutex_unlock(&inode->i_mutex); |
57 | |||
58 | nilfs = inode->i_sb->s_fs_info; | ||
59 | if (!err && nilfs_test_opt(nilfs, BARRIER)) { | ||
60 | err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); | ||
61 | if (err != -EIO) | ||
62 | err = 0; | ||
63 | } | ||
60 | return err; | 64 | return err; |
61 | } | 65 | } |
62 | 66 | ||