All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Directly kick-off EH when device removed with active IO
@ 2022-12-21  9:25 Xingui Yang
  2022-12-21  9:25 ` [PATCH v3 1/3] scsi: libsas: Add sas_device_task_abort() Xingui Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xingui Yang @ 2022-12-21  9:25 UTC (permalink / raw)
  To: jejb, martin.petersen, john.g.garry
  Cc: linux-scsi, linux-kernel, linuxarm, yangxingui, prime.zeng, kangfenglong

The following patches solve the age-old problem - that is, EH eventually
kicking in only after 30 seconds when a disk is removed with active IO.

This series add a new libsas API - sas_device_task_abort() - to abort
device active io and define a interface lldd_device_task_abort() for
LLDD to implement.

Changes since v2:
- Support both for sas and sata device
- Add a new libsas API
- LLDD implement lldd_device_task_abort()

Xingui Yang (3):
  scsi: libsas: Add sas_device_task_abort()
  scsi: libsas: Directly kick-off EH when device removed with active IO
  scsi: hisi_sas: Implement lldd_device_task_abort()

 drivers/scsi/hisi_sas/hisi_sas_main.c | 19 +++++++++++++++++++
 drivers/scsi/libsas/sas_discover.c    |  3 +++
 drivers/scsi/libsas/sas_scsi_host.c   |  9 +++++++++
 include/scsi/libsas.h                 |  2 ++
 4 files changed, 33 insertions(+)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/3] scsi: libsas: Add sas_device_task_abort()
  2022-12-21  9:25 [PATCH v3 0/3] Directly kick-off EH when device removed with active IO Xingui Yang
@ 2022-12-21  9:25 ` Xingui Yang
  2022-12-21  9:25 ` [PATCH v3 2/3] scsi: libsas: Directly kick-off EH when device removed with active IO Xingui Yang
  2022-12-21  9:25 ` [PATCH v3 3/3] scsi: hisi_sas: Implement lldd_device_task_abort() Xingui Yang
  2 siblings, 0 replies; 4+ messages in thread
From: Xingui Yang @ 2022-12-21  9:25 UTC (permalink / raw)
  To: jejb, martin.petersen, john.g.garry
  Cc: linux-scsi, linux-kernel, linuxarm, yangxingui, prime.zeng, kangfenglong

Add support for abort all active IOs for device, and define a LLDD
interface lldd_device_task_abort for LLDD to implement.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
 drivers/scsi/libsas/sas_scsi_host.c | 9 +++++++++
 include/scsi/libsas.h               | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index a36fa1c128a8..4ac7cffcbada 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -1230,6 +1230,15 @@ void sas_task_abort(struct sas_task *task)
 }
 EXPORT_SYMBOL_GPL(sas_task_abort);
 
