Skip to content

Commit 242a49e

Browse files
Christoph Hellwigaxboe
authored andcommitted
nbd: freeze the queue for queue limits updates
nbd currently updates the logical and physical block sizes as well as the discard_sectors on a live queue. Freeze the queue first to make sure there are not commands in flight that can see torn or inconsistent limits. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 7ea201f commit 242a49e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/block/nbd.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock,
316316
nsock->sent = 0;
317317
}
318318

319-
static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
319+
static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
320320
loff_t blksize)
321321
{
322322
if (!blksize)
@@ -348,6 +348,18 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
348348
return 0;
349349
}
350350

351+
static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
352+
loff_t blksize)
353+
{
354+
int error;
355+
356+
blk_mq_freeze_queue(nbd->disk->queue);
357+
error = __nbd_set_size(nbd, bytesize, blksize);
358+
blk_mq_unfreeze_queue(nbd->disk->queue);
359+
360+
return error;
361+
}
362+
351363
static void nbd_complete_rq(struct request *req)
352364
{
353365
struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);

0 commit comments

Comments
 (0)