* [PATCH 0/2] add error handling support for add_disk()
@ 2021-11-04 8:33 Wu Bo
2021-11-04 8:33 ` [PATCH 1/2] brd: " Wu Bo
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wu Bo @ 2021-11-04 8:33 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, linfeilong, wubo40
We never checked for errors on add_disk() as this function
returned void. Now that is fixed.
So add error handling support for add_disk().
Wu Bo (2):
brd: add error handling support for add_disk()
z2ram: add error handling support for add_disk()
drivers/block/brd.c | 7 ++++++-
drivers/block/z2ram.c | 8 ++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] brd: add error handling support for add_disk()
2021-11-04 8:33 [PATCH 0/2] add error handling support for add_disk() Wu Bo
@ 2021-11-04 8:33 ` Wu Bo
2021-11-04 8:33 ` [PATCH 2/2] z2ram: " Wu Bo
2021-11-04 8:45 ` [PATCH 0/2] " Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Wu Bo @ 2021-11-04 8:33 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, linfeilong, wubo40
We never checked for errors on add_disk() as this function
returned void. Now that is fixed.
So add error handling support for add_disk().
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/block/brd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index aa04727..34a0d9c 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -370,6 +370,7 @@ static int brd_alloc(int i)
struct brd_device *brd;
struct gendisk *disk;
char buf[DISK_NAME_LEN];
+ int err;
mutex_lock(&brd_devices_mutex);
list_for_each_entry(brd, &brd_devices, brd_list) {
@@ -420,10 +421,14 @@ static int brd_alloc(int i)
/* Tell the block layer that this is not a rotational device */
blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue);
- add_disk(disk);
+ err = add_disk(disk);
+ if (err)
+ goto out_cleanup_disk;
return 0;
+out_cleanup_disk:
+ blk_cleanup_disk(disk);
out_free_dev:
mutex_lock(&brd_devices_mutex);
list_del(&brd->brd_list);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] z2ram: add error handling support for add_disk()
2021-11-04 8:33 [PATCH 0/2] add error handling support for add_disk() Wu Bo
2021-11-04 8:33 ` [PATCH 1/2] brd: " Wu Bo
@ 2021-11-04 8:33 ` Wu Bo
2021-11-04 8:45 ` [PATCH 0/2] " Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Wu Bo @ 2021-11-04 8:33 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, linfeilong, wubo40
We never checked for errors on add_disk() as this function
returned void. Now that is fixed.
So add error handling support for add_disk().
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/block/z2ram.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 4eef218..822df1d 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -318,6 +318,7 @@ static void z2_release(struct gendisk *disk, fmode_t mode)
static int z2ram_register_disk(int minor)
{
struct gendisk *disk;
+ int err;
disk = blk_mq_alloc_disk(&tag_set, NULL);
if (IS_ERR(disk))
@@ -333,8 +334,11 @@ static int z2ram_register_disk(int minor)
sprintf(disk->disk_name, "z2ram");
z2ram_gendisk[minor] = disk;
- add_disk(disk);
- return 0;
+ err = add_disk(disk);
+ if (err)
+ blk_cleanup_disk(disk);
+
+ return err;
}
static int __init z2_init(void)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] add error handling support for add_disk()
2021-11-04 8:33 [PATCH 0/2] add error handling support for add_disk() Wu Bo
2021-11-04 8:33 ` [PATCH 1/2] brd: " Wu Bo
2021-11-04 8:33 ` [PATCH 2/2] z2ram: " Wu Bo
@ 2021-11-04 8:45 ` Christoph Hellwig
2021-11-05 2:06 ` Wu Bo
2 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-11-04 8:45 UTC (permalink / raw)
To: Wu Bo; +Cc: axboe, linux-block, linux-kernel, linfeilong
Luis has an outstanding series that also covers these two drivers.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] add error handling support for add_disk()
2021-11-04 8:45 ` [PATCH 0/2] " Christoph Hellwig
@ 2021-11-05 2:06 ` Wu Bo
0 siblings, 0 replies; 5+ messages in thread
From: Wu Bo @ 2021-11-05 2:06 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: axboe, linux-block, linux-kernel, linfeilong
On 2021/11/4 16:45, Christoph Hellwig wrote:
> Luis has an outstanding series that also covers these two drivers.
> .
>
OK, Please ignore this patch.
Thanks.
Wu Bo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-05 2:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 8:33 [PATCH 0/2] add error handling support for add_disk() Wu Bo
2021-11-04 8:33 ` [PATCH 1/2] brd: " Wu Bo
2021-11-04 8:33 ` [PATCH 2/2] z2ram: " Wu Bo
2021-11-04 8:45 ` [PATCH 0/2] " Christoph Hellwig
2021-11-05 2:06 ` Wu Bo
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).