diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2010-10-01 16:55:47 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-10-08 17:03:42 -0400 |
commit | 56dd2c0691a5a387b7b05835fe547dc6fade9407 (patch) | |
tree | d7ff3abef5b42f554128b30072aaa1e2aa7eab08 | |
parent | 39a985547cbfcbb0b23667b69b8ae82a6cf312ac (diff) |
[SCSI] libsas: Don't issue commands to devices that have been hot-removed
sd will get hung up issuing commands to flush write cache if a SAS
device behind the expander is unplugged without warning. Change libsas
to reject commands to domain devices that have already gone away.
[maciej.trela@intel.com: removed setting ->gone in sas_deform_port() to
permit sync cache commands at module removal]
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Tested-by: Haipao Fan <haipao.fan@intel.com>
Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r-- | drivers/scsi/libsas/sas_ata.c | 4 | ||||
-rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 3 | ||||
-rw-r--r-- | drivers/scsi/libsas/sas_scsi_host.c | 7 | ||||
-rw-r--r-- | include/scsi/libsas.h | 1 |
4 files changed, 15 insertions, 0 deletions
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index ddbade7beec9..e1a395b438ee 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c | |||
@@ -162,6 +162,10 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) | |||
162 | unsigned int xfer = 0; | 162 | unsigned int xfer = 0; |
163 | unsigned int si; | 163 | unsigned int si; |
164 | 164 | ||
165 | /* If the device fell off, no sense in issuing commands */ | ||
166 | if (dev->gone) | ||
167 | return AC_ERR_SYSTEM; | ||
168 | |||
165 | task = sas_alloc_task(GFP_ATOMIC); | 169 | task = sas_alloc_task(GFP_ATOMIC); |
166 | if (!task) | 170 | if (!task) |
167 | return AC_ERR_SYSTEM; | 171 | return AC_ERR_SYSTEM; |
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 83dd5070a15c..61d81f858a5a 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
@@ -1724,6 +1724,7 @@ static void sas_unregister_ex_tree(struct domain_device *dev) | |||
1724 | struct domain_device *child, *n; | 1724 | struct domain_device *child, *n; |
1725 | 1725 | ||
1726 | list_for_each_entry_safe(child, n, &ex->children, siblings) { | 1726 | list_for_each_entry_safe(child, n, &ex->children, siblings) { |
1727 | child->gone = 1; | ||
1727 | if (child->dev_type == EDGE_DEV || | 1728 | if (child->dev_type == EDGE_DEV || |
1728 | child->dev_type == FANOUT_DEV) | 1729 | child->dev_type == FANOUT_DEV) |
1729 | sas_unregister_ex_tree(child); | 1730 | sas_unregister_ex_tree(child); |
@@ -1744,6 +1745,7 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent, | |||
1744 | &ex_dev->children, siblings) { | 1745 | &ex_dev->children, siblings) { |
1745 | if (SAS_ADDR(child->sas_addr) == | 1746 | if (SAS_ADDR(child->sas_addr) == |
1746 | SAS_ADDR(phy->attached_sas_addr)) { | 1747 | SAS_ADDR(phy->attached_sas_addr)) { |
1748 | child->gone = 1; | ||
1747 | if (child->dev_type == EDGE_DEV || | 1749 | if (child->dev_type == EDGE_DEV || |
1748 | child->dev_type == FANOUT_DEV) | 1750 | child->dev_type == FANOUT_DEV) |
1749 | sas_unregister_ex_tree(child); | 1751 | sas_unregister_ex_tree(child); |
@@ -1752,6 +1754,7 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent, | |||
1752 | break; | 1754 | break; |
1753 | } | 1755 | } |
1754 | } | 1756 | } |
1757 | parent->gone = 1; | ||
1755 | sas_disable_routing(parent, phy->attached_sas_addr); | 1758 | sas_disable_routing(parent, phy->attached_sas_addr); |
1756 | } | 1759 | } |
1757 | memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); | 1760 | memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); |
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index f0cfba9a1fc8..1787bd2eb4a6 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c | |||
@@ -228,6 +228,13 @@ int sas_queuecommand(struct scsi_cmnd *cmd, | |||
228 | goto out; | 228 | goto out; |
229 | } | 229 | } |
230 | 230 | ||
231 | /* If the device fell off, no sense in issuing commands */ | ||
232 | if (dev->gone) { | ||
233 | cmd->result = DID_BAD_TARGET << 16; | ||
234 | scsi_done(cmd); | ||
235 | goto out; | ||
236 | } | ||
237 | |||
231 | res = -ENOMEM; | 238 | res = -ENOMEM; |
232 | task = sas_create_task(cmd, dev, GFP_ATOMIC); | 239 | task = sas_create_task(cmd, dev, GFP_ATOMIC); |
233 | if (!task) | 240 | if (!task) |
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index d06e13be717b..3dec1949f69c 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h | |||
@@ -205,6 +205,7 @@ struct domain_device { | |||
205 | }; | 205 | }; |
206 | 206 | ||
207 | void *lldd_dev; | 207 | void *lldd_dev; |
208 | int gone; | ||
208 | }; | 209 | }; |
209 | 210 | ||
210 | struct sas_discovery_event { | 211 | struct sas_discovery_event { |