Skip to content

Commit 9fc5a8a

Browse files
author
Ming Lei
committed
nbd: fix queue freeze vs limits lock order
JIRA: https://issues.redhat.com/browse/RHEL-71345 Upstream Status: for-6.4/block commit f3dec61 Author: Christoph Hellwig <hch@lst.de> Date: Fri Jan 10 06:47:16 2025 +0100 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 <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20250110054726.1499538-9-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent e17473f commit 9fc5a8a

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
@@ -329,8 +329,7 @@ static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock,
329329
nsock->sent = 0;
330330
}
331331

332-
static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
333-
loff_t blksize)
332+
static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, loff_t blksize)
334333
{
335334
struct queue_limits lim;
336335
int error;
@@ -370,7 +369,7 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
370369

371370
lim.logical_block_size = blksize;
372371
lim.physical_block_size = blksize;
373-
error = queue_limits_commit_update(nbd->disk->queue, &lim);
372+
error = queue_limits_commit_update_frozen(nbd->disk->queue, &lim);
374373
if (error)
375374
return error;
376375

@@ -381,18 +380,6 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
381380
return 0;
382381
}
383382

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

0 commit comments

Comments
 (0)