aboutsummaryrefslogtreecommitdiff
path: root/fs/super.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-03 20:16:57 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:43:04 -0400
commit43e15cdbefea4ce6d68113de98d4f61c0cf45687 (patch)
tree75676aae179fc56bbb9d861c0ab656a9edaa7ca4 /fs/super.c
parent44396f4b5cb8566f7118aec55eeac99be7ad94cb (diff)
new helper: iterate_supers_type()
Call the given function for all superblocks of given type. Function gets a superblock (with s_umount locked shared) and (void *) argument supplied by caller of iterator. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r--fs/super.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/fs/super.c b/fs/super.c
index ab3d672db0d..444da957906 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -452,6 +452,42 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg)
}
/**
+ * iterate_supers_type - call function for superblocks of given type
+ * @type: fs type
+ * @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_type(struct file_system_type *type,
+ void (*f)(struct super_block *, void *), void *arg)
+{
+ struct super_block *sb, *p = NULL;
+
+ spin_lock(&sb_lock);
+ list_for_each_entry(sb, &type->fs_supers, s_instances) {
+ 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);
+ if (p)
+ __put_super(p);
+ p = sb;
+ }
+ if (p)
+ __put_super(p);
+ spin_unlock(&sb_lock);
+}
+
+EXPORT_SYMBOL(iterate_supers_type);
+
+/**
* get_super - get the superblock of a device
* @bdev: device to get the superblock for
*