Commit 2e9e31be authored by Luis Chamberlain's avatar Luis Chamberlain Committed by Jens Axboe

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: default avatarJack Wang <jinpu.wang@ionos.com>
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20211015233028.2167651-9-mcgrof@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 66638f16
...@@ -1384,8 +1384,10 @@ static void setup_request_queue(struct rnbd_clt_dev *dev) ...@@ -1384,8 +1384,10 @@ static void setup_request_queue(struct rnbd_clt_dev *dev)
blk_queue_write_cache(dev->queue, dev->wc, dev->fua); 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->major = rnbd_client_major;
dev->gd->first_minor = idx << RNBD_PART_BITS; dev->gd->first_minor = idx << RNBD_PART_BITS;
dev->gd->minors = 1 << 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) ...@@ -1410,7 +1412,11 @@ static void rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx)
if (!dev->rotational) if (!dev->rotational)
blk_queue_flag_set(QUEUE_FLAG_NONROT, dev->queue); 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) 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) ...@@ -1426,8 +1432,7 @@ static int rnbd_client_setup_device(struct rnbd_clt_dev *dev)
rnbd_init_mq_hw_queues(dev); rnbd_init_mq_hw_queues(dev);
setup_request_queue(dev); setup_request_queue(dev);
rnbd_clt_setup_gen_disk(dev, idx); return rnbd_clt_setup_gen_disk(dev, idx);
return 0;
} }
static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment