Skip to content

Commit 0f3fce5

Browse files
djbwJames Bottomley
authored andcommitted
[SCSI] libsas: fix ata_eh clobbering ex_phys via smp_ata_check_ready
The check_ready implementation in the expander-attached ata device case polls on sas_ex_phy_discover(). The effect is that the ex_phy fields (critically ->attached_sas_addr) can change. When ata_eh ends and libsas comes along to revalidate the domain sas_unregister_devs_sas_addr() can fail to lookup devices to remove, or fail to re-add an ata device that ata_eh marked as disabled. So change the code to skip the sas_address and change count updates when ata_eh is active. Cc: Jack Wang <jack_wang@usish.com> Tested-by: Maciej Patelczyk <maciej.patelczyk@intel.com> Tested-by: Bartek Nowakowski <bartek.nowakowski@intel.com> Tested-by: Jacek Danecki <jacek.danecki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 9487669 commit 0f3fce5

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎drivers/scsi/libsas/sas_expander.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,16 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
202202
u8 sas_addr[SAS_ADDR_SIZE];
203203
struct smp_resp *resp = rsp;
204204
struct discover_resp *dr = &resp->disc;
205+
struct sas_ha_struct *ha = dev->port->ha;
205206
struct expander_device *ex = &dev->ex_dev;
206207
struct ex_phy *phy = &ex->ex_phy[phy_id];
207208
struct sas_rphy *rphy = dev->rphy;
208209
bool new_phy = !phy->phy;
209210
char *type;
210211

211212
if (new_phy) {
213+
if (WARN_ON_ONCE(test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)))
214+
return;
212215
phy->phy = sas_phy_alloc(&rphy->dev, phy_id);
213216

214217
/* FIXME: error_handling */
@@ -233,6 +236,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
233236
memcpy(sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE);
234237

235238
phy->attached_dev_type = to_dev_type(dr);
239+
if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state))
240+
goto out;
236241
phy->phy_id = phy_id;
237242
phy->linkrate = dr->linkrate;
238243
phy->attached_sata_host = dr->attached_sata_host;
@@ -266,6 +271,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
266271
return;
267272
}
268273

274+
out:
269275
switch (phy->attached_dev_type) {
270276
case SATA_PENDING:
271277
type = "stp pending";
@@ -304,7 +310,15 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
304310
else
305311
return;
306312

307-
SAS_DPRINTK("ex %016llx phy%02d:%c:%X attached: %016llx (%s)\n",
313+
/* if the attached device type changed and ata_eh is active,
314+
* make sure we run revalidation when eh completes (see:
315+
* sas_enable_revalidation)
316+
*/
317+
if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state))
318+
set_bit(DISCE_REVALIDATE_DOMAIN, &dev->port->disc.pending);
319+
320+
SAS_DPRINTK("%sex %016llx phy%02d:%c:%X attached: %016llx (%s)\n",
321+
test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state) ? "ata: " : "",
308322
SAS_ADDR(dev->sas_addr), phy->phy_id,
309323
sas_route_char(dev, phy), phy->linkrate,
310324
SAS_ADDR(phy->attached_sas_addr), type);

0 commit comments

Comments
 (0)