linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, jejb@linux.ibm.com, martin.petersen@oracle.com,
	agk@redhat.com, snitzer@redhat.com, colyli@suse.de,
	kent.overstreet@gmail.com, boris.ostrovsky@oracle.com,
	jgross@suse.com, sstabellini@kernel.org, roger.pau@citrix.com,
	geert@linux-m68k.org, ulf.hansson@linaro.org, tj@kernel.org,
	hare@suse.de, jdike@addtoit.com, richard@nod.at,
	anton.ivanov@cambridgegreys.com, johannes.berg@intel.com,
	krisman@collabora.com, chris.obbard@collabora.com,
	thehajime@gmail.com, zhuyifei1999@gmail.com,
	haris.iqbal@ionos.com, jinpu.wang@ionos.com,
	miquel.raynal@bootlin.com, vigneshr@ti.com,
	linux-mtd@lists.infradead.org
Cc: linux-scsi@vger.kernel.org, dm-devel@redhat.com,
	linux-bcache@vger.kernel.org, xen-devel@lists.xenproject.org,
	linux-m68k@lists.linux-m68k.org, linux-um@lists.infradead.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 4/9] bcache: add error handling support for add_disk()
Date: Fri, 15 Oct 2021 16:30:23 -0700	[thread overview]
Message-ID: <20211015233028.2167651-5-mcgrof@kernel.org> (raw)
In-Reply-To: <20211015233028.2167651-1-mcgrof@kernel.org>

We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.

This driver doesn't do any unwinding with blk_cleanup_disk()
even on errors after add_disk() and so we follow that
tradition.

Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/md/bcache/super.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index f2874c77ff79..f0c32cdd6594 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1082,7 +1082,9 @@ int bch_cached_dev_run(struct cached_dev *dc)
 		closure_sync(&cl);
 	}
 
-	add_disk(d->disk);
+	ret = add_disk(d->disk);
+	if (ret)
+		goto out;
 	bd_link_disk_holder(dc->bdev, dc->disk.disk);
 	/*
 	 * won't show up in the uevent file, use udevadm monitor -e instead
@@ -1534,10 +1536,11 @@ static void flash_dev_flush(struct closure *cl)
 
 static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
 {
+	int err = -ENOMEM;
 	struct bcache_device *d = kzalloc(sizeof(struct bcache_device),
 					  GFP_KERNEL);
 	if (!d)
-		return -ENOMEM;
+		goto err_ret;
 
 	closure_init(&d->cl, NULL);
 	set_closure_fn(&d->cl, flash_dev_flush, system_wq);
@@ -1551,9 +1554,12 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
 	bcache_device_attach(d, c, u - c->uuids);
 	bch_sectors_dirty_init(d);
 	bch_flash_dev_request_init(d);
-	add_disk(d->disk);
+	err = add_disk(d->disk);
+	if (err)
+		goto err;
 
-	if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache"))
+	err = kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache");
+	if (err)
 		goto err;
 
 	bcache_device_link(d, c, "volume");
@@ -1567,7 +1573,8 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
 	return 0;
 err:
 	kobject_put(&d->kobj);
-	return -ENOMEM;
+err_ret:
+	return err;
 }
 
 static int flash_devs_run(struct cache_set *c)
-- 
2.30.2


  parent reply	other threads:[~2021-10-15 23:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 23:30 [PATCH 0/9] block: reviewed add_disk() error handling set Luis Chamberlain
2021-10-15 23:30 ` [PATCH 1/9] scsi/sd: add error handling support for add_disk() Luis Chamberlain
2021-10-17  2:51   ` Martin K. Petersen
2021-10-18 20:31     ` Luis Chamberlain
2021-10-19  2:52       ` Martin K. Petersen
2021-10-15 23:30 ` [PATCH 2/9] scsi/sr: " Luis Chamberlain
2021-10-17  2:53   ` Martin K. Petersen
2021-10-15 23:30 ` [PATCH 3/9] dm: add add_disk() error handling Luis Chamberlain
2021-10-15 23:30 ` Luis Chamberlain [this message]
2021-10-15 23:30 ` [PATCH 5/9] xen-blkfront: add error handling support for add_disk() Luis Chamberlain
2021-10-15 23:30 ` [PATCH 6/9] m68k/emu/nfblock: " Luis Chamberlain
2021-10-15 23:30 ` [PATCH 7/9] um/drivers/ubd_kern: " Luis Chamberlain
2021-10-15 23:30 ` [PATCH 8/9] rnbd: " Luis Chamberlain
2021-10-15 23:30 ` [PATCH 9/9] mtd: add add_disk() error handling Luis Chamberlain
2021-10-21  3:42 ` [PATCH 0/9] block: reviewed add_disk() error handling set Martin K. Petersen
2021-10-21 15:01 ` (subset) " Jens Axboe

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=20211015233028.2167651-5-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=agk@redhat.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=axboe@kernel.dk \
    --cc=boris.ostrovsky@oracle.com \
    --cc=chris.obbard@collabora.com \
    --cc=colyli@suse.de \
    --cc=dm-devel@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=hare@suse.de \
    --cc=haris.iqbal@ionos.com \
    --cc=jdike@addtoit.com \
    --cc=jejb@linux.ibm.com \
    --cc=jgross@suse.com \
    --cc=jinpu.wang@ionos.com \
    --cc=johannes.berg@intel.com \
    --cc=kent.overstreet@gmail.com \
    --cc=krisman@collabora.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=roger.pau@citrix.com \
    --cc=snitzer@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=thehajime@gmail.com \
    --cc=tj@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vigneshr@ti.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=zhuyifei1999@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).