Skip to contentSkip to conversation

Release lock before scsi_remove_device and don't block

PATCH In review Brian Bunker 2 participants 2 messages Dec 1, 2025 – Dec 8, 2025 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Release lock before scsi_remove_device and don't block

Martin, I have added a couple of changes to the patch. Here is the diff from the v2 that I posted. I have made the scsi_remove_device a non-blocking call. I also release the lock before removing the device decreasing the potential for lock contention since what is done under the lock is minimal.

I definitely would prefer multipath-tools to be the mechanism for the purging. Any other option would be in competetion with multipath-tools in obtaining the path state and acting on it. A single point of control seems advantagous.

There are two issues where multipath-tools is a victim. The first one is addressed in the recheck_wwid function. The second one however also leads to an unexpected I/O error when running I/O to the multipath device. There are issues in volume mobility between two arrays where the inquiry data changes and the resurrection of the path with its original inquiry data with the now incorrect inquiry data also leads to an I/O error. In this case multipath-tools is the victim of the kernel not being able to update inquiry data with either inquiry data changed unit attentions or rescans. If you needd more details please letme know.

There may be other reasons to have a purge of disconnected (orphaned sd devices) that we have not encountered. Having a way to purge them seems like a nice step forward.

I also made the man page more clear as to what is happening with the option.

---
 libmultipath/libmultipath.version |   1 +
 libmultipath/sysfs.c              |  58 ++++++-
 libmultipath/sysfs.h              |   2 +
 multipath/multipath.conf.5.in     |  11 +-
 multipathd/main.c                 | 250 +++++++++++++++++++++++-------
 5 files changed, 260 insertions(+), 62 deletions(-)
libmultipath/libmultipath.version +1 -0
index 89ae2a3c..c435847f 100644
@@ -239,6 +239,7 @@ global:
 	snprint_tgt_wwnn;
 	snprint_tgt_wwpn;
 	sysfs_attr_set_value;
+	sysfs_attr_set_value_nonblock;
 	sysfs_attr_get_value;
 	sysfs_get_asymmetric_access_state;
 
libmultipath/sysfs.c +57 -1

70 lines not on this page · raw message

libmultipath/sysfs.h +2 -0
index 45f24c37..da2deaa3 100644
@@ -10,6 +10,8 @@
 int devt2devname (char *, int, const char *);
 ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
 			     const char * value, size_t value_len);
+ssize_t sysfs_attr_set_value_nonblock(struct udev_device *dev, const char *attr_name,
+				      const char * value, size_t value_len);
 ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
 			     char * value, size_t value_len);
 ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name,
multipath/multipath.conf.5.in +6 -5
index 1f806da8..84cd1a0a 100644
@@ -1309,11 +1309,12 @@ The default is: \fBno\fR
 .B purge_disconnected
 If set to
 .I yes
-, multipathd will automatically remove paths that are in the disconnected state
-by writing to the SCSI device's sysfs delete attribute. This triggers kernel-level
-device removal. Paths are retried multiple times before being forcibly cleaned up
-if the kernel removal fails. This option is useful for cleaning up stale paths
-from storage arrays that have been disconnected or removed.
+, multipathd will automatically remove devices that are in a disconnected state.
+A path is considered disconnected when the TUR (Test Unit Ready) path checker
+receives the SCSI sense code "LOGICAL UNIT NOT SUPPORTED" (sense key 0x5,
+ASC/ASCQ 0x25/0x00). This typically indicates that the LUN has been unmapped
+or is no longer presented by the storage array. This option helps clean up
+stale device entries that would otherwise remain in the system.
 .RS
 .TP
 The default is: \fBno\fR
multipathd/main.c +194 -56

324 lines not on this page · raw message

Signature · 1 line
2.51.2
#1 lore raw
Quoted 8 lines · Brian Bunker

Martin, I have added a couple of changes to the patch. Here is the diff
from the v2 that I posted. I have made the scsi_remove_device a non- blocking
call. I also release the lock before removing the device decreasing the
potential for lock contention since what is done under the lock is minimal.

Let's rather not start with patches to patches ;-)

I've looked at your v3; Ben has already provided feedback and I've just added a quick remark.

Quoted 7 lines

I definitely would prefer multipath-tools to be the mechanism for the purging.
Any other option would be in competetion with multipath-tools in obtaining
the path state and acting on it. A single point of control seems advantagous.

OK. But as noted in my reply to the v3 patch, I'd like to keep the access to multipathd's internal data structures to a minimum, preferrably zero. I think it's doable.

Quoted 19 lines

There are two issues where multipath-tools is a victim. The first one is
addressed in the recheck_wwid function. The second one however also leads
to an unexpected I/O error when running I/O to the multipath device. There
are issues in volume mobility between two arrays where the inquiry data changes
and the resurrection of the path with its original inquiry data with the now
incorrect inquiry data also leads to an I/O error. In this case multipath-tools
is the victim of the kernel not being able to update inquiry data with either
inquiry data changed unit attentions or rescans. If you needd more details
please letme know.

Quoted 5 lines

There may be other reasons to have a purge of disconnected (orphaned sd
devices) that we have not encountered. Having a way to purge them seems like
a nice step forward.

I am not questioning that. I appreciate your efforts.

Regards,
Martin