[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250324084933.15932-2-a.kovaleva@yadro.com>
Date: Mon, 24 Mar 2025 11:49:33 +0300
From: Anastasia Kovaleva <a.kovaleva@...ro.com>
To: <James.Bottomley@...senPartnership.com>, <martin.petersen@...cle.com>,
<hare@...e.de>, <axboe@...nel.dk>
CC: <linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux@...ro.com>
Subject: [PATCH 1/1] scsi: uninit not completed scsi cmd
Scsi commands that have not been completed with scsi_done() do not clear
the SCMD_INITIALIZED flag and therefore will not be properly
reinitialized. Thus, the next time the scsi_cmnd structure is used, the
scsi command may fail in scsi_cmd_runtime_exceeced() due to the old
jiffies_at_alloc field of the scsi command:
kernel: sd 16:0:1:84: [sdts] tag#405 timing out command, waited 720s
kernel: sd 16:0:1:84: [sdts] tag#405 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=66636s
Clear the SCMD_INITIALIZED flag for scsi commands, that have not been
completed by SCSI, so that they can be initialised when queueing.
Fixes: 4abafdc4360d ("block: remove the initialize_rq_fn blk_mq_ops method")
Signed-off-by: Anastasia Kovaleva <a.kovaleva@...ro.com>
---
drivers/scsi/scsi_lib.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 79a8fb317a2d..db4c0f07ea72 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1237,8 +1237,12 @@ EXPORT_SYMBOL_GPL(scsi_alloc_request);
*/
static void scsi_cleanup_rq(struct request *rq)
{
+ struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
+
+ cmd->flags &= ~SCMD_INITIALIZED;
+
if (rq->rq_flags & RQF_DONTPREP) {
- scsi_mq_uninit_cmd(blk_mq_rq_to_pdu(rq));
+ scsi_mq_uninit_cmd(cmd);
rq->rq_flags &= ~RQF_DONTPREP;
}
}
--
2.40.3
Powered by blists - more mailing lists