+void sas_device_task_abort(struct domain_device *dev)
+{
+	struct sas_internal *i =
+		to_sas_internal(dev->port->ha->core.shost->transportt);
+	if (i->dft->lldd_device_task_abort)
+		i->dft->lldd_device_task_abort(dev);
+}
+EXPORT_SYMBOL_GPL(sas_device_task_abort);
+
 int sas_slave_alloc(struct scsi_device *sdev)
 {
 	if (dev_is_sata(sdev_to_domain_dev(sdev)) && sdev->lun)
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 1aee3d0ebbb2..1bf1cfb13912 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -678,6 +678,7 @@ struct sas_domain_function_template {
 	int (*lldd_abort_task_set)(struct domain_device *, u8 *lun);
 	int (*lldd_clear_task_set)(struct domain_device *, u8 *lun);
 	int (*lldd_I_T_nexus_reset)(struct domain_device *);
+	int (*lldd_device_task_abort)(struct domain_device *dev);
 	int (*lldd_ata_check_ready)(struct domain_device *);
 	void (*lldd_ata_set_dmamode)(struct domain_device *);
 	int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
@@ -743,6 +744,7 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *);
 void sas_init_dev(struct domain_device *);
 
 void sas_task_abort(struct sas_task *);
+void sas_device_task_abort(struct domain_device *dev);
 int sas_eh_abort_handler(struct scsi_cmnd *cmd);
 int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
 int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/3] scsi: libsas: Directly kick-off EH when device removed with active IO
  2022-12-21  9:25 [PATCH v3 0/3] Directly kick-off EH when device removed with active IO Xingui Yang
  2022-12-21  9:25 ` [PATCH v3 1/3] scsi: libsas: Add sas_device_task_abort() Xingui Yang
@ 2022-12-21  9:25 ` Xingui Yang
  2022-12-21  9:25 ` [PATCH v3 3/3] scsi: hisi_sas: Implement lldd_device_task_abort() Xingui Yang
  2 siblings, 0 replies; 4+ messages in thread
From: Xingui Yang @ 2022-12-21  9:25 UTC (permalink / raw)
  To: jejb, martin.petersen, john.g.garry
  Cc: linux-scsi, linux-kernel, linuxarm, yangxingui, prime.zeng, kangfenglong

If the device is gone, call sas_device_task_abort() directly and abort
active IO to kick-off EH Immediately. This avoids having to wait for block
layer timeouts.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
 drivers/scsi/libsas/sas_discover.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index d5bc1314c341..ea5609f9967b 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -362,6 +362,9 @@ static void sas_destruct_ports(struct asd_sas_port *port)
 
 void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev)
 {
+	if (test_bit(SAS_DEV_GONE, &dev->state))
+		sas_device_task_abort(dev);
+
 	if (!test_bit(SAS_DEV_DESTROY, &dev->state) &&
 	    !list_empty(&dev->disco_list_node)) {
 		/* this rphy never saw sas_rphy_add */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 3/3] scsi: hisi_sas: Implement lldd_device_task_abort()
  2022-12-21  9:25 [PATCH v3 0/3] Directly kick-off EH when device removed with active IO Xingui Yang
  2022-12-21  9:25 ` [PATCH v3 1/3] scsi: libsas: Add sas_device_task_abort() Xingui Yang
  2022-12-21  9:25 ` [PATCH v3 2/3] scsi: libsas: Directly kick-off EH when device removed with active IO Xingui Yang
@ 2022-12-21  9:25 ` Xingui Yang
  2 siblings, 0 replies; 4+ messages in thread
From: Xingui Yang @ 2022-12-21  9:25 UTC (permalink / raw)
  To: jejb, martin.petersen, john.g.garry
  Cc: linux-scsi, linux-kernel, linuxarm, yangxingui, prime.zeng, kangfenglong

Implement lldd_device_task_abort() to abort active io for device.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 41ba22f6c7f0..647479e54b62 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1839,6 +1839,24 @@ static int hisi_sas_clear_nexus_ha(struct sas_ha_struct *sas_ha)
 	return TMF_RESP_FUNC_COMPLETE;
 }
 
+static int hisi_sas_device_task_abort(struct domain_device *dev)
+{
+	struct hisi_sas_device *sas_dev = dev->lldd_dev;
+	struct hisi_sas_slot *slot, *slot2;
+	struct sas_task *task;
+
+	spin_lock(&sas_dev->lock);
+	list_for_each_entry_safe(slot, slot2, &sas_dev->list, entry) {
+		task = slot->task;
+		if (unlikely(!task || !task->lldd_task || !task->dev))
+			continue;
+		sas_task_abort(task);
+	}
+	spin_unlock(&sas_dev->lock);
+
+	return 0;
+}
+
 static int hisi_sas_query_task(struct sas_task *task)
 {
 	int rc = TMF_RESP_FUNC_FAILED;
@@ -2029,6 +2047,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = {
 	.lldd_abort_task_set	= hisi_sas_abort_task_set,
 	.lldd_I_T_nexus_reset	= hisi_sas_I_T_nexus_reset,
 	.lldd_lu_reset		= hisi_sas_lu_reset,
+	.lldd_device_task_abort = hisi_sas_device_task_abort,
 	.lldd_query_task	= hisi_sas_query_task,
 	.lldd_clear_nexus_ha	= hisi_sas_clear_nexus_ha,
 	.lldd_port_formed	= hisi_sas_port_formed,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-21  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21  9:25 [PATCH v3 0/3] Directly kick-off EH when device removed with active IO Xingui Yang
2022-12-21  9:25 ` [PATCH v3 1/3] scsi: libsas: Add sas_device_task_abort() Xingui Yang
2022-12-21  9:25 ` [PATCH v3 2/3] scsi: libsas: Directly kick-off EH when device removed with active IO Xingui Yang
2022-12-21  9:25 ` [PATCH v3 3/3] scsi: hisi_sas: Implement lldd_device_task_abort() Xingui Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.