diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-03-23 11:06:58 +0100 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-22 00:31:16 +0200 |
commit | 01a05b337a5b647909e1d6670f57e7202318a5fb (patch) | |
tree | 7877f08db14877d06346c8e1ef52aa17f2483e93 /fs/super.c | |
parent | Bury __put_super_and_need_restart() (diff) | |
download | linux-01a05b337a5b647909e1d6670f57e7202318a5fb.tar.xz linux-01a05b337a5b647909e1d6670f57e7202318a5fb.zip |
new helper: iterate_supers()
... and switch the simple "loop over superblocks and do something"
loops to it.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/super.c b/fs/super.c index 95adbb3d8e58..2c3e370c60d9 100644 --- a/fs/super.c +++ b/fs/super.c @@ -392,6 +392,36 @@ void sync_supers(void) } /** + * iterate_supers - call function for all active superblocks + * @f: function to call + * @arg: argument to pass to it + * + * Scans the superblock list and calls given function, passing it + * locked superblock and given argument. + */ +void iterate_supers(void (*f)(struct super_block *, void *), void *arg) +{ + struct super_block *sb, *n; + + spin_lock(&sb_lock); + list_for_each_entry_safe(sb, n, &super_blocks, s_list) { + if (list_empty(&sb->s_instances)) + continue; + sb->s_count++; + spin_unlock(&sb_lock); + + down_read(&sb->s_umount); + if (sb->s_root) + f(sb, arg); + up_read(&sb->s_umount); + + spin_lock(&sb_lock); + __put_super(sb); + } + spin_unlock(&sb_lock); +} + +/** * get_super - get the superblock of a device * @bdev: device to get the superblock for * |