Skip to content

Commit c78a826

Browse files
committed
scsi: smartpqi: Fix logical volume rescan race condition
jira LE-2157 Rebuild_History Non-Buildable kernel-5.14.0-503.14.1.el9_5 commit-author Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com> commit fb4cece Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-5.14.0-503.14.1.el9_5/fb4cece1.failed Correct rescan flag race condition. Multiple conditions are being evaluated before notifying OS to do a rescan. Driver will skip rescanning the device if any one of the following conditions are met: - Devices that have not yet been added to the OS or devices that have been removed. - Devices which are already marked for removal or in the phase of removal. Under very rare conditions, after logical volume size expansion, the OS still sees the size of the logical volume which was before expansion. The rescan flag in the driver is used to signal the need for a logical volume rescan. A race condition can occur in the driver, and it leads to one thread overwriting the flag inadvertently. As a result, driver is not notifying the OS SML to rescan the logical volume. Move device->rescan update into new function pqi_mark_volumes_for_rescan() and protect with a spin lock. Move check for device->rescan into new function pqi_volume_rescan_needed() and protect function call with a spin_lock. Reviewed-by: Scott Teel <scott.teel@microchip.com> Reviewed-by: Scott Benesh <scott.benesh@microchip.com> Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com> Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com> Co-developed-by: Murthy Bhat <Murthy.Bhat@microchip.com> Signed-off-by: Murthy Bhat <Murthy.Bhat@microchip.com> Signed-off-by: Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com> Signed-off-by: Don Brace <don.brace@microchip.com> Link: https://lore.kernel.org/r/20231219193653.277553-3-don.brace@microchip.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit fb4cece) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # drivers/scsi/smartpqi/smartpqi_init.c
1 parent 066164b commit c78a826

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
scsi: smartpqi: Fix logical volume rescan race condition
2+
3+
jira LE-2157
4+
Rebuild_History Non-Buildable kernel-5.14.0-503.14.1.el9_5
5+
commit-author Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com>
6+
commit fb4cece17b4583f55b34a8538e27a4adc833c9d4
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-5.14.0-503.14.1.el9_5/fb4cece1.failed
10+
11+
Correct rescan flag race condition.
12+
13+
Multiple conditions are being evaluated before notifying OS to do a rescan.
14+
15+
Driver will skip rescanning the device if any one of the following
16+
conditions are met:
17+
18+
- Devices that have not yet been added to the OS or devices that have been
19+
removed.
20+
21+
- Devices which are already marked for removal or in the phase of removal.
22+
23+
Under very rare conditions, after logical volume size expansion, the OS
24+
still sees the size of the logical volume which was before expansion.
25+
26+
The rescan flag in the driver is used to signal the need for a logical
27+
volume rescan. A race condition can occur in the driver, and it leads to
28+
one thread overwriting the flag inadvertently. As a result, driver is not
29+
notifying the OS SML to rescan the logical volume.
30+
31+
Move device->rescan update into new function pqi_mark_volumes_for_rescan()
32+
and protect with a spin lock.
33+
34+
Move check for device->rescan into new function pqi_volume_rescan_needed()
35+
and protect function call with a spin_lock.
36+
37+
Reviewed-by: Scott Teel <scott.teel@microchip.com>
38+
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
39+
Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
40+
Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
41+
Co-developed-by: Murthy Bhat <Murthy.Bhat@microchip.com>
42+
Signed-off-by: Murthy Bhat <Murthy.Bhat@microchip.com>
43+
Signed-off-by: Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com>
44+
Signed-off-by: Don Brace <don.brace@microchip.com>
45+
Link: https://lore.kernel.org/r/20231219193653.277553-3-don.brace@microchip.com
46+
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
47+
(cherry picked from commit fb4cece17b4583f55b34a8538e27a4adc833c9d4)
48+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
49+
50+
# Conflicts:
51+
# drivers/scsi/smartpqi/smartpqi_init.c
52+
diff --cc drivers/scsi/smartpqi/smartpqi_init.c
53+
index aafd7f17269d,081bb2c09806..000000000000
54+
--- a/drivers/scsi/smartpqi/smartpqi_init.c
55+
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
56+
@@@ -2285,9 -2296,13 +2297,18 @@@ static void pqi_update_device_list(stru
57+
if (device->sdev && device->queue_depth != device->advertised_queue_depth) {
58+
device->advertised_queue_depth = device->queue_depth;
59+
scsi_change_queue_depth(device->sdev, device->advertised_queue_depth);
60+
++<<<<<<< HEAD
61+
+ if (device->rescan) {
62+
+ scsi_rescan_device(&device->sdev->sdev_gendev);
63+
++=======
64+
+ spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
65+
+ if (pqi_volume_rescan_needed(device)) {
66+
++>>>>>>> fb4cece17b45 (scsi: smartpqi: Fix logical volume rescan race condition)
67+
device->rescan = false;
68+
+ spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
69+
+ scsi_rescan_device(device->sdev);
70+
+ } else {
71+
+ spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
72+
}
73+
}
74+
}
75+
diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
76+
index eea90b3ae782..1cb4df29d1e1 100644
77+
--- a/drivers/scsi/smartpqi/smartpqi.h
78+
+++ b/drivers/scsi/smartpqi/smartpqi.h
79+
@@ -1347,7 +1347,6 @@ struct pqi_ctrl_info {
80+
bool controller_online;
81+
bool block_requests;
82+
bool scan_blocked;
83+
- u8 logical_volume_rescan_needed : 1;
84+
u8 inbound_spanning_supported : 1;
85+
u8 outbound_spanning_supported : 1;
86+
u8 pqi_mode_enabled : 1;
87+
* Unmerged path drivers/scsi/smartpqi/smartpqi_init.c

0 commit comments

Comments
 (0)