linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] block: fourth batch of add_disk() error handling conversions
@ 2021-09-01 21:00 Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 01/10] mtip32xx: add error handling support for add_disk() Luis Chamberlain
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

The full set of changes can be found on my branch titled
20210901-for-axboe-add-disk-error-handling [0] which is
now based on axboe/master.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20210901-for-axboe-add-disk-error-handling

Luis Chamberlain (10):
  mtip32xx: add error handling support for add_disk()
  pktcdvd: add error handling support for add_disk()
  ps3disk: add error handling support for add_disk()
  ps3vram: add error handling support for add_disk()
  rnbd: add error handling support for add_disk()
  block/rsxx: add error handling support for add_disk()
  block/sunvdc: add error handling support for add_disk()
  block/sx8: add error handling support for add_disk()
  pf: add error handling support for add_disk()
  mtd/ubi/block: add error handling support for add_disk()

 drivers/block/mtip32xx/mtip32xx.c |  4 +++-
 drivers/block/paride/pf.c         |  4 +++-
 drivers/block/pktcdvd.c           |  4 +++-
 drivers/block/ps3disk.c           |  8 ++++++--
 drivers/block/ps3vram.c           |  7 ++++++-
 drivers/block/rnbd/rnbd-clt.c     | 13 +++++++++----
 drivers/block/rsxx/core.c         |  4 +++-
 drivers/block/rsxx/dev.c          | 12 +++++++++---
 drivers/block/sunvdc.c            | 14 +++++++++++---
 drivers/block/sx8.c               | 13 +++++++++----
 drivers/mtd/ubi/block.c           |  8 +++++++-
 11 files changed, 69 insertions(+), 22 deletions(-)

-- 
2.30.2


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

* [PATCH 01/10] mtip32xx: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 02/10] pktcdvd: " Luis Chamberlain
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

The read_capacity_error error label already does what we need,
so just re-use that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/mtip32xx/mtip32xx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 901855717cb5..d0b40309f47e 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3633,7 +3633,9 @@ static int mtip_block_initialize(struct driver_data *dd)
 	set_capacity(dd->disk, capacity);
 
 	/* Enable the block device and add it to /dev */
-	device_add_disk(&dd->pdev->dev, dd->disk, mtip_disk_attr_groups);
+	rv = device_add_disk(&dd->pdev->dev, dd->disk, mtip_disk_attr_groups);
+	if (rv)
+		goto read_capacity_error;
 
 	if (dd->mtip_svc_handler) {
 		set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag);
-- 
2.30.2


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

* [PATCH 02/10] pktcdvd: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 01/10] mtip32xx: add error handling support for add_disk() Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 03/10] ps3disk: " Luis Chamberlain
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

The out_mem2 error label already does what we need so
re-use that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/pktcdvd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 0f26b2510a75..415248962e67 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2729,7 +2729,9 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
 	/* inherit events of the host device */
 	disk->events = pd->bdev->bd_disk->events;
 
-	add_disk(disk);
+	ret = add_disk(disk);
+	if (ret)
+		goto out_mem2;
 
 	pkt_sysfs_dev_new(pd);
 	pkt_debugfs_dev_new(pd);
-- 
2.30.2


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

* [PATCH 03/10] ps3disk: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 01/10] mtip32xx: add error handling support for add_disk() Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 02/10] pktcdvd: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 04/10] ps3vram: " Luis Chamberlain
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/ps3disk.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index 8d51efbe045d..3054adf77460 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -467,9 +467,13 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)
 		 gendisk->disk_name, priv->model, priv->raw_capacity >> 11,
 		 get_capacity(gendisk) >> 11);
 
-	device_add_disk(&dev->sbd.core, gendisk, NULL);
-	return 0;
+	error = device_add_disk(&dev->sbd.core, gendisk, NULL);
+	if (error)
+		goto fail_cleanup_disk;
 
