6 ALWAYS_EXCEPT="$LFSCK_PERFORMANCE_EXCEPT"
7 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
17 skip "lfsck performance only for ldiskfs" && exit 0
19 require_dsh_mds || exit 0
22 skip "skip lfsck performance test under non-SLOW mode" && exit 0
24 NTHREADS=${NTHREADS:-0}
26 MINCOUNT=${MINCOUNT:-8192}
27 MAXCOUNT=${MAXCOUNT:-32768}
28 MINCOUNT_REPAIR=${MINCOUNT_REPAIR:-8192}
29 MAXCOUNT_REPAIR=${MAXCOUNT_REPAIR:-32768}
30 BASE_COUNT=${BASE_COUNT:-1048576}
32 INCFACTOR=${INCFACTOR:-25} #percent
34 RCMD="do_facet ${SINGLEMDS}"
35 RLCTL="${RCMD} ${LCTL}"
36 MDT_DEV="${FSNAME}-MDT0000"
37 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
38 START_NAMESPACE="${RLCTL} lfsck_start -M ${MDT_DEV} -t namespace"
39 STOP_LFSCK="${RLCTL} lfsck_stop -M ${MDT_DEV}"
40 SHOW_NAMESPACE="${RLCTL} get_param -n mdd.${MDT_DEV}.lfsck_namespace"
41 MNTOPTS_NOSCRUB="-o user_xattr,noscrub"
42 remote_mds && ECHOCMD=${RCMD} || ECHOCMD="eval"
44 if [ ${NTHREADS} -eq 0 ]; then
45 CPUCORE=$(${RCMD} cat /proc/cpuinfo | grep "processor.*:" | wc -l)
46 NTHREADS=$((CPUCORE * 2))
50 ${ECHOCMD} "${LCTL} <<-EOF
51 attach echo_client lfsck-MDT0000 lfsck-MDT0000_UUID
57 ${ECHOCMD} "${LCTL} <<-EOF
65 local echodev=$(${RLCTL} dl | grep echo_client|awk '{print $1}')
68 ${ECHOCMD} "${LCTL} <<-EOF
73 for ((j = 1; j < ${threads}; j++)); do
74 ${ECHOCMD} "${LCTL} <<-EOF
76 test_mkdir ${tdir}${j}
80 ${ECHOCMD} "${LCTL} <<-EOF
82 --threads ${threads} 0 ${echodev} test_create \
83 -d ${tdir} -D ${threads} -b ${lbase} -c 0 -n ${usize}
88 do_rpc_nodes $(facet_active_host $SINGLEMDS) unload_modules
92 lfsck_create_nfiles() {
97 local ldir="/test-${lbase}"
102 [ ${count} -eq 0 -o ${count} -gt ${total} ] && count=${total}
103 local usize=$((count / NTHREADS))
104 [ ${usize} -eq 0 ] && break
105 local tdir=${ldir}-${cycle}-
107 echo "[cycle: ${cycle}] [threads: ${threads}]"\
108 "[files: ${count}] [basedir: ${tdir}]"
109 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB ||
110 error "Fail to start MDS!"
111 #define OBD_FAIL_FID_IGIF 0x1504
112 [ ! -z $linkea ] && ${RLCTL} set_param fail_loc=0x1504
118 [ ! -z $linkea ] && ${RLCTL} set_param fail_loc=0x0
119 stop ${SINGLEMDS} || error "Fail to stop MDS!"
121 total=$((total - usize * NTHREADS))
122 [ ${total} -eq 0 ] && break
123 lbase=$((lbase + usize))
135 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
136 reformat_external_journal
137 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype \
138 ldiskfs --reformat ${MDT_DEVNAME} $(mdsvdevname 1) > /dev/null ||
139 error "Fail to reformat the MDS!"
141 for ((i = $MINCOUNT; i <= $MAXCOUNT; i = $((i * FACTOR)))); do
142 local nfiles=$((i - BCOUNT))
144 echo "+++ start to create for ${i} files set at: $(date) +++"
145 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
146 error "Fail to create files!"
147 echo "+++ end to create for ${i} files set at: $(date) +++"
150 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
151 error "Fail to start MDS!"
153 echo "start lfsck_namespace for ${i} files set at: $(date)"
154 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
157 local STATUS=$($SHOW_NAMESPACE |
158 awk '/^status/ { print $2 }')
159 [ "$STATUS" == "completed" ] && break
160 sleep 3 # check status every 3 seconds
163 echo "end lfsck_namespace for ${i} files set at: $(date)"
164 SPEED=$($SHOW_NAMESPACE |
165 awk '/^average_speed_phase1/ { print $2 }')
166 echo "lfsck_namespace speed is ${SPEED}/sec"
167 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
170 run_test 0 "lfsck performance test (routine case) without load"
177 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
178 reformat_external_journal
179 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype \
180 ldiskfs --reformat ${MDT_DEVNAME} $(mdsvdevname 1) > /dev/null ||
181 error "Fail to reformat the MDS!"
183 for ((i = $MINCOUNT_REPAIR; i <= $MAXCOUNT_REPAIR;
184 i = $((i * FACTOR)))); do
185 local nfiles=$((i - BCOUNT))
187 echo "+++ start to create for ${i} files set at: $(date) +++"
188 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
189 error "Fail to create files!"
190 echo "+++ end to create for ${i} files set at: $(date) +++"
193 local stime=$(date +%s)
194 echo "backup/restore ${i} files start at: $(date)"
195 mds_backup_restore $SINGLEMDS || error "Fail to backup/restore!"
196 echo "backup/restore ${i} files end at: $(date)"
197 local etime=$(date +%s)
198 local delta=$((etime - stime))
199 [ $delta -gt 0 ] || delta=1
200 echo "backup/restore ${i} files used ${delta} seconds"
201 echo "backup/restore speed is $((i / delta))/sec"
203 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
204 error "Fail to start MDS!"
206 echo "start lfsck_namespace for ${i} files set at: $(date)"
207 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
210 local STATUS=$($SHOW_NAMESPACE |
211 awk '/^status/ { print $2 }')
212 [ "$STATUS" == "completed" ] && break
213 sleep 3 # check status every 3 seconds
216 echo "end lfsck_namespace for ${i} files set at: $(date)"
217 local SPEED=$($SHOW_NAMESPACE |
218 awk '/^average_speed_phase1/ { print $2 }')
219 echo "lfsck_namespace speed is ${SPEED}/sec"
220 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
223 run_test 1 "lfsck performance test (backup/restore) without load"
228 for ((i = $MINCOUNT_REPAIR; i <= $MAXCOUNT_REPAIR;
229 i = $((i * FACTOR)))); do
231 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
232 reformat_external_journal
233 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) \
234 --backfstype ldiskfs --reformat ${MDT_DEVNAME} \
235 $(mdsvdevname 1) > /dev/null ||
236 error "Fail to reformat the MDS!"
238 echo "+++ start to create for ${i} files set at: $(date) +++"
239 lfsck_create_nfiles ${i} 0 ${NTHREADS} 1 ||
240 error "Fail to create files!"
241 echo "+++ end to create for ${i} files set at: $(date) +++"
243 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
244 error "Fail to start MDS!"
246 echo "start lfsck_namespace for ${i} files set at: $(date)"
247 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
250 local STATUS=$($SHOW_NAMESPACE |
251 awk '/^status/ { print $2 }')
252 [ "$STATUS" == "completed" ] && break
253 sleep 3 # check status every 3 seconds
256 echo "end lfsck_namespace for ${i} files set at: $(date)"
257 local SPEED=$($SHOW_NAMESPACE |
258 awk '/^average_speed_phase1/ { print $2 }')
259 echo "lfsck_namespace speed is ${SPEED}/sec"
260 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
263 run_test 2 "lfsck performance test (simulate upgrade from 1.8) without load"
266 [ $MDSSIZE -lt 4000000 ] &&
267 skip "MDT device is too small, expect at last 4GB" && exit 0
269 [ $BASE_COUNT -lt 1048576 ] && BASE_COUNT=1048576
270 [ $INCFACTOR -gt 25 ] && INCFACTOR=25
272 local inc_count=$((BASE_COUNT * INCFACTOR / 100))
277 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
278 reformat_external_journal
279 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype \
280 ldiskfs --reformat ${MDT_DEVNAME} $(mdsvdevname 1) > /dev/null ||
281 error "Fail to reformat the MDS!"
283 for ((i = $inc_count; i <= $BASE_COUNT; i = $((i + inc_count)))); do
284 local nfiles=$((i - BCOUNT))
286 echo "+++ start to create for ${i} files set at: $(date) +++"
287 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
288 error "Fail to create files!"
289 echo "+++ end to create for ${i} files set at: $(date) +++"
293 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
294 error "Fail to start MDS!"
296 echo "start lfsck_namespace for ${BASE_COUNT} files set at: $(date)"
297 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
300 local STATUS=$($SHOW_NAMESPACE |
301 awk '/^status/ { print $2 }')
302 [ "$STATUS" == "completed" ] && break
303 sleep 3 # check status every 3 seconds
306 echo "end lfsck_namespace for ${BASE_COUNT} files set at: $(date)"
307 local FULL_SPEED=$($SHOW_NAMESPACE |
308 awk '/^average_speed_phase1/ { print $2 }')
309 echo "lfsck_namespace full_speed is ${FULL_SPEED}/sec"
310 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
311 local inc_speed=$((FULL_SPEED * INCFACTOR / 100))
314 for ((j = $inc_speed; j < $FULL_SPEED; j = $((j + inc_speed)))); do
315 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
316 error "Fail to start MDS!"
318 $STOP_LFSCK > /dev/null 2>&1
319 echo "start lfsck_namespace with speed ${j} at: $(date)"
320 $START_NAMESPACE --reset -s ${j} ||
321 error "Fail to start lfsck_namespace with speed ${j}!"
322 # lfsck_namespace will be paused when MDS stop,
323 # and will be restarted automatically when mount up again.
324 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
326 local nfiles=$(((i - BCOUNT) / 2))
328 echo "+++ start to create for ${i} files set at: $(date) +++"
329 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
330 error "Fail to create files!"
331 echo "+++ end to create for ${i} files set at: $(date) +++"
336 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
337 error "Fail to start MDS!"
339 $STOP_LFSCK /dev/null 2>&1
340 echo "start lfsck_namespace with full speed at: $(date)"
341 $START_NAMESPACE --reset -s 0 ||
342 error "Fail to start lfsck_namespace with full speed!"
343 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
345 local nfiles=$(((i - BCOUNT) / 2))
347 echo "+++ start to create for ${i} files set at: $(date) +++"
348 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
349 error "Fail to create files!"
350 echo "+++ end to create for ${i} files set at: $(date) +++"
352 run_test 3 "lfsck performance test (routine case) without load"
354 # cleanup the system at last