[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1666693096-180008-6-git-send-email-john.garry@huawei.com>
Date: Tue, 25 Oct 2022 18:17:59 +0800
From: John Garry <john.garry@...wei.com>
To: <axboe@...nel.dk>, <damien.lemoal@...nsource.wdc.com>,
<jejb@...ux.ibm.com>, <martin.petersen@...cle.com>,
<jinpu.wang@...ud.ionos.com>, <hare@...e.de>, <bvanassche@....org>,
<hch@....de>, <ming.lei@...hat.com>, <niklas.cassel@....com>
CC: <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-ide@...r.kernel.org>, <linux-scsi@...r.kernel.org>,
<linuxarm@...wei.com>, John Garry <john.garry@...wei.com>
Subject: [PATCH RFC v3 05/22] scsi: core: Add support for reserved command timeout handling
Add support for reserved timeout handling. Any driver which specifies
that it supports reserved tags must supply a handler.
Signed-off-by: John Garry <john.garry@...wei.com>
---
drivers/scsi/hosts.c | 15 +++++++++++----
drivers/scsi/scsi_error.c | 3 +++
include/scsi/scsi_host.h | 1 +
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 78968553089f..52346085b3c1 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -230,10 +230,17 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
goto fail;
}
- if (shost->nr_reserved_cmds && !sht->reserved_queuecommand) {
- shost_printk(KERN_ERR, shost,
- "nr_reserved_cmds set but no method to queue\n");
- goto fail;
+ if (shost->nr_reserved_cmds) {
+ if (!sht->reserved_queuecommand) {
+ shost_printk(KERN_ERR, shost,
+ "nr_reserved_cmds set but no method to queue\n");
+ goto fail;
+ }
+ if (!sht->reserved_timedout) {
+ shost_printk(KERN_ERR, shost,
+ "nr_reserved_cmds set but no method to handle timeouts\n");
+ goto fail;
+ }
}
/* Use min_t(int, ...) in case shost->can_queue exceeds SHRT_MAX */
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 6995c8979230..2f86a4284f29 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -338,6 +338,9 @@ enum blk_eh_timer_return scsi_timeout(struct request *req)
if (host->eh_deadline != -1 && !host->last_reset)
host->last_reset = jiffies;
+ if (blk_mq_is_reserved_rq(req))
+ return host->hostt->reserved_timedout(scmd);
+
if (host->hostt->eh_timed_out)
rtn = host->hostt->eh_timed_out(scmd);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index a39f36aa0b0d..266c13e731de 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -74,6 +74,7 @@ struct scsi_host_template {
*/
int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
int (*reserved_queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
+ enum blk_eh_timer_return (*reserved_timedout)(struct scsi_cmnd *);
/*
* The commit_rqs function is used to trigger a hardware
--
2.35.3
Powered by blists - more mailing lists