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

Submitted by Andrey Ryabinin on Nov. 1, 2019, 7:12 p.m.


Message ID 20191101191218.31833-4-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Nov. 1, 2019, 7:12 p.m.
From: Josef Bacik <jbacik@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@vger.kernel.org
Fixes: 29eaadc ("nbd: stop using the bdev everywhere")
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

(cherry picked from commit 639812a1ed9bf49ae2c026086fbf975339cd1eef)
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

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);