From patchwork Tue Jan 7 06:30:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13928288 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55B7B1E2844; Tue, 7 Jan 2025 06:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736231511; cv=none; b=bYNwcICF8OAU+9hblL5lkAo6IGzOVl+hAUU6BgX0SVaU4Ujwbpn4SuCQ/ZoyhQjKYg+E6InyCWsRF9d3XWNNu3mbtUBrdZKGzEFhgffkQEM/sivR81QI2Pyg5jGLTgsL1MpiulYZmVmNJMHM/GG1ZIGWpVmW+TPlgIoaTjEE+cA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736231511; c=relaxed/simple; bh=Rqj7w2vHlAcMhHIMadV+YFz2wCf4BhOoXQ/EcQgbnYY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sPrUYfqbDbCbdz7/pElHJfpM6vkKaw41AoZuXtmewmd4J5M/UESL01RYpEIS00bH5g+YRbA52Vq/TOgiIMMq1tLJAk817+DLE1Nl8B+T5gr+UNY/c0GTDc0kOTjlktVG5R5qBhR1sYJTmAKjXY7qLQjmSrBnnQhGSZzi5SLVjHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=mKbwr5cU; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="mKbwr5cU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6hI+ugNTaOvOszOzcEqkSFZCj8TAzJYYPeYzQzSN93E=; b=mKbwr5cUU0Sh2IUw9Lon73LrUw VSTEY2ckPtX19mPyRd9oLxdmvlLwAUDTSdYL6QFY861GNhSBHyST6ftq9bpnC+MrrrFOWugJZ6U2g 44v3oXZ15I2ERizi1v6mNg6IMvakndSEJ63rJW8UYR3AzrsbY9k27SCMqlk60GdzoPhfJxJ5oIzVn zt3gPcXf/JkfZy5/Jsm+oPs1yLtRiNx5xZpe9IBEaySkU1O4ZHVJMXOF/0Bm/DadLOvN92Qwtuiy4 2TspZYbV7yiI7EDaQJs2EmirWm94NECCqN5JVWPs7xY7znuG/A7k2q64V2nkTwoP+DxX6Izqt0INU A3E/pIpQ==; Received: from 2a02-8389-2341-5b80-d467-d75d-35bf-0eb6.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:d467:d75d:35bf:eb6] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tV37v-00000003e1g-09Rm; Tue, 07 Jan 2025 06:31:43 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Damien Le Moal , Ming Lei , Nilay Shroff , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, nbd@other.debian.org, linux-scsi@vger.kernel.org, usb-storage@lists.one-eyed-alien.net Subject: [PATCH 7/8] nbd: fix queue freeze vs limits lock order Date: Tue, 7 Jan 2025 07:30:39 +0100 Message-ID: <20250107063120.1011593-8-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250107063120.1011593-1-hch@lst.de> References: <20250107063120.1011593-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 Reviewed-by: Damien Le Moal Reviewed-by: Nilay Shroff --- drivers/block/nbd.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 259bd57fc529..efa05c3c06bf 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -327,8 +327,7 @@ static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock, nsock->sent = 0; } -static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize, - loff_t blksize) +static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, loff_t blksize) { struct queue_limits lim; int error; @@ -368,7 +367,7 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize, lim.logical_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) return error; @@ -379,18 +378,6 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize, 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) { struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);