Skip to contentSkip to conversation

nbd: don't set the device size until we're connected

PATCH Applied Josef Bacik 2 participants 2 messages Oct 9, 2017

Subsystems (3)
lore
Share & tools
lore

Josef Bacik

author maintainer
#0 lore raw

PATCH 1/1 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.

Fixes 29eaadc ("nbd: stop using the bdev everywhere")
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 883dfeb..baebbdf 100644
@@ -243,7 +243,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_complete_rq(struct request *req)
@@ -1094,6 +1093,7 @@ static int nbd_start_device(struct nbd_device *nbd)
 		args->index = i;
 		queue_work(recv_workqueue, &args->work);
 	}
+	nbd_size_update(nbd);
 	return error;
 }
 
Signature · 1 line
2.9.5
maintainer Applied
#1 lore raw
Quoted 6 lines · Josef Bacik

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.

Applied, thanks Josef.

Signature · 1 line
Jens Axboe