3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
10 ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT"
11 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
15 . $LUSTRE/tests/test-framework.sh
17 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
20 # remove the check when ZFS backend iteration is ready
21 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
22 skip "test LFSCK only for ldiskfs" && exit 0
23 [ $(facet_fstype ost1) != ldiskfs ] &&
24 skip "test LFSCK only for ldiskfs" && exit 0
26 require_dsh_mds || exit 0
28 MCREATE=${MCREATE:-mcreate}
29 SAVED_MDSSIZE=${MDSSIZE}
30 SAVED_OSTSIZE=${OSTSIZE}
31 # use small MDS + OST size to speed formatting time
32 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
36 check_and_setup_lustre
38 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.60) ]] &&
39 skip "Need MDS version at least 2.3.60" && check_and_cleanup_lustre &&
42 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.4.90) ]] &&
43 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 2c"
45 [[ $(lustre_version_code ost1) -lt $(version_code 2.5.50) ]] &&
46 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 12"
50 $LCTL set_param debug=+lfsck > /dev/null || true
52 MDT_DEV="${FSNAME}-MDT0000"
53 OST_DEV="${FSNAME}-OST0000"
54 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
55 START_NAMESPACE="do_facet $SINGLEMDS \
56 $LCTL lfsck_start -M ${MDT_DEV} -t namespace"
57 START_LAYOUT_ON_OST="do_facet ost1 $LCTL lfsck_start -M ${OST_DEV} -t layout"
58 STOP_LFSCK="do_facet $SINGLEMDS $LCTL lfsck_stop -M ${MDT_DEV}"
59 SHOW_NAMESPACE="do_facet $SINGLEMDS \
60 $LCTL get_param -n mdd.${MDT_DEV}.lfsck_namespace"
61 SHOW_LAYOUT_ON_OST="do_facet ost1 \
62 $LCTL get_param -n obdfilter.${OST_DEV}.lfsck_layout"
63 MOUNT_OPTS_SCRUB="-o user_xattr"
64 MOUNT_OPTS_NOSCRUB="-o user_xattr,noscrub"
77 if [ ! -z $igif ]; then
78 #define OBD_FAIL_FID_IGIF 0x1504
79 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1504
82 echo "preparing... ${nfiles} * ${ndirs} files will be created."
84 cp $LUSTRE/tests/*.sh $DIR/
85 for ((i = 0; i < ${ndirs}; i++)); do
86 mkdir $DIR/$tdir/d${i}
87 touch $DIR/$tdir/f${i}
88 for ((j = 0; j < ${nfiles}; j++)); do
89 touch $DIR/$tdir/d${i}/f${j}
91 mkdir $DIR/$tdir/e${i}
94 if [ ! -z $igif ]; then
95 touch $DIR/$tdir/dummy
96 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
100 cleanup_mount $MOUNT > /dev/null || error "Fail to stop client!"
101 echo "stop $SINGLEMDS"
102 stop $SINGLEMDS > /dev/null || error "Fail to stop MDS!"
107 echo "start $SINGLEMDS"
108 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
109 error "(1) Fail to start MDS!"
111 #define OBD_FAIL_LFSCK_DELAY1 0x1600
112 do_facet $SINGLEMDS $LCTL set_param fail_val=3
113 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1600
114 $START_NAMESPACE || error "(2) Fail to start LFSCK for namespace!"
116 $SHOW_NAMESPACE || error "Fail to monitor LFSCK (3)"
118 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
119 [ "$STATUS" == "scanning-phase1" ] ||
120 error "(4) Expect 'scanning-phase1', but got '$STATUS'"
122 $STOP_LFSCK || error "(5) Fail to stop LFSCK!"
124 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
125 [ "$STATUS" == "stopped" ] ||
126 error "(6) Expect 'stopped', but got '$STATUS'"
128 $START_NAMESPACE || error "(7) Fail to start LFSCK for namespace!"
130 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
131 [ "$STATUS" == "scanning-phase1" ] ||
132 error "(8) Expect 'scanning-phase1', but got '$STATUS'"
134 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
135 do_facet $SINGLEMDS $LCTL set_param fail_val=0
137 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
138 [ "$STATUS" == "completed" ] ||
139 error "(9) Expect 'completed', but got '$STATUS'"
141 local repaired=$($SHOW_NAMESPACE |
142 awk '/^updated_phase1/ { print $2 }')
143 [ $repaired -eq 0 ] ||
144 error "(10) Expect nothing to be repaired, but got: $repaired"
146 local scanned1=$($SHOW_NAMESPACE | awk '/^success_count/ { print $2 }')
147 $START_NAMESPACE -r || error "(11) Fail to reset LFSCK!"
150 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
151 [ "$STATUS" == "completed" ] ||
152 error "(12) Expect 'completed', but got '$STATUS'"
154 local scanned2=$($SHOW_NAMESPACE | awk '/^success_count/ { print $2 }')
155 [ $((scanned1 + 1)) -eq $scanned2 ] ||
156 error "(13) Expect success $((scanned1 + 1)), but got $scanned2"
158 echo "stopall, should NOT crash LU-3649"
161 run_test 0 "Control LFSCK manually"
165 echo "start $SINGLEMDS"
166 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
167 error "(1) Fail to start MDS!"
169 mount_client $MOUNT || error "(2) Fail to start client!"
171 #define OBD_FAIL_FID_INDIR 0x1501
172 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1501
173 touch $DIR/$tdir/dummy
175 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
177 $START_NAMESPACE || error "(3) Fail to start LFSCK for namespace!"
180 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
181 [ "$STATUS" == "completed" ] ||
182 error "(4) Expect 'completed', but got '$STATUS'"
184 local repaired=$($SHOW_NAMESPACE |
185 awk '/^updated_phase1/ { print $2 }')
186 [ $repaired -eq 1 ] ||
187 error "(5) Fail to repair crashed FID-in-dirent: $repaired"
189 mount_client $MOUNT || error "(6) Fail to start client!"
191 #define OBD_FAIL_FID_LOOKUP 0x1505
192 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1505
193 ls $DIR/$tdir/ > /dev/null || error "(7) no FID-in-dirent."
195 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
197 run_test 1a "LFSCK can find out and repair crashed FID-in-dirent"
202 echo "start $SINGLEMDS"
203 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
204 error "(1) Fail to start MDS!"
206 mount_client $MOUNT || error "(2) Fail to start client!"
208 #define OBD_FAIL_FID_INLMA 0x1502
209 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1502
210 touch $DIR/$tdir/dummy
212 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
214 #define OBD_FAIL_FID_NOLMA 0x1506
215 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1506
216 $START_NAMESPACE || error "(3) Fail to start LFSCK for namespace!"
219 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
220 [ "$STATUS" == "completed" ] ||
221 error "(4) Expect 'completed', but got '$STATUS'"
223 local repaired=$($SHOW_NAMESPACE |
224 awk '/^updated_phase1/ { print $2 }')
225 [ $repaired -eq 1 ] ||
226 error "(5) Fail to repair missed FID-in-LMA: $repaired"
228 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
229 mount_client $MOUNT || error "(6) Fail to start client!"
231 #define OBD_FAIL_FID_LOOKUP 0x1505
232 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1505
233 stat $DIR/$tdir/dummy > /dev/null || error "(7) no FID-in-LMA."
235 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
237 run_test 1b "LFSCK can find out and repair missed FID-in-LMA"
241 echo "start $SINGLEMDS"
242 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
243 error "(1) Fail to start MDS!"
245 mount_client $MOUNT || error "(2) Fail to start client!"
247 #define OBD_FAIL_LFSCK_LINKEA_CRASH 0x1603
248 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1603
249 touch $DIR/$tdir/dummy
251 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
253 $START_NAMESPACE || error "(3) Fail to start LFSCK for namespace!"
256 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
257 [ "$STATUS" == "completed" ] ||
258 error "(4) Expect 'completed', but got '$STATUS'"
260 local repaired=$($SHOW_NAMESPACE |
261 awk '/^updated_phase1/ { print $2 }')
262 [ $repaired -eq 1 ] ||
263 error "(5) Fail to repair crashed linkEA: $repaired"
265 mount_client $MOUNT || error "(6) Fail to start client!"
267 stat $DIR/$tdir/dummy | grep "Links: 1" > /dev/null ||
268 error "(7) Fail to stat $DIR/$tdir/dummy"
270 local dummyfid=$($LFS path2fid $DIR/$tdir/dummy)
271 local dummyname=$($LFS fid2path $DIR $dummyfid)
272 [ "$dummyname" == "$DIR/$tdir/dummy" ] ||
273 error "(8) Fail to repair linkEA: $dummyfid $dummyname"
275 run_test 2a "LFSCK can find out and repair crashed linkEA entry"
280 echo "start $SINGLEMDS"
281 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
282 error "(1) Fail to start MDS!"
284 mount_client $MOUNT || error "(2) Fail to start client!"
286 #define OBD_FAIL_LFSCK_LINKEA_MORE 0x1604
287 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1604
288 touch $DIR/$tdir/dummy
290 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
292 $START_NAMESPACE || error "(3) Fail to start LFSCK for namespace!"
295 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
296 [ "$STATUS" == "completed" ] ||
297 error "(4) Expect 'completed', but got '$STATUS'"
299 local repaired=$($SHOW_NAMESPACE |
300 awk '/^updated_phase2/ { print $2 }')
301 [ $repaired -eq 1 ] ||
302 error "(5) Fail to repair crashed linkEA: $repaired"
304 mount_client $MOUNT || error "(6) Fail to start client!"
306 stat $DIR/$tdir/dummy | grep "Links: 1" > /dev/null ||
307 error "(7) Fail to stat $DIR/$tdir/dummy"
309 local dummyfid=$($LFS path2fid $DIR/$tdir/dummy)
310 local dummyname=$($LFS fid2path $DIR $dummyfid)
311 [ "$dummyname" == "$DIR/$tdir/dummy" ] ||
312 error "(8) Fail to repair linkEA: $dummyfid $dummyname"
314 run_test 2b "LFSCK can find out and remove invalid linkEA entry"
319 echo "start $SINGLEMDS"
320 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
321 error "(1) Fail to start MDS!"
323 mount_client $MOUNT || error "(2) Fail to start client!"
325 #define OBD_FAIL_LFSCK_LINKEA_MORE2 0x1605
326 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1605
327 touch $DIR/$tdir/dummy
329 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
331 $START_NAMESPACE || error "(3) Fail to start LFSCK for namespace!"
334 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
335 [ "$STATUS" == "completed" ] ||
336 error "(4) Expect 'completed', but got '$STATUS'"
338 local repaired=$($SHOW_NAMESPACE |
339 awk '/^updated_phase2/ { print $2 }')
340 [ $repaired -eq 1 ] ||
341 error "(5) Fail to repair crashed linkEA: $repaired"
343 mount_client $MOUNT || error "(6) Fail to start client!"
345 stat $DIR/$tdir/dummy | grep "Links: 1" > /dev/null ||
346 error "(7) Fail to stat $DIR/$tdir/dummy"
348 local dummyfid=$($LFS path2fid $DIR/$tdir/dummy)
349 local dummyname=$($LFS fid2path $DIR $dummyfid)
350 [ "$dummyname" == "$DIR/$tdir/dummy" ] ||
351 error "(8) Fail to repair linkEA: $dummyfid $dummyname"
353 run_test 2c "LFSCK can find out and remove repeated linkEA entry"
358 mds_backup_restore $SINGLEMDS || error "(1) Fail to backup/restore!"
359 echo "start $SINGLEMDS with disabling OI scrub"
360 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_NOSCRUB > /dev/null ||
361 error "(2) Fail to start MDS!"
363 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
364 [ "$STATUS" == "init" ] ||
365 error "(3) Expect 'init', but got '$STATUS'"
367 #define OBD_FAIL_LFSCK_DELAY2 0x1601
368 do_facet $SINGLEMDS $LCTL set_param fail_val=1
369 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
370 $START_NAMESPACE || error "(4) Fail to start LFSCK for namespace!"
373 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
374 [ "$STATUS" == "scanning-phase1" ] ||
375 error "(5) Expect 'scanning-phase1', but got '$STATUS'"
377 local FLAGS=$($SHOW_NAMESPACE | awk '/^flags/ { print $2 }')
378 [ "$FLAGS" == "inconsistent" ] ||
379 error "(6) Expect 'inconsistent', but got '$FLAGS'"
381 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
382 do_facet $SINGLEMDS $LCTL set_param fail_val=0
384 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
385 [ "$STATUS" == "completed" ] ||
386 error "(7) Expect 'completed', but got '$STATUS'"
388 FLAGS=$($SHOW_NAMESPACE | awk '/^flags/ { print $2 }')
389 [ -z "$FLAGS" ] || error "(8) Expect empty flags, but got '$FLAGS'"
391 local repaired=$($SHOW_NAMESPACE |
392 awk '/^updated_phase1/ { print $2 }')
393 [ $repaired -ge 9 ] ||
394 error "(9) Fail to repair crashed linkEA: $repaired"
396 mount_client $MOUNT || error "(10) Fail to start client!"
398 #define OBD_FAIL_FID_LOOKUP 0x1505
399 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1505
400 ls $DIR/$tdir/ > /dev/null || error "(11) no FID-in-dirent."
402 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
404 run_test 4 "FID-in-dirent can be rebuilt after MDT file-level backup/restore"
409 mds_backup_restore $SINGLEMDS 1 || error "(1) Fail to backup/restore!"
410 echo "start $SINGLEMDS with disabling OI scrub"
411 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_NOSCRUB > /dev/null ||
412 error "(2) Fail to start MDS!"
414 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
415 [ "$STATUS" == "init" ] ||
416 error "(3) Expect 'init', but got '$STATUS'"
418 #define OBD_FAIL_LFSCK_DELAY2 0x1601
419 do_facet $SINGLEMDS $LCTL set_param fail_val=1
420 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
421 $START_NAMESPACE || error "(4) Fail to start LFSCK for namespace!"
424 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
425 [ "$STATUS" == "scanning-phase1" ] ||
426 error "(5) Expect 'scanning-phase1', but got '$STATUS'"
428 local FLAGS=$($SHOW_NAMESPACE | awk '/^flags/ { print $2 }')
429 [ "$FLAGS" == "inconsistent,upgrade" ] ||
430 error "(6) Expect 'inconsistent,upgrade', but got '$FLAGS'"
432 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
433 do_facet $SINGLEMDS $LCTL set_param fail_val=0
435 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
436 [ "$STATUS" == "completed" ] ||
437 error "(7) Expect 'completed', but got '$STATUS'"
439 FLAGS=$($SHOW_NAMESPACE | awk '/^flags/ { print $2 }')
440 [ -z "$FLAGS" ] || error "(8) Expect empty flags, but got '$FLAGS'"
442 local repaired=$($SHOW_NAMESPACE |
443 awk '/^updated_phase1/ { print $2 }')
444 [ $repaired -ge 2 ] ||
445 error "(9) Fail to repair crashed linkEA: $repaired"
447 mount_client $MOUNT || error "(10) Fail to start client!"
449 #define OBD_FAIL_FID_LOOKUP 0x1505
450 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1505
451 stat $DIR/$tdir/dummy > /dev/null || error "(11) no FID-in-LMA."
453 ls $DIR/$tdir/ > /dev/null || error "(12) no FID-in-dirent."
455 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
456 local dummyfid=$($LFS path2fid $DIR/$tdir/dummy)
457 local dummyname=$($LFS fid2path $DIR $dummyfid)
458 [ "$dummyname" == "$DIR/$tdir/dummy" ] ||
459 error "(13) Fail to generate linkEA: $dummyfid $dummyname"
461 run_test 5 "LFSCK can handle IFIG object upgrading"
465 echo "start $SINGLEMDS"
466 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
467 error "(1) Fail to start MDS!"
469 #define OBD_FAIL_LFSCK_DELAY1 0x1600
470 do_facet $SINGLEMDS $LCTL set_param fail_val=1
471 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1600
472 $START_NAMESPACE || error "(2) Fail to start LFSCK for namespace!"
474 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
475 [ "$STATUS" == "scanning-phase1" ] ||
476 error "(3) Expect 'scanning-phase1', but got '$STATUS'"
478 # Sleep 3 sec to guarantee at least one object processed by LFSCK
480 # Fail the LFSCK to guarantee there is at least one checkpoint
481 #define OBD_FAIL_LFSCK_FATAL1 0x1608
482 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80001608
484 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
485 [ "$STATUS" == "failed" ] ||
486 error "(4) Expect 'failed', but got '$STATUS'"
488 local POSITION0=$($SHOW_NAMESPACE |
489 awk '/^last_checkpoint_position/ { print $2 }' |
492 #define OBD_FAIL_LFSCK_DELAY1 0x1600
493 do_facet $SINGLEMDS $LCTL set_param fail_val=1
494 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1600
495 $START_NAMESPACE || error "(5) Fail to start LFSCK for namespace!"
497 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
498 [ "$STATUS" == "scanning-phase1" ] ||
499 error "(6) Expect 'scanning-phase1', but got '$STATUS'"
501 local POSITION1=$($SHOW_NAMESPACE |
502 awk '/^latest_start_position/ { print $2 }' |
504 [ $POSITION0 -lt $POSITION1 ] ||
505 error "(7) Expect larger than: $POSITION0, but got $POSITION1"
507 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
508 do_facet $SINGLEMDS $LCTL set_param fail_val=0
510 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
511 [ "$STATUS" == "completed" ] ||
512 error "(8) Expect 'completed', but got '$STATUS'"
514 run_test 6a "LFSCK resumes from last checkpoint (1)"
518 echo "start $SINGLEMDS"
519 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
520 error "(1) Fail to start MDS!"
522 #define OBD_FAIL_LFSCK_DELAY2 0x1601
523 do_facet $SINGLEMDS $LCTL set_param fail_val=1
524 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
525 $START_NAMESPACE || error "(2) Fail to start LFSCK for namespace!"
527 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
528 [ "$STATUS" == "scanning-phase1" ] ||
529 error "(3) Expect 'scanning-phase1', but got '$STATUS'"
531 # Sleep 3 sec to guarantee at least one object processed by LFSCK
533 # Fail the LFSCK to guarantee there is at least one checkpoint
534 #define OBD_FAIL_LFSCK_FATAL2 0x1609
535 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80001609
537 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
538 [ "$STATUS" == "failed" ] ||
539 error "(4) Expect 'failed', but got '$STATUS'"
541 local POSITION0=$($SHOW_NAMESPACE |
542 awk '/^last_checkpoint_position/ { print $4 }')
544 #define OBD_FAIL_LFSCK_DELAY2 0x1601
545 do_facet $SINGLEMDS $LCTL set_param fail_val=1
546 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
547 $START_NAMESPACE || error "(5) Fail to start LFSCK for namespace!"
549 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
550 [ "$STATUS" == "scanning-phase1" ] ||
551 error "(6) Expect 'scanning-phase1', but got '$STATUS'"
553 local POSITION1=$($SHOW_NAMESPACE |
554 awk '/^latest_start_position/ { print $4 }')
555 if [ $POSITION0 -gt $POSITION1 ]; then
556 [ $POSITION1 -eq 0 -a $POSITION0 -eq $((POSITION1 + 1)) ] ||
557 error "(7) Expect larger than: $POSITION0, but got $POSITION1"
560 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
561 do_facet $SINGLEMDS $LCTL set_param fail_val=0
563 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
564 [ "$STATUS" == "completed" ] ||
565 error "(8) Expect 'completed', but got '$STATUS'"
567 run_test 6b "LFSCK resumes from last checkpoint (2)"
572 echo "start $SINGLEMDS"
573 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
574 error "(1) Fail to start MDS!"
576 #define OBD_FAIL_LFSCK_DELAY2 0x1601
577 do_facet $SINGLEMDS $LCTL set_param fail_val=1
578 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
579 $START_NAMESPACE || error "(2) Fail to start LFSCK for namespace!"
581 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
582 [ "$STATUS" == "scanning-phase1" ] ||
583 error "(3) Expect 'scanning-phase1', but got '$STATUS'"
585 # Sleep 3 sec to guarantee at least one object processed by LFSCK
587 echo "stop $SINGLEMDS"
588 stop $SINGLEMDS > /dev/null || error "(4) Fail to stop MDS!"
590 echo "start $SINGLEMDS"
591 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
592 error "(5) Fail to start MDS!"
594 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
595 [ "$STATUS" == "scanning-phase1" ] ||
596 error "(6) Expect 'scanning-phase1', but got '$STATUS'"
598 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
599 do_facet $SINGLEMDS $LCTL set_param fail_val=0
601 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
602 [ "$STATUS" == "completed" ] ||
603 error "(7) Expect 'completed', but got '$STATUS'"
605 run_test 7a "non-stopped LFSCK should auto restarts after MDS remount (1)"
610 echo "start $SINGLEMDS"
611 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
612 error "(1) Fail to start MDS!"
614 mount_client $MOUNT || error "(2) Fail to start client!"
616 #define OBD_FAIL_LFSCK_LINKEA_MORE 0x1604
617 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1604
618 for ((i = 0; i < 20; i++)); do
619 touch $DIR/$tdir/dummy${i}
622 #define OBD_FAIL_LFSCK_DELAY3 0x1602
623 do_facet $SINGLEMDS $LCTL set_param fail_val=1
624 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1602
625 $START_NAMESPACE || error "(3) Fail to start LFSCK for namespace!"
628 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
629 [ "$STATUS" == "scanning-phase2" ] ||
630 error "(4) Expect 'scanning-phase2', but got '$STATUS'"
632 echo "stop $SINGLEMDS"
633 stop $SINGLEMDS > /dev/null || error "(5) Fail to stop MDS!"
635 echo "start $SINGLEMDS"
636 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
637 error "(6) Fail to start MDS!"
639 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
640 [ "$STATUS" == "scanning-phase2" ] ||
641 error "(7) Expect 'scanning-phase2', but got '$STATUS'"
643 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
644 do_facet $SINGLEMDS $LCTL set_param fail_val=0
646 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
647 [ "$STATUS" == "completed" ] ||
648 error "(8) Expect 'completed', but got '$STATUS'"
650 run_test 7b "non-stopped LFSCK should auto restarts after MDS remount (2)"
655 echo "start $SINGLEMDS"
656 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
657 error "(1) Fail to start MDS!"
659 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
660 [ "$STATUS" == "init" ] ||
661 error "(2) Expect 'init', but got '$STATUS'"
663 mount_client $MOUNT || error "(3) Fail to start client!"
665 #define OBD_FAIL_LFSCK_LINKEA_CRASH 0x1603
666 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1603
667 mkdir $DIR/$tdir/crashed
669 #define OBD_FAIL_LFSCK_LINKEA_MORE 0x1604
670 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1604
671 for ((i = 0; i < 5; i++)); do
672 touch $DIR/$tdir/dummy${i}
675 #define OBD_FAIL_LFSCK_DELAY2 0x1601
676 do_facet $SINGLEMDS $LCTL set_param fail_val=2
677 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
678 $START_NAMESPACE || error "(4) Fail to start LFSCK for namespace!"
680 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
681 [ "$STATUS" == "scanning-phase1" ] ||
682 error "(5) Expect 'scanning-phase1', but got '$STATUS'"
684 $STOP_LFSCK || error "(6) Fail to stop LFSCK!"
686 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
687 [ "$STATUS" == "stopped" ] ||
688 error "(7) Expect 'stopped', but got '$STATUS'"
690 $START_NAMESPACE || error "(8) Fail to start LFSCK for namespace!"
692 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
693 [ "$STATUS" == "scanning-phase1" ] ||
694 error "(9) Expect 'scanning-phase1', but got '$STATUS'"
696 #define OBD_FAIL_LFSCK_FATAL2 0x1609
697 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80001609
699 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
700 [ "$STATUS" == "failed" ] ||
701 error "(10) Expect 'failed', but got '$STATUS'"
703 #define OBD_FAIL_LFSCK_DELAY1 0x1600
704 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1600
705 $START_NAMESPACE || error "(11) Fail to start LFSCK for namespace!"
707 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
708 [ "$STATUS" == "scanning-phase1" ] ||
709 error "(12) Expect 'scanning-phase1', but got '$STATUS'"
711 #define OBD_FAIL_LFSCK_CRASH 0x160a
712 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x160a
715 echo "stop $SINGLEMDS"
716 stop $SINGLEMDS > /dev/null || error "(13) Fail to stop MDS!"
718 #define OBD_FAIL_LFSCK_NO_AUTO 0x160b
719 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x160b
721 echo "start $SINGLEMDS"
722 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
723 error "(14) Fail to start MDS!"
725 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
726 [ "$STATUS" == "crashed" ] ||
727 error "(15) Expect 'crashed', but got '$STATUS'"
729 #define OBD_FAIL_LFSCK_DELAY2 0x1601
730 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
731 $START_NAMESPACE || error "(16) Fail to start LFSCK for namespace!"
733 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
734 [ "$STATUS" == "scanning-phase1" ] ||
735 error "(17) Expect 'scanning-phase1', but got '$STATUS'"
737 echo "stop $SINGLEMDS"
738 stop $SINGLEMDS > /dev/null || error "(18) Fail to stop MDS!"
740 #define OBD_FAIL_LFSCK_NO_AUTO 0x160b
741 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x160b
743 echo "start $SINGLEMDS"
744 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
745 error "(19) Fail to start MDS!"
747 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
748 [ "$STATUS" == "paused" ] ||
749 error "(20) Expect 'paused', but got '$STATUS'"
751 #define OBD_FAIL_LFSCK_DELAY3 0x1602
752 do_facet $SINGLEMDS $LCTL set_param fail_val=2
753 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1602
755 $START_NAMESPACE || error "(21) Fail to start LFSCK for namespace!"
757 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
758 [ "$STATUS" == "scanning-phase2" ] ||
759 error "(22) Expect 'scanning-phase2', but got '$STATUS'"
761 local FLAGS=$($SHOW_NAMESPACE | awk '/^flags/ { print $2 }')
762 [ "$FLAGS" == "scanned-once,inconsistent" ] ||
763 error "(23) Expect 'scanned-once,inconsistent',but got '$FLAGS'"
765 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
766 do_facet $SINGLEMDS $LCTL set_param fail_val=0
768 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
769 [ "$STATUS" == "completed" ] ||
770 error "(24) Expect 'completed', but got '$STATUS'"
772 FLAGS=$($SHOW_NAMESPACE | awk '/^flags/ { print $2 }')
773 [ -z "$FLAGS" ] || error "(25) Expect empty flags, but got '$FLAGS'"
776 run_test 8 "LFSCK state machine"
779 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
780 skip "Testing on UP system, the speed may be inaccurate."
785 echo "start $SINGLEMDS"
786 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
787 error "(1) Fail to start MDS!"
789 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
790 [ "$STATUS" == "init" ] ||
791 error "(2) Expect 'init', but got '$STATUS'"
793 local BASE_SPEED1=100
795 $START_NAMESPACE -s $BASE_SPEED1 || error "(3) Fail to start LFSCK!"
798 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
799 [ "$STATUS" == "scanning-phase1" ] ||
800 error "(3) Expect 'scanning-phase1', but got '$STATUS'"
802 local SPEED=$($SHOW_NAMESPACE |
803 awk '/^average_speed_phase1/ { print $2 }')
805 # There may be time error, normally it should be less than 2 seconds.
806 # We allow another 20% schedule error.
808 # MAX_MARGIN = 1.2 = 12 / 10
809 local MAX_SPEED=$((BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) / \
810 RUN_TIME1 * 12 / 10))
811 [ $SPEED -lt $MAX_SPEED ] ||
812 error "(4) Got speed $SPEED, expected less than $MAX_SPEED"
815 local BASE_SPEED2=300
817 do_facet $SINGLEMDS \
818 $LCTL set_param -n mdd.${MDT_DEV}.lfsck_speed_limit $BASE_SPEED2
821 SPEED=$($SHOW_NAMESPACE | awk '/^average_speed_phase1/ { print $2 }')
822 # MIN_MARGIN = 0.8 = 8 / 10
823 local MIN_SPEED=$(((BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) + \
824 BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) / \
825 (RUN_TIME1 + RUN_TIME2) * 8 / 10))
826 [ $SPEED -gt $MIN_SPEED ] ||
827 error "(5) Got speed $SPEED, expected more than $MIN_SPEED"
829 # MAX_MARGIN = 1.2 = 12 / 10
830 MAX_SPEED=$(((BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) + \
831 BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) / \
832 (RUN_TIME1 + RUN_TIME2) * 12 / 10))
833 [ $SPEED -lt $MAX_SPEED ] ||
834 error "(6) Got speed $SPEED, expected less than $MAX_SPEED"
836 do_facet $SINGLEMDS \
837 $LCTL set_param -n mdd.${MDT_DEV}.lfsck_speed_limit 0
839 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
840 [ "$STATUS" == "completed" ] ||
841 error "(7) Expect 'completed', but got '$STATUS'"
843 run_test 9a "LFSCK speed control (1)"
846 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
847 skip "Testing on UP system, the speed may be inaccurate."
852 echo "start $SINGLEMDS"
853 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
854 error "(1) Fail to start MDS!"
856 mount_client $MOUNT || error "(2) Fail to start client!"
858 echo "Another preparing... 50 * 50 files (with error) will be created."
859 #define OBD_FAIL_LFSCK_LINKEA_MORE 0x1604
860 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1604
861 for ((i = 0; i < 50; i++)); do
862 mkdir -p $DIR/$tdir/d${i}
863 touch $DIR/$tdir/f${i}
864 for ((j = 0; j < 50; j++)); do
865 touch $DIR/$tdir/d${i}/f${j}
869 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
870 [ "$STATUS" == "init" ] ||
871 error "(3) Expect 'init', but got '$STATUS'"
873 #define OBD_FAIL_LFSCK_NO_DOUBLESCAN 0x160c
874 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x160c
875 $START_NAMESPACE || error "(4) Fail to start LFSCK!"
878 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
879 [ "$STATUS" == "stopped" ] ||
880 error "(5) Expect 'stopped', but got '$STATUS'"
882 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
886 $START_NAMESPACE -s $BASE_SPEED1 || error "(6) Fail to start LFSCK!"
889 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
890 [ "$STATUS" == "scanning-phase2" ] ||
891 error "(7) Expect 'scanning-phase2', but got '$STATUS'"
893 local SPEED=$($SHOW_NAMESPACE |
894 awk '/^average_speed_phase2/ { print $2 }')
895 # There may be time error, normally it should be less than 2 seconds.
896 # We allow another 20% schedule error.
898 # MAX_MARGIN = 1.2 = 12 / 10
899 local MAX_SPEED=$((BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) / \
900 RUN_TIME1 * 12 / 10))
901 [ $SPEED -lt $MAX_SPEED ] ||
902 error "(8) Got speed $SPEED, expected less than $MAX_SPEED"
905 local BASE_SPEED2=150
907 do_facet $SINGLEMDS \
908 $LCTL set_param -n mdd.${MDT_DEV}.lfsck_speed_limit $BASE_SPEED2
911 SPEED=$($SHOW_NAMESPACE | awk '/^average_speed_phase2/ { print $2 }')
912 # MIN_MARGIN = 0.8 = 8 / 10
913 local MIN_SPEED=$(((BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) + \
914 BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) / \
915 (RUN_TIME1 + RUN_TIME2) * 8 / 10))
916 [ $SPEED -gt $MIN_SPEED ] ||
917 error "(9) Got speed $SPEED, expected more than $MIN_SPEED"
919 # MAX_MARGIN = 1.2 = 12 / 10
920 MAX_SPEED=$(((BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) + \
921 BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) / \
922 (RUN_TIME1 + RUN_TIME2) * 12 / 10))
923 [ $SPEED -lt $MAX_SPEED ] ||
924 error "(10) Got speed $SPEED, expected less than $MAX_SPEED"
926 do_facet $SINGLEMDS \
927 $LCTL set_param -n mdd.${MDT_DEV}.lfsck_speed_limit 0
929 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
930 [ "$STATUS" == "completed" ] ||
931 error "(11) Expect 'completed', but got '$STATUS'"
933 run_test 9b "LFSCK speed control (2)"
938 echo "start $SINGLEMDS"
939 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
940 error "(1) Fail to start MDS!"
942 mount_client $MOUNT || error "(2) Fail to start client!"
944 #define OBD_FAIL_LFSCK_LINKEA_CRASH 0x1603
945 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1603
946 for ((i = 0; i < 1000; i = $((i+2)))); do
947 mkdir -p $DIR/$tdir/d${i}
948 touch $DIR/$tdir/f${i}
949 for ((j = 0; j < 5; j++)); do
950 touch $DIR/$tdir/d${i}/f${j}
954 #define OBD_FAIL_LFSCK_LINKEA_MORE 0x1604
955 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1604
956 for ((i = 1; i < 1000; i = $((i+2)))); do
957 mkdir -p $DIR/$tdir/d${i}
958 touch $DIR/$tdir/f${i}
959 for ((j = 0; j < 5; j++)); do
960 touch $DIR/$tdir/d${i}/f${j}
964 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
965 ln $DIR/$tdir/f200 $DIR/$tdir/d200/dummy
968 mount_client $MOUNT || error "(3) Fail to start client!"
970 local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
971 [ "$STATUS" == "init" ] ||
972 error "(4) Expect 'init', but got '$STATUS'"
974 $START_NAMESPACE -s 100 || error "(5) Fail to start LFSCK!"
977 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
978 [ "$STATUS" == "scanning-phase1" ] ||
979 error "(6) Expect 'scanning-phase1', but got '$STATUS'"
981 ls -ailR $MOUNT > /dev/null || error "(7) Fail to ls!"
983 touch $DIR/$tdir/d198/a0 || error "(8) Fail to touch!"
985 mkdir $DIR/$tdir/d199/a1 || error "(9) Fail to mkdir!"
987 unlink $DIR/$tdir/f200 || error "(10) Fail to unlink!"
989 rm -rf $DIR/$tdir/d201 || error "(11) Fail to rmdir!"
991 mv $DIR/$tdir/f202 $DIR/$tdir/d203/ || error "(12) Fail to rename!"
993 ln $DIR/$tdir/f204 $DIR/$tdir/d205/a3 || error "(13) Fail to hardlink!"
995 ln -s $DIR/$tdir/d206 $DIR/$tdir/d207/a4 ||
996 error "(14) Fail to softlink!"
998 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
999 [ "$STATUS" == "scanning-phase1" ] ||
1000 error "(15) Expect 'scanning-phase1', but got '$STATUS'"
1002 do_facet $SINGLEMDS \
1003 $LCTL set_param -n mdd.${MDT_DEV}.lfsck_speed_limit 0
1004 umount_client $MOUNT
1006 STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
1007 [ "$STATUS" == "completed" ] ||
1008 error "(16) Expect 'completed', but got '$STATUS'"
1010 run_test 10 "System is available during LFSCK scanning"
1013 ost_remove_lastid() {
1016 local rcmd="do_facet ost${ost}"
1018 echo "remove LAST_ID on ost${ost}: idx=${idx}"
1020 # step 1: local mount
1021 mount_fstype ost${ost} || return 1
1022 # step 2: remove the specified LAST_ID
1023 ${rcmd} rm -fv $(facet_mntpt ost${ost})/O/${idx}/LAST_ID
1025 unmount_fstype ost${ost} || return 2
1032 formatall > /dev/null
1034 setupall > /dev/null
1037 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
1038 createmany -o $DIR/$tdir/f 64
1043 ost_remove_lastid 1 0 || error "(1) Fail to remove LAST_ID"
1046 start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
1047 error "(2) Fail to start ost1"
1049 local STATUS=$($SHOW_LAYOUT_ON_OST | awk '/^status/ { print $2 }')
1050 [ "$STATUS" == "init" ] ||
1051 error "(3) Expect 'init', but got '$STATUS'"
1053 #define OBD_FAIL_LFSCK_DELAY4 0x160e
1054 do_facet ost1 $LCTL set_param fail_val=3
1055 do_facet ost1 $LCTL set_param fail_loc=0x160e
1057 echo "trigger LFSCK for layout on ost1 to rebuild the LAST_ID(s)"
1058 $START_LAYOUT_ON_OST || error "(4) Fail to start LFSCK on OST!"
1060 wait_update_facet ost1 "$LCTL get_param -n \
1061 obdfilter.${OST_DEV}.lfsck_layout |
1062 awk '/^flags/ { print \\\$2 }'" "crashed_lastid" 60 || {
1067 do_facet ost1 $LCTL set_param fail_val=0
1068 do_facet ost1 $LCTL set_param fail_loc=0
1070 wait_update_facet ost1 "$LCTL get_param -n \
1071 obdfilter.${OST_DEV}.lfsck_layout |
1072 awk '/^status/ { print \\\$2 }'" "completed" 3 || {
1077 echo "the LAST_ID(s) should have been rebuilt"
1078 FLAGS=$($SHOW_LAYOUT_ON_OST | awk '/^flags/ { print $2 }')
1079 [ -z "$FLAGS" ] || error "(7) Expect empty flags, but got '$FLAGS'"
1081 run_test 11a "LFSCK can rebuild lost last_id"
1087 formatall > /dev/null
1089 setupall > /dev/null
1092 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
1094 echo "set fail_loc=0x160d to skip the updating LAST_ID on-disk"
1095 #define OBD_FAIL_LFSCK_SKIP_LASTID 0x160d
1096 do_facet ost1 $LCTL set_param fail_loc=0x160d
1097 createmany -o $DIR/$tdir/f 64
1098 local lastid1=$(do_facet ost1 "lctl get_param -n \
1099 obdfilter.${ost1_svc}.last_id" | grep 0x100000000 |
1100 awk -F: '{ print $2 }')
1102 umount_client $MOUNT
1104 stop ost1 || error "(1) Fail to stop ost1"
1106 #define OBD_FAIL_OST_ENOSPC 0x215
1107 do_facet ost1 $LCTL set_param fail_loc=0x215
1110 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
1111 error "(2) Fail to start ost1"
1113 local STATUS=$($SHOW_LAYOUT_ON_OST | awk '/^status/ { print $2 }')
1114 [ "$STATUS" == "init" ] ||
1115 error "(3) Expect 'init', but got '$STATUS'"
1117 for ((i = 0; i < 60; i++)); do
1118 lastid2=$(do_facet ost1 "lctl get_param -n \
1119 obdfilter.${ost1_svc}.last_id" | grep 0x100000000 |
1120 awk -F: '{ print $2 }')
1121 [ ! -z $lastid2 ] && break;
1125 echo "the on-disk LAST_ID should be smaller than the expected one"
1126 [ $lastid1 -gt $lastid2 ] ||
1127 error "(4) expect lastid1 [ $lastid1 ] > lastid2 [ $lastid2 ]"
1129 echo "trigger LFSCK for layout on ost1 to rebuild the on-disk LAST_ID"
1130 $START_LAYOUT_ON_OST || error "(5) Fail to start LFSCK on OST!"
1132 wait_update_facet ost1 "$LCTL get_param -n \
1133 obdfilter.${OST_DEV}.lfsck_layout |
1134 awk '/^status/ { print \\\$2 }'" "completed" 3 || {
1140 stop ost1 || error "(7) Fail to stop ost1"
1143 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
1144 error "(8) Fail to start ost1"
1146 echo "the on-disk LAST_ID should have been rebuilt"
1147 wait_update_facet ost1 "$LCTL get_param -n \
1148 obdfilter.${ost1_svc}.last_id | grep 0x100000000 |
1149 awk -F: '{ print \\\$2 }'" "$lastid1" 60 || {
1150 $LCTL get_param -n obdfilter.${ost1_svc}.last_id
1151 error "(9) expect lastid1 0x100000000:$lastid1"
1154 do_facet ost1 $LCTL set_param fail_loc=0
1156 run_test 11b "LFSCK can rebuild crashed last_id"
1159 [ $MDSCOUNT -lt 2 ] &&
1160 skip "We need at least 2 MDSes for test_12" && exit 0
1165 formatall > /dev/null
1167 setupall > /dev/null
1169 echo "All the LFSCK targets should be in 'init' status."
1170 for k in $(seq $MDSCOUNT); do
1171 local STATUS=$(do_facet mds${k} $LCTL get_param -n \
1172 mdd.$(facet_svc mds${k}).lfsck_layout |
1173 awk '/^status/ { print $2 }')
1174 [ "$STATUS" == "init" ] ||
1175 error "(1) MDS${k} Expect 'init', but got '$STATUS'"
1177 $LFS mkdir -i $((k - 1)) $DIR/${k}
1178 createmany -o $DIR/${k}/f 100
1181 echo "Trigger LFSCK on all targets by single command (limited speed)."
1182 do_facet mds1 $LCTL lfsck_start -M ${FSNAME}-MDT0000 -t layout -A \
1183 -s 10 || error "(2) Fail to start LFSCK on all devices!"
1185 echo "All the LFSCK targets should be in 'scanning-phase1' status."
1186 for k in $(seq $MDSCOUNT); do
1187 local STATUS=$(do_facet mds${k} $LCTL get_param -n \
1188 mdd.$(facet_svc mds${k}).lfsck_layout |
1189 awk '/^status/ { print $2 }')
1190 [ "$STATUS" == "scanning-phase1" ] ||
1191 error "(3) MDS${k} Expect 'scanning-phase1', but got '$STATUS'"
1194 echo "Stop layout LFSCK on all targets by single lctl command."
1195 do_facet mds1 $LCTL lfsck_stop -M ${FSNAME}-MDT0000 -A ||
1196 error "(4) Fail to stop LFSCK on all devices!"
1198 echo "All the LFSCK targets should be in 'stopped' status."
1199 for k in $(seq $MDSCOUNT); do
1200 local STATUS=$(do_facet mds${k} $LCTL get_param -n \
1201 mdd.$(facet_svc mds${k}).lfsck_layout |
1202 awk '/^status/ { print $2 }')
1203 [ "$STATUS" == "stopped" ] ||
1204 error "(5) MDS${k} Expect 'stopped', but got '$STATUS'"
1207 for k in $(seq $OSTCOUNT); do
1208 local STATUS=$(do_facet ost${k} $LCTL get_param -n \
1209 obdfilter.$(facet_svc ost${k}).lfsck_layout |
1210 awk '/^status/ { print $2 }')
1211 [ "$STATUS" == "stopped" ] ||
1212 error "(6) OST${k} Expect 'stopped', but got '$STATUS'"
1215 echo "Re-trigger LFSCK on all targets by single command (full speed)."
1216 do_facet mds1 $LCTL lfsck_start -M ${FSNAME}-MDT0000 -t layout -A \
1217 -s 0 || error "(7) Fail to start LFSCK on all devices!"
1219 echo "All the LFSCK targets should be in 'completed' status."
1220 for k in $(seq $MDSCOUNT); do
1221 # The LFSCK status query internal is 30 seconds. For the case
1222 # of some LFSCK_NOTIFY RPCs failure/lost, we will wait enough
1223 # time to guarantee the status sync up.
1224 wait_update_facet mds${k} "$LCTL get_param -n \
1225 mdd.$(facet_svc mds${k}).lfsck_layout |
1226 awk '/^status/ { print \\\$2 }'" "completed" 32 ||
1227 error "(8) MDS${k} is not the expected 'completed'"
1230 run_test 12 "single command to trigger LFSCK on all devices"
1232 $LCTL set_param debug=-lfsck > /dev/null || true
1234 # restore MDS/OST size
1235 MDSSIZE=${SAVED_MDSSIZE}
1236 OSTSIZE=${SAVED_OSTSIZE}
1238 # cleanup the system at last