forked from SUSE/s390-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dasd_reload
137 lines (126 loc) · 3 KB
/
dasd_reload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
#
# 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
if [ ! -x /sbin/rmmod -o ! -x /sbin/modprobe ]; then
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
if [ -f $dev/use_diag ]; then
read _online < $dev/online
read _alias < $dev/alias
if [ "$_online" -eq 1 -a "$_alias" -eq 1 ]; then
echo "setting DASD HyperPAV alias $(basename $dev) offline"
echo "0" > $dev/online
read _online < $dev/online
dasd_alias="$dasd_alias $(basename $dev)"
if [ "$_online" -eq 1 ]; then
echo "failure on setting DASD HyperPAV alias $(basename $dev) offline !"
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
if [ -f $dev/use_diag ]; then
read _online < $dev/online
read _alias < $dev/alias
if [ "$_online" -eq 1 -a "$_alias" -eq 0 ]; then
echo "setting DASD $(basename $dev) offline"
echo "0" > $dev/online
read _online < $dev/online
dasd_base="$dasd_base $(basename $dev)"
if [ "$_online" -eq 1 ]; then
echo "failure on setting DASD $(basename $dev) offline !"
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"
for module in $module_test_list; do
if grep -q "$module" /proc/modules; then
module_list="$module $module_list"
: Unloading $module
/sbin/rmmod $module
fi
done
if [ -d /etc/udev/rules.d ]; then
cd /etc/udev/rules.d
#
# Re-activating "normal" DASD and HyperPAV base devices
#
for dasd in $dasd_base; do
file="51-dasd-${dasd}.rules"
if [ -f "$file" ] ; then
echo Activating $dasd
if grep -q use_diag $file ; then
DASD_USE_DIAG=1
else
DASD_USE_DIAG=0
fi
/sbin/dasd_configure $dasd 1 $DASD_USE_DIAG
fi
done
#
# Re-activating HyperPAV alias devices
#
for dasd in $dasd_alias; do
file="51-dasd-${dasd}.rules"
if [ -f "$file" ] ; then
echo Activating $dasd
if grep -q use_diag $file ; then
DASD_USE_DIAG=1
else
DASD_USE_DIAG=0
fi
/sbin/dasd_configure $dasd 1 $DASD_USE_DIAG
fi
done
fi
exit ${EXITRC}