diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-03-23 06:06:58 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 18:31:16 -0400 |
commit | 01a05b337a5b647909e1d6670f57e7202318a5fb (patch) | |
tree | 7877f08db14877d06346c8e1ef52aa17f2483e93 /fs/super.c | |
parent | 35cf7ba0b46dc3582a01c3860b14bff122662aa3 (diff) |
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) | |||
392 | } | 392 | } |
393 | 393 | ||
394 | /** | 394 | /** |
395 | * iterate_supers - call function for all active superblocks | ||
396 | * @f: function to call | ||
397 | * @arg: argument to pass to it | ||
398 | * | ||
399 | * Scans the superblock list and calls given function, passing it | ||
400 | * locked superblock and given argument. | ||
401 | */ | ||
402 | void iterate_supers(void (*f)(struct super_block *, void *), void *arg) | ||
403 | { | ||
404 | struct super_block *sb, *n; | ||
405 | |||
406 | spin_lock(&sb_lock); | ||
407 | list_for_each_entry_safe(sb, n, &super_blocks, s_list) { | ||
408 | if (list_empty(&sb->s_instances)) | ||
409 | continue; | ||
410 | sb->s_count++; | ||
411 | spin_unlock(&sb_lock); | ||
412 | |||
413 | down_read(&sb->s_umount); | ||
414 | if (sb->s_root) | ||
415 | f(sb, arg); | ||
416 | up_read(&sb->s_umount); | ||
417 | |||
418 | spin_lock(&sb_lock); | ||
419 | __put_super(sb); | ||
420 | } | ||
421 | spin_unlock(&sb_lock); | ||
422 | } | ||
423 | |||
424 | /** | ||
395 | * get_super - get the superblock of a device | 425 | * get_super - get the superblock of a device |
396 | * @bdev: device to get the superblock for | 426 | * @bdev: device to get the superblock for |
397 | * | 427 | * |