Commit e5004753 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f3da392e
...@@ -399,16 +399,14 @@ void drop_super(struct super_block *sb) ...@@ -399,16 +399,14 @@ void drop_super(struct super_block *sb)
EXPORT_SYMBOL(drop_super); EXPORT_SYMBOL(drop_super);
static inline void write_super(struct super_block *sb) /**
{ * sync_supers - helper for periodic superblock writeback
lock_super(sb); *
if (sb->s_root && sb->s_dirt) * Call the write_super method if present on all dirty superblocks in
if (sb->s_op->write_super) * the system. This is for the periodic writeback used by most older
sb->s_op->write_super(sb); * filesystems. For data integrity superblock writeback use
unlock_super(sb); * sync_filesystems() instead.
} *
/*
* Note: check the dirty flag before waiting, so we don't * Note: check the dirty flag before waiting, so we don't
* hold up the sync while mounting a device. (The newly * hold up the sync while mounting a device. (The newly
* mounted device won't need syncing.) * mounted device won't need syncing.)
...@@ -420,12 +418,17 @@ void sync_supers(void) ...@@ -420,12 +418,17 @@ void sync_supers(void)
spin_lock(&sb_lock); spin_lock(&sb_lock);
restart: restart:
list_for_each_entry(sb, &super_blocks, s_list) { list_for_each_entry(sb, &super_blocks, s_list) {
if (sb->s_dirt) { if (sb->s_op->write_super && sb->s_dirt) {
sb->s_count++; sb->s_count++;
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
down_read(&sb->s_umount); down_read(&sb->s_umount);
write_super(sb); lock_super(sb);
if (sb->s_root && sb->s_dirt)
sb->s_op->write_super(sb);
unlock_super(sb);
up_read(&sb->s_umount); up_read(&sb->s_umount);
spin_lock(&sb_lock); spin_lock(&sb_lock);
if (__put_super_and_need_restart(sb)) if (__put_super_and_need_restart(sb))
goto restart; goto restart;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment