#!/bin/sh
-#
+MULTIPATH_RCSID='$Revision$ $Date:: $'
+
# geninitrd mod: dm-multipath
USE_MULTIPATH=${USE_MULTIPATH:-yes}
local devpath="$1"
# multipath disabled
- if ! is_yes "$USE_MULTIPATH"; then
+ if is_no "$USE_MULTIPATH"; then
return 1
fi
DM_NAME=
eval $(dm_export "$devpath")
if [ -z "$DM_NAME" ]; then
- die "dm_export failed unexpectedly"
+ die "Couldn't extract DM_NAME from $devpath"
fi
# Partition:
lvm_ignore_devices="$lvm_ignore_devices $p"
done
- # TODO: handle newer multipath-tools:
- # size=7.0G features='0' hwhandler='0' wp=rw
- list=$(echo "$info" | awk '/hwhandler=1/{sub(/.*hwhandler=1 /, ""); sub(/\]$/, ""); print}')
+ list=$(mp_parse_hwhandler "$info")
for p in $list; do
- find_module "dm-$p"
+ find_module "$p"
done
list=$(mp_parse_policy "$info")
# generate initrd fragment
# @access public
initrd_gen_multipath() {
+ if ! is_yes "$have_multipath"; then
+ return
+ fi
+
inst_d /sbin /lib/udev /etc/multipath
inst_exec /sbin/kpartx /sbin
inst_exec /sbin/multipath /sbin
# for udev callouts
- local scsi_id=$(find_tool /lib/udev/scsi_id /sbin/scsi_id)
+ local scsi_id=$(find_tool /$_lib/udev/scsi_id /lib/udev/scsi_id /sbin/scsi_id)
inst_exec $scsi_id /lib/udev
- if [ -d /lib/multipath ]; then
- inst_d /lib/multipath
- inst_exec /lib/multipath/* /lib/multipath
+ if [ -d /$_lib/multipath ]; then
+ inst_d /$_lib/multipath
+ inst_exec /$_lib/multipath/* /$_lib/multipath
else
inst_exec /sbin/mpath* /sbin
fi
}
' | sort -u
}
+
+# parse hwhandler from multipath output
+# takes 'multipath -l' output as input
+mp_parse_hwhandler() {
+ local info="$1"
+
+ # TODO: actually the dm-emc vs scsi-dh-emc is dependant on kernel version
+ # not version of the tools installed
+
+ # multipath-tools-0.4.8-0.12.amd64
+ # [size=12G][features=1 queue_if_no_path][hwhandler=1 emc]
+ #
+ # multipath-tools-0.4.8-11.x86_64
+ # size=7.0G features='0' hwhandler='0' wp=rw
+ # size=2.0G features='1 queue_if_no_path' hwhandler='1 emc' wp=rw
+ echo "$info" | sed -ne "
+ # multipath-tools-0.4.8-0.12.amd64
+ /\[hwhandler=1/{
+ s,^.*\[hwhandler=1 \([^]]*\)\].*$,dm-\1,
+ p
+ }
+ # multipath-tools-0.4.8-11.x86_64
+ /hwhandler='1/{
+ s,^.*hwhandler='1 \([^']*\)'.*$,scsi-dh-\1,
+ p
+ }
+ " | sort -u
+}