Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] libsas: fix/amend device gone notification in sas_deform_port()

Commit 56dd2c06 "libsas: Don't issue commands to devices that have been
hot-removed" edited Darrick's original patch to remove setting 'gone' in
the sas_deform_port() path because that prevented scsi sync cache
commands from being issued when the driver was unloaded. However, this
allows true device gone notifications (as signaled port phy events) to
trigger sync cache commands to devices that are known to be unreachable.

Teach libsas which sas_deform_port() invocations are likely device gone
events.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <jbottomley@parallels.com>

authored by

Dan Williams and committed by
James Bottomley
90f1e10d c95286d8

+15 -12
+1 -1
drivers/scsi/libsas/sas_internal.h
··· 57 57 int sas_init_events(struct sas_ha_struct *sas_ha); 58 58 void sas_shutdown_queue(struct sas_ha_struct *sas_ha); 59 59 60 - void sas_deform_port(struct asd_sas_phy *phy); 60 + void sas_deform_port(struct asd_sas_phy *phy, int gone); 61 61 62 62 void sas_porte_bytes_dmaed(struct work_struct *work); 63 63 void sas_porte_broadcast_rcvd(struct work_struct *work);
+2 -2
drivers/scsi/libsas/sas_phy.c
··· 39 39 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock, 40 40 &phy->phy_events_pending); 41 41 phy->error = 0; 42 - sas_deform_port(phy); 42 + sas_deform_port(phy, 1); 43 43 } 44 44 45 45 static void sas_phye_oob_done(struct work_struct *work) ··· 66 66 sas_begin_event(PHYE_OOB_ERROR, &phy->ha->event_lock, 67 67 &phy->phy_events_pending); 68 68 69 - sas_deform_port(phy); 69 + sas_deform_port(phy, 1); 70 70 71 71 if (!port && phy->enabled && i->dft->lldd_control_phy) { 72 72 phy->error++;
+12 -9
drivers/scsi/libsas/sas_port.c
··· 57 57 58 58 if (port) { 59 59 if (!phy_is_wideport_member(port, phy)) 60 - sas_deform_port(phy); 60 + sas_deform_port(phy, 0); 61 61 else { 62 62 SAS_DPRINTK("%s: phy%d belongs to port%d already(%d)!\n", 63 63 __func__, phy->id, phy->port->id, ··· 153 153 * This is called when the physical link to the other phy has been 154 154 * lost (on this phy), in Event thread context. We cannot delay here. 155 155 */ 156 - void sas_deform_port(struct asd_sas_phy *phy) 156 + void sas_deform_port(struct asd_sas_phy *phy, int gone) 157 157 { 158 158 struct sas_ha_struct *sas_ha = phy->ha; 159 159 struct asd_sas_port *port = phy->port; 160 160 struct sas_internal *si = 161 161 to_sas_internal(sas_ha->core.shost->transportt); 162 + struct domain_device *dev; 162 163 unsigned long flags; 163 164 164 165 if (!port) 165 166 return; /* done by a phy event */ 166 167 167 - if (port->port_dev) 168 - port->port_dev->pathways--; 168 + dev = port->port_dev; 169 + if (dev) 170 + dev->pathways--; 169 171 170 172 if (port->num_phys == 1) { 173 + if (dev && gone) 174 + dev->gone = 1; 171 175 sas_unregister_domain_devices(port); 172 176 sas_port_delete(port->port); 173 177 port->port = NULL; 174 178 } else 175 179 sas_port_delete_phy(port->port, phy->phy); 176 - 177 180 178 181 if (si->dft->lldd_port_deformed) 179 182 si->dft->lldd_port_deformed(phy); ··· 247 244 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock, 248 245 &phy->port_events_pending); 249 246 250 - sas_deform_port(phy); 247 + sas_deform_port(phy, 1); 251 248 } 252 249 253 250 void sas_porte_timer_event(struct work_struct *work) ··· 259 256 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock, 260 257 &phy->port_events_pending); 261 258 262 - sas_deform_port(phy); 259 + sas_deform_port(phy, 1); 263 260 } 264 261 265 262 void sas_porte_hard_reset(struct work_struct *work) ··· 271 268 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock, 272 269 &phy->port_events_pending); 273 270 274 - sas_deform_port(phy); 271 + sas_deform_port(phy, 1); 275 272 } 276 273 277 274 /* ---------- SAS port registration ---------- */ ··· 309 306 310 307 for (i = 0; i < sas_ha->num_phys; i++) 311 308 if (sas_ha->sas_phy[i]->port) 312 - sas_deform_port(sas_ha->sas_phy[i]); 309 + sas_deform_port(sas_ha->sas_phy[i], 0); 313 310 314 311 }