+	return 0;
+fail_cleanup_disk:
+	blk_cleanup_disk(gendisk);
 fail_free_tag_set:
 	blk_mq_free_tag_set(&priv->tag_set);
 fail_teardown:
-- 
2.30.2


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

* [PATCH 04/10] ps3vram: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
                   ` (2 preceding siblings ...)
  2021-09-01 21:00 ` [PATCH 03/10] ps3disk: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 05/10] rnbd: " Luis Chamberlain
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/ps3vram.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index c7b19e128b03..af2a0d09c598 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -755,9 +755,14 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev)
 	dev_info(&dev->core, "%s: Using %llu MiB of GPU memory\n",
 		 gendisk->disk_name, get_capacity(gendisk) >> 11);
 
-	device_add_disk(&dev->core, gendisk, NULL);
+	error = device_add_disk(&dev->core, gendisk, NULL);
+	if (error)
+		goto out_cleanup_disk;
+
 	return 0;
 
+out_cleanup_disk:
+	blk_cleanup_disk(gendisk);
 out_cache_cleanup:
 	remove_proc_entry(DEVICE_NAME, NULL);
 	ps3vram_cache_cleanup(dev);
-- 
2.30.2


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

* [PATCH 05/10] rnbd: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
                   ` (3 preceding siblings ...)
  2021-09-01 21:00 ` [PATCH 04/10] ps3vram: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-02  5:32   ` Jinpu Wang
  2021-09-01 21:00 ` [PATCH 06/10] block/rsxx: " Luis Chamberlain
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

Signed-off-by: Luis Chamberlain <mcgrof@kernel.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 bd4a41afbbfc..1ba1c868535a 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


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

* [PATCH 06/10] block/rsxx: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
                   ` (4 preceding siblings ...)
  2021-09-01 21:00 ` [PATCH 05/10] rnbd: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 07/10] block/sunvdc: " Luis Chamberlain
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/rsxx/core.c |  4 +++-
 drivers/block/rsxx/dev.c  | 12 +++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index 83636714b8d7..8d9d69f5dfbc 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -935,7 +935,9 @@ static int rsxx_pci_probe(struct pci_dev *dev,
 			card->size8 = 0;
 	}
 
-	rsxx_attach_dev(card);
+	st = rsxx_attach_dev(card);
+	if (st)
+		goto failed_create_dev;
 
 	/************* Setup Debugfs *************/
 	rsxx_debugfs_dev_new(card);
diff --git a/drivers/block/rsxx/dev.c b/drivers/block/rsxx/dev.c
index 1cc40b0ea761..b2d3ac3efce2 100644
--- a/drivers/block/rsxx/dev.c
+++ b/drivers/block/rsxx/dev.c
@@ -192,6 +192,8 @@ static bool rsxx_discard_supported(struct rsxx_cardinfo *card)
 
 int rsxx_attach_dev(struct rsxx_cardinfo *card)
 {
+	int err = 0;
+
 	mutex_lock(&card->dev_lock);
 
 	/* The block device requires the stripe size from the config. */
@@ -200,13 +202,17 @@ int rsxx_attach_dev(struct rsxx_cardinfo *card)
 			set_capacity(card->gendisk, card->size8 >> 9);
 		else
 			set_capacity(card->gendisk, 0);
-		device_add_disk(CARD_TO_DEV(card), card->gendisk, NULL);
-		card->bdev_attached = 1;
+		err = device_add_disk(CARD_TO_DEV(card), card->gendisk, NULL);
+		if (err == 0)
+			card->bdev_attached = 1;
 	}
 
 	mutex_unlock(&card->dev_lock);
 
-	return 0;
+	if (err)
+		blk_cleanup_disk(card->gendisk);
+
+	return err;
 }
 
 void rsxx_detach_dev(struct rsxx_cardinfo *card)
-- 
2.30.2


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

