[RHEL7,COMMIT] ms/nbd: don't set the device size until we're connected

Submitted by Konstantin Khorenko on Nov. 5, 2019, 8:06 a.m.


Message ID 201911050806.xA586FgI015925@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Nov. 5, 2019, 8:06 a.m.
The commit is pushed to "branch-rh7-3.10.0-1062.4.1.vz7.115.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.4.1.vz7.115.7
commit 5f668a634ca9a60c2636698c8825a97f3abd430a
Author: Josef Bacik <jbacik@fb.com>
Date:   Tue Nov 5 11:06:15 2019 +0300

    ms/nbd: don't set the device size until we're connected
    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);