Skip to contentSkip to conversation

libsas error handling + discovery v11

PATCH New Dan Williams 1 participant 3 messages Mar 14, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v11 cover libsas error handling + discovery v11

Changes since v10: http://marc.info/?l=linux-scsi&m=133143989626340&0w=2

Rebase the tree on the scsi-misc to drop the accepted patches and resolve the conflicts in -next. Only "libsas: enforce eh strategy handlers only in eh context" had to be fixed up (collision in sas_init_dev).

Add a new fix for a regression in sas_get_port_device().

[libsas PATCH 1/2 v11] libsas: enforce eh strategy handlers only in eh context [libsas PATCH 2/2 v11] libsas: fix sas_get_port_device regression

The delta vs scsi-misc is now (cd8df93..libsas-eh-reworks-v11):

Dan Carpenter (1):
mvsas: remove unused variable in mvs_task_exec()

Dan Williams (9):
libsas: introduce sas_work to fix sas_drain_work vs sas_queue_work
libsas: cleanup spurious calls to scsi_schedule_eh libata, libsas: introduce sched_eh and end_eh port ops
libsas: enforce eh strategy handlers only in eh context
libsas: add sas_eh_abort_handler
libsas: use ->lldd_I_T_nexus_reset for ->eh_bus_reset_handler
isci: use sas eh strategy handlers
libsas: trim sas_task of slow path infrastructure
libsas: fix sas_get_port_device regression

Jeff Skirvin (1):
libsas: sas_rediscover_dev did not look at the SMP exec status.

Thomas Jackson (1):
libsas: fix sas_find_bcast_phy() in the presence of 'vacant' phys

 drivers/ata/libata-core.c           |    4 +
 drivers/ata/libata-eh.c             |   57 ++++++++--
 drivers/scsi/isci/init.c            |    3 +
 drivers/scsi/libsas/sas_ata.c       |   63 ++++++-----
 drivers/scsi/libsas/sas_discover.c  |   54 ++++++----
 drivers/scsi/libsas/sas_event.c     |   36 ++++---
 drivers/scsi/libsas/sas_expander.c  |   44 +++++---
 drivers/scsi/libsas/sas_init.c      |   50 ++++++---
 drivers/scsi/libsas/sas_internal.h  |    6 +-
 drivers/scsi/libsas/sas_phy.c       |   21 ++---
 drivers/scsi/libsas/sas_port.c      |   15 +--
 drivers/scsi/libsas/sas_scsi_host.c |  199 ++++++++++++++++++++++++++++++-----
 drivers/scsi/mvsas/mv_sas.c         |   21 ++--
 drivers/scsi/pm8001/pm8001_sas.c    |   37 ++++---
 include/linux/libata.h              |    4 +
 include/scsi/libsas.h               |   69 ++++++++++--
 include/scsi/sas_ata.h              |    9 +-
 17 files changed, 487 insertions(+), 205 deletions(-)
#1 lore raw

PATCH v11 1/2 libsas: enforce eh strategy handlers only in eh context

The strategy handlers may be called in places that are problematic for libsas (i.e. sata resets outside of domain revalidation filtering / libata link recovery), or problematic for userspace (non-blocking ioctl to sleeping reset functions). However, these routines are also called for eh escalations and recovery of scsi_eh_prep_cmnd(), so permit them as long as we are running in the host's error handler, otherwise arrange for them to be triggered in eh_context.

---
 drivers/scsi/libsas/sas_discover.c  |   11 +++
 drivers/scsi/libsas/sas_init.c      |    2 +
 drivers/scsi/libsas/sas_scsi_host.c |  121 ++++++++++++++++++++++++++++++++++-
 include/scsi/libsas.h               |   10 +++
 4 files changed, 140 insertions(+), 4 deletions(-)