* [PATCH 07/10] block/sunvdc: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
                   ` (5 preceding siblings ...)
  2021-09-01 21:00 ` [PATCH 06/10] block/rsxx: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 08/10] block/sx8: " Luis Chamberlain
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

We re-use the same free tag call, so we also add a label for
that as well.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/sunvdc.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 4d4bb810c2ae..6f45a53f7cbf 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -826,8 +826,8 @@ static int probe_disk(struct vdc_port *port)
 	if (IS_ERR(g)) {
 		printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n",
 		       port->vio.name);
-		blk_mq_free_tag_set(&port->tag_set);
-		return PTR_ERR(g);
+		err = PTR_ERR(g);
+		goto out_free_tag;
 	}
 
 	port->disk = g;
@@ -879,9 +879,17 @@ static int probe_disk(struct vdc_port *port)
 	       port->vdisk_size, (port->vdisk_size >> (20 - 9)),
 	       port->vio.ver.major, port->vio.ver.minor);
 
-	device_add_disk(&port->vio.vdev->dev, g, NULL);
+	err = device_add_disk(&port->vio.vdev->dev, g, NULL);
+	if (err)
+		goto out_cleanup_disk;
 
 	return 0;
+
+out_cleanup_disk:
+	blk_cleanup_disk(g);
+out_free_tag:
+	blk_mq_free_tag_set(&port->tag_set);
+	return err;
 }
 
 static struct ldc_channel_config vdc_ldc_cfg = {
-- 
2.30.2


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

* [PATCH 08/10] block/sx8: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
                   ` (6 preceding siblings ...)
  2021-09-01 21:00 ` [PATCH 07/10] block/sunvdc: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 09/10] pf: " Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 10/10] mtd/ubi/block: " Luis Chamberlain
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

A completion is used to notify the initial probe what is
happening and so we must defer error handling on completion.
Do this by remembering the error and using the shared cleanup
function.

The tags are shared and so are hanlded later for the
driver already.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/sx8.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 420cd952ddc4..1c79248c4826 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -297,6 +297,7 @@ struct carm_host {
 
 	struct work_struct		fsm_task;
 
+	int probe_err;
 	struct completion		probe_comp;
 };
 
@@ -1181,8 +1182,11 @@ static void carm_fsm_task (struct work_struct *work)
 				struct gendisk *disk = port->disk;
 
 				set_capacity(disk, port->capacity);
-				add_disk(disk);
-				activated++;
+				host->probe_err = add_disk(disk);
+				if (!host->probe_err)
+					activated++;
+				else
+					break;
 			}
 
 		printk(KERN_INFO DRV_NAME "(%s): %d ports activated\n",
@@ -1192,11 +1196,9 @@ static void carm_fsm_task (struct work_struct *work)
 		reschedule = 1;
 		break;
 	}
-
 	case HST_PROBE_FINISHED:
 		complete(&host->probe_comp);
 		break;
-
 	case HST_ERROR:
 		/* FIXME: TODO */
 		break;
@@ -1507,7 +1509,10 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto err_out_free_irq;
 
 	DPRINTK("waiting for probe_comp\n");
+	host->probe_err = -ENODEV;
 	wait_for_completion(&host->probe_comp);
