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; i=$((i * FACTOR)))); do
184 local nfiles=$((i - BCOUNT))
186 echo "+++ start to create for ${i} files set at: $(date) +++"
187 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
188 error "Fail to create files!"
189 echo "+++ end to create for ${i} files set at: $(date) +++"
192 local stime=$(date +%s)
193 echo "backup/restore ${i} files start at: $(date)"
194 mds_backup_restore || error "Fail to backup/restore!"
195 echo "backup/restore ${i} files end at: $(date)"
196 local etime=$(date +%s)
197 local delta=$((etime - stime))
198 [ $delta -gt 0 ] || delta=1
199 echo "backup/restore ${i} files used ${delta} seconds"
200 echo "backup/restore speed is $((i / delta))/sec"
202 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
203 error "Fail to start MDS!"
205 echo "start lfsck_namespace for ${i} files set at: $(date)"
206 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
209 local STATUS=$($SHOW_NAMESPACE |
210 awk '/^status/ { print $2 }')
211 [ "$STATUS" == "completed" ] && break
212 sleep 3 # check status every 3 seconds
215 echo "end lfsck_namespace for ${i} files set at: $(date)"
216 local SPEED=$($SHOW_NAMESPACE |
217 awk '/^average_speed_phase1/ { print $2 }')
218 echo "lfsck_namespace speed is ${SPEED}/sec"
219 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
222 run_test 1 "lfsck performance test (backup/restore) without load"
227 for ((i=$MINCOUNT_REPAIR; i<=$MAXCOUNT_REPAIR; i=$((i * FACTOR)))); do
229 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
230 reformat_external_journal
231 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) \
232 --backfstype ldiskfs --reformat ${MDT_DEVNAME} \
233 $(mdsvdevname 1) > /dev/null ||
234 error "Fail to reformat the MDS!"
236 echo "+++ start to create for ${i} files set at: $(date) +++"
237 lfsck_create_nfiles ${i} 0 ${NTHREADS} 1 ||
238 error "Fail to create files!"
239 echo "+++ end to create for ${i} files set at: $(date) +++"
241 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
242 error "Fail to start MDS!"
244 echo "start lfsck_namespace for ${i} files set at: $(date)"
245 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
248 local STATUS=$($SHOW_NAMESPACE |
249 awk '/^status/ { print $2 }')
250 [ "$STATUS" == "completed" ] && break
251 sleep 3 # check status every 3 seconds
254 echo "end lfsck_namespace for ${i} files set at: $(date)"
255 local SPEED=$($SHOW_NAMESPACE |
256 awk '/^average_speed_phase1/ { print $2 }')
257 echo "lfsck_namespace speed is ${SPEED}/sec"
258 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
261 run_test 2 "lfsck performance test (simulate upgrade from 1.8) without load"
264 [ $MDSSIZE -lt 4000000 ] &&
265 skip "MDT device is too small, expect at last 4GB" && exit 0
267 [ $BASE_COUNT -lt 1048576 ] && BASE_COUNT=1048576
268 [ $INCFACTOR -gt 25 ] && INCFACTOR=25
270 local inc_count=$((BASE_COUNT * INCFACTOR / 100))
275 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
276 reformat_external_journal
277 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype \
278 ldiskfs --reformat ${MDT_DEVNAME} $(mdsvdevname 1) > /dev/null ||
279 error "Fail to reformat the MDS!"
281 for ((i=$inc_count; i<=$BASE_COUNT; i=$((i + inc_count)))); do
282 local nfiles=$((i - BCOUNT))
284 echo "+++ start to create for ${i} files set at: $(date) +++"
285 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
286 error "Fail to create files!"
287 echo "+++ end to create for ${i} files set at: $(date) +++"
291 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
292 error "Fail to start MDS!"
294 echo "start lfsck_namespace for ${BASE_COUNT} files set at: $(date)"
295 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
298 local STATUS=$($SHOW_NAMESPACE |
299 awk '/^status/ { print $2 }')
300 [ "$STATUS" == "completed" ] && break
301 sleep 3 # check status every 3 seconds
304 echo "end lfsck_namespace for ${BASE_COUNT} files set at: $(date)"
305 local FULL_SPEED=$($SHOW_NAMESPACE |
306 awk '/^average_speed_phase1/ { print $2 }')
307 echo "lfsck_namespace full_speed is ${FULL_SPEED}/sec"
308 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
309 local inc_speed=$((FULL_SPEED * INCFACTOR / 100))
312 for ((j=$inc_speed; j<$FULL_SPEED; j=$((j + inc_speed)))); do
313 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
314 error "Fail to start MDS!"
316 $STOP_LFSCK > /dev/null 2>&1
317 echo "start lfsck_namespace with speed ${j} at: $(date)"
318 $START_NAMESPACE --reset -s ${j} ||
319 error "Fail to start lfsck_namespace with speed ${j}!"
320 # lfsck_namespace will be paused when MDS stop,
321 # and will be restarted automatically when mount up again.
322 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
324 local nfiles=$(((i - BCOUNT) / 2))
326 echo "+++ start to create for ${i} files set at: $(date) +++"
327 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
328 error "Fail to create files!"
329 echo "+++ end to create for ${i} files set at: $(date) +++"
334 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
335 error "Fail to start MDS!"
337 $STOP_LFSCK /dev/null 2>&1
338 echo "start lfsck_namespace with full speed at: $(date)"
339 $START_NAMESPACE --reset -s 0 ||
340 error "Fail to start lfsck_namespace with full speed!"
341 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
343 local nfiles=$(((i - BCOUNT) / 2))
345 echo "+++ start to create for ${i} files set at: $(date) +++"
346 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
347 error "Fail to create files!"
348 echo "+++ end to create for ${i} files set at: $(date) +++"
350 run_test 3 "lfsck performance test (routine case) without load"
352 # cleanup the system at last