From: Anastasia Kovaleva <a.kovaleva@yadro.com>
To: <James.Bottomley@HansenPartnership.com>,
<martin.petersen@oracle.com>, <hare@suse.de>, <axboe@kernel.dk>
Cc: <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux@yadro.com>
Subject: [PATCH 1/1] scsi: uninit not completed scsi cmd
Date: Mon, 24 Mar 2025 11:49:33 +0300 [thread overview]
Message-ID: <20250324084933.15932-2-a.kovaleva@yadro.com> (raw)
In-Reply-To: <20250324084933.15932-1-a.kovaleva@yadro.com>
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@yadro.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
next prev parent reply other threads:[~2025-03-24 8:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 8:49 [PATCH 0/1] Fix not fully initialized SCSI commands Anastasia Kovaleva
2025-03-24 8:49 ` Anastasia Kovaleva [this message]
2025-03-24 11:52 ` James Bottomley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250324084933.15932-2-a.kovaleva@yadro.com \
--to=a.kovaleva@yadro.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux@yadro.com \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®