2019-04-18 20:16:03 +02:00
|
|
|
#!/bin/sh
|
2017-02-21 12:14:26 +01:00
|
|
|
#
|
|
|
|
# dasd_reload
|
|
|
|
# $Id: dasd_reload,v 1.2 2004/05/26 15:17:09 hare Exp $
|
|
|
|
#
|
|
|
|
# Deconfigures all active DASDs, unloads the modules
|
|
|
|
# and activates the configured DASDs again.
|
|
|
|
# Needed to establish an identical device mapping
|
|
|
|
# in the installation system and in the running system.
|
|
|
|
# All DASD access need to be cancelled prior to running
|
|
|
|
# this script.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# dasd_reload
|
|
|
|
#
|
|
|
|
# Return values:
|
|
|
|
# 1 Cannot read /proc/modules
|
|
|
|
# 2 Missing module programs
|
|
|
|
# 3 /sys not mounted
|
|
|
|
# 4 Failure on deactivate DASDs
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ ! -r /proc/modules ]; then
|
|
|
|
echo "Cannot read /proc/modules"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-06-02 18:42:42 +02:00
|
|
|
if [ ! -x /usr/sbin/rmmod -o ! -x /usr/sbin/modprobe ]; then
|
2017-02-21 12:14:26 +01:00
|
|
|
echo "Missing module programs"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /sys/bus ]; then
|
|
|
|
echo "sysfs not mounted"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
let anymd=0
|
|
|
|
if [ -f /proc/mdstat ]; then
|
|
|
|
for mddevice in $(grep active /proc/mdstat | cut -f1 -d:); do
|
|
|
|
mdadm -S /dev/${mddevice}
|
|
|
|
let anymd=1
|
|
|
|
done
|
|
|
|
udevadm settle
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Setting HyperPAV alias devices offline
|
|
|
|
#
|
|
|
|
dasd_alias=
|
|
|
|
let EXITRC=0
|
|
|
|
for dev in /sys/bus/ccw/devices/*; do
|
2018-08-24 20:54:31 +02:00
|
|
|
if [ -f ${dev}/use_diag ]; then
|
|
|
|
read _online < ${dev}/online
|
|
|
|
read _alias < ${dev}/alias
|
2017-02-21 12:14:26 +01:00
|
|
|
if [ "$_online" -eq 1 -a "$_alias" -eq 1 ]; then
|
2018-08-24 20:54:31 +02:00
|
|
|
echo "setting DASD HyperPAV alias $(basename ${dev}) offline"
|
|
|
|
echo "0" > ${dev}/online
|
|
|
|
read _online < ${dev}/online
|
|
|
|
dasd_alias="${dasd_alias} $(basename ${dev})"
|
2017-02-21 12:14:26 +01:00
|
|
|
if [ "$_online" -eq 1 ]; then
|
2018-08-24 20:54:31 +02:00
|
|
|
echo "failure on setting DASD HyperPAV alias $(basename ${dev}) offline !"
|
2017-02-21 12:14:26 +01:00
|
|
|
let EXITRC=4
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Setting "normal" DASD and HyperPAV base devices offline
|
|
|
|
#
|
|
|
|
dasd_base=
|
|
|
|
for dev in /sys/bus/ccw/devices/*; do
|
2018-08-24 20:54:31 +02:00
|
|
|
if [ -f ${dev}/use_diag ]; then
|
|
|
|
read _online < ${dev}/online
|
|
|
|
read _alias < ${dev}/alias
|
2017-02-21 12:14:26 +01:00
|
|
|
if [ "$_online" -eq 1 -a "$_alias" -eq 0 ]; then
|
2018-08-24 20:54:31 +02:00
|
|
|
echo "setting DASD $(basename ${dev}) offline"
|
|
|
|
echo "0" > ${dev}/online
|
|
|
|
read _online < ${dev}/online
|
|
|
|
dasd_base="${dasd_base} $(basename ${dev})"
|
2017-02-21 12:14:26 +01:00
|
|
|
if [ "$_online" -eq 1 ]; then
|
2018-08-24 20:54:31 +02:00
|
|
|
echo "failure on setting DASD $(basename ${dev}) offline !"
|
2017-02-21 12:14:26 +01:00
|
|
|
let EXITRC=4
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
udevadm settle
|
|
|
|
|
|
|
|
module_list=
|
|
|
|
module_test_list="dasd_diag_mod dasd_eckd_mod dasd_fba_mod dasd_mod"
|
2018-08-24 20:54:31 +02:00
|
|
|
for module in ${module_test_list}; do
|
|
|
|
if grep -q "${module}" /proc/modules; then
|
|
|
|
module_list="${module} ${module_list}"
|
|
|
|
: Unloading ${module}
|
2022-06-02 18:42:42 +02:00
|
|
|
/usr/sbin/rmmod ${module}
|
2017-02-21 12:14:26 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-08-24 20:54:31 +02:00
|
|
|
udevadm settle
|
|
|
|
sleep 2
|
|
|
|
|
2017-02-21 12:14:26 +01:00
|
|
|
if [ -d /etc/udev/rules.d ]; then
|
|
|
|
cd /etc/udev/rules.d
|
|
|
|
#
|
|
|
|
# Re-activating "normal" DASD and HyperPAV base devices
|
|
|
|
#
|
2018-08-24 20:54:31 +02:00
|
|
|
# We need to move all the DASD udev rules out from /etc/udev/rules.d
|
|
|
|
# because if we don't, then when the first DASD volume gets brought
|
|
|
|
# back online, they are all brought back online, in a non-deterministic
|
|
|
|
# order, not the numeric order we expect.
|
|
|
|
#
|
|
|
|
mv -i 41-dasd-*.rules 51-dasd-*.rules /tmp
|
|
|
|
cd /tmp
|
|
|
|
for dasd in ${dasd_base}; do
|
|
|
|
for file in 41-dasd-*-${dasd}.rules 51-dasd-${dasd}.rules; do
|
|
|
|
[ -f "${file}" ] || continue
|
|
|
|
#
|
|
|
|
# Special handling is needed for old udev rules that start with 51-
|
|
|
|
# since the chzdev command won't look for that name
|
|
|
|
#
|
|
|
|
prefix="$(echo ${file} | cut -f1 -d-)"
|
|
|
|
if [ "${prefix}" == "51" ]; then
|
|
|
|
if [ -h /sys/bus/ccw/drivers/dasd-eckd/${dasd} ]; then
|
|
|
|
mv -i ${file} 41-dasd-eckd-${dasd}.rules
|
|
|
|
elif [ -h /sys/bus/ccw/drivers/dasd-fba/${dasd} ]; then
|
|
|
|
mv -i ${file} 41-dasd-fba-${dasd}.rules
|
|
|
|
else echo "DASD volume ${dasd} is neither an ECKD or FBA device."
|
|
|
|
let EXITRC=4
|
|
|
|
fi
|
2017-02-21 12:14:26 +01:00
|
|
|
fi
|
2018-08-24 20:54:31 +02:00
|
|
|
echo Activating ${dasd}
|
|
|
|
mv -i "${file}" /etc/udev/rules.d/
|
2022-06-02 18:42:42 +02:00
|
|
|
/usr/sbin/chzdev dasd --apply --configured -q --no-root-update ${dasd}
|
2018-08-24 20:54:31 +02:00
|
|
|
lsdasd
|
|
|
|
break
|
|
|
|
done
|
2017-02-21 12:14:26 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Re-activating HyperPAV alias devices
|
|
|
|
#
|
2018-08-24 20:54:31 +02:00
|
|
|
for dasd in ${dasd_alias}; do
|
|
|
|
for file in 41-dasd-*-${dasd}.rules 51-dasd-${dasd}.rules; do
|
|
|
|
[ -f "${file}" ] || continue
|
|
|
|
echo Activating ${dasd}
|
|
|
|
mv -i "${file}" /etc/udev/rules.d/
|
2022-06-02 18:42:42 +02:00
|
|
|
/usr/sbin/chzdev dasd --apply --configured -q --no-root-update ${dasd}
|
2018-08-24 20:54:31 +02:00
|
|
|
break
|
|
|
|
done
|
2017-02-21 12:14:26 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2019-04-18 20:16:03 +02:00
|
|
|
exit ${EXITRC}
|