[Devel] [PATCH rh7 4/8] nbd: don't set the device size until we're connected

Andrey Ryabinin aryabinin at virtuozzo.com
Fri Nov 1 22:12:14 MSK 2019


From: Josef Bacik <jbacik at fb.com>

A user reported a regression with using the normal ioctl interface on
newer kernels.  This happens because I was setting the device size
before the device was actually connected, which caused us to error out
and close everything down.  This didn't happen on netlink because we
hold the device lock the whole time we're setting things up, but we
don't do that for the ioctl path.  This fixes the problem.

Cc: stable at vger.kernel.org
Fixes: 29eaadc ("nbd: stop using the bdev everywhere")
Signed-off-by: Josef Bacik <jbacik at fb.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>

https://jira.sw.ru/browse/PSBM-99102
(cherry picked from commit 639812a1ed9bf49ae2c026086fbf975339cd1eef)
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 6713deae68cb..9e0450300cc1 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -205,7 +205,6 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize,
 	struct nbd_config *config = nbd->config;
 	config->blksize = blocksize;
 	config->bytesize = blocksize * nr_blocks;
-	nbd_size_update(nbd);
 }
 
 static void nbd_end_request(struct nbd_cmd *cmd)
@@ -966,6 +965,7 @@ static int nbd_start_device(struct nbd_device *nbd, struct block_device *bdev)
 		args->nbd = nbd;
 		args->index = i;
 		queue_work(recv_workqueue, &args->work);
+		nbd_size_update(nbd);
 	}
 	error = wait_event_interruptible(config->recv_wq,
 					 atomic_read(&config->recv_threads) == 0);
-- 
2.23.0



More information about the Devel mailing list