Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Christoph Hellwig and committed by
Jens Axboe
f3dec61d 473106dd

+2 -15
+2 -15
drivers/block/nbd.c
··· 327 327 nsock->sent = 0; 328 328 } 329 329 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) 332 331 { 333 332 struct queue_limits lim; 334 333 int error; ··· 367 368 368 369 lim.logical_block_size = blksize; 369 370 lim.physical_block_size = blksize; 370 - error = queue_limits_commit_update(nbd->disk->queue, &lim); 371 + error = queue_limits_commit_update_frozen(nbd->disk->queue, &lim); 371 372 if (error) 372 373 return error; 373 374 ··· 376 377 if (!set_capacity_and_notify(nbd->disk, bytesize >> 9)) 377 378 kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); 378 379 return 0; 379 - } 380 - 381 - static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, 382 - loff_t blksize) 383 - { 384 - int error; 385 - 386 - blk_mq_freeze_queue(nbd->disk->queue); 387 - error = __nbd_set_size(nbd, bytesize, blksize); 388 - blk_mq_unfreeze_queue(nbd->disk->queue); 389 - 390 - return error; 391 380 } 392 381 393 382 static void nbd_complete_rq(struct request *req)