summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnett <kevin.barnett@microchip.com>2022-07-08 13:47:51 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2022-07-13 23:42:04 -0400
commit2d80f4054f7f901b8ad97358a9069616ac8524c7 (patch)
tree4506f56f1047027699ae8a2958d03ee9493d2ac8
parentcf15c3e734e8d25de7b4d9170f5a69ace633a583 (diff)
downloadlinux-stable-2d80f4054f7f901b8ad97358a9069616ac8524c7.tar.gz
linux-stable-2d80f4054f7f901b8ad97358a9069616ac8524c7.tar.bz2
linux-stable-2d80f4054f7f901b8ad97358a9069616ac8524c7.zip
scsi: smartpqi: Update deleting a LUN via sysfs
Change removing a LUN using sysfs from an internal driver function pqi_remove_all_scsi_devices() to using the .slave_destroy entry in the scsi_host_template. A LUN can be deleted via sysfs using this syntax: echo 1 > /sys/block/sdX/device/delete Link: https://lore.kernel.org/r/165730607154.177165.9723066932202995774.stgit@brunhilda Reviewed-by: Scott Teel <scott.teel@microchip.com> Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com> Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com> Signed-off-by: Don Brace <don.brace@microchip.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/smartpqi/smartpqi_init.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 2df1e8453029..122772628a2f 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2536,23 +2536,6 @@ out:
return rc;
}
-static void pqi_remove_all_scsi_devices(struct pqi_ctrl_info *ctrl_info)
-{
- unsigned long flags;
- struct pqi_scsi_dev *device;
- struct pqi_scsi_dev *next;
-
- list_for_each_entry_safe(device, next, &ctrl_info->scsi_device_list,
- scsi_device_list_entry) {
- if (pqi_is_device_added(device))
- pqi_remove_device(ctrl_info, device);
- spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
- list_del(&device->scsi_device_list_entry);
- pqi_free_device(device);
- spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
- }
-}
-
static int pqi_scan_scsi_devices(struct pqi_ctrl_info *ctrl_info)
{
int rc;
@@ -6476,6 +6459,35 @@ static int pqi_slave_configure(struct scsi_device *sdev)
return rc;
}
+static void pqi_slave_destroy(struct scsi_device *sdev)
+{
+ struct pqi_ctrl_info *ctrl_info;
+ struct pqi_scsi_dev *device;
+ int mutex_acquired;
+ unsigned long flags;
+
+ ctrl_info = shost_to_hba(sdev->host);
+
+ mutex_acquired = mutex_trylock(&ctrl_info->scan_mutex);
+ if (!mutex_acquired)
+ return;
+
+ device = sdev->hostdata;
+ if (!device) {
+ mutex_unlock(&ctrl_info->scan_mutex);
+ return;
+ }
+
+ spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
+ list_del(&device->scsi_device_list_entry);
+ spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+
+ mutex_unlock(&ctrl_info->scan_mutex);
+
+ pqi_dev_info(ctrl_info, "removed", device);
+ pqi_free_device(device);
+}
+
static int pqi_getpciinfo_ioctl(struct pqi_ctrl_info *ctrl_info, void __user *arg)
{
struct pci_dev *pci_dev;
@@ -7363,6 +7375,7 @@ static struct scsi_host_template pqi_driver_template = {
.ioctl = pqi_ioctl,
.slave_alloc = pqi_slave_alloc,
.slave_configure = pqi_slave_configure,
+ .slave_destroy = pqi_slave_destroy,
.map_queues = pqi_map_queues,
.sdev_groups = pqi_sdev_groups,
.shost_groups = pqi_shost_groups,
@@ -8649,7 +8662,6 @@ static void pqi_remove_ctrl(struct pqi_ctrl_info *ctrl_info)
pqi_fail_all_outstanding_requests(ctrl_info);
ctrl_info->pqi_mode_enabled = false;
}
- pqi_remove_all_scsi_devices(ctrl_info);
pqi_unregister_scsi(ctrl_info);
if (ctrl_info->pqi_mode_enabled)
pqi_revert_to_sis_mode(ctrl_info);