From patchwork Wed Mar 27 17:21:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13607119 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 DA03114D6EA for ; Wed, 27 Mar 2024 17:21:50 +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=1711560112; cv=none; b=tlDS7ekCqNgNIZclT+U6GlFiAxdwwfyOiqiz+NvZf9s1mqBwLu8IHMp+Zy2ntKrJWsKMzyw4jOJ2KocPsZAt4Aobw9L+yngc/fMIknY1uCdz6E8CYZQomZqm/kC5Xyz2ajgdtUZXicQ07ZPC+zXxSvaGrt051qIqqPoXU3ECSPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711560112; c=relaxed/simple; bh=xBDlBQTeionAa7BitgK6+Y1KkNbqDzeo3ZWLYmN7Yn4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=UreZuhl/38jnBTn/q5JMvbsZjDVmxv/yZUGmXlPXQsMvybDFiXa+Z0pROFbBtuRKUyuS3oHLM152HHulmEvs8/Qhee/4p4wcVWH5Y1ty0YwaVlc7g+lN2pqo2LYT8zMpOkMwv30ZR6ekXrKKtgSW7kISOYZY4bEAQs73ZuLfhxc= 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=jG/QyNM7; 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="jG/QyNM7" 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:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=DZ0DaQAcEntvKxWanANi3dsLKA1cy5dkz9RnbD1mfQw=; b=jG/QyNM7r9QuiZIXh+DbrkWBwb cgzwfFABhfUpmuz416KPQrM7prhsXHePlgDTUKhJ7eotQRYqLEHbZrCPm04D5APoQ2AtNEfim+0v+ 1FTSWi2IncaMlxmOU/MGVSjxI0DfBAWjSpV1N/esqbf3Os1b117j5dEyi1BMwIfzp0+/8dHdBSw50 xd7FjX4z4Tin1/5YFBxfE/krVKeZdz6zvifzJWsX9mrnh0okhEPrawiP66wMRUdE2NM9vCV1SJELL 7UZ2RFwZ/o35g04Q9RZNH8PqbUwRV4shDpHXXq17U51PNKquQiLzXeQXtlGbrBsZLEYUY8lzoFmvG K//4tGwg==; Received: from 089144220178.atnat0029.highway.webapn.at ([89.144.220.178] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpWyD-0000000AH5M-1whv; Wed, 27 Mar 2024 17:21:50 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: kbusch@kernel.org, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Subject: [PATCH 1/2] block: add a helper to cancel atomic queue limit updates Date: Wed, 27 Mar 2024 18:21:44 +0100 Message-Id: <20240327172145.2844065-1-hch@lst.de> X-Mailer: git-send-email 2.39.2 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 Drivers might have to perform complex actions to determine queue limits, and those might fail. Add a helper to cancel a queue limit update that can be called in those cases. Signed-off-by: Christoph Hellwig --- include/linux/blkdev.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f9b87c39cab047..39fedc8ef9c41f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -892,6 +892,19 @@ int queue_limits_commit_update(struct request_queue *q, struct queue_limits *lim); int queue_limits_set(struct request_queue *q, struct queue_limits *lim); +/** + * queue_limits_cancel_update - cancel an atomic update of queue limits + * @q: queue to update + * + * This functions cancels an atomic update of the queue limits started by + * queue_limits_start_update() and should be used when an error occurs after + * starting update. + */ +static inline void queue_limits_cancel_update(struct request_queue *q) +{ + mutex_lock(&q->limits_lock); +} + /* * Access functions for manipulating queue properties */ From patchwork Wed Mar 27 17:21:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13607120 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 D4CBD14D6E9 for ; Wed, 27 Mar 2024 17:21:56 +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=1711560118; cv=none; b=IU914O0A7SivzZHf8XFkbzsIR9cpDQ0em4DIi7Gr5aJl3sY8xUOKZHkI15azKFMnbDi6QwhGUVhUqMWUgWCPsK2TXqGth7vONi+4AeRa+YsuKZ0syTTaKR+eXWfuBgU+LMGkM4lPLSPaKsSIsiyW/RMcDnWnRqpsUus4suJB6Ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711560118; c=relaxed/simple; bh=2y6qqpnua++1bY+LO4H78bijPUkjALGOJS2mDwO+RFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i6s6LyaZJNufkxvP+5FfyRfpxPP3d7zLYONWa9cZ0IUk9R6Cp3g0y2rI4t8ip/hHhe0gxuopor9UzplTuBQLYZJDqLN9qDddSdKJatMVdjEgBx8x2qhT18Yyzah8/V0NO8qCaxCppp93btQvAWpG1I5y7bpeCoIKB8Xtp0KkrWY= 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=lAPuHZbZ; 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="lAPuHZbZ" 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=JMfSUduTvICr0rbJirGIevmfZNskKYKvkkydG+5NhaE=; b=lAPuHZbZqLp08IKMcJY34H/pKG lCyhInqGd0VdsJFnGLyjgTjEMppMC2lfMSdSIfjw2/im205r/BUDN/WCaJzmIuUeXYRGF6cFNB44X i4G6KoaKsbMdr/eRU9wv8cHsM4/H9CjsKYZts5r3jolVzqpocIeq4waqSph9oT90UfBIcWUMmGIga +MlzQWwYUlr2OapOIv1pJowplEkHOqMxEujAbSKWQ2zSXOsgXN8GJWvS+449/rpeUmUWsdXbz/WA+ 9b2DL6CODJKsPQUO4irWvfeTw4MMRvCSHDUtb4crJUNa014TAzTHt/NqnQf2et4B+ZOhtMFGBytwj W/+wIgYw==; Received: from 089144220178.atnat0029.highway.webapn.at ([89.144.220.178] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpWyH-0000000AH6Y-3LKX; Wed, 27 Mar 2024 17:21:54 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: kbusch@kernel.org, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Kanchan Joshi Subject: [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails Date: Wed, 27 Mar 2024 18:21:45 +0100 Message-Id: <20240327172145.2844065-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240327172145.2844065-1-hch@lst.de> References: <20240327172145.2844065-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 Starting an atomic queue limits update takes a mutex and thus needs to be finished, or with the newly added helper, canceled to not leak the lock critical section. Fixes: 9b130d681443 ("nvme: use the atomic queue limits update API") Reported-by: Kanchan Joshi Signed-off-by: Christoph Hellwig --- drivers/nvme/host/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 943d72bdd794ca..f8a9565bee41d2 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2115,6 +2115,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, ns->head->ids.csi == NVME_CSI_ZNS) { ret = nvme_update_zone_info(ns, lbaf, &lim); if (ret) { + queue_limits_cancel_update(ns->disk->queue); blk_mq_unfreeze_queue(ns->disk->queue); goto out; }