aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/the_nilfs.h
diff options
context:
space:
mode:
authorAndreas Rohner <andreas.rohner@gmx.net>2014-10-13 18:53:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 20:18:20 -0400
commite2c7617ae36b27f97643bfa08aabe27e630c1a76 (patch)
tree306dc0642ffbd8c4f837b7fbae960a49116053e6 /fs/nilfs2/the_nilfs.h
parent0f2a84f41aff6cefd1bc768738159d0cacea2f2d (diff)
nilfs2: add missing blkdev_issue_flush() to nilfs_sync_fs()
Under normal circumstances nilfs_sync_fs() writes out the super block, which causes a flush of the underlying block device. But this depends on the THE_NILFS_SB_DIRTY flag, which is only set if the pointer to the last segment crosses a segment boundary. So if only a small amount of data is written before the call to nilfs_sync_fs(), no flush of the block device occurs. In the above case an additional call to blkdev_issue_flush() is needed. To prevent unnecessary overhead, the new flag nilfs->ns_flushed_device is introduced, which is cleared whenever new logs are written and set whenever the block device is flushed. For convenience the function nilfs_flush_device() is added, which contains the above logic. Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net> Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nilfs2/the_nilfs.h')
-rw-r--r--fs/nilfs2/the_nilfs.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index d01ead1bea9a..23778d385836 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -46,6 +46,7 @@ enum {
46/** 46/**
47 * struct the_nilfs - struct to supervise multiple nilfs mount points 47 * struct the_nilfs - struct to supervise multiple nilfs mount points
48 * @ns_flags: flags 48 * @ns_flags: flags
49 * @ns_flushed_device: flag indicating if all volatile data was flushed
49 * @ns_bdev: block device 50 * @ns_bdev: block device
50 * @ns_sem: semaphore for shared states 51 * @ns_sem: semaphore for shared states
51 * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts 52 * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts
@@ -103,6 +104,7 @@ enum {
103 */ 104 */
104struct the_nilfs { 105struct the_nilfs {
105 unsigned long ns_flags; 106 unsigned long ns_flags;
107 int ns_flushed_device;
106 108
107 struct block_device *ns_bdev; 109 struct block_device *ns_bdev;
108 struct rw_semaphore ns_sem; 110 struct rw_semaphore ns_sem;
@@ -371,4 +373,24 @@ static inline int nilfs_segment_is_active(struct the_nilfs *nilfs, __u64 n)
371 return n == nilfs->ns_segnum || n == nilfs->ns_nextnum; 373 return n == nilfs->ns_segnum || n == nilfs->ns_nextnum;
372} 374}
373 375
376static inline int nilfs_flush_device(struct the_nilfs *nilfs)
377{
378 int err;
379
380 if (!nilfs_test_opt(nilfs, BARRIER) || nilfs->ns_flushed_device)
381 return 0;
382
383 nilfs->ns_flushed_device = 1;
384 /*
385 * the store to ns_flushed_device must not be reordered after
386 * blkdev_issue_flush().
387 */
388 smp_wmb();
389
390 err = blkdev_issue_flush(nilfs->ns_bdev, GFP_KERNEL, NULL);
391 if (err != -EIO)
392 err = 0;
393 return err;
394}
395
374#endif /* _THE_NILFS_H */ 396#endif /* _THE_NILFS_H */