From patchwork Thu Jan 9 05:57:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13932061 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 92E341FBEA6; Thu, 9 Jan 2025 05:58: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=1736402326; cv=none; b=UH7M1R7SMutw0ultgyR2w/S1UBRkIvc0nPOhhCu1S5na5V3pwIzs4tuloXE6KBIBy/GEJwTFqV0JVd+RmU/JWQx5OPRPiCQEcJPpjelSjCkR76l+LBpW8lLX11XcsVwhdBp5tEwfumtRU/PqdWASYC589CZcgb3zy/qUCgQfNr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736402326; c=relaxed/simple; bh=dhqVrdtZKF+zvs+XegpxbVyJZwP84K/ov92DkFKMiWc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y8SWhPBFOlCy9NpcfYXwuNgeX4esis+EzE/AoktKvOvtUrxl1jlF+QDT9CZv5sIww8kQpqinNisooZ/3qxvRCHaADYbRqd6rSHVGKAmkxXBNljH+T6b/rJoYWl4S+5GA7DSmyGvPYYajNlengouJGkL3YLG7dv+gH0hmSOIHS54= 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=pd6IUaJ6; 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="pd6IUaJ6" 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=fuOazopibpAs20wub1IJXrvMuywQGVOpmNTUuhx/xHA=; b=pd6IUaJ69No3UVx46TSio0C0Kb +s8dRlNw0+D4LcM1iivIo69qRh7e3igduRw+Bw925uYvRa/Ghe7+x7yI2SRqgYw/X279jkwbyna1x OVzBSUODY8HZvioNgyMexHuvYB+bXQh6WwRiJ5I3jf3zZURFh5P+2yGt8YvSvjDhFpsB2c/vYP8/N sDvop4A1BkfDobMagrRjdWINWnv+W9A/NFSd2lfTtT1DYcmrtkkOhgxJQdzcxMJg4wHDBZuHgW6Vm gOFu6A3b8LMx6/iGam1k0WW0nb+L+WKTyUgDXqEMhxCI+QVqTHMaxoNE2t7BAaB5YdTLvgkM6BICU H1MNl0nA==; Received: from 2a02-8389-2341-5b80-ddeb-cdec-70b9-e2f0.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:ddeb:cdec:70b9:e2f0] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tVlZ5-0000000ArV0-3Gjh; Thu, 09 Jan 2025 05:58:44 +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, Johannes Thumshirn Subject: [PATCH 08/11] nbd: fix queue freeze vs limits lock order Date: Thu, 9 Jan 2025 06:57:29 +0100 Message-ID: <20250109055810.1402918-9-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250109055810.1402918-1-hch@lst.de> References: <20250109055810.1402918-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: Ming Lei Reviewed-by: Damien Le Moal Reviewed-by: Nilay Shroff Reviewed-by: Johannes Thumshirn --- 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);