-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-fs-iostats
284 lines (260 loc) · 8.22 KB
/
test-fs-iostats
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/bin/bash
CR="\033[1G"
CLREND="\033[0K"
CLROK='[40m'
CLRATTN='[41m'
function regdata {
IDX=$1
echo -n -e "${CR}sync-and-measure $IDX$CLREND${CR}"; sync;sleep 0.5;sync
IO1=`iostat $DEV | grep $DEV`
KB1=`echo $IO1 | awk '{print $7}'`
if [ $LAST -eq 0 ]; then
KB=$KB1
else
KB=$(($KB1-${data_kb1[${data_nm[$LAST]}]}))
fi
LAST=${#data_nm[@]}
data_nm+=($IDX)
data_io[$IDX]=$IO1
data_kb[$IDX]=$KB
data_kb1[$IDX]=$KB1
}
WD=/tmp/fstest
mkdir $WD > /dev/null 2>&1
mkdir $WD/tst > /dev/null 2>&1
cd $WD
dd if=/dev/urandom of=$WD/tstfile.512 bs=512 count=1 > /dev/null 2>&1
dd if=/dev/urandom of=$WD/tstfile.4k bs=1k count=4 > /dev/null 2>&1
dd if=/dev/urandom of=$WD/tstfile.16k bs=1k count=16 > /dev/null 2>&1
dd if=/dev/urandom of=$WD/tstfile.1m bs=1M count=1 > /dev/null 2>&1
dd if=/dev/urandom of=$WD/tstfile.10m bs=1M count=10 > /dev/null 2>&1
dd if=/dev/urandom of=$WD/tstfile.16m bs=1M count=16 > /dev/null 2>&1
STATHDR=`iostat | grep Device`
RO=ro
for FS in ext4 ext3 xfs jfs zfs btrfs ; do
LAST=0
# num-ordered
unset data_nm; declare -a data_nm
# associative
unset data_io; declare -A data_io
unset data_kb; declare -A data_kb
unset data_kb1; declare -A data_kb1
unset data_cmnt; declare -A data_cmnt
NOTOOLS=0
if [ "$FS" = "zfs" ]; then
echo OK
NOTOOLS=0
else
which mkfs.$FS > /dev/null 2>&1
if [ $? -ne 0 ]; then
NOTOOLS=1
fi
fi
if [ $NOTOOLS -ne 1 ]; then
echo preparing for $FS
dd if=/dev/zero of=$WD/$FS.img bs=1M count=256 > /dev/null 2>&1
DEV=`losetup -f | sed -e 's/\/dev\///'`
regdata 'DEVCREATE'
losetup /dev/$DEV $WD/$FS.img > /dev/null 2>&1
case $FS in
zfs)
#echo zpool-create
zpool create -O sync=always -m $WD/tst ZFSTest /dev/$DEV
#echo zfs-mountpoint
zfs set mountpoint=legacy ZFSTest
#umount $WD/tst
;;
btrfs)
mkfs.$FS -f /dev/$DEV > /dev/null 2>&1
;;
jfs)
mkfs.$FS -f /dev/$DEV > /dev/null 2>&1
;;
ocfs2)
mkfs.$FS -F --mount=local /dev/$DEV > /dev/null 2>&1
;;
*)
mkfs.$FS /dev/$DEV > /dev/null 2>&1
;;
esac
regdata 'FSCREATE'
echo mounting
case $FS in
zfs)
#echo ZFS - mounted already
mount.zfs /dev/$DEV $WD/tst -o rw,sync,noatime
;;
btrfs)
mount -t $FS /dev/$DEV $WD/tst -o rw,noatime
#,nodatacow
;;
*)
mount -t $FS /dev/$DEV $WD/tst -o rw,noatime
esac
regdata 'FSMOUNT'
cp $WD/tstfile.512 $WD/tst/tstfile.512
regdata 'cp.512.1-st'
cp $WD/tstfile.512 $WD/tst/tstfile.512
regdata 'cp.512.2nd'
cp $WD/tstfile.4k $WD/tst/tstfile.4k
regdata 'cp.4k.00'
cp $WD/tstfile.4k $WD/tst/tstfile.4k.1
regdata 'cp.4k.01'
cp $WD/tstfile.4k $WD/tst/tstfile.4k.2
regdata 'cp.4k.02'
cp $WD/tstfile.4k $WD/tst/tstfile.4k.3
regdata 'cp.4k.03'
cp $WD/tstfile.16k $WD/tst/tstfile.16k
regdata 'cp.16k.0'
cp $WD/tstfile.16k $WD/tst/tstfile.16k.1
regdata 'cp.16k.1'
cp $WD/tstfile.16k $WD/tst/tstfile.16k.2
regdata 'cp.16k.2'
cp $WD/tstfile.16k $WD/tst/tstfile.16k.3
regdata 'cp.16k.3'
cp $WD/tstfile.1m $WD/tst/tstfile.1m
regdata 'cp.1m.00'
cp $WD/tstfile.1m $WD/tst/tstfile.1m.1
regdata 'cp.1m.01'
cp $WD/tstfile.1m $WD/tst/tstfile.1m.2
regdata 'cp.1m.02'
cp $WD/tstfile.1m $WD/tst/tstfile.1m.3
regdata 'cp.1m.03'
cp $WD/tstfile.10m $WD/tst/tstfile.10m
regdata 'cp.10m.0'
cp $WD/tstfile.10m $WD/tst/tstfile.10m.1
regdata 'cp.10m.1'
cp $WD/tstfile.10m $WD/tst/tstfile.10m.2
regdata 'cp.10m.2'
cp $WD/tstfile.10m $WD/tst/tstfile.10m.3
regdata 'cp.10m.3'
cp $WD/tstfile.16m $WD/tst/tstfile.16m
regdata 'cp.16m.0'
cp $WD/tstfile.16m $WD/tst/tstfile.16m.1
regdata 'cp.16m.1'
cp $WD/tstfile.16m $WD/tst/tstfile.16m.2
regdata 'cp.16m.2'
cp $WD/tstfile.16m $WD/tst/tstfile.16m.3
regdata 'cp.16m.3'
dd if="$WD/tstfile.512" of="$WD/tst/tstfile.16m" > /dev/null 2>&1
regdata 'dd.512.16m-beg'
#IDX='dd.512.16m-beg';sync;sleep 0.2;sync;IO1=`iostat $DEV | grep $DEV`;KB1=`echo $IO1 | awk '{print $7}'`;KB=$(($KB1-${data_kb1[${data_nm[$LAST]}]}));LAST=${#data_nm[@]};data_nm+=($IDX);data_io[$IDX]=$IO1;data_kb[$IDX]=$KB;data_kb1[$IDX]=$KB1
dd if="$WD/tstfile.512" of="$WD/tst/tstfile.16m" bs=512 seek=1 > /dev/null 2>&1
#IDX='dd.512.16m-2nd';sync;sleep 0.2;sync;IO1=`iostat $DEV | grep $DEV`;KB1=`echo $IO1 | awk '{print $7}'`;KB=$(($KB1-${data_kb1[${data_nm[$LAST]}]}));LAST=${#data_nm[@]};data_nm+=($IDX);data_io[$IDX]=$IO1;data_kb[$IDX]=$KB;data_kb1[$IDX]=$KB1
regdata 'dd.512.16m-2nd'
dd if="$WD/tstfile.512" of="$WD/tst/tstfile.16m" bs=512 seek=2 > /dev/null 2>&1
#IDX='dd.512.16m-3rd';sync;sleep 0.2;sync;IO1=`iostat $DEV | grep $DEV`;KB1=`echo $IO1 | awk '{print $7}'`;KB=$(($KB1-${data_kb1[${data_nm[$LAST]}]}));LAST=${#data_nm[@]};data_nm+=($IDX);data_io[$IDX]=$IO1;data_kb[$IDX]=$KB;data_kb1[$IDX]=$KB1
regdata 'dd.512.16m-3rd'
dd if="$WD/tstfile.512" of="$WD/tst/tstfile.16m" bs=512 seek=3 > /dev/null 2>&1
#IDX='dd.512.16m-4th';sync;sleep 0.2;sync;IO1=`iostat $DEV | grep $DEV`;KB1=`echo $IO1 | awk '{print $7}'`;KB=$(($KB1-${data_kb1[${data_nm[$LAST]}]}));LAST=${#data_nm[@]};data_nm+=($IDX);data_io[$IDX]=$IO1;data_kb[$IDX]=$KB;data_kb1[$IDX]=$KB1
regdata 'dd.512.16m-4th'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.16m"
regdata 'cat.512.16m.e1'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.16m"
regdata 'cat.512.16m.e2'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.16m"
regdata 'cat.512.16m.e3'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.16m"
regdata 'cat.512.16m.e4'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.512"
regdata 'cat.512.512.e1'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.512"
regdata 'cat.512.512.e2'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.512"
regdata 'cat.512.512.e3'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.512"
regdata 'cat.512.512.e4'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.512"
regdata 'cat.512.512.e5'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.512"
regdata 'cat.512.512.e6'
cat "$WD/tstfile.512" >> "$WD/tst/tstfile.512"
regdata 'cat.512.512.e7'
if [ "$FS" = "zfs" ]; then
# umount $WD/tst
zpool export ZFSTest
else
umount /dev/$DEV
fi
regdata 'FSUNMOUNT'
echo -e "\n"
if [ "$FS" = "zfs" ]; then
echo "ZFS - RO"
echo if problem - then create symlink 'zfs-disc' in '/dev/disk/by-id' to '../../loop0'
ln -s /dev/$DEV /dev/disk/by-id/z.Test
SHA10=$(sha1sum $WD/$FS.img)
zpool import -o ro -d /dev/disk/by-id/z.Test ZFSTest
SHA101=$(sha1sum $WD/$FS.img)
sync;sleep 0.5;sync
mount.zfs /dev/$DEV $WD/tst -o ro,noatime,sync
SHA102=$(sha1sum $WD/$FS.img)
sync;sleep 0.5;sync
umount $WD/tst
SHA103=$(sha1sum $WD/$FS.img)
zpool export ZFSTest
sync;sleep 0.5;sync
SHA11=$(sha1sum $WD/$FS.img)
zpool import -o ro -d /dev/disk/by-id/ ZFSTest
zpool list | grep ZFSTest
zfs list | grep ZFSTest
mount.zfs /dev/$DEV $WD/tst -o ro,noatime,sync
if [ "$SHA10" == "$SHA11" ];then
CLR=$CLROK
else
CLR=$CLRATTN
fi
echo -e "MOUNT-UMOUNT : $CLR$SHA10\nIMPORT: $SHA101\nMOUNT: $SHA102\nUMOUNT: $SHA103\nEXPORT: $SHA11$CLROK"
dd if=$WD/tst/tstfile.512 of=/dev/null > /dev/null 2>&1
sync;sleep 0.5;sync
umount $WD/tst
zpool export ZFSTest
#zpool destroy ZFSTest
sync;sleep 0.5;sync
rm -f /dev/disk/by-id/z.Test
else
echo mounting RO
MNTOPTS=''
SHA10=$(sha1sum $WD/$FS.img)
mount -t $FS /dev/$DEV $WD/tst -o ro,noatime$MNTOPTS
sync;sleep 0.5;sync
umount /dev/$DEV
sync;sleep 0.5;sync
SHA11=$(sha1sum $WD/$FS.img)
mount -t $FS /dev/$DEV $WD/tst -o ro,noatime$MNTOPTS
if [ "$SHA10" == "$SHA11" ];then
CLR=$CLROK
else
CLR=$CLRATTN
fi
echo -e "$CLR$SHA10 $SHA11$CLROK"
sync;sleep 0.5;sync
dd if=$WD/tst/tstfile.512 of=/dev/null > /dev/null 2>&1
umount /dev/$DEV
sync;sleep 0.5;sync
fi
regdata 'FSRO'
echo -e "\n"
#losetup -d /dev/$DEV
echo "========================================"
echo "$STATHDR = FS KB OP"
# Dump colected Array data
CNT=${#data_nm[@]}
#echo $CNT
for (( i=0; i<CNT; i++ ))
do
IDX=${data_nm[$i]}
#echo -e "${data_io[$IDX]} = $FS $IDX ${data_kb[$IDX]}"
printf "%s = %s %s %s\n" "${data_io[$IDX]}" "$FS" "${data_kb[$IDX]}" "$IDX"
done
echo "========================================"
# rm -f $WD/$FS.img
else
echo NO TOOLS for $FS
fi
sleep 0.3
echo $DEV
losetup -d /dev/$DEV
ls -l /dev/$DEV
rmmod loop
done
#losetup -D