aboutsummaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-05-05 10:08:56 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-11 21:36:06 -0400
commite5004753388dcf5e1b8a52ac0ab807d232340fbb (patch)
tree4a74a93f1468acb111ba9a3e9ed4a55f338f51fe /fs/super.c
parentf3da392e9ff14b9f388e74319e6d195848991c07 (diff)
cleanup sync_supers
Merge the write_super helper into sync_super and move the check for ->write_super earlier so that we can avoid grabbing a reference to a superblock that doesn't have it. While we're at it also add a little comment documenting sync_supers. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r--fs/super.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/fs/super.c b/fs/super.c
index d9a29d5b1d28..cb19fffc7681 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -399,16 +399,14 @@ void drop_super(struct super_block *sb)
399 399
400EXPORT_SYMBOL(drop_super); 400EXPORT_SYMBOL(drop_super);
401 401
402static inline void write_super(struct super_block *sb) 402/**
403{ 403 * sync_supers - helper for periodic superblock writeback
404 lock_super(sb); 404 *
405 if (sb->s_root && sb->s_dirt) 405 * Call the write_super method if present on all dirty superblocks in
406 if (sb->s_op->write_super) 406 * the system. This is for the periodic writeback used by most older
407 sb->s_op->write_super(sb); 407 * filesystems. For data integrity superblock writeback use
408 unlock_super(sb); 408 * sync_filesystems() instead.
409} 409 *
410
411/*
412 * Note: check the dirty flag before waiting, so we don't 410 * Note: check the dirty flag before waiting, so we don't
413 * hold up the sync while mounting a device. (The newly 411 * hold up the sync while mounting a device. (The newly
414 * mounted device won't need syncing.) 412 * mounted device won't need syncing.)
@@ -420,12 +418,17 @@ void sync_supers(void)
420 spin_lock(&sb_lock); 418 spin_lock(&sb_lock);
421restart: 419restart:
422 list_for_each_entry(sb, &super_blocks, s_list) { 420 list_for_each_entry(sb, &super_blocks, s_list) {
423 if (sb->s_dirt) { 421 if (sb->s_op->write_super && sb->s_dirt) {
424 sb->s_count++; 422 sb->s_count++;
425 spin_unlock(&sb_lock); 423 spin_unlock(&sb_lock);
424
426 down_read(&sb->s_umount); 425 down_read(&sb->s_umount);
427 write_super(sb); 426 lock_super(sb);
427 if (sb->s_root && sb->s_dirt)
428 sb->s_op->write_super(sb);
429 unlock_super(sb);
428 up_read(&sb->s_umount); 430 up_read(&sb->s_umount);
431
429 spin_lock(&sb_lock); 432 spin_lock(&sb_lock);
430 if (__put_super_and_need_restart(sb)) 433 if (__put_super_and_need_restart(sb))
431 goto restart; 434 goto restart;