[linux-nvme:nvme-7.2 2/7] drivers/nvme/host/core.c:5259 nvme_wait_freeze_timeout() warn: 'timeout' unsigned <= 0

Maurizio Lombardi mlombard at arkamax.eu
Thu May 21 01:21:16 PDT 2026


On Thu May 21, 2026 at 8:43 AM CEST, Dan Carpenter wrote:
> tree:   git://git.infradead.org/nvme.git nvme-7.2
> head:   00d7b33351aac0ea55d17167561e12bbeca73138
> commit: 23b6d2cbf75ff15647efbb7c0e5c03bd7ed1fe1a [2/7] nvme: remove redundant timeout argument from nvme_wait_freeze_timeout
> config: s390-randconfig-r073-20260521 (https://download.01.org/0day-ci/archive/20260521/202605211257.STzj2Ujv-lkp@intel.com/config)
> compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
> smatch: v0.5.0-9185-gbcc58b9c
>
>
> 302ad8cc09339ea Keith Busch       2017-03-01  5260  			break;
> 302ad8cc09339ea Keith Busch       2017-03-01  5261  	}
> be647e2c76b27f4 Keith Busch       2024-05-21  5262  	srcu_read_unlock(&ctrl->srcu, srcu_idx);
> 7cf0d7c0f3c3b02 Sagi Grimberg     2020-07-30  5263  	return timeout;
>
> This returns is nonsense.  ;)  >= 1 on success or empty.  0 on timeout.

What about 0 on success, -ETIMEDOUT on timeout?

nvme: standardize nvme_wait_freeze_timeout return value

Currently, nvme_wait_freeze_timeout() returns the remaining timeout
value (in jiffies) on success, and 0 on timeout.

Update the function to follow standard kernel conventions by returning
0 on success and -ETIMEDOUT on failure.

Signed-off-by: Maurizio Lombardi <mlombard at redhat.com>
---
 drivers/nvme/host/core.c | 7 +++++--
 drivers/nvme/host/rdma.c | 2 +-
 drivers/nvme/host/tcp.c  | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 26a65404279f..85d94d3b6a28 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5249,16 +5249,19 @@ int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl)
 	unsigned long timeout = ctrl->io_timeout;
 	struct nvme_ns *ns;
 	int srcu_idx;
+	int ret = 0;

 	srcu_idx = srcu_read_lock(&ctrl->srcu);
 	list_for_each_entry_srcu(ns, &ctrl->namespaces, list,
 				 srcu_read_lock_held(&ctrl->srcu)) {
 		timeout = blk_mq_freeze_queue_wait_timeout(ns->queue, timeout);
-		if (!timeout)
+		if (!timeout) {
+			ret = -ETIMEDOUT;
 			break;
+		}
 	}
 	srcu_read_unlock(&ctrl->srcu, srcu_idx);
-	return timeout;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(nvme_wait_freeze_timeout);

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index bf73135c1439..3ac0a7e390e1 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -888,7 +888,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
 	if (!new) {
 		nvme_start_freeze(&ctrl->ctrl);
 		nvme_unquiesce_io_queues(&ctrl->ctrl);
-		if (!nvme_wait_freeze_timeout(&ctrl->ctrl)) {
+		if (nvme_wait_freeze_timeout(&ctrl->ctrl)) {
 			/*
 			 * If we timed out waiting for freeze we are likely to
 			 * be stuck.  Fail the controller initialization just
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 0552aa8a1150..52bd4478181e 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2208,7 +2208,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
 	if (!new) {
 		nvme_start_freeze(ctrl);
 		nvme_unquiesce_io_queues(ctrl);
-		if (!nvme_wait_freeze_timeout(ctrl)) {
+		if (nvme_wait_freeze_timeout(ctrl)) {
 			/*
 			 * If we timed out waiting for freeze we are likely to
 			 * be stuck.  Fail the controller initialization just
--
2.54.0


Maurizio



More information about the Linux-nvme mailing list