Skip to content

Commit 9f3f797

Browse files
diwakar-kristappagarirobn
authored andcommitted
vdev_id: symlinks creation for multipath disk partitions (openzfs#17331)
It has been observed that the symlinks are not being created for the disk partitions on multipath enabled systems. This fix addresses the issue. Signed-off-by: Diwakar Kristappagari <[email protected]> Reviewed-by: Akash B <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Ameer Hamza <[email protected]> (cherry picked from commit e2ba0f7)
1 parent 00d72ed commit 9f3f797

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

udev/vdev_id

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,20 @@ sas_handler() {
288288
# we have to append the -part suffix directly in the
289289
# helper.
290290
if [ "$DEVTYPE" != "partition" ] ; then
291-
# Match p[number], remove the 'p' and prepend "-part"
292-
PART=$(echo "$DM_NAME" |
293-
awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
291+
# WWNs end with number -> p<partition>, alphabet -> <partition>
292+
# '3' + (WWN length 16) = 17
293+
PART=${DM_NAME:17}
294+
if [[ $PART = "p"* ]]; then
295+
# Match p[number], remove the 'p' and prepend "-part"
296+
PART=$(echo "$DM_NAME" |
297+
awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
298+
elif [[ $PART != "" ]]; then
299+
PART="-part"${PART}
300+
fi
294301
fi
295302

296303
# Strip off partition information.
297-
DM_NAME=$(echo "$DM_NAME" | sed 's/p[0-9][0-9]*$//')
304+
DM_NAME=${DM_NAME:0:17}
298305
if [ -z "$DM_NAME" ] ; then
299306
return
300307
fi
@@ -305,10 +312,20 @@ sas_handler() {
305312
# If our DEVNAME is something like /dev/dm-177, then we may be
306313
# able to get our DMDEV from it.
307314
DMDEV=$(echo $DEVNAME | sed 's;/dev/;;g')
315+
if [ -n "$DMDEV" ]; then
316+
DEV=$(ls /sys/block/$DMDEV/slaves)
317+
for elm in "${DEV[@]}"; do
318+
if [[ $elm == "dm-"* ]]; then
319+
DMDEV=$elm
320+
break
321+
fi
322+
done
323+
fi
324+
308325
if [ ! -e /sys/block/$DMDEV/slaves/* ] ; then
309326
# It's not there, try looking in /dev/mapper
310327
DMDEV=$(ls -l --full-time /dev/mapper | grep $DM_NAME |
311-
awk '{gsub("../", " "); print $NF}')
328+
awk '{gsub("../", " "); print $NF}' | head -n 1)
312329
fi
313330

314331
# Use sysfs pointers in /sys/block/dm-X/slaves because using
@@ -520,13 +537,20 @@ scsi_handler() {
520537
# we have to append the -part suffix directly in the
521538
# helper.
522539
if [ "$DEVTYPE" != "partition" ] ; then
523-
# Match p[number], remove the 'p' and prepend "-part"
524-
PART=$(echo "$DM_NAME" |
525-
awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
540+
# WWNs end with number -> p<partition>, alphabet -> <partition>
541+
# '3' + (WWN length 16) = 17
542+
PART=${DM_NAME:17}
543+
if [[ $PART = "p"* ]]; then
544+
# Match p[number], remove the 'p' and prepend "-part"
545+
PART=$(echo "$DM_NAME" |
546+
awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
547+
elif [[ $PART != "" ]]; then
548+
PART="-part"${PART}
549+
fi
526550
fi
527551

528552
# Strip off partition information.
529-
DM_NAME=$(echo "$DM_NAME" | sed 's/p[0-9][0-9]*$//')
553+
DM_NAME=${DM_NAME:0:17}
530554
if [ -z "$DM_NAME" ] ; then
531555
return
532556
fi

0 commit comments

Comments
 (0)