drivers/nvme/host/core.c:5259 nvme_wait_freeze_timeout() warn: 'timeout' unsigned <= 0
Dan Carpenter
build botBCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Maurizio Lombardi <[email protected]>
CC: Keith Busch <[email protected]>
CC: Daniel Wagner <[email protected]>
CC: Mohamed Khalfella <[email protected]>
CC: Hannes Reinecke <[email protected]>
CC: Christoph Hellwig <[email protected]>
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
:::::: branch date: 10 hours ago
:::::: commit date: 10 hours ago
config: s390-randconfig-r073-20260521 (https://download.01.org/0day-ci/archive/20260521/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
smatch: v0.5.0-9185-gbcc58b9c
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:drivers/nvme/host/core.c:5259 nvme_wait_freeze_timeout() warn: 'timeout' unsigned <= 0
vim +/timeout +5259 drivers/nvme/host/core.c
302ad8cc09339ea Keith Busch 2017-03-01 5248
23b6d2cbf75ff15 Maurizio Lombardi 2026-05-14 5249 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl)
302ad8cc09339ea Keith Busch 2017-03-01 5250 {
23b6d2cbf75ff15 Maurizio Lombardi 2026-05-14 5251 unsigned long timeout = NVME_IO_TIMEOUT;
302ad8cc09339ea Keith Busch 2017-03-01 5252 struct nvme_ns *ns;
be647e2c76b27f4 Keith Busch 2024-05-21 5253 int srcu_idx;
302ad8cc09339ea Keith Busch 2017-03-01 5254
be647e2c76b27f4 Keith Busch 2024-05-21 5255 srcu_idx = srcu_read_lock(&ctrl->srcu);
6d1c69945ce63a9 Breno Leitao 2024-11-04 5256 list_for_each_entry_srcu(ns, &ctrl->namespaces, list,
6d1c69945ce63a9 Breno Leitao 2024-11-04 5257 srcu_read_lock_held(&ctrl->srcu)) {
302ad8cc09339ea Keith Busch 2017-03-01 5258 timeout = blk_mq_freeze_queue_wait_timeout(ns->queue, timeout);
302ad8cc09339ea Keith Busch 2017-03-01 @5259 if (timeout <= 0)
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;
302ad8cc09339ea Keith Busch 2017-03-01 5264 }
302ad8cc09339ea Keith Busch 2017-03-01 5265 EXPORT_SYMBOL_GPL(nvme_wait_freeze_timeout);
302ad8cc09339ea Keith Busch 2017-03-01 5266 :::::: The code at line 5259 was first introduced by commit
:::::: 302ad8cc09339ea261eef58a8d5f4a116a8ffda5 nvme: Complete all stuck requests
:::::: TO: Keith Busch <[email protected]>
:::::: CC: Jens Axboe <[email protected]>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Quoted 16 lines · Dan Carpenter
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/[email protected]/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) smatch: v0.5.0-9185-gbcc58b9cIf you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/smatch warnings:
drivers/nvme/host/core.c:5259nvme_wait_freeze_timeout()warn: 'timeout' unsigned <= 0
Quoted 8 lines
vim +/timeout +5259
drivers/nvme/host/core.c23b6d2cbf75ff15 Maurizio Lombardi 2026-05-14 5249 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl) 302ad8cc09339ea Keith Busch 2017-03-01 5250 { 23b6d2cbf75ff15 Maurizio Lombardi 2026-05-14 5251 unsigned long timeout = NVME_IO_TIMEOUT; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This is unsigned.
NVME_IO_TIMEOUTis 30 * HZ. Can the&ctrl->namespaceslist ever be empty?
I already had a patch for this, I am going to submit it today.
https://lore.kernel.org/linux-nvme/[email protected]/
Thanks.
Quoted 25 lines
302ad8cc09339ea Keith Busch 2017-03-01 5252 struct nvme_ns *ns; be647e2c76b27f4 Keith Busch 2024-05-21 5253 int srcu_idx; 302ad8cc09339ea Keith Busch 2017-03-01 5254 be647e2c76b27f4 Keith Busch 2024-05-21 5255 srcu_idx = srcu_read_lock(&ctrl->srcu); 6d1c69945ce63a9 Breno Leitao 2024-11-04 5256 list_for_each_entry_srcu(ns, &ctrl->namespaces, list, 6d1c69945ce63a9 Breno Leitao 2024-11-04 5257 srcu_read_lock_held(&ctrl->srcu)) { 302ad8cc09339ea Keith Busch 2017-03-01 5258 timeout = blk_mq_freeze_queue_wait_timeout(ns->queue, timeout); 302ad8cc09339ea Keith Busch 2017-03-01 @5259 if (timeout <= 0)
blk_mq_freeze_queue_wait_timeout()returns 0 on timeout and >= 1 on success.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.
302ad8cc09339eaKeith Busch 2017-03-01 5264 }--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Quoted 8 lines · Dan Carpenter
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/[email protected]/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) smatch: v0.5.0-9185-gbcc58b9c
Quoted 6 lines
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.
--- 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(-)
drivers/nvme/host/core.c +5 -2
@@ -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);
drivers/nvme/host/rdma.c +1 -1
@@ -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
drivers/nvme/host/tcp.c +1 -1
@@ -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