mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
fs: Provide infrastructure for dynamic BDIs in filesystems
Provide helper functions for setting up dynamically allocated backing_dev_info structures for filesystems and cleaning them up on superblock destruction. CC: [email protected] CC: [email protected] CC: Petr Vandrovec <[email protected]> CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
62bf42adc4
commit
fca39346a5
3 changed files with 56 additions and 1 deletions
49
fs/super.c
49
fs/super.c
|
|
@ -446,6 +446,11 @@ void generic_shutdown_super(struct super_block *sb)
|
|||
hlist_del_init(&sb->s_instances);
|
||||
spin_unlock(&sb_lock);
|
||||
up_write(&sb->s_umount);
|
||||
if (sb->s_iflags & SB_I_DYNBDI) {
|
||||
bdi_put(sb->s_bdi);
|
||||
sb->s_bdi = &noop_backing_dev_info;
|
||||
sb->s_iflags &= ~SB_I_DYNBDI;
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(generic_shutdown_super);
|
||||
|
|
@ -1255,6 +1260,50 @@ out:
|
|||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup private BDI for given superblock. It gets automatically cleaned up
|
||||
* in generic_shutdown_super().
|
||||
*/
|
||||
int super_setup_bdi_name(struct super_block *sb, char *fmt, ...)
|
||||
{
|
||||
struct backing_dev_info *bdi;
|
||||
int err;
|
||||
va_list args;
|
||||
|
||||
bdi = bdi_alloc(GFP_KERNEL);
|
||||
if (!bdi)
|
||||
return -ENOMEM;
|
||||
|
||||
bdi->name = sb->s_type->name;
|
||||
|
||||
va_start(args, fmt);
|
||||
err = bdi_register_va(bdi, NULL, fmt, args);
|
||||
va_end(args);
|
||||
if (err) {
|
||||
bdi_put(bdi);
|
||||
return err;
|
||||
}
|
||||
WARN_ON(sb->s_bdi != &noop_backing_dev_info);
|
||||
sb->s_bdi = bdi;
|
||||
sb->s_iflags |= SB_I_DYNBDI;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(super_setup_bdi_name);
|
||||
|
||||
/*
|
||||
* Setup private BDI for given superblock. I gets automatically cleaned up
|
||||
* in generic_shutdown_super().
|
||||
*/
|
||||
int super_setup_bdi(struct super_block *sb)
|
||||
{
|
||||
static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
|
||||
|
||||
return super_setup_bdi_name(sb, "%.28s-%ld", sb->s_type->name,
|
||||
atomic_long_inc_return(&bdi_seq));
|
||||
}
|
||||
EXPORT_SYMBOL(super_setup_bdi);
|
||||
|
||||
/*
|
||||
* This is an internal function, please use sb_end_{write,pagefault,intwrite}
|
||||
* instead.
|
||||
|
|
|
|||
Loading…
Reference in a new issue