drivers/scsi/libsas/sas_discover.c +11 -0
index b82949c..c140355 100644
@@ -39,6 +39,7 @@ void sas_init_dev(struct domain_device *dev)
 {
 	switch (dev->dev_type) {
 	case SAS_END_DEV:
+		INIT_LIST_HEAD(&dev->ssp_dev.eh_list_node);
 		break;
 	case EDGE_DEV:
 	case FANOUT_DEV:
@@ -274,6 +275,8 @@ void sas_free_device(struct kref *kref)
 
 static void sas_unregister_common_dev(struct asd_sas_port *port, struct domain_device *dev)
 {
+	struct sas_ha_struct *ha = port->ha;
+
 	sas_notify_lldd_dev_gone(dev);
 	if (!dev->parent)
 		dev->port->port_dev = NULL;
@@ -286,6 +289,14 @@ static void sas_unregister_common_dev(struct asd_sas_port *port, struct domain_d
 		sas_ata_end_eh(dev->sata_dev.ap);
 	spin_unlock_irq(&port->dev_list_lock);
 
+	spin_lock_irq(&ha->lock);
+	if (dev->dev_type == SAS_END_DEV &&
+	    !list_empty(&dev->ssp_dev.eh_list_node)) {
+		list_del_init(&dev->ssp_dev.eh_list_node);
+		ha->eh_active--;
+	}
+	spin_unlock_irq(&ha->lock);
+
 	sas_put_device(dev);
 }
 
drivers/scsi/libsas/sas_init.c +2 -0
index 6909fef..1bbab3d 100644
@@ -116,7 +116,9 @@ int sas_register_ha(struct sas_ha_struct *sas_ha)
 	set_bit(SAS_HA_REGISTERED, &sas_ha->state);
 	spin_lock_init(&sas_ha->lock);
 	mutex_init(&sas_ha->drain_mutex);
+	init_waitqueue_head(&sas_ha->eh_wait_q);
 	INIT_LIST_HEAD(&sas_ha->defer_q);
+	INIT_LIST_HEAD(&sas_ha->eh_dev_q);
 
 	error = sas_register_phys(sas_ha);
 	if (error) {
drivers/scsi/libsas/sas_scsi_host.c +117 -4

151 lines not on this page · raw message

include/scsi/libsas.h +10 -0
index c0c94b3..1b14d80 100644
@@ -174,10 +174,17 @@ struct sata_device {
 	struct ata_taskfile tf;
 };
 
+struct ssp_device {
+	struct list_head eh_list_node; /* pending a user requested eh action */
+	struct scsi_lun reset_lun;
+};
+
 enum {
 	SAS_DEV_GONE,
 	SAS_DEV_DESTROY,
 	SAS_DEV_EH_PENDING,
+	SAS_DEV_LU_RESET,
+	SAS_DEV_RESET,
 };
 
 struct domain_device {
@@ -211,6 +218,7 @@ struct domain_device {
         union {
                 struct expander_device ex_dev;
                 struct sata_device     sata_dev; /* STP & directly attached */
+		struct ssp_device      ssp_dev;
         };
 
         void *lldd_dev;
@@ -387,6 +395,8 @@ struct sas_ha_struct {
 	unsigned long	  state;
 	spinlock_t 	  lock;
 	int		  eh_active;
+	wait_queue_head_t eh_wait_q;
+	struct list_head  eh_dev_q;
 
 	struct mutex disco_mutex;
 
#2 lore raw

PATCH v11 2/2 libsas: fix sas_get_port_device regression

In reply to Dan Williams

Commit 899fcf4 "[SCSI] libsas: set attached device type and target protocols for local phys" setup 'phy' to be dereferenced after list_for_each_entry(phy, &port->phy_list, port_phy_el) (i.e. phy == &port->phy_list) resulting in reports like:

  BUG: unable to handle kernel NULL pointer dereference at 00000000000002b0
  IP: [<ffffffffa00ce948>] sas_discover_domain+0x29e/0x4fb [libsas]

...fix by deferring sas_phy_set_target() to the end of sas_get_port_device().

---
 drivers/scsi/libsas/sas_discover.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/scsi/libsas/sas_discover.c +5 -4
index c140355..8ab1de6 100644
@@ -135,10 +135,6 @@ static int sas_get_port_device(struct asd_sas_port *port)
 		return -ENODEV;
 	}
 
-	spin_lock_irq(&port->phy_list_lock);
-	list_for_each_entry(phy, &port->phy_list, port_phy_el)
-		sas_phy_set_target(phy, dev);
-	spin_unlock_irq(&port->phy_list_lock);
 	rphy->identify.phy_identifier = phy->phy->identify.phy_identifier;
 	memcpy(dev->sas_addr, port->attached_sas_addr, SAS_ADDR_SIZE);
 	sas_fill_in_rphy(dev, rphy);
@@ -165,6 +161,11 @@ static int sas_get_port_device(struct asd_sas_port *port)
 		spin_unlock_irq(&port->dev_list_lock);
 	}
 
+	spin_lock_irq(&port->phy_list_lock);
+	list_for_each_entry(phy, &port->phy_list, port_phy_el)
+		sas_phy_set_target(phy, dev);
+	spin_unlock_irq(&port->phy_list_lock);
+
 	return 0;
 }