mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] block: turn Oops into WARNING if bdi_register_dev fails.
@ 2015-04-27  5:19 NeilBrown
  2015-04-27 13:04 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2015-04-27  5:19 UTC (permalink / raw)
  To: Jens Axboe, Tejun Heo; +Cc: Christoph Hellwig, lkml

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]


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.

Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/block/genhd.c b/block/genhd.c
index 0a536dc05f3b..e351fc521053 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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);

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: turn Oops into WARNING if bdi_register_dev fails.
  2015-04-27  5:19 [PATCH] block: turn Oops into WARNING if bdi_register_dev fails NeilBrown
@ 2015-04-27 13:04 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2015-04-27 13:04 UTC (permalink / raw)
  To: NeilBrown; +Cc: Jens Axboe, Tejun Heo, Christoph Hellwig, lkml, viro

On Mon, Apr 27, 2015 at 03:19:31PM +1000, NeilBrown wrote:
> 
> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-27 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-27  5:19 [PATCH] block: turn Oops into WARNING if bdi_register_dev fails NeilBrown
2015-04-27 13:04 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®