Skip to content

Commit f3dec61

Browse files
Christoph Hellwigaxboe
authored andcommitted
nbd: fix queue freeze vs limits lock order
Match the locking order used by the core block code by only freezing the queue after taking the limits lock using the queue_limits_commit_update_frozen helper. This also allows removes the need for the separate __nbd_set_size helper, so remove it. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Ming Lei <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Nilay Shroff <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 473106d commit f3dec61

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

drivers/block/nbd.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock,
327327
nsock->sent = 0;
328328
}
329329

330-
static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
331-
loff_t blksize)
330+
static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, loff_t blksize)
332331
{
333332
struct queue_limits lim;
334333
int error;
@@ -368,7 +367,7 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
368367

369368
lim.logical_block_size = blksize;
370369
lim.physical_block_size = blksize;
371-
error = queue_limits_commit_update(nbd->disk->queue, &lim);
370+
error = queue_limits_commit_update_frozen(nbd->disk->queue, &lim);
372371
if (error)
373372
return error;
374373

@@ -379,18 +378,6 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
379378
return 0;
380379
}
381380

382-
static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
383-
loff_t blksize)
384-
{
385-
int error;
386-
387-
blk_mq_freeze_queue(nbd->disk->queue);
388-
error = __nbd_set_size(nbd, bytesize, blksize);
389-
blk_mq_unfreeze_queue(nbd->disk->queue);
390-
391-
return error;
392-
}
393-
394381
static void nbd_complete_rq(struct request *req)
395382
{
396383
struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);

0 commit comments

Comments
 (0)