bdi: add error handle for bdi_debug_register

In order to make error handle more cleaner we call bdi_debug_register
before set state to WB_registered, that we can avoid call bdi_unregister
in release_bdi().

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
weiping zhang 2017-11-17 23:06:04 +08:00 committed by Jens Axboe
parent 97f0769793
commit a0747a859e

View File

@ -882,10 +882,13 @@ int bdi_register_va(struct backing_dev_info *bdi, const char *fmt, va_list args)
if (IS_ERR(dev))
return PTR_ERR(dev);
if (bdi_debug_register(bdi, dev_name(dev))) {
device_destroy(bdi_class, dev->devt);
return -ENOMEM;
}
cgwb_bdi_register(bdi);
bdi->dev = dev;
bdi_debug_register(bdi, dev_name(dev));
set_bit(WB_registered, &bdi->wb.state);
spin_lock_bh(&bdi_lock);