Re: [PATCH 4/4] block: add WARN_ON if bdi register fail
On Mon, Oct 30, 2017 at 02:14:30PM +0100, Jan Kara wrote: > On Fri 27-10-17 01:36:42, weiping zhang wrote: > > device_add_disk need do more safety error handle, so this patch just > > add WARN_ON. > > > > Signed-off-by: weiping zhang > > --- > > block/genhd.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/block/genhd.c b/block/genhd.c > > index dd305c65ffb0..cb55eea821eb 100644 > > --- a/block/genhd.c > > +++ b/block/genhd.c > > @@ -660,7 +660,9 @@ void device_add_disk(struct device *parent, struct > > gendisk *disk) > > > > /* Register BDI before referencing it from bdev */ > > bdi = disk->queue->backing_dev_info; > > - bdi_register_owner(bdi, disk_to_dev(disk)); > > + retval = bdi_register_owner(bdi, disk_to_dev(disk)); > > + if (retval) > > + WARN_ON(1); > > Just a nit: You can do > > WARN_ON(retval); > > Otherwise you can add: > > Reviewed-by: Jan Kara > more claner, I'll apply at V2, Thanks -- weiping
Re: [PATCH 4/4] block: add WARN_ON if bdi register fail
On Fri 27-10-17 01:36:42, weiping zhang wrote: > device_add_disk need do more safety error handle, so this patch just > add WARN_ON. > > Signed-off-by: weiping zhang > --- > block/genhd.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/block/genhd.c b/block/genhd.c > index dd305c65ffb0..cb55eea821eb 100644 > --- a/block/genhd.c > +++ b/block/genhd.c > @@ -660,7 +660,9 @@ void device_add_disk(struct device *parent, struct > gendisk *disk) > > /* Register BDI before referencing it from bdev */ > bdi = disk->queue->backing_dev_info; > - bdi_register_owner(bdi, disk_to_dev(disk)); > + retval = bdi_register_owner(bdi, disk_to_dev(disk)); > + if (retval) > + WARN_ON(1); Just a nit: You can do WARN_ON(retval); Otherwise you can add: Reviewed-by: Jan Kara Honza -- Jan Kara SUSE Labs, CR
[PATCH 4/4] block: add WARN_ON if bdi register fail
device_add_disk need do more safety error handle, so this patch just add WARN_ON. Signed-off-by: weiping zhang --- block/genhd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index dd305c65ffb0..cb55eea821eb 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -660,7 +660,9 @@ void device_add_disk(struct device *parent, struct gendisk *disk) /* Register BDI before referencing it from bdev */ bdi = disk->queue->backing_dev_info; - bdi_register_owner(bdi, disk_to_dev(disk)); + retval = bdi_register_owner(bdi, disk_to_dev(disk)); + if (retval) + WARN_ON(1); blk_register_region(disk_devt(disk), disk->minors, NULL, exact_match, exact_lock, disk); -- 2.14.2