mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
new helper: iterate_supers()
... and switch the simple "loop over superblocks and do something" loops to it. Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
35cf7ba0b4
commit
01a05b337a
6 changed files with 56 additions and 82 deletions
30
fs/super.c
30
fs/super.c
|
|
@ -391,6 +391,36 @@ void sync_supers(void)
|
|||
spin_unlock(&sb_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue