diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-06-03 20:16:57 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-20 01:43:04 -0400 |
commit | 43e15cdbefea4ce6d68113de98d4f61c0cf45687 (patch) | |
tree | 75676aae179fc56bbb9d861c0ab656a9edaa7ca4 /fs | |
parent | 44396f4b5cb8566f7118aec55eeac99be7ad94cb (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')
-rw-r--r-- | fs/super.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fs/super.c b/fs/super.c index ab3d672db0de..444da9579068 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -452,6 +452,42 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) | |||
452 | } | 452 | } |
453 | 453 | ||
454 | /** | 454 | /** |
455 | * iterate_supers_type - call function for superblocks of given type | ||
456 | * @type: fs type | ||
457 | * @f: function to call | ||
458 | * @arg: argument to pass to it | ||
459 | * | ||
460 | * Scans the superblock list and calls given function, passing it | ||
461 | * locked superblock and given argument. | ||
462 | */ | ||
463 | void iterate_supers_type(struct file_system_type *type, | ||
464 | void (*f)(struct super_block *, void *), void *arg) | ||
465 | { | ||
466 | struct super_block *sb, *p = NULL; | ||
467 | |||
468 | spin_lock(&sb_lock); | ||
469 | list_for_each_entry(sb, &type->fs_supers, s_instances) { | ||
470 | sb->s_count++; | ||
471 | spin_unlock(&sb_lock); | ||
472 | |||
473 | down_read(&sb->s_umount); | ||
474 | if (sb->s_root) | ||
475 | f(sb, arg); | ||
476 | up_read(&sb->s_umount); | ||
477 | |||
478 | spin_lock(&sb_lock); | ||
479 | if (p) | ||
480 | __put_super(p); | ||
481 | p = sb; | ||
482 | } | ||
483 | if (p) | ||
484 | __put_super(p); | ||
485 | spin_unlock(&sb_lock); | ||
486 | } | ||
487 | |||
488 | EXPORT_SYMBOL(iterate_supers_type); | ||
489 | |||
490 | /** | ||
455 | * get_super - get the superblock of a device | 491 | * get_super - get the superblock of a device |
456 | * @bdev: device to get the superblock for | 492 | * @bdev: device to get the superblock for |
457 | * | 493 | * |