From: Wenchao Hao <haowenchao@huawei.com>
To: "James E . J . Bottomley" <jejb@linux.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Steffen Maier <maier@linux.ibm.com>, <liuzhiqiang26@huawei.com>,
<linfeilong@huawei.com>, Wenchao Hao <haowenchao@huawei.com>
Subject: [PATCH v2 1/2] scsi: increase scsi device's iodone_cnt in scsi_timeout()
Date: Fri, 21 Oct 2022 19:56:37 -0400 [thread overview]
Message-ID: <20221021235638.1968832-2-haowenchao@huawei.com> (raw)
In-Reply-To: <20221021235638.1968832-1-haowenchao@huawei.com>
If an scsi command time out and going to be aborted, we should
increase the iodone_cnt of the related scsi device, or the
iodone_cnt would be less than iorequest_cnt
Increase iodone_cnt in scsi_timeout() would not cause double
accounting issue, briefly analysed as following:
- we add the iodone_cnt when BLK_EH_DONE would be returned in
scsi_timeout(), so the related scsi command's timeout event
would not happened
- if the abort succeed and do not retry, the command would be done
with scsi_finish_command() which would not increase iodone_cnt;
- if the abort succeed and retry the command, it would be requeue,
a scsi_dispatch_cmd() would be called and iorequest_cnt would be
increased again
- if the abort failed, the error handler successfully recover the
device, do not retry this command, the command would be done
with scsi_finish_command() which would not increase iodone_cnt;
- if the abort failed, the error handler successfully recover the
device, and retry this command, the iorequest_cnt would be
increased again
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
---
drivers/scsi/scsi_error.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 6995c8979230..052b00f57b56 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -356,6 +356,7 @@ enum blk_eh_timer_return scsi_timeout(struct request *req)
*/
if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state))
return BLK_EH_RESET_TIMER;
+ atomic_inc(&scmd->device->iodone_cnt);
if (scsi_abort_command(scmd) != SUCCESS) {
set_host_byte(scmd, DID_TIME_OUT);
scsi_eh_scmd_add(scmd);
--
2.35.3
next prev parent reply other threads:[~2022-10-21 10:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-21 23:56 [PATCH v2 0/2] Fix scsi device's iodone_cnt mismatch with iorequest_cnt Wenchao Hao
2022-10-21 23:56 ` Wenchao Hao [this message]
2022-11-22 16:25 ` [PATCH v2 1/2] scsi: increase scsi device's iodone_cnt in scsi_timeout() Mike Christie
2022-10-21 23:56 ` [PATCH v2 2/2] scsi: donot increase scsi_device's iorequest_cnt if dispatch failed Wenchao Hao
2022-11-22 16:32 ` Mike Christie
2022-11-08 3:08 ` [PATCH v2 0/2] Fix scsi device's iodone_cnt mismatch with iorequest_cnt Wenchao Hao
2022-11-21 14:38 ` Wenchao Hao
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=20221021235638.1968832-2-haowenchao@huawei.com \
--to=haowenchao@huawei.com \
--cc=jejb@linux.ibm.com \
--cc=linfeilong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liuzhiqiang26@huawei.com \
--cc=maier@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).