Skip to contentSkip to conversation

scsi: smartpqi: fixes for scsi device removal

PATCH NAK [email protected] 3 participants 6 messages Jun 17, 2020 – Jun 18, 2020

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

v2 cover scsi: smartpqi: fixes for scsi device removal

From: Martin Wilck <[email protected]>

Hi Don, Martin,

here's a small update for the mini-series I sent yesterday.

Regards
Martin

Changes wrt v1:
- added patch 3/3.

Martin Wilck (3):
scsi: smartpqi: grab scsi device ref in slave_configure()
scsi: smartpqi: check sdev in pqi_scsi_find_entry
scsi: smartpqi: remove conditional before pqi_remove_device()

 drivers/scsi/smartpqi/smartpqi.h      |   1 +
 drivers/scsi/smartpqi/smartpqi_init.c | 131 +++++++++++++++++++++-----
 2 files changed, 107 insertions(+), 25 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/3 scsi: smartpqi: grab scsi device ref in slave_configure()

From: Martin Wilck <[email protected]>

We have observed kernel crashes caused by the smartpqi driver holding a pointer to a struct scsi_device that had been removed already. Fix this by getting and holding a ref for the device as long as the driver uses it.

Use a lock to avoid races between device probing and removal.

---
 drivers/scsi/smartpqi/smartpqi.h      |   1 +
 drivers/scsi/smartpqi/smartpqi_init.c | 122 +++++++++++++++++++++-----
 2 files changed, 103 insertions(+), 20 deletions(-)
drivers/scsi/smartpqi/smartpqi.h +1 -0
index 1129fe7a27ed..5801080c8dbc 100644
@@ -954,6 +954,7 @@ struct pqi_scsi_dev {
 	struct raid_map *raid_map;	/* RAID bypass map */
 
 	struct pqi_sas_port *sas_port;
+	spinlock_t sdev_lock;		/* protect access to sdev */
 	struct scsi_device *sdev;
 
 	struct list_head scsi_device_list_entry;
drivers/scsi/smartpqi/smartpqi_init.c +102 -20

176 lines not on this page · raw message

Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/3 scsi: smartpqi: check sdev in pqi_scsi_find_entry

In reply to [email protected]

From: Martin Wilck <[email protected]>

If a scsi device has been destroyed e.g. using the sysfs "delete" attribute, subsequent host rescans won't re-discover it. This patch makes it work at least via the smartqpi-specific "rescan" sysfs attribute.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -1
index 54a72f465f85..87089b67ff74 100644
@@ -1612,7 +1612,8 @@ static enum pqi_find_result pqi_scsi_find_entry(struct pqi_ctrl_info *ctrl_info,
 			device->scsi3addr)) {
 			*matching_device = device;
 			if (pqi_device_equal(device_to_find, device)) {
-				if (device_to_find->volume_offline)
+				if (device_to_find->volume_offline ||
+				    !pqi_get_scsi_device(device))
 					return DEVICE_CHANGED;
 				return DEVICE_SAME;
 			}
Signature · 1 line
2.26.2
#3 lore raw

PATCH v2 3/3 scsi: smartpqi: remove conditional before pqi_remove_device()

In reply to [email protected]

From: Martin Wilck <[email protected]>

pqi_remove_device() checks if there's anything to remove, for both logical and SAS devices. So these conditionals are redundant. They may actually be wrong, because they would skip removing pysical devices which are not SMP expanders.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -4
index 87089b67ff74..7e4d5c5ea2b0 100644
@@ -1879,8 +1879,7 @@ static void pqi_update_device_list(struct pqi_ctrl_info *ctrl_info,
 		} else {
 			pqi_dev_info(ctrl_info, "removed", device);
 		}
-		if (pqi_is_device_added(device))
-			pqi_remove_device(ctrl_info, device);
+		pqi_remove_device(ctrl_info, device);
 		list_del(&device->delete_list_entry);
 		pqi_free_device(device);
 	}
@@ -2223,8 +2222,7 @@ static void pqi_remove_all_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 		if (!device)
 			break;
 
-		if (pqi_is_device_added(device))
-			pqi_remove_device(ctrl_info, device);
+		pqi_remove_device(ctrl_info, device);
 		pqi_free_device(device);
 	}
 }
Signature · 1 line
2.26.2
Reviewed-by on v2 3/3
#4 lore raw

RE: [PATCH v2 3/3] scsi: smartpqi: remove conditional before pqi_remove_device()

One small typo in the commit message pysical should be physical.

Quoted 51 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Wednesday, 17 June 2020 6:35 PM
To: Don Brace <[email protected]>; Martin K. Petersen <[email protected]>
Cc: [email protected]; [email protected]; Seymour, Shane M <[email protected]>; Martin Wilck <[email protected]>
Subject: [PATCH v2 3/3] scsi: smartpqi: remove conditional before pqi_remove_device()

From: Martin Wilck <[email protected]>

pqi_remove_device() checks if there's anything to remove, for both logical and SAS devices. So these conditionals are redundant. They may actually be wrong, because they would skip removing pysical devices which are not SMP expanders.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +1 -2
index 87089b67ff74..7e4d5c5ea2b0 100644
@@ -1879,8 +1879,7 @@ static void pqi_update_device_list(struct
 pqi_ctrl_info *ctrl_info,
 		} else {
 			pqi_dev_info(ctrl_info, "removed", device);
 		}
-		if (pqi_is_device_added(device))
-			pqi_remove_device(ctrl_info, device);
+		pqi_remove_device(ctrl_info, device);
 		list_del(&device->delete_list_entry);
 		pqi_free_device(device);
drivers/scsi/smartpqi/smartpqi_init.c +1 -2
 	}
@@ -2223,8 +2222,7 @@ static void pqi_remove_all_scsi_devices(struct
 pqi_ctrl_info *ctrl_info)
 		if (!device)
 			break;
 
-		if (pqi_is_device_added(device))
-			pqi_remove_device(ctrl_info, device);
+		pqi_remove_device(ctrl_info, device);
 		pqi_free_device(device);
 	}

}
--
2.26.2