blob: c8e9bb5834cad75ea2fec99824b5887c03257995 (
plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
#!/bin/bash
#
# ZFS/ZPOOL configuration test script.
basedir="$(dirname $0)"
SCRIPT_COMMON=common.sh
if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
. "${basedir}/${SCRIPT_COMMON}"
else
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
fi
PROG=zpios-sanity.sh
HEADER=
FAILS=0
usage() {
cat << EOF
USAGE:
$0 [hvxfc]
DESCRIPTION:
ZPIOS sanity tests
OPTIONS:
-h Show this message
-v Verbose
-x Destructive hd/sd/md/dm/ram tests
-f Don't prompt due to -x
-c Cleanup lo+file devices at start
EOF
}
while getopts 'hvxfc?' OPTION; do
case $OPTION in
h)
usage
exit 1
;;
v)
VERBOSE=1
;;
x)
DANGEROUS=1
;;
f)
FORCE=1
;;
c)
CLEANUP=1
;;
?)
usage
exit
;;
esac
done
if [ $(id -u) != 0 ]; then
die "Must run as root"
fi
# Perform pre-cleanup is requested
if [ ${CLEANUP} ]; then
cleanup_loop_devices
rm -f /tmp/zpool.cache.*
fi
zpios_test() {
CONFIG=$1
TEST=$2
LOG=`mktemp`
${ZPIOS_SH} -f -c ${CONFIG} -t ${TEST} &>${LOG}
if [ $? -ne 0 ]; then
FAILS=1
if [ ${VERBOSE} ]; then
printf "FAIL: %-13s\n" ${CONFIG}
cat ${LOG}
else
if [ ! ${HEADER} ]; then
head -2 ${LOG}
HEADER=1
fi
printf "FAIL: %-13s" ${CONFIG}
tail -1 ${LOG}
fi
else
if [ ${VERBOSE} ]; then
cat ${LOG}
else
if [ ! ${HEADER} ]; then
head -2 ${LOG}
HEADER=1
fi
tail -1 ${LOG}
fi
fi
rm -f ${LOG}
}
if [ ${DANGEROUS} ] && [ ! ${FORCE} ]; then
cat << EOF
The -x option was passed which will result in UNRECOVERABLE DATA LOSS
on on the following block devices:
/dev/sd[abcd]
/dev/hda
/dev/ram0
/dev/md0
/dev/dm-0
To continue please confirm by entering YES:
EOF
read CONFIRM
if [ ${CONFIRM} != "YES" ] && [ ${CONFIRM} != "yes" ]; then
exit 0;
fi
fi
#
# These configurations are all safe and pose no risk to any data on
# the system which runs them. They will confine all their IO to a
# file in /tmp or a loopback device configured to use a file in /tmp.
#
SAFE_CONFIGS=( \
file-raid0 file-raid10 file-raidz file-raidz2 \
lo-raid0 lo-raid10 lo-raidz lo-raidz2 \
)
#
# These configurations are down right dangerous. They will attempt
# to use various real block devices on your system which may contain
# data you car about. You are STRONGLY advised not to run this unless
# you are certain there is no data on the system you care about.
#
DANGEROUS_CONFIGS=( \
hda-raid0 \
sda-raid0 \
ram0-raid0 \
md0-raid10 md0-raid5 \
dm0-raid0 \
)
for CONFIG in ${SAFE_CONFIGS[*]}; do
zpios_test $CONFIG tiny
done
if [ ${DANGEROUS} ]; then
for CONFIG in ${DANGEROUS_CONFIGS[*]}; do
zpios_test $CONFIG tiny
done
fi
exit $FAILS
|