block: turn Oops into WARNING if bdi_register_dev fails.
PATCH 1/1 block: turn Oops into WARNING if bdi_register_dev fails.
add_disk() does not return an error status, but it can still fail if there are problems elsewhere.
In particular a recent problem caused bdi_register_dev() to sometimes fail because the name was already in use.
In that case bdi->dev is NULL, so
retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj, "bdi");
triggers an oops, after having already produced warnings.
This patch causes add_disk() to WARN and return if bdi_register_dev() fails, much like it already does if blk_alloc_devt() fails.
This should make no difference on a correctly functioning system, but can make a developers life a bit easier.
block/genhd.c +4 -0
@@ -612,6 +612,10 @@ void add_disk(struct gendisk *disk)/* Register BDI before referencing it from bdev */ bdi = &disk->queue->backing_dev_info;bdi_register_dev (bdi,disk_devt (disk)); +if (!bdi->dev) { +WARN_ON (1 ); +return ; + }blk_register_region (disk_devt (disk), disk->minors,NULL , exact_match, exact_lock, disk);
Quoted 6 lines · NeilBrown
add_disk()does not return an error status, but it can still fail if there are problems elsewhere.In particular a recent problem caused
bdi_register_dev()to sometimes fail because the name was already in use.
I guess that's the best workaround for now, but we'll really need to tackle the problem that add_disk can return errors proper eventually.