diff mbox series

[20/30] nullb: use blk_mq_alloc_disk

Message ID 20210602065345.355274-21-hch@lst.de
State New
Headers show
Series [01/30] blk-mq: factor out a blk_mq_alloc_sq_tag_set helper | expand

Commit Message

Christoph Hellwig June 2, 2021, 6:53 a.m. UTC
Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and
request_queue allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/null_blk/main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Chaitanya Kulkarni June 3, 2021, 12:10 a.m. UTC | #1
On 6/1/21 23:56, Christoph Hellwig wrote:
> Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and
> request_queue allocation.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/block/null_blk/main.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index d8e098f1e5b5..74fb2ec63219 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -1851,13 +1851,12 @@ static int null_add_dev(struct nullb_device *dev)
>  
>  		rv = -ENOMEM;

Is above initialization needed ?

>  		nullb->tag_set->timeout = 5 * HZ;
> -		nullb->q = blk_mq_init_queue_data(nullb->tag_set, nullb);
> -		if (IS_ERR(nullb->q))
> -			goto out_cleanup_tags;
> -		nullb->disk = alloc_disk_node(1, nullb->dev->home_node);
> -		if (!nullb->disk)
> +		nullb->disk = blk_mq_alloc_disk(nullb->tag_set, nullb);
> +		if (IS_ERR(nullb->disk)) {
> +			rv = PTR_ERR(nullb->disk);
>  			goto out_cleanup_disk;
> -		nullb->disk->queue = nullb->q;
> +		}
> +		nullb->q = nullb->disk->queue;
>  	} else if (dev->queue_mode == NULL_Q_BIO) {
>  		rv = -ENOMEM;
>  		nullb->disk = blk_alloc_disk(nullb->dev->home_node);
Christoph Hellwig June 8, 2021, 5:39 a.m. UTC | #2
On Thu, Jun 03, 2021 at 12:10:09AM +0000, Chaitanya Kulkarni wrote:
> > diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> > index d8e098f1e5b5..74fb2ec63219 100644
> > --- a/drivers/block/null_blk/main.c
> > +++ b/drivers/block/null_blk/main.c
> > @@ -1851,13 +1851,12 @@ static int null_add_dev(struct nullb_device *dev)
> >  
> >  		rv = -ENOMEM;
> 
> Is above initialization needed ?

It isn't strictly required any more.
diff mbox series

Patch

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index d8e098f1e5b5..74fb2ec63219 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1851,13 +1851,12 @@  static int null_add_dev(struct nullb_device *dev)
 
 		rv = -ENOMEM;
 		nullb->tag_set->timeout = 5 * HZ;
-		nullb->q = blk_mq_init_queue_data(nullb->tag_set, nullb);
-		if (IS_ERR(nullb->q))
-			goto out_cleanup_tags;
-		nullb->disk = alloc_disk_node(1, nullb->dev->home_node);
-		if (!nullb->disk)
+		nullb->disk = blk_mq_alloc_disk(nullb->tag_set, nullb);
+		if (IS_ERR(nullb->disk)) {
+			rv = PTR_ERR(nullb->disk);
 			goto out_cleanup_disk;
-		nullb->disk->queue = nullb->q;
+		}
+		nullb->q = nullb->disk->queue;
 	} else if (dev->queue_mode == NULL_Q_BIO) {
 		rv = -ENOMEM;
 		nullb->disk = blk_alloc_disk(nullb->dev->home_node);