From: JiangJianJun <jiangjianjun3@huawei.com>
To: <James.Bottomley@HansenPartnership.com>,
<martin.petersen@oracle.com>, <linux-scsi@vger.kernel.org>
Cc: <bvanassche@acm.org>, <john.g.garry@oracle.com>,
<hewenliang4@huawei.com>, <yangyun50@huawei.com>,
<wuyifeng10@huawei.com>
Subject: [PATCH] scsi: scsi_debug: make timeout faults by set delay to maximum value
Date: Wed, 5 Nov 2025 19:57:22 +0800 [thread overview]
Message-ID: <20251105115722.1634895-1-jiangjianjun3@huawei.com> (raw)
In-Reply-To: <20250224115517.495899-5-john.g.garry@oracle.com>
The injection of timeout faults is achieved by directly discarding the
SCSI command.
However, after the timeout, the SCSI mid-layer cancels the SCSI command.
At this point, if the command is checked during cancellation, it will result
in a "not found" outcome, making it impossible to cancel the command properly.
Therefore, the approach has been changed to avoid direct cancellation, and the
delay is set to the maximum value(0x7FFFFFFF).
Signed-off-by: JiangJianJun <jiangjianjun3@huawei.com>
---
drivers/scsi/scsi_debug.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 353cb60e1abe..7d86a6f10130 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -9249,6 +9249,7 @@ static int scsi_debug_queuecommand(struct Scsi_Host *shost,
bool inject_now;
int ret = 0;
struct sdebug_err_inject err;
+ bool timeout = false;
scsi_set_resid(scp, 0);
if (sdebug_statistics) {
@@ -9291,7 +9292,7 @@ static int scsi_debug_queuecommand(struct Scsi_Host *shost,
if (sdebug_timeout_cmd(scp)) {
scmd_printk(KERN_INFO, scp, "timeout command 0x%x\n", opcode);
- return 0;
+ timeout = true;
}
ret = sdebug_fail_queue_cmd(scp);
@@ -9398,7 +9399,9 @@ static int scsi_debug_queuecommand(struct Scsi_Host *shost,
pfp = r_pfp; /* if leaf function ptr NULL, try the root's */
fini:
- if (F_DELAY_OVERR & flags) /* cmds like INQUIRY respond asap */
+ if (unlikely(timeout)) /* inject timeout */
+ return schedule_resp(scp, devip, errsts, pfp, 0x7FFFFFFF, 0x7FFFFFFF);
+ else if (F_DELAY_OVERR & flags) /* cmds like INQUIRY respond asap */
return schedule_resp(scp, devip, errsts, pfp, 0, 0);
else if ((flags & F_LONG_DELAY) && (sdebug_jdelay > 0 ||
sdebug_ndelay > 10000)) {
--
2.33.0
next prev parent reply other threads:[~2025-11-05 11:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 11:55 [PATCH 0/4] scsi_debug improvements John Garry
2025-02-24 11:55 ` [PATCH 1/4] scsi: scsi_debug: Remove sdebug_device_access_info John Garry
2025-02-24 18:04 ` Bart Van Assche
2025-02-24 11:55 ` [PATCH 2/4] scsi: scsi_debug: Remove a reference to in_use_bm John Garry
2025-02-24 11:55 ` [PATCH 3/4] scsi: scsi_debug: Simplify command handling John Garry
2025-02-24 11:55 ` [PATCH 4/4] scsi: scsi_debug: Do not sleep in atomic sections John Garry
2025-11-05 11:57 ` JiangJianJun [this message]
2025-11-05 12:00 ` [PATCH] scsi: scsi_debug: make timeout faults by set delay to maximum value JiangJianJun
2025-11-05 12:01 ` JiangJianJun
2025-11-05 11:54 ` John Garry
2025-11-06 12:03 ` JiangJianJun
2025-11-07 10:05 ` John Garry
2025-11-08 8:29 ` JiangJianJun
2025-11-08 9:38 ` John Garry
2025-11-11 10:59 ` JiangJianJun
2025-11-12 8:53 ` John Garry
2025-11-12 13:38 ` JiangJianJun
2025-11-12 16:02 ` John Garry
2025-11-13 11:22 ` JiangJianJun
2025-11-13 11:48 ` John Garry
2025-02-25 1:57 ` [PATCH 0/4] scsi_debug improvements Martin K. Petersen
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=20251105115722.1634895-1-jiangjianjun3@huawei.com \
--to=jiangjianjun3@huawei.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bvanassche@acm.org \
--cc=hewenliang4@huawei.com \
--cc=john.g.garry@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=wuyifeng10@huawei.com \
--cc=yangyun50@huawei.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