[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211015233028.2167651-9-mcgrof@kernel.org>
Date: Fri, 15 Oct 2021 16:30:27 -0700
From: Luis Chamberlain <mcgrof@...nel.org>
To: axboe@...nel.dk, jejb@...ux.ibm.com, martin.petersen@...cle.com,
agk@...hat.com, snitzer@...hat.com, colyli@...e.de,
kent.overstreet@...il.com, boris.ostrovsky@...cle.com,
jgross@...e.com, sstabellini@...nel.org, roger.pau@...rix.com,
geert@...ux-m68k.org, ulf.hansson@...aro.org, tj@...nel.org,
hare@...e.de, jdike@...toit.com, richard@....at,
anton.ivanov@...bridgegreys.com, johannes.berg@...el.com,
krisman@...labora.com, chris.obbard@...labora.com,
thehajime@...il.com, zhuyifei1999@...il.com, haris.iqbal@...os.com,
jinpu.wang@...os.com, miquel.raynal@...tlin.com, vigneshr@...com,
linux-mtd@...ts.infradead.org
Cc: linux-scsi@...r.kernel.org, dm-devel@...hat.com,
linux-bcache@...r.kernel.org, xen-devel@...ts.xenproject.org,
linux-m68k@...ts.linux-m68k.org, linux-um@...ts.infradead.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
Luis Chamberlain <mcgrof@...nel.org>
Subject: [PATCH 8/9] rnbd: add error handling support for add_disk()
We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.
Acked-by: Jack Wang <jinpu.wang@...os.com>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
drivers/block/rnbd/rnbd-clt.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 5864c9b46cb9..3b78dc55a9a2 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -1384,8 +1384,10 @@ static void setup_request_queue(struct rnbd_clt_dev *dev)
blk_queue_write_cache(dev->queue, dev->wc, dev->fua);
}
-static void rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx)
+static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx)
{
+ int err;
+
dev->gd->major = rnbd_client_major;
dev->gd->first_minor = idx << RNBD_PART_BITS;
dev->gd->minors = 1 << RNBD_PART_BITS;
@@ -1410,7 +1412,11 @@ static void rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx)
if (!dev->rotational)
blk_queue_flag_set(QUEUE_FLAG_NONROT, dev->queue);
- add_disk(dev->gd);
+ err = add_disk(dev->gd);
+ if (err)
+ blk_cleanup_disk(dev->gd);
+
+ return err;
}
static int rnbd_client_setup_device(struct rnbd_clt_dev *dev)
@@ -1426,8 +1432,7 @@ static int rnbd_client_setup_device(struct rnbd_clt_dev *dev)
rnbd_init_mq_hw_queues(dev);
setup_request_queue(dev);
- rnbd_clt_setup_gen_disk(dev, idx);
- return 0;
+ return rnbd_clt_setup_gen_disk(dev, idx);
}
static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
--
2.30.2
Powered by blists - more mailing lists