diff mbox series

[PATCHv2,for-next,10/24] block/rnbd-clt: Move add_disk(dev->gd) to rnbd_clt_setup_gen_disk

Message ID 20210330073752.1465613-11-gi-oh.kim@ionos.com (mailing list archive)
State New, archived
Headers show
Series Misc update for rnbd | expand

Commit Message

Gioh Kim March 30, 2021, 7:37 a.m. UTC
From: Guoqing Jiang <guoqing.jiang@gmx.com>

It makes more sense to add gendisk in rnbd_clt_setup_gen_disk, instead
of do it in rnbd_clt_map_device.

Signed-off-by: Guoqing Jiang <guoqing.jiang@gmx.com>
Reviewed-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
---
 drivers/block/rnbd/rnbd-clt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Chaitanya Kulkarni March 30, 2021, 11:55 p.m. UTC | #1
On 3/30/21 00:39, Gioh Kim wrote:
> From: Guoqing Jiang <guoqing.jiang@gmx.com>
>
> It makes more sense to add gendisk in rnbd_clt_setup_gen_disk, instead
> of do it in rnbd_clt_map_device.
>
> Signed-off-by: Guoqing Jiang <guoqing.jiang@gmx.com>
> Reviewed-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
> Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
> Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>

The add disk call seems to be out of the lock, I hope that will not
result in any issues since this patch moves add_disk call when
dev->lock is held.

Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Gioh Kim March 31, 2021, 6:32 a.m. UTC | #2
On Wed, Mar 31, 2021 at 1:55 AM Chaitanya Kulkarni
<Chaitanya.Kulkarni@wdc.com> wrote:
>
> On 3/30/21 00:39, Gioh Kim wrote:
> > From: Guoqing Jiang <guoqing.jiang@gmx.com>
> >
> > It makes more sense to add gendisk in rnbd_clt_setup_gen_disk, instead
> > of do it in rnbd_clt_map_device.
> >
> > Signed-off-by: Guoqing Jiang <guoqing.jiang@gmx.com>
> > Reviewed-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
> > Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
> > Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
>
> The add disk call seems to be out of the lock, I hope that will not
> result in any issues since this patch moves add_disk call when
> dev->lock is held.

I checked other modules and found that pktcdvd and mtd/ubi does add_disk
when holding mutex.
I hope so.

Thank you.

>
> Looks good.
>
> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>
>
diff mbox series

Patch

diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 5d085bc80e24..d8b9c552271c 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -1358,6 +1358,7 @@  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);
 }
 
 static int rnbd_client_setup_device(struct rnbd_clt_dev *dev)
@@ -1561,8 +1562,6 @@  struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname,
 		       dev->max_hw_sectors, dev->rotational, dev->wc, dev->fua);
 
 	mutex_unlock(&dev->lock);
-
-	add_disk(dev->gd);
 	rnbd_clt_put_sess(sess);
 
 	return dev;