block: fourth batch of add_disk() error handling conversions
Subsystems (7)
PATCH v2 3/10 ps3disk: add error handling support for add_disk()
In reply to Luis ChamberlainWe never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling.
--- drivers/block/ps3disk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/block/ps3disk.c +6 -2
@@ -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:
Signature · 1 line
2.30.2
PATCH v2 7/10 block/sunvdc: add error handling support for add_disk()
In reply to Luis ChamberlainWe 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.
--- drivers/block/sunvdc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/block/sunvdc.c +11 -3
@@ -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 = {
Signature · 1 line
2.30.2
PATCH v2 6/10 block/rsxx: add error handling support for add_disk()
In reply to Luis ChamberlainWe never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling.
--- drivers/block/rsxx/core.c | 4 +++- drivers/block/rsxx/dev.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/block/rsxx/core.c +3 -1
@@ -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);
drivers/block/rsxx/dev.c +9 -3
@@ -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)
Signature · 1 line
2.30.2
PATCH v2 2/10 pktcdvd: add error handling support for add_disk()
In reply to Luis ChamberlainWe 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.
--- drivers/block/pktcdvd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/pktcdvd.c +3 -1
@@ -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);
Signature · 1 line
2.30.2
PATCH v2 4/10 ps3vram: add error handling support for add_disk()
In reply to Luis ChamberlainWe never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling.
--- drivers/block/ps3vram.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/block/ps3vram.c +6 -1
@@ -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);
Signature · 1 line
2.30.2
PATCH v2 10/10 mtd/ubi/block: add error handling support for add_disk()
In reply to Luis ChamberlainWe never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling.
--- drivers/mtd/ubi/block.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mtd/ubi/block.c +7 -1
@@ -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:
Signature · 1 line
2.30.2
PATCH v2 1/10 mtip32xx: add error handling support for add_disk()
In reply to Luis ChamberlainWe 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.
--- drivers/block/mtip32xx/mtip32xx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/mtip32xx/mtip32xx.c +3 -1
@@ -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);
Signature · 1 line
2.30.2
v2 cover block: fourth batch of add_disk() error handling conversions
This is the fourth batch of add_disk() error handling driver conversions. This set along with the entire 7 set of driver conversions can be found on my 20210927-for-axboe-add-disk-error-handling branch [0].
On this v2 series the following modifications have been made since the last v1 series of this patch set:
- rebased onto linux-next tag 20210927
- added the only reviewed-by tag for this series for rnbd Jack Wang
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(-)
Signature · 1 line
2.30.2
PATCH v2 5/10 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.
--- drivers/block/rnbd/rnbd-clt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/block/rnbd/rnbd-clt.c +9 -4
@@ -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,
Signature · 1 line
2.30.2
PATCH v2 8/10 block/sx8: add error handling support for add_disk()
In reply to Luis ChamberlainWe 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.
--- drivers/block/sx8.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/block/sx8.c +9 -4
@@ -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,
Signature · 1 line
2.30.2
PATCH v2 9/10 pf: add error handling support for add_disk()
In reply to Luis ChamberlainWe never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling.
--- drivers/block/paride/pf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/paride/pf.c +3 -1
@@ -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 ;
Signature · 1 line
2.30.2
Jens Axboe
maintainerQuoted 4 lines · Luis Chamberlain
This is the fourth batch of
add_disk()error handling driver conversions. This set along with the entire 7 set of driver conversions can be found on my 20210927-for-axboe-add-disk-error-handling branch [0].
Applied 1-2, 6, 8-9, thanks.
Signature · 1 line
Jens Axboe