summaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2010-03-23 06:06:58 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-05-21 18:31:16 -0400
commit01a05b337a5b647909e1d6670f57e7202318a5fb (patch)
tree7877f08db14877d06346c8e1ef52aa17f2483e93 /fs/super.c
parent35cf7ba0b46dc3582a01c3860b14bff122662aa3 (diff)
downloadlinux-stable-01a05b337a5b647909e1d6670f57e7202318a5fb.tar.gz
linux-stable-01a05b337a5b647909e1d6670f57e7202318a5fb.tar.bz2
linux-stable-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.c30
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
*