+	if (host->probe_err)
+		goto err_out_free_irq;
 
 	printk(KERN_INFO "%s: pci %s, ports %d, io %llx, irq %u, major %d\n",
 	       host->name, pci_name(pdev), (int) CARM_MAX_PORTS,
-- 
2.30.2


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

* [PATCH 09/10] pf: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
                   ` (7 preceding siblings ...)
  2021-09-01 21:00 ` [PATCH 08/10] block/sx8: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  2021-09-01 21:00 ` [PATCH 10/10] mtd/ubi/block: " Luis Chamberlain
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/paride/pf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index f471d48a87bc..380d80e507c7 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -962,7 +962,9 @@ static int __init pf_init_unit(struct pf_unit *pf, bool autoprobe, int port,
 	if (pf_probe(pf))
 		goto out_pi_release;
 
-	add_disk(disk);
+	ret = add_disk(disk);
+	if (ret)
+		goto out_pi_release;
 	pf->present = 1;
 	return 0;
 
-- 
2.30.2


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

* [PATCH 10/10] mtd/ubi/block: add error handling support for add_disk()
  2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
                   ` (8 preceding siblings ...)
  2021-09-01 21:00 ` [PATCH 09/10] pf: " Luis Chamberlain
@ 2021-09-01 21:00 ` Luis Chamberlain
  9 siblings, 0 replies; 12+ messages in thread
From: Luis Chamberlain @ 2021-09-01 21:00 UTC (permalink / raw)
  To: axboe, bhelgaas, liushixin2, thunder.leizhen, lee.jones, geoff,
	mpe, benh, paulus, jim, haris.iqbal, jinpu.wang, josh.h.morris,
	pjk1939, tim, richard, miquel.raynal, vigneshr
  Cc: linux-mtd, linuxppc-dev, linux-block, linux-kernel, Luis Chamberlain

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

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/mtd/ubi/block.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index e003b4b44ffa..062e6c2c45f5 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -447,12 +447,18 @@ int ubiblock_create(struct ubi_volume_info *vi)
 	list_add_tail(&dev->list, &ubiblock_devices);
 
 	/* Must be the last step: anyone can call file ops from now on */
-	add_disk(dev->gd);
+	ret = add_disk(dev->gd);
+	if (ret)
+		goto out_destroy_wq;
+
 	dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
 		 dev->ubi_num, dev->vol_id, vi->name);
 	mutex_unlock(&devices_mutex);
 	return 0;
 
+out_destroy_wq:
+	list_del(&dev->list);
+	destroy_workqueue(dev->wq);
 out_remove_minor:
 	idr_remove(&ubiblock_minor_idr, gd->first_minor);
 out_cleanup_disk:
-- 
2.30.2


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

* Re: [PATCH 05/10] rnbd: add error handling support for add_disk()
  2021-09-01 21:00 ` [PATCH 05/10] rnbd: " Luis Chamberlain
@ 2021-09-02  5:32   ` Jinpu Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Jinpu Wang @ 2021-09-02  5:32 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: Jens Axboe, Bjorn Helgaas, Liu Shixin, Zhen Lei, Lee Jones,
	Geoff Levand, Michael Ellerman, benh, paulus, jim, Haris Iqbal,
	josh.h.morris, pjk1939, Tim Waugh, Richard Weinberger,
	Miquel Raynal, Vignesh Raghavendra, linux-mtd, linuxppc-dev,
	linux-block, open list

On Wed, Sep 1, 2021 at 11:01 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> We never checked for errors on add_disk() as this function
> returned void. Now that this is fixed, use the shiny new
> error handling.
>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
looks good to me.
Acked-by: Jack Wang <jinpu.wang@ionos.com>
> ---
>  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 bd4a41afbbfc..1ba1c868535a 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
>

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

end of thread, other threads:[~2021-09-02  5:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 21:00 [PATCH 00/10] block: fourth batch of add_disk() error handling conversions Luis Chamberlain
2021-09-01 21:00 ` [PATCH 01/10] mtip32xx: add error handling support for add_disk() Luis Chamberlain
2021-09-01 21:00 ` [PATCH 02/10] pktcdvd: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 03/10] ps3disk: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 04/10] ps3vram: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 05/10] rnbd: " Luis Chamberlain
2021-09-02  5:32   ` Jinpu Wang
2021-09-01 21:00 ` [PATCH 06/10] block/rsxx: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 07/10] block/sunvdc: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 08/10] block/sx8: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 09/10] pf: " Luis Chamberlain
2021-09-01 21:00 ` [PATCH 10/10] mtd/ubi/block: " Luis Chamberlain

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).