mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Jens Axboe <axboe@fb.com>, Tejun Heo <tj@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] block: turn Oops into WARNING if bdi_register_dev fails.
Date: Mon, 27 Apr 2015 15:19:31 +1000	[thread overview]
Message-ID: <20150427151931.7a43ecc6@notabene.brown> (raw)

[-- 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 --]

             reply	other threads:[~2015-04-27  5:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27  5:19 NeilBrown [this message]
2015-04-27 13:04 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150427151931.7a43ecc6@notabene.brown \
    --to=neilb@suse.de \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®