/[smeserver]/rpms/mkinitrd/sme8/mkinitrd-5.1.19.6-multipath.patch
ViewVC logotype

Contents of /rpms/mkinitrd/sme8/mkinitrd-5.1.19.6-multipath.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Thu Dec 20 18:36:32 2007 UTC (16 years, 11 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
No longer needed

1 diff -up mkinitrd-5.1.19.6/mkinitrd.multipath mkinitrd-5.1.19.6/mkinitrd
2 --- mkinitrd-5.1.19.6/mkinitrd.multipath 2007-07-18 13:39:44.000000000 -0400
3 +++ mkinitrd-5.1.19.6/mkinitrd 2007-07-18 13:40:46.000000000 -0400
4 @@ -42,7 +42,6 @@ VERSION=5.1.19.6
5 PROBE="yes"
6 MODULES=""
7 PREMODS=""
8 -DMDEVS=""
9 NET_LIST=""
10
11 CFG_DIR=${MKINITRD_CONFIG_DIR:-/etc/sysconfig/mkinitrd}
12 @@ -64,11 +63,8 @@ img_vers=""
13 builtins=""
14 modulefile=/etc/modules.conf
15 withusb=1
16 -if [ "$MULTIPATH" == "no" ]; then
17 - withmpath=0
18 -else
19 - withmpath=1
20 -fi
21 +[ "$MULTIPATH" == "no" ] && withmpath=0 || withmpath=1
22 +[ "$DMRAID" == "no" ] && withdmraid=0 || withdmraid=1
23 rc=0
24
25 IMAGESIZE=8000
26 @@ -109,7 +105,8 @@ usage () {
27 $cmd " [--force-ide-probe] [--force-scsi-probe | --omit-scsi-modules]"
28 $cmd " [--image-version] [--force-raid-probe | --omit-raid-modules]"
29 $cmd " [--with=<module>] [--force-lvm-probe | --omit-lvm-modules]"
30 - $cmd " [--builtin=<module>] [--omit-dmraid] [--net-dev=<interface>]"
31 + $cmd " [--builtin=<module>] [--net-dev=<interface>]"
32 + $cmd " [--without-usb] [--without-multipath] [--without-dmraid]"
33 $cmd " [--fstab=<fstab>] [--nocompress] <initrd-image> <kernel-version>"
34 $cmd ""
35 $cmd " (ex: `basename $0` /boot/initrd-2.2.5-15.img 2.2.5-15)"
36 @@ -136,14 +133,63 @@ findall() {
37 echo nash-find "$@" | /sbin/nash --force --quiet
38 }
39
40 -dm_get_uuid() {
41 - echo nash-dm get_uuid "$1" | /sbin/nash --force --quiet
42 -}
43 -
44 resolve_device_name() {
45 echo nash-resolveDevice "$1" | /sbin/nash --forcequiet
46 }
47
48 +find_dm_in_sysblock() {
49 + devname=$(resolve_device_name $1)
50 + [ -z "$devname" ] && return 1
51 + majmin=$(get_numeric_dev dec $devname)
52 + [ -z "$majmin" ] && return 1
53 + findall /sys/block -name dev | while read device ; do \
54 + echo "$majmin" | cmp -s $device && echo $device ; done \
55 + | sed -e 's,/dev$,,'
56 +}
57 +
58 +is_mpath() {
59 + major=$(echo $1 | cut -d: -f1)
60 + minor=$(echo $1 | cut -d: -f2)
61 + for target in $(dmsetup -C -j $major -m $minor table 2>/dev/null | \
62 + grep -v "No devices found" | awk ' { print $3 }') ; do
63 + [ "$target" == "multipath" ] && return 0
64 + done
65 + return 1
66 +}
67 +
68 +# this sucks; we need a generic way to get the hardware handler
69 +is_emc() {
70 + major=$(echo $1 | cut -d: -f1)
71 + minor=$(echo $1 | cut -d: -f2)
72 + if dmsetup -C -j $major -m $minor table 2>/dev/null | \
73 + grep -v "No devices found" | grep -q " emc " ; then
74 + return 0
75 + fi
76 + return 1
77 +}
78 +
79 +find_mpath_deps() {
80 + local devpath="/dev/$(echo $1 | sed -e 's,.*/\([^/]\+\),\1,' )"
81 + local arg2="$2"
82 + local majmin=$(cat $1/dev)
83 + local ret=1
84 + if is_mpath ${majmin} ; then
85 + arg2=yes
86 + if is_emc ${majmin} ; then
87 + ret=0
88 + fi
89 + fi
90 + slaves="$1/slaves/*"
91 + for slave in $slaves ; do
92 + [ -e $slave ] || continue
93 + find_mpath_deps $(readlink $slave) ${arg2} && ret=0
94 + done
95 + if [ "$2" == "yes" ]; then
96 + echo $devpath
97 + fi
98 + return $ret
99 +}
100 +
101 findmodule() {
102 skiperrors=""
103
104 @@ -259,38 +305,13 @@ findmodule() {
105 fi
106 }
107
108 -finddmmods() {
109 - line=$(/sbin/dmsetup table "$1" 2>/dev/null)
110 - [ -z "$line" ] && return 1
111 - type=$(echo "$line" | awk '{ print $3 }')
112 - [ -z "$type" ] && return 1
113 - case "$type" in
114 - mirror)
115 - findmodule -dm-mirror
116 - ;;
117 - emc)
118 - findmodule -dm-emc
119 - findmodule -dm-round-robin
120 - ;;
121 - multipath)
122 - findmodule -dm-multipath
123 - findmodule -dm-round-robin
124 - ;;
125 - crypt)
126 - findmodule -dm-crypt
127 - ;;
128 - zero)
129 - findmodule -dm-zero
130 - ;;
131 - esac
132 -}
133 -
134 inst() {
135 if [ "$#" != "2" ];then
136 echo "usage: inst <file> <destination>"
137 return
138 fi
139 vecho "$1 -> $2"
140 + mkdir -p $(dirname $2)
141 cp $1 $2
142 }
143
144 @@ -569,7 +590,6 @@ handlenfs() {
145 addnetdev $netdev
146 }
147
148 -
149 while [ $# -gt 0 ]; do
150 case $1 in
151 --fstab*)
152 @@ -595,6 +615,14 @@ while [ $# -gt 0 ]; do
153 withusb=0
154 ;;
155
156 + --without-multipath)
157 + withmpath=0
158 + ;;
159 +
160 + --without-dmraid)
161 + withdmraid=0
162 + ;;
163 +
164 --with*)
165 if [ "$1" != "${1##--with=}" ]; then
166 modname=${1##--with=}
167 @@ -664,9 +692,6 @@ while [ $# -gt 0 ]; do
168 --omit-lvm-modules)
169 nolvm=1
170 ;;
171 - --omit-dmraid)
172 - nodmraid=1
173 - ;;
174 --force-ide-probe)
175 forceide=1
176 ;;
177 @@ -933,17 +958,61 @@ if [ -n "${loopfs}" ] || [[ "$rootopts"
178 fi
179
180 # If we use LVM or dm-based raid, include dm-mod
181 -# XXX: dm not really supported yet.
182 testdm=""
183 [ -n "$vg_list" ] && testdm="yes"
184 [ -n "$forceraid" -o -n "$forcelvm" ] && testdm="yes"
185 [ -z "$nolvm" -o -z "$noraid" ] && testdm="yes"
186 [ "x$PROBE" != "xyes" ] && testdm=""
187
188 +use_multipath=0
189 +use_emc=0
190 if [ -n "$testdm" -a -x /sbin/dmsetup -a -e /dev/mapper/control ]; then
191 dmout=$(/sbin/dmsetup ls 2>/dev/null)
192 if [ "$dmout" != "No devices found" -a "$dmout" != "" ]; then
193 -
194 + sysroot=$(find_dm_in_sysblock ${rootdev})
195 + rootdevs=""
196 + if [ "${withmpath}" -eq 1 -a -n "${sysroot}" ]; then
197 + for rd in ${sysroot} ; do
198 + somedeps=$(find_mpath_deps ${rd})
199 + [ "$?" == "0" ] && use_emc=1
200 + [ -z "$somedeps" ] && continue
201 + for dep in ${somedeps} ; do
202 + majmin=$(get_numeric_dev dec ${dep})
203 + [[ ${majmin} =~ ^9: ]] && continue
204 + [[ ${dep} =~ ^/dev/xvd.+ ]] && continue
205 + case " ${rootdevs} " in
206 + *" ${dep} "*) continue ;;
207 + *) rootdevs="${rootdevs} ${dep}" ;;
208 + esac
209 + done
210 + done
211 + fi
212 +
213 + if [ -z "$rootdevs" ]; then
214 + rootdevs="$rootdev"
215 + fi
216 +
217 + root_wwids=""
218 + if [ "${withmpath}" -eq "1" ]; then
219 + for rootdev in ${rootdevs} ; do
220 + disk=$(find_dm_in_sysblock ${rootdev} | sed -e 's,^/sys,,')
221 + wwid=$(/sbin/scsi_id -g -u -s ${disk})
222 + if [ -z "${wwid}" ]; then
223 + # Could be EMC unit requiring special option
224 + wwid=$(/sbin/scsi_id -g -ppre-spc3-83 -u -s ${disk})
225 + fi
226 + if [ -n "${wwid}" ]; then
227 + case " ${root_wwids} " in
228 + *" ${wwid} "*) continue ;;
229 + *) root_wwids="${root_wwids} ${wwid}" ;;
230 + esac
231 + fi
232 + done
233 + if [ -n "$root_wwids" ]; then
234 + use_multipath=1
235 + fi
236 + fi
237 +
238 findmodule -dm-mod
239
240 # DM requires all of these to be there in case someone used the
241 @@ -951,58 +1020,15 @@ if [ -n "$testdm" -a -x /sbin/dmsetup -a
242 findmodule -dm-mirror
243 findmodule -dm-zero
244 findmodule -dm-snapshot
245 -
246 - RAIDS=$(/sbin/dmraid -s -craidname 2>/dev/null | grep -vi "no raid disks")
247
248 - # I fucking hate shell.
249 - lineno=1
250 - PREV=""
251 - LINE=""
252 - while :; do
253 - PREV="$LINE"
254 - LINE=$(/sbin/dmsetup table | head -$lineno | tail -1)
255 - if [ "$LINE" == "$PREV" ]; then
256 - break;
257 + # If we use dm-multipath devices, include the needed modules
258 + if [ "$use_multipath" == "1" ]; then
259 + findmodule -dm-multipath
260 + findmodule -dm-round-robin
261 + if [ "$use_emc" == "1" ]; then
262 + findmodule -dm-emc
263 fi
264 -
265 - eval $(echo $LINE | \
266 - while read NAME START END TYPE TABLE ; do
267 - echo NAME=\"$(sed 's/:$//'<<< "$NAME")\"
268 - echo START=\"$START\"
269 - echo END=\"$END\"
270 - echo TYPE=\"$TYPE\"
271 - echo TABLE=\"$TABLE\"
272 - done)
273 -
274 - case "$TYPE" in
275 - multipath|emc)
276 - [ "$withmpath" == "0" ] && continue
277 - # ugggh. We could try to fish the module name out, but it
278 - # requires real parsing...
279 - # XXX also covered by #132001
280 - for mod in $TABLE ; do
281 - DMMODS="$DMMODS $([[ "$mod" =~ "[[:alpha:]]" ]] && echo "$mod")"
282 - done
283 - DMDEVS="$DMDEVS $NAME"
284 - ;;
285 - *)
286 - for raid in $RAIDS ; do
287 - if [ "$raid" == "$NAME" ]; then
288 - dmname=$(resolve_dm_name $NAME)
289 - DMDEVS="$DMDEVS $dmname"
290 - RAIDS=$(sed 's/ $NAME //' <<< "$RAIDS")
291 - break
292 - fi
293 - done
294 - ;;
295 - esac
296 - lineno=$(($lineno + 1))
297 - done
298 -
299 - for mod in $(tr ' ' '\n' <<< $DMMODS | sort -u) ; do
300 - findmodule -dm-$mod
301 - done
302 - DMDEVS=$(tr ' ' '\n' <<< $DMDEVS | sort -u)
303 + fi
304 fi
305 fi
306
307 @@ -1014,8 +1040,6 @@ for n in $CONFMODS; do
308 findmodule $n
309 done
310
311 -finddmmods
312 -
313 vecho "Using modules: $MODULES"
314
315 MNTIMAGE=`mktemp -d ${TMPDIR}/initrd.XXXXXX`
316 @@ -1037,34 +1061,6 @@ emit()
317 echo $NONL "$@" >> $RCFILE
318 }
319
320 -emitdm()
321 -{
322 - vecho "Adding dm map \"$1\""
323 - UUID=$(dm_get_uuid "$1")
324 - if [ -n "$UUID" ]; then
325 - UUID="--uuid $UUID"
326 - fi
327 - emit dm create "$1" $UUID $(/sbin/dmsetup table "$1")
328 -}
329 -
330 -emitdms()
331 -{
332 - [ -z "$DMDEVS" ] && return 0
333 - echo dm list $DMDEVS | nash --force --quiet | while read ACTION NAME ; do
334 - case $ACTION in
335 - rmparts)
336 - emit rmparts "$NAME"
337 - ;;
338 - create)
339 - emitdm "$NAME"
340 - ;;
341 - part)
342 - emit dm partadd "$NAME"
343 - ;;
344 - esac
345 - done
346 -}
347 -
348 if [ -z "$MNTIMAGE" -o -z "$IMAGE" ]; then
349 error "Error creating temporaries. Try again"
350 exit 1
351 @@ -1136,6 +1132,39 @@ if [ -n "$vg_list" ]; then
352 fi
353 fi
354
355 +if [ "$use_multipath" == "1" ]; then
356 + # For multipath command
357 + inst /sbin/multipath.static $MNTIMAGE/bin/multipath
358 + if [ -f /etc/multipath.conf ]; then
359 + inst /etc/multipath.conf $MNTIMAGE/etc/multipath.conf
360 + fi
361 + if [ -f /var/lib/multipath/bindings ]; then
362 + inst /var/lib/multipath/bindings $MNTIMAGE/var/lib/multipath/bindings
363 + fi
364 + inst /sbin/scsi_id $MNTIMAGE/bin/scsi_id
365 + inst /etc/scsi_id.config $MNTIMAGE/etc/scsi_id.config
366 + # This includes all mpath_prio checkers in the image (~2.5M)
367 + # Alternately we can only include those that are used by the
368 + # current mpath config. This would require users to rebuild
369 + # the initrd if migrating/adding controllers from different
370 + # storage vendors
371 + for M in /sbin/mpath_prio_*.static ; do
372 + inst ${M} $MNTIMAGE/${M%%.static};
373 + done
374 + mkdir -p $MNTIMAGE/tmp
375 +
376 + # For kpartx command which creates device maps for disk partitions
377 + # and creates device files
378 + inst /sbin/dmsetup.static $MNTIMAGE/bin/dmsetup
379 + inst /sbin/kpartx.static $MNTIMAGE/bin/kpartx
380 +fi
381 +
382 +if [ "$withdmraid" == "1" ]; then
383 + # Only dmraid is needed to set up dmraid volume
384 + inst /sbin/dmraid.static "$MNTIMAGE/bin/dmraid"
385 + inst /sbin/kpartx.static "$MNTIMAGE/bin/kpartx"
386 +fi
387 +
388 echo -n >| $RCFILE
389 cemit << EOF
390 #!/bin/nash
391 @@ -1247,17 +1276,6 @@ EOF
392 done
393 unset usb_mounted
394
395 -if [ -n "$scsi" ]; then
396 - emit "echo Waiting for driver initialization."
397 - emit "stabilized --hash --interval 250 /proc/scsi/scsi"
398 -fi
399 -
400 -
401 -if [ -n "$vg_list" ]; then
402 - emit "echo Making device-mapper control node"
403 - emit "mkdmnod"
404 -fi
405 -
406 if [ -n "$net_list" ]; then
407 for netdev in $net_list; do
408 emit "echo Bringing up $netdev"
409 @@ -1268,12 +1286,39 @@ fi
410
411 emit_iscsi
412
413 +if [ -n "$scsi" ]; then
414 + emit "echo Waiting for driver initialization."
415 + emit "stabilized --hash --interval 250 /proc/scsi/scsi"
416 +fi
417 +
418 # HACK: module loading + device creation isn't necessarily synchronous...
419 # this will make sure that we have all of our devices before trying
420 # things like RAID or LVM
421 emit "mkblkdevs"
422
423 -emitdms
424 +#if [ -n "$vg_list" ]; then
425 +# emit "echo Making device-mapper control node"
426 +# emit "mkdmnod"
427 +#fi
428 +
429 +if [ "$use_multipath" == "1" ]; then
430 + emit "echo Creating multipath devices"
431 + for wwid in $root_wwids ; do
432 + emit "/bin/multipath -v 0 $wwid"
433 + done
434 + emit "dmsetup ls --target multipath --exec 'kpartx -a -p p'"
435 +fi
436 +
437 +if [ "$withdmraid" == "1" ]; then
438 + emit "echo Scanning and configuring dmraid supported devices"
439 + for x in $(/sbin/dmraid.static -ay -i -p -t 2>/dev/null | \
440 + egrep -iv "^no " | awk -F ':' '{ print $1 }') ; do
441 + dmname=$(resolve_dm_name $x)
442 + [ -z "$dmname" ] && continue
443 + emit "dmraid -ay -i -p \"$dmname\""
444 + emit "kpartx -a -p p \"/dev/mapper/$dmname\""
445 + done
446 +fi
447
448 if [ -n "$raiddevices" ]; then
449 for dev in $raiddevices; do

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed