Whamcloud - gitweb
LU-4713 tests: fix fhandle syscall test progarm
[fs/lustre-release.git] / lustre / tests / lfsck-performance.sh
1 #!/bin/bash
2
3 set -e
4
5 ONLY=${ONLY:-"$*"}
6 ALWAYS_EXCEPT="$LFSCK_PERFORMANCE_EXCEPT"
7 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
9
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
11 . $LUSTRE/tests/test-framework.sh
12 init_test_env $@
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
14 init_logging
15
16 require_dsh_mds || exit 0
17 require_dsh_ost || exit 0
18
19 [ "$SLOW" = "no" ] &&
20         skip "skip lfsck performance test under non-SLOW mode" && exit 0
21
22 NTHREADS=${NTHREADS:-0}
23 UNIT=${UNIT:-8192}
24 MINCOUNT=${MINCOUNT:-4096}
25 MAXCOUNT=${MAXCOUNT:-8192}
26 MINCOUNT_REPAIR=${MINCOUNT_REPAIR:-4096}
27 MAXCOUNT_REPAIR=${MAXCOUNT_REPAIR:-8192}
28 BASE_COUNT=${BASE_COUNT:-8192}
29 FACTOR=${FACTOR:-2}
30 INCFACTOR=${INCFACTOR:-25} #percent
31 MINSUBDIR=${MINSUBDIR:-1}
32 MAXSUBDIR=${MAXSUBDIR:-2}
33 TOTSUBDIR=${TOTSUBDIR:-2}
34 WTIME=${WTIME:-86400}
35
36 RCMD="do_facet ${SINGLEMDS}"
37 RLCTL="${RCMD} ${LCTL}"
38 MDT_DEV="${FSNAME}-MDT0000"
39 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
40 START_NAMESPACE="${RLCTL} lfsck_start -M ${MDT_DEV} -t namespace"
41 STOP_LFSCK="${RLCTL} lfsck_stop -M ${MDT_DEV}"
42 SHOW_NAMESPACE="${RLCTL} get_param -n mdd.${MDT_DEV}.lfsck_namespace"
43 MNTOPTS_NOSCRUB="-o user_xattr,noscrub"
44 remote_mds && ECHOCMD=${RCMD} || ECHOCMD="eval"
45
46 if [ ${NTHREADS} -eq 0 ]; then
47         CPUCORE=$(${RCMD} cat /proc/cpuinfo | grep "processor.*:" | wc -l)
48         NTHREADS=$((CPUCORE * 2))
49 fi
50
51 lfsck_attach() {
52         ${ECHOCMD} "${LCTL} <<-EOF
53                 attach echo_client lfsck-MDT0000 lfsck-MDT0000_UUID
54                 setup ${MDT_DEV} mdd
55         EOF"
56 }
57
58 lfsck_detach() {
59         ${ECHOCMD} "${LCTL} <<-EOF
60                 device lfsck-MDT0000
61                 cleanup
62                 detach
63         EOF"
64 }
65
66 lfsck_create() {
67         local echodev=$(${RLCTL} dl | grep echo_client|awk '{print $1}')
68         local j
69
70         ${ECHOCMD} "${LCTL} <<-EOF
71                 cfg_device ${echodev}
72                 test_mkdir ${tdir}
73         EOF"
74
75         for ((j = 1; j < ${threads}; j++)); do
76                 ${ECHOCMD} "${LCTL} <<-EOF
77                         cfg_device ${echodev}
78                         test_mkdir ${tdir}${j}
79                 EOF"
80         done
81
82         ${ECHOCMD} "${LCTL} <<-EOF
83                 cfg_device ${echodev}
84                 --threads ${threads} 0 ${echodev} test_create \
85                 -d ${tdir} -D ${threads} -b ${lbase} -c 0 -n ${usize}
86         EOF"
87 }
88
89 lfsck_cleanup() {
90         do_rpc_nodes $(facet_active_host $SINGLEMDS) unload_modules
91         formatall
92 }
93
94 lfsck_create_nfiles() {
95         local total=$1
96         local lbase=$2
97         local threads=$3
98         local linkea=$4
99         local ldir="/test-${lbase}"
100         local cycle=0
101         local count=${UNIT}
102
103         while true; do
104                 [ ${count} -eq 0 -o  ${count} -gt ${total} ] && count=${total}
105                 local usize=$((count / NTHREADS))
106                 [ ${usize} -eq 0 ] && break
107                 local tdir=${ldir}-${cycle}-
108
109                 echo "[cycle: ${cycle}] [threads: ${threads}]"\
110                      "[files: ${count}] [basedir: ${tdir}]"
111                 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB ||
112                         error "Fail to start MDS!"
113                 #define OBD_FAIL_FID_IGIF       0x1504
114                 [ ! -z $linkea ] && ${RLCTL} set_param fail_loc=0x1504
115
116                 lfsck_attach
117                 lfsck_create
118                 lfsck_detach
119
120                 [ ! -z $linkea ] && ${RLCTL} set_param fail_loc=0x0
121                 stop ${SINGLEMDS} || error "Fail to stop MDS!"
122
123                 total=$((total - usize * NTHREADS))
124                 [ ${total} -eq 0 ] && break
125                 lbase=$((lbase + usize))
126                 cycle=$((cycle + 1))
127         done
128 }
129
130 build_test_filter
131
132 test_0() {
133         local BCOUNT=0
134         local i
135
136         stopall
137         do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
138         reformat_external_journal
139         add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype \
140                 $(facet_fstype ${SINGLEMDS}) --reformat ${MDT_DEVNAME} \
141                 $(mdsvdevname 1) >/dev/null || error "Fail to reformat the MDS!"
142
143         for ((i = $MINCOUNT; i <= $MAXCOUNT; i = $((i * FACTOR)))); do
144                 local nfiles=$((i - BCOUNT))
145
146                 echo "+++ start to create for ${i} files set at: $(date) +++"
147                 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
148                         error "Fail to create files!"
149                 echo "+++ end to create for ${i} files set at: $(date) +++"
150
151                 BCOUNT=${i}
152                 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
153                         error "Fail to start MDS!"
154
155                 echo "start lfsck_namespace for ${i} files set at: $(date)"
156                 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
157
158                 while true; do
159                         local STATUS=$($SHOW_NAMESPACE |
160                                         awk '/^status/ { print $2 }')
161                         [ "$STATUS" == "completed" ] && break
162                         sleep 3 # check status every 3 seconds
163                 done
164
165                 echo "end lfsck_namespace for ${i} files set at: $(date)"
166                 SPEED=$($SHOW_NAMESPACE |
167                         awk '/^average_speed_phase1/ { print $2 }')
168                 echo "lfsck_namespace speed is ${SPEED}/sec"
169                 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
170         done
171 }
172 run_test 0 "lfsck namespace performance (routine case) without load"
173
174 test_1() {
175         [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
176                 skip "not implemented for ZFS" && return
177
178         local BCOUNT=0
179         local i
180
181         stopall
182         do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
183         reformat_external_journal
184         add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype \
185                 $(facet_fstype ${SINGLEMDS}) --reformat ${MDT_DEVNAME} \
186                 $(mdsvdevname 1) > /dev/null || error "Fail to reformat the MDS"
187
188         for ((i = $MINCOUNT_REPAIR; i <= $MAXCOUNT_REPAIR;
189               i = $((i * FACTOR)))); do
190                 local nfiles=$((i - BCOUNT))
191
192                 echo "+++ start to create for ${i} files set at: $(date) +++"
193                 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
194                         error "Fail to create files!"
195                 echo "+++ end to create for ${i} files set at: $(date) +++"
196
197                 BCOUNT=${i}
198                 local stime=$(date +%s)
199                 echo "backup/restore ${i} files start at: $(date)"
200                 mds_backup_restore $SINGLEMDS || error "Fail to backup/restore!"
201                 echo "backup/restore ${i} files end at: $(date)"
202                 local etime=$(date +%s)
203                 local delta=$((etime - stime))
204                 [ $delta -gt 0 ] || delta=1
205                 echo "backup/restore ${i} files used ${delta} seconds"
206                 echo "backup/restore speed is $((i / delta))/sec"
207
208                 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
209                         error "Fail to start MDS!"
210
211                 echo "start lfsck_namespace for ${i} files set at: $(date)"
212                 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
213
214                 while true; do
215                         local STATUS=$($SHOW_NAMESPACE |
216                                         awk '/^status/ { print $2 }')
217                         [ "$STATUS" == "completed" ] && break
218                         sleep 3 # check status every 3 seconds
219                 done
220
221                 echo "end lfsck_namespace for ${i} files set at: $(date)"
222                 local SPEED=$($SHOW_NAMESPACE |
223                               awk '/^average_speed_phase1/ { print $2 }')
224                 echo "lfsck_namespace speed is ${SPEED}/sec"
225                 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
226         done
227 }
228 run_test 1 "lfsck namespace performance (backup/restore) without load"
229
230 test_2() {
231         local i
232
233         for ((i = $MINCOUNT_REPAIR; i <= $MAXCOUNT_REPAIR;
234               i = $((i * FACTOR)))); do
235                 stopall
236                 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
237                 reformat_external_journal
238                 add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) \
239                         --backfstype $(facet_fstype ${SINGLEMDS}) --reformat \
240                         ${MDT_DEVNAME} $(mdsvdevname 1) > /dev/null ||
241                         error "Fail to reformat the MDS!"
242
243                 echo "+++ start to create for ${i} files set at: $(date) +++"
244                 lfsck_create_nfiles ${i} 0 ${NTHREADS} 1 ||
245                         error "Fail to create files!"
246                 echo "+++ end to create for ${i} files set at: $(date) +++"
247
248                 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
249                         error "Fail to start MDS!"
250
251                 echo "start lfsck_namespace for ${i} files set at: $(date)"
252                 $START_NAMESPACE || error "Fail to start lfsck_namespace!"
253
254                 while true; do
255                         local STATUS=$($SHOW_NAMESPACE |
256                                         awk '/^status/ { print $2 }')
257                         [ "$STATUS" == "completed" ] && break
258                         sleep 3 # check status every 3 seconds
259                 done
260
261                 echo "end lfsck_namespace for ${i} files set at: $(date)"
262                 local SPEED=$($SHOW_NAMESPACE |
263                               awk '/^average_speed_phase1/ { print $2 }')
264                 echo "lfsck_namespace speed is ${SPEED}/sec"
265                 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
266         done
267 }
268 run_test 2 "lfsck namespace performance (upgrade from 1.8) without load"
269
270 test_3() {
271         [ $INCFACTOR -gt 25 ] && INCFACTOR=25
272
273         local inc_count=$((BASE_COUNT * INCFACTOR / 100))
274         local BCOUNT=0
275         local i
276
277         stopall
278         do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules_local
279         reformat_external_journal
280         add ${SINGLEMDS} $(mkfs_opts ${SINGLEMDS} ${MDT_DEVNAME}) --backfstype \
281                 $(facet_fstype ${SINGLEMDS}) --reformat ${MDT_DEVNAME} \
282                 $(mdsvdevname 1) > /dev/null || error "Fail to reformat the MDS"
283
284         for ((i = $inc_count; i <= $BASE_COUNT; i = $((i + inc_count)))); do
285                 local nfiles=$((i - BCOUNT))
286
287                 echo "+++ start to create for ${i} files set at: $(date) +++"
288                 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
289                         error "Fail to create files!"
290                 echo "+++ end to create for ${i} files set at: $(date) +++"
291                 BCOUNT=${i}
292         done
293
294         start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
295                 error "Fail to start MDS!"
296
297         echo "start lfsck_namespace for ${BASE_COUNT} files set at: $(date)"
298         $START_NAMESPACE || error "Fail to start lfsck_namespace!"
299
300         while true; do
301                 local STATUS=$($SHOW_NAMESPACE |
302                                 awk '/^status/ { print $2 }')
303                 [ "$STATUS" == "completed" ] && break
304                 sleep 3 # check status every 3 seconds
305         done
306
307         echo "end lfsck_namespace for ${BASE_COUNT} files set at: $(date)"
308         local FULL_SPEED=$($SHOW_NAMESPACE |
309                       awk '/^average_speed_phase1/ { print $2 }')
310         echo "lfsck_namespace full_speed is ${FULL_SPEED}/sec"
311         stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
312         local inc_speed=$((FULL_SPEED * INCFACTOR / 100))
313         local j
314
315         for ((j = $inc_speed; j < $FULL_SPEED; j = $((j + inc_speed)))); do
316                 start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
317                         error "Fail to start MDS!"
318
319                 $STOP_LFSCK > /dev/null 2>&1
320                 echo "start lfsck_namespace with speed ${j} at: $(date)"
321                 $START_NAMESPACE --reset -s ${j} ||
322                         error "Fail to start lfsck_namespace with speed ${j}!"
323                 # lfsck_namespace will be paused when MDS stop,
324                 # and will be restarted automatically when mount up again.
325                 stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
326
327                 local nfiles=$(((i - BCOUNT) / 2))
328
329                 echo "+++ start to create for ${i} files set at: $(date) +++"
330                 lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
331                         error "Fail to create files!"
332                 echo "+++ end to create for ${i} files set at: $(date) +++"
333                 BCOUNT=${i}
334                 i=$((i + inc_count))
335         done
336
337         start ${SINGLEMDS} $MDT_DEVNAME $MNTOPTS_NOSCRUB > /dev/null ||
338                 error "Fail to start MDS!"
339
340         $STOP_LFSCK /dev/null 2>&1
341         echo "start lfsck_namespace with full speed at: $(date)"
342         $START_NAMESPACE --reset -s 0 ||
343                 error "Fail to start lfsck_namespace with full speed!"
344         stop ${SINGLEMDS} > /dev/null || error "Fail to stop MDS!"
345
346         local nfiles=$(((i - BCOUNT) / 2))
347
348         echo "+++ start to create for ${i} files set at: $(date) +++"
349         lfsck_create_nfiles ${nfiles} ${BCOUNT} ${NTHREADS} ||
350                 error "Fail to create files!"
351         echo "+++ end to create for ${i} files set at: $(date) +++"
352 }
353 run_test 3 "lfsck namespace impact on create performance"
354
355 show_layout() {
356         local idx=$1
357
358         $RLCTL get_param -n mdd.$(facet_svc mds${idx}).lfsck_layout
359 }
360
361 layout_test_one()
362 {
363         echo "***** Start layout LFSCK on all devices at: $(date) *****"
364         $RLCTL lfsck_start -M ${MDT_DEV} -t layout -A -r || return 21
365
366         wait_update_facet $SINGLEMDS "$LCTL get_param -n \
367                 mdd.${MDT_DEV}.lfsck_layout |
368                 awk '/^status/ { print \\\$2 }'" "completed" $WTIME || {
369                 show_layout 1
370                 return 22
371         }
372         echo "***** End layout LFSCK on all devices at: $(date) *****"
373
374         for n in $(seq $MDSCOUNT); do
375                 show_layout ${n}
376
377                 local SPEED=$(show_layout ${n} |
378                               awk '/^average_speed_phase1/ { print $2 }')
379                 echo
380                 echo "lfsck_layout speed on MDS_${n} is $SPEED objs/sec"
381                 echo
382         done
383 }
384
385 layout_gen_one()
386 {
387         local idx1=$1
388         local idx2=$2
389         local mntpt="/mnt/lustre_lfsck_${idx1}_${idx2}"
390         local basedir="$mntpt/$tdir/$idx1/$idx2"
391
392         mkdir -p $mntpt || {
393                 error_noexit "(11) Fail to mkdir $mntpt"
394                 return 11
395         }
396
397         mount_client $mntpt || {
398                 error_noexit "(12) Fail to mount $mntpt"
399                 return 12
400         }
401
402         mkdir $basedir || {
403                 umount_client $mntpt
404                 error_noexit "(13) Fail to mkdir $basedir"
405                 return 13
406         }
407
408         echo "&&&&& Start create $UNIT files under $basedir at: $(date) &&&&&"
409         createmany -o ${basedir}/f $UNIT || {
410                 umount_client $mntpt
411                 error_noexit "(14) Fail to gen $UNIT files under $basedir"
412                 return 14
413         }
414         echo "&&&&& End create $UNIT files under $basedir at: $(date) &&&&&"
415
416         umount_client $mntpt
417 }
418
419 layout_gen_set()
420 {
421         local cnt=$1
422
423         echo "##### Start generate test set for subdirs=$cnt at: $(date) #####"
424         for ((k = 0; k < $MDSCOUNT; k++)); do
425                 $LFS mkdir -i ${k} $LFSCKDIR/${k} || return 10
426
427                 for ((l = 1; l <= $cnt; l++)); do
428                         layout_gen_one ${k} ${l} &
429                 done
430         done
431
432         wait
433         echo "##### End generate test set for subdirs=$cnt at: $(date) #####"
434 }
435
436 t4_test()
437 {
438         local saved_mdscount=$MDSCOUNT
439         local saved_ostcount=$OSTCOUNT
440
441         echo "stopall"
442         stopall > /dev/null || error "(1) Fail to stopall"
443
444         LFSCKDIR="$DIR/$tdir"
445         MDSCOUNT=1
446         for ((i = 1; i <= $saved_ostcount; i = $((i * 2)))); do
447                 OSTCOUNT=${i}
448
449                 echo "+++++ Start cycle ostcount=$OSTCOUNT at: $(date) +++++"
450                 echo
451
452                 for ((j = $MINSUBDIR; j <= $MAXSUBDIR; j = $((j * FACTOR)))); do
453                         echo "formatall"
454                         formatall > /dev/null ||
455                                 error "(2) Fail to formatall, subdirs=${j}"
456
457                         echo "setupall"
458                         setupall > /dev/null ||
459                                 error "(3) Fail to setupall, subdirs=${j}"
460
461                         mkdir $LFSCKDIR ||
462                                 error "(4) mkdir $LFSCKDIR, subdirs=${j}"
463
464                         $LFS setstripe -c ${OSTCOUNT} -i 0 $LFSCKDIR ||
465                                 error "(5) setstripe on $LFSCKDIR, subdirs=${j}"
466
467                         local RC=0
468                         layout_gen_set ${j} || RC=$?
469                         [ $RC -eq 0 ] ||
470                                 error "(6) generate set $RC, subdirs=${j}"
471
472                         RC=0
473                         layout_test_one || RC=$?
474                         [ $RC -eq 0 ] ||
475                                 error "(7) LFSCK failed with $RC, subdirs=${j}"
476                 done
477
478                 echo "stopall"
479                 stopall > /dev/null || error "(8) Fail to stopall, subdirs=${j}"
480
481                 echo
482                 echo "----- Stop cycle ostcount=$OSTCOUNT at: $(date) -----"
483         done
484
485         MDSCOUNT=$saved_mdscount
486         OSTCOUNT=$saved_ostcount
487 }
488
489 test_4a() {
490         t4_test
491 }
492 run_test 4a "Single MDS lfsck layout performance (routine case) without load"
493
494 test_4b() {
495         echo "Inject failure stub to simulate dangling reference"
496         #define OBD_FAIL_LFSCK_DANGLING 0x1610
497         do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0x1610
498
499         t4_test
500 }
501 run_test 4b "Single MDS lfsck layout performance (repairing case) without load"
502
503 t5_test()
504 {
505         local saved_mdscount=$MDSCOUNT
506
507         echo "stopall"
508         stopall > /dev/null || error "(1) Fail to stopall"
509
510         LFSCKDIR="$DIR/$tdir"
511         for ((i = 1; i <= $saved_mdscount; i++)); do
512                 MDSCOUNT=${i}
513
514                 echo "+++++ Start cycle mdscount=$MDSCOUNT at: $(date) +++++"
515                 echo
516
517                 for ((j = $MINSUBDIR; j <= $MAXSUBDIR; j = $((j * FACTOR)))); do
518                         echo "formatall"
519                         formatall > /dev/null ||
520                                 error "(2) Fail to formatall, subdirs=${j}"
521
522                         echo "setupall"
523                         setupall > /dev/null ||
524                                 error "(3) Fail to setupall, subdirs=${j}"
525
526                         mkdir $LFSCKDIR ||
527                                 error "(4) mkdir $LFSCKDIR, subdirs=${j}"
528
529                         $LFS setstripe -c ${OSTCOUNT} -i 0 $LFSCKDIR ||
530                                 error "(5) setstripe on $LFSCKDIR, subdirs=${j}"
531
532                         local RC=0
533                         layout_gen_set ${j} || RC=$?
534                         [ $RC -eq 0 ] ||
535                                 error "(6) generate set $RC, subdirs=${j}"
536
537                         RC=0
538                         layout_test_one || RC=$?
539                         [ $RC -eq 0 ] ||
540                                 error "(7) LFSCK failed with $RC, subdirs=${j}"
541                 done
542
543                 echo "stopall"
544                 stopall > /dev/null || error "(8) Fail to stopall"
545
546                 echo
547                 echo "----- Stop cycle mdscount=$MDSCOUNT at: $(date) -----"
548         done
549
550         MDSCOUNT=$saved_mdscount
551 }
552
553 test_5a() {
554         t5_test
555 }
556 run_test 5a "lfsck layout performance (routine case) without load for DNE"
557
558 test_5b() {
559         echo "Inject failure stub to simulate dangling reference"
560         #define OBD_FAIL_LFSCK_DANGLING 0x1610
561         do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0x1610
562
563         t5_test
564 }
565 run_test 5b "lfsck layout performance (repairing case) without load for DNE"
566
567 layout_fast_create() {
568         local total=$1
569         local lbase=$2
570         local threads=$3
571         local ldir="/test-${lbase}"
572         local cycle=0
573         local count=$UNIT
574
575         while true; do
576                 [ $count -eq 0 -o  $count -gt ${total} ] && count=$total
577                 local usize=$((count / NTHREADS))
578                 [ ${usize} -eq 0 ] && break
579                 local tdir=${ldir}-${cycle}-
580
581                 echo "[cycle: $cycle] [threads: $threads]"\
582                      "[files: $count] [basedir: $tdir]"
583
584                 lfsck_create
585
586                 total=$((total - usize * NTHREADS))
587                 [ $total -eq 0 ] && break
588                 lbase=$((lbase + usize))
589                 cycle=$((cycle + 1))
590         done
591 }
592
593 lfsck_detach_error()
594 {
595         lfsck_detach
596         error "$@"
597 }
598
599 test_6() {
600         [ $INCFACTOR -gt 25 ] && INCFACTOR=25
601
602         echo "stopall"
603         stopall > /dev/null || error "(1) Fail to stopall"
604
605         local saved_mdscount=$MDSCOUNT
606
607         LFSCKDIR="$DIR/$tdir"
608         MDSCOUNT=1
609         echo "formatall"
610         formatall > /dev/null || error "(2) Fail to formatall"
611
612         echo "setupall"
613         setupall > /dev/null || error "(3) Fail to setupall"
614
615         mkdir $LFSCKDIR || error "(4) Fail to mkdir $LFSCKDIR"
616
617         $LFS setstripe -c ${OSTCOUNT} -i 0 $LFSCKDIR ||
618                 error "(5) Fail to setstripe on $LFSCKDIR"
619
620         local RC=0
621         layout_gen_set $TOTSUBDIR || RC=$?
622         [ $RC -eq 0 ] ||
623                 error "(6) Fail to generate set $RC, subdirs=$TOTSUBDIR"
624
625         echo
626         echo "***** Start layout LFSCK on single MDS at: $(date) *****"
627         $RLCTL lfsck_start -M ${MDT_DEV} -t layout -r ||
628                 error "(7) Fail to start layout LFSCK"
629
630         wait_update_facet $SINGLEMDS "$LCTL get_param -n \
631                 mdd.${MDT_DEV}.lfsck_layout |
632                 awk '/^status/ { print \\\$2 }'" "completed" $WTIME || {
633                 show_layout 1
634                 error "(8) layout LFSCK cannot finished in time"
635         }
636         echo "***** End layout LFSCK on single MDS at: $(date) *****"
637
638         local SPEED=$(show_layout 1 |
639                       awk '/^average_speed_phase1/ { print $2 }')
640         echo "lfsck_layout full_speed is $SPEED objs/sec"
641
642         local inc_count=$((BASE_COUNT * INCFACTOR / 100))
643         local nfiles=$((inc_count / 2))
644
645         lfsck_attach
646         for ((m = 0, n = $INCFACTOR; n < 100;
647               m = $((m + inc_count)), n = $((n + INCFACTOR)))); do
648                 local sl=$((SPEED * n / 100))
649
650                 $STOP_LFSCK > /dev/null 2>&1
651                 echo
652                 echo "start lfsck_layout with speed ${sl} at: $(date)"
653                 $RLCTL lfsck_start -M ${MDT_DEV} -t layout -r -s ${sl} ||
654                         lfsck_detach_error \
655                         "(9) Fail to start lfsck_layout with speed ${sl}"
656
657                 echo "&&&&& Start create files set from ${m} at: $(date) &&&&&"
658                 layout_fast_create $nfiles ${m} $NTHREADS ||
659                         lfsck_detach_error "(10) Fail to create files"
660                 echo "&&&&& End create files set from ${m} at: $(date) &&&&&"
661         done
662
663         $STOP_LFSCK > /dev/null 2>&1
664         echo
665         echo "start lfsck_layout with full speed at: $(date)"
666         $RLCTL lfsck_start -M ${MDT_DEV} -t layout -r -s 0 ||
667                 lfsck_detach_error \
668                 "(11) Fail to start lfsck_layout with full speed"
669
670         echo "&&&&& start to create files set from ${m} at: $(date) &&&&&"
671         layout_fast_create $nfiles ${m} $NTHREADS ||
672                 lfsck_detach_error "(12) Fail to create files"
673         echo "&&&&& end to create files set from ${m} at: $(date) &&&&&"
674
675         m=$((m + inc_count))
676         $STOP_LFSCK > /dev/null 2>&1
677         echo
678         echo "create without lfsck_layout run back-ground"
679         echo "&&&&& start to create files set from ${m} at: $(date) &&&&&"
680         layout_fast_create $nfiles ${m} $NTHREADS ||
681                 lfsck_detach_error "(13) Fail to create files"
682         echo "&&&&& end to create files set from ${m} at: $(date) &&&&&"
683
684         lfsck_detach
685         echo
686         echo "stopall"
687         stopall > /dev/null || error "(14) Fail to stopall"
688
689         MDSCOUNT=$saved_mdscount
690 }
691 run_test 6 "lfsck layout impact on create performance"
692
693 # cleanup the system at last
694 lfsck_cleanup
695 complete $SECONDS
696 exit_status