UPSTREAM: 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. Change-Id: I3e9468cd5d844e149176bc54b4123f2524baaa77 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> (cherry picked from commit f3dec61d7544a90685f1dd9a87fd4afc751996d0) Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
committed by
Bart Van Assche
parent
1bf8be0b4e
commit
96dfef3be8
+2
-15
@@ -327,8 +327,7 @@ static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock,
|
|||||||
nsock->sent = 0;
|
nsock->sent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
|
static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, loff_t blksize)
|
||||||
loff_t blksize)
|
|
||||||
{
|
{
|
||||||
struct queue_limits lim;
|
struct queue_limits lim;
|
||||||
int error;
|
int error;
|
||||||
@@ -368,7 +367,7 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
|
|||||||
|
|
||||||
lim.logical_block_size = blksize;
|
lim.logical_block_size = blksize;
|
||||||
lim.physical_block_size = blksize;
|
lim.physical_block_size = blksize;
|
||||||
error = queue_limits_commit_update(nbd->disk->queue, &lim);
|
error = queue_limits_commit_update_frozen(nbd->disk->queue, &lim);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -379,18 +378,6 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
|
|
||||||
loff_t blksize)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
blk_mq_freeze_queue(nbd->disk->queue);
|
|
||||||
error = __nbd_set_size(nbd, bytesize, blksize);
|
|
||||||
blk_mq_unfreeze_queue(nbd->disk->queue);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nbd_complete_rq(struct request *req)
|
static void nbd_complete_rq(struct request *req)
|
||||||
{
|
{
|
||||||
struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
|
struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
|
||||||
|
|||||||
Reference in New Issue
Block a user