8 PTLDEBUG=${PTLDEBUG:--1}
9 export FORCE_TEST_111=${FORCE_TEST_111:-false}
11 LUSTRE=${LUSTRE:-$(dirname $0)/..}
12 . $LUSTRE/tests/test-framework.sh
14 . $LUSTRE/tests/conf-sanity-framework.sh
18 # tool to create lustre filesystem images
19 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 32newtarball"
22 always_except LU-9795 84 86 103
25 if ! combined_mgs_mds; then
26 always_except LU-11991 32a 32b 32c 32d 32e
27 always_except LU-9897 84
28 always_except LU-12032 123F
32 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111 114"
34 if [[ "$mds1_FSTYPE" == "zfs" ]]; then
35 always_except LU-18652 108a 112a 112b 113 117 119 121 122a
36 always_except LU-18652 123aa 123ab 123ac 123ad 123ae 123af 123ag 123ah 123ahi
37 always_except LU-18652 123F 123G 123H 126 129 132 133 135 136 137 150 152 153a 153b 153c 155 802a
42 # use small MDS + OST size to speed formatting time
43 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
44 # STORED_MDSSIZE is used in test_18
54 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
55 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
56 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
60 require_dsh_mds || exit 0
61 require_dsh_ost || exit 0
65 if [ "$ONLY" == "setup" ]; then
70 if [ "$ONLY" == "cleanup" ]; then
77 #create single point mountpoint
83 check_mount || error "check_mount failed"
84 cleanup || error "cleanup failed with $?"
86 run_test 0 "single mount setup"
89 start_mds || error "MDS start failed"
90 start_ost || error "unable to start OST"
91 echo "start ost second time..."
92 start_ost && error "2nd OST start should fail"
93 mount_client $MOUNT || error "client start failed"
94 check_mount || error "check_mount failed"
95 cleanup || error "cleanup failed with $?"
97 run_test 1 "start up ost twice (should return errors)"
100 start_mds || error "MDT start failed"
101 echo "start mds second time.."
102 start_mds && error "2nd MDT start should fail"
103 start_ost || error "OST start failed"
104 mount_client $MOUNT || error "mount_client failed to start client"
105 check_mount || error "check_mount failed"
106 cleanup || error "cleanup failed with $?"
108 run_test 2 "start up mds twice (should return err)"
112 #mount.lustre returns an error if already in mtab
113 mount_client $MOUNT && error "2nd client mount should fail"
114 check_mount || error "check_mount failed"
115 cleanup || error "cleanup failed with $?"
117 run_test 3 "mount client twice (should return err)"
121 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
122 stop_ost || error "Unable to stop OST1"
123 umount_client $MOUNT -f || error "unmount $MOUNT failed"
126 # ok for ost to fail shutdown
127 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
128 error "cleanup failed with $?"
131 run_test 4 "force cleanup ost, then cleanup"
133 test_5a() { # was test_5
135 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
136 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
138 stop_mds || error "Unable to stop MDS"
140 # cleanup may return an error from the failed
141 # disconnects; for now I'll consider this successful
142 # if all the modules have unloaded.
146 echo "killing umount"
147 kill -TERM $UMOUNT_PID
148 echo "waiting for umount to finish"
150 if grep " $MOUNT " /proc/mounts; then
151 echo "test 5: /proc/mounts after failed umount"
155 echo "killing umount"
156 kill -TERM $UMOUNT_PID
157 echo "waiting for umount to finish"
159 grep " $MOUNT " /proc/mounts &&
160 error "/proc/mounts after second umount"
163 # manual_mount_client may fail due to umount succeeding above
165 # stop_mds is a no-op here, and should not fail
166 cleanup_nocli || error "cleanup_nocli failed with $?"
167 # df may have lingering entry
169 # mtab may have lingering entry
173 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
175 grep -q $MOUNT" " /etc/mtab || break
176 echo "Waiting /etc/mtab updated ... "
177 WAIT=$(( WAIT + sleep))
179 [ "$WAIT" -eq "$MAX_WAIT" ] &&
180 error "/etc/mtab is not updated in $WAIT secs"
181 echo "/etc/mtab updated in $WAIT secs"
183 run_test 5a "force cleanup mds, then cleanup"
191 grep " $MOUNT " /etc/mtab &&
192 error false "unexpected entry in mtab before mount" && return 10
194 start_ost || error "OST start failed"
195 if ! combined_mgs_mds ; then
196 trap cleanup_5b EXIT ERR
197 start_mds || error "MDS start failed"
201 mount_client $MOUNT && error "mount_client $MOUNT should fail"
202 grep " $MOUNT " /etc/mtab &&
203 error "$MOUNT entry in mtab after failed mount"
205 # stop_mds is a no-op here, and should not fail
206 cleanup_nocli || error "cleanup_nocli failed with $?"
207 if ! combined_mgs_mds ; then
211 run_test 5b "Try to start a client with no MGS (should return errs)"
214 grep " $MOUNT " /etc/mtab &&
215 error false "unexpected entry in mtab before mount" && return 10
217 start_mds || error "MDS start failed"
218 start_ost || error "OST start failed"
219 local oldfs="${FSNAME}"
220 FSNAME="wrong.${FSNAME}"
221 mount_client $MOUNT || :
223 grep " $MOUNT " /etc/mtab &&
224 error "$MOUNT entry in mtab after failed mount"
226 cleanup_nocli || error "cleanup_nocli failed with $?"
228 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
231 grep " $MOUNT " /etc/mtab &&
232 error "unexpected entry in mtab before mount"
234 start_ost || error "OST start failed"
235 start_mds || error "MDS start failed"
236 stop_ost -f || error "Unable to stop OST1"
237 mount_client $MOUNT || error "mount_client $MOUNT failed"
238 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
239 cleanup_nocli || error "cleanup_nocli failed with $?"
240 ! grep " $MOUNT " /etc/mtab ||
241 error "$MOUNT entry in mtab after unmount"
243 run_test 5d "mount with ost down"
246 grep " $MOUNT " /etc/mtab &&
247 error false "unexpected entry in mtab before mount" && return 10
249 start_mds || error "MDS start failed"
250 start_ost || error "OST start failed"
252 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
253 do_facet client "$LCTL set_param fail_loc=0x80000506"
254 mount_client $MOUNT || echo "mount failed (not fatal)"
255 cleanup || error "cleanup failed with $?"
256 grep " $MOUNT " /etc/mtab &&
257 error "$MOUNT entry in mtab after unmount"
260 run_test 5e "delayed connect, don't crash (bug 10268)"
263 combined_mgs_mds && skip "needs separate mgs and mds"
265 grep " $MOUNT " /etc/mtab &&
266 error false "unexpected entry in mtab before mount" && return 10
269 start_ost || error "OST start failed"
270 mount_client $MOUNT &
272 echo client_mount pid is $pid
276 if ! ps -f -p $pid >/dev/null; then
279 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
280 error "mount returns $rc, expected to hang"
282 cleanup || error "cleanup failed with $?"
287 start_mds || error "start MDS failed"
289 # mount should succeed after start mds
291 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
292 cleanup || error "final call to cleanup failed with rc $?"
294 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
298 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
299 skip "automount of debugfs missing before 2.9.53"
300 umount /sys/kernel/debug
301 $LCTL get_param -n devices | egrep -v "error" && \
302 error "lctl can't access debugfs data"
303 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
305 run_test 5g "handle missing debugfs"
308 (( $MDS1_VERSION >= $(version_code 2.12.54) )) ||
309 skip "Need MDS version at least 2.12.54"
314 #define OBD_FAIL_MDS_FS_SETUP 0x135
315 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
316 start_mdt 1 && error "start mdt should fail"
317 start_mdt 1 || error "start mdt failed"
318 client_up || error "client_up failed"
321 run_test 5h "start mdt failure at mdt_fs_setup()"
324 (( $MDS1_VERSION >= $(version_code 2.12.54) )) ||
325 skip "Need MDS version at least 2.12.54"
330 #define OBD_FAIL_QUOTA_INIT 0xA05
331 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
332 start_mdt 1 && error "start mdt should fail"
333 start_mdt 1 || error "start mdt failed"
334 client_up || error "client_up failed"
337 run_test 5i "start mdt failure at mdt_quota_init()"
341 load_module ../libcfs/libcfs/libcfs ||
342 error "Failed to load modules libcfs rc = $?"
343 $LCTL set_param debug=all
346 run_test 5j "verify libcfs doesn't crash when setting debug flags"
351 mount_client $MOUNT || error "mount_client $MOUNT failed"
352 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
353 cleanup || error "cleanup failed with rc $?"
355 run_test 6 "manual umount, then mount again"
360 cleanup_nocli || error "cleanup_nocli failed with $?"
362 run_test 7 "manual umount, then cleanup"
366 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
367 check_mount2 || error "check_mount2 failed"
368 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
369 cleanup || error "cleanup failed with rc $?"
371 run_test 8 "double mount setup"
374 start_ost || error "OST start failed"
376 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
377 error "do_facet ost1 set_param inode trace failed."
378 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
379 error "do_facet ost1 set_param debug mds ost failed."
381 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
382 if [ "$CHECK_PTLDEBUG" ] && { \
383 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
384 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
385 echo "lnet.debug success"
387 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
389 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
390 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
391 echo "lnet.subsystem_debug success"
393 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
395 stop_ost || error "Unable to stop OST1"
397 run_test 9 "test ptldebug and subsystem for mkfs"
402 if ! combined_mgs_mds; then
403 files=$(do_facet mgs "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
404 [ -z $files ] || echo "MGS $files is a broken symlink"
407 files=$(do_facet mds1 "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
408 [ -z $files ] || echo "MDS $files is a broken symlink"
410 files=$(do_facet ost1 "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
411 [ -z $files ] || echo "OSS $files is a broken symlink"
413 files=$(do_facet client "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
414 [ -z $files ] || echo "clients $files is a broken symlink"
416 cleanup || error "cleanup failed with rc $?"
418 run_test 10a "find lctl param broken symlinks"
421 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
422 # But with new MDS stack we don't care about the mode of local objects
423 # anymore, so this test is removed. See bug 22944 for more details.
427 if [ "$mds1_FSTYPE" != ldiskfs ]; then
428 skip "ldiskfs only test"
432 check_mount || error "check_mount failed"
433 cleanup || error "cleanup failed with rc $?"
435 echo "Remove mds config log"
436 if ! combined_mgs_mds ; then
440 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
441 $(mgsdevname) || return \$?" ||
442 error "do_facet mgs failed with $?"
444 if ! combined_mgs_mds ; then
448 start_ost || error "OST start failed"
449 start_mds && error "MDS start succeeded, but should fail"
452 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
455 if [ "$mds1_FSTYPE" != ldiskfs ]; then
456 skip "ldiskfs only test"
459 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
464 # check if current MDSSIZE is large enough
465 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
466 log "use MDSSIZE=$MDSSIZE"
468 # check if the global config has a large enough MDSSIZE
469 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
470 [ $STORED_MDSSIZE -ge $MIN ] &&
471 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
472 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
474 # check if the block device is large enough
475 is_blkdev $SINGLEMDS $MDSDEV $MIN
476 local large_enough=$?
477 if [ -n "$OK" ]; then
478 [ $large_enough -ne 0 ] && OK=""
480 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
481 log "use device $MDSDEV with MIN=$MIN"
484 # check if a loopback device has enough space for fs metadata (5%)
486 if [ -z "$OK" ]; then
487 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
488 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
489 awk '($1 != "Filesystem") { print $4 }')
490 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
491 OK=1 && myMDSSIZE=$MIN &&
492 log "use file $MDSDEV with MIN=$MIN"
495 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
497 echo "mount mds with large journal..."
499 local OLD_MDSSIZE=$MDSSIZE
503 echo "mount lustre system..."
505 check_mount || error "check_mount failed"
507 echo "check journal size..."
508 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
509 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
510 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
512 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
515 cleanup || error "cleanup failed with rc $?"
520 run_test 18 "check mkfs creates large journals"
523 start_mds || error "MDS start failed"
524 stop_mds || error "Unable to stop MDS"
526 run_test 19a "start/stop MDS without OSTs"
529 start_ost || error "Unable to start OST1"
530 stop_ost -f || error "Unable to stop OST1"
532 run_test 19b "start/stop OSTs without MDS"
535 # first format the ost/mdt
536 start_mds || error "MDS start failed"
537 start_ost || error "Unable to start OST1"
538 mount_client $MOUNT || error "mount_client $MOUNT failed"
539 check_mount || error "check_mount failed"
540 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
541 mount_client $MOUNT remount,ro || error "remount client with ro failed"
542 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
543 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
544 mount_client $MOUNT remount,rw || error "remount client with rw failed"
545 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
546 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
547 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
549 stop_mds || error "Unable to stop MDS"
550 stop_ost || error "Unable to stop OST1"
552 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
555 start_mds || error "MDS start failed"
556 start_ost || error "unable to start OST1"
557 wait_osc_import_state mds ost FULL
558 stop_ost || error "unable to stop OST1"
559 stop_mds || error "unable to stop MDS"
561 run_test 21a "start mds before ost, stop ost first"
564 start_ost || error "unable to start OST1"
565 start_mds || error "MDS start failed"
566 wait_osc_import_state mds ost FULL
567 stop_mds || error "unable to stop MDS"
568 stop_ost || error "unable to stop OST1"
570 run_test 21b "start ost before mds, stop mds first"
573 start_ost || error "Unable to start OST1"
574 start_mds || error "MDS start failed"
575 start_ost2 || error "Unable to start OST2"
576 wait_osc_import_state mds ost2 FULL
577 stop_ost || error "Unable to stop OST1"
578 stop_ost2 || error "Unable to stop OST2"
579 stop_mds || error "Unable to stop MDS"
580 #writeconf to remove all ost2 traces for subsequent tests
581 writeconf_or_reformat
583 run_test 21c "start mds between two osts, stop mds last"
586 combined_mgs_mds && skip "need separate mgs device"
591 start_mgs || error "unable to start MGS"
592 start_ost || error "unable to start OST1"
593 start_ost2 || error "unable to start OST2"
594 start_mds || error "MDS start failed"
595 wait_osc_import_state mds ost2 FULL
597 local zkeeper=${KEEP_ZPOOL}
598 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
601 stop_ost || error "Unable to stop OST1"
602 stop_ost2 || error "Unable to stop OST2"
603 stop_mds || error "Unable to stop MDS"
605 #writeconf to remove all ost2 traces for subsequent tests
606 writeconf_or_reformat
607 KEEP_ZPOOL="${zkeeper}"
609 start_mgs || error "unable to start MGS"
611 run_test 21d "start mgs then ost and then mds"
614 MGSNID="$saved_mgsnid"
616 echo "stopping fs2mgs ..."
617 stop $fs2mgs -f || true
620 test_21e() { # LU-5863
621 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
622 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
623 skip_env "mixed loopback and real device not working"
626 local fs2mdsdev=$(mdsdevname 1_2)
627 local fs2ostdev=$(ostdevname 1_2)
628 local fs3ostdev=$(ostdevname 2_2)
630 local fs2mdsvdev=$(mdsvdevname 1_2)
631 local fs2ostvdev=$(ostvdevname 1_2)
632 local fs3ostvdev=$(ostvdevname 2_2)
634 # temporarily use fs3ost as fs2mgs
636 local fs2mgsdev=$fs3ostdev
637 local fs2mgsvdev=$fs3ostvdev
639 local fsname=test1234
641 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
642 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
643 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
644 error "start fs2mgs failed"
646 local saved_mgsnid="$MGSNID"
647 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
649 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
650 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
651 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
652 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
654 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
655 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
657 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
658 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
659 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
663 run_test 21e "separate MGS and MDS"
666 start_mds || error "MDS start failed"
668 echo "Client mount with ost in logs, but none running"
669 start_ost || error "unable to start OST1"
670 # wait until mds connected to ost and open client connection
671 wait_osc_import_state mds ost FULL
672 stop_ost || error "unable to stop OST1"
673 mount_client $MOUNT || error "mount_client $MOUNT failed"
674 # check_mount will block trying to contact ost
675 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
676 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
677 umount_client $MOUNT -f
680 echo "Client mount with a running ost"
681 start_ost || error "unable to start OST1"
683 # if gss enabled, wait full time to let connection from
684 # mds to ost be established, due to the mismatch between
685 # initial connect timeout and gss context negotiation timeout.
686 # This perhaps could be remove after AT landed.
687 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
688 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
690 mount_client $MOUNT || error "mount_client $MOUNT failed"
691 wait_osc_import_state mds ost FULL
692 wait_osc_import_ready client ost
693 check_mount || error "check_mount failed"
696 cleanup || error "cleanup failed with rc $?"
698 run_test 22 "start a client before osts (should return errs)"
700 test_23a() { # was test_23
703 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
704 # force down client so that recovering mds waits for reconnect
705 local running=$(grep -c $MOUNT /proc/mounts) || true
706 if [ $running -ne 0 ]; then
707 echo "Stopping client $MOUNT (opts: -f)"
711 # enter recovery on failed mds
712 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
713 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
714 # try to start a new client
715 mount_client $MOUNT &
717 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
718 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
719 grep -v grep | awk '{print $2}')
720 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
722 ps --ppid $MOUNT_LUSTRE_PID
723 echo "waiting for mount to finish"
725 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
726 # SIGTERM works but it does not spread to offspring processses
727 kill -s TERM $MOUNT_PID
728 kill -s TERM $MOUNT_LUSTRE_PID
729 # we can not wait $MOUNT_PID because it is not a child of this shell
735 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
737 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
738 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
741 [ -z "$PID1" -a -z "$PID2" ] && break
742 echo "waiting for mount to finish ... "
743 WAIT=$(( WAIT + sleep))
745 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
746 error "MOUNT_PID $MOUNT_PID and "\
747 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
750 cleanup || error "cleanup failed with rc $?"
752 run_test 23a "interrupt client during recovery mount delay"
754 test_23b() { # was test_23
755 start_mds || error "MDS start failed"
756 start_ost || error "Unable to start OST1"
757 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
758 $LCTL set_param fail_loc=0x80000313
760 cleanup || error "cleanup failed with rc $?"
762 run_test 23b "Simulate -EINTR during mount"
765 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
767 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
768 is_blkdev $SINGLEMDS $MDSDEV &&
769 skip_env "mixed loopback and real device not working"
772 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
774 local fs2mdsdev=$(mdsdevname 1_2)
775 local fs2ostdev=$(ostdevname 1_2)
776 local fs2mdsvdev=$(mdsvdevname 1_2)
777 local fs2ostvdev=$(ostvdevname 1_2)
780 # LU-9733 test fsname started with numbers as well
781 local FSNAME2=969362ae
783 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
784 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
786 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
787 --reformat $fs2ostdev $fs2ostvdev || exit 10
790 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
791 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
792 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
793 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
795 # LU-9733 test fsname started with numbers
796 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
797 changelog_register -n) ||
798 error "register changelog failed"
800 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
801 changelog_deregister $cl_user ||
802 error "deregister changelog failed"
804 check_mount || error "check_mount failed"
805 # files written on 1 should not show up on 2
806 cp /etc/passwd $DIR/$tfile
808 [ -e $MOUNT2/$tfile ] && error "File bleed"
811 cp /etc/passwd $MOUNT2/$tfile ||
812 error "cp /etc/passwd $MOUNT2/$tfile failed"
813 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
814 # 2 is actually mounted
815 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
817 facet_failover fs2mds
818 facet_failover fs2ost
821 # the MDS must remain up until last MDT
823 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
824 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
825 [ -z "$MDS" ] && error "No MDT"
827 cleanup_nocli || error "cleanup_nocli failed with rc $?"
829 run_test 24a "Multiple MDTs on a single node"
832 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
834 skip "needs combined MGT and MDT device"
836 if [ -z "$fs2mds_DEV" ]; then
837 local dev=${SINGLEMDS}_dev
839 is_blkdev $SINGLEMDS $MDSDEV &&
840 skip_env "mixed loopback and real device not working"
843 local fs2mdsdev=$(mdsdevname 1_2)
844 local fs2mdsvdev=$(mdsvdevname 1_2)
846 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
847 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
849 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
851 error "start MDS should fail"
854 cleanup || error "cleanup failed with rc $?"
856 run_test 24b "Multiple MGSs on a single node (should return err)"
860 check_mount || error "check_mount failed"
861 local MODULES=$($LCTL modules | awk '{ print $2 }')
862 rmmod $MODULES 2>/dev/null || true
863 cleanup || error "cleanup failed with $?"
865 run_test 25 "Verify modules are referenced"
869 # we need modules before mount for sysctl, so make sure...
870 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
871 #define OBD_FAIL_MDS_FS_SETUP 0x135
872 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
873 start_mds && error "MDS started but should not have started"
874 $LCTL get_param -n devices
875 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
876 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
877 # start mds to drop writeconf setting
878 start_mds || error "Unable to start MDS"
879 stop_mds || error "Unable to stop MDS"
880 unload_modules_conf || error "unload_modules_conf failed with $?"
882 run_test 26 "MDT startup failure cleans LOV (should return errs)"
886 start_ost || error "Unable to start OST1"
887 start_mds || error "Unable to start MDS"
888 echo "Requeue thread should have started: "
889 ps -e | grep ll_cfg_requeue
890 set_persistent_param_and_check ost1 \
891 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
892 "$FSNAME-OST0000.ost.client_cache_seconds"
893 cleanup_nocli || error "cleanup_nocli failed with rc $?"
895 run_test 27a "Reacquire MGS lock if OST started first"
900 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
901 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
903 facet_failover $SINGLEMDS
904 set_persistent_param_and_check $SINGLEMDS \
905 "mdt.$device.identity_acquire_expire" \
906 "$device.mdt.identity_acquire_expire"
907 set_persistent_param_and_check client \
908 "mdc.$device-mdc-*.max_rpcs_in_flight" \
909 "$device.mdc.max_rpcs_in_flight"
911 cleanup || error "cleanup failed with $?"
913 run_test 27b "Reacquire MGS lock after failover"
915 test_28A() { # was test_28
918 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
919 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
920 local orig=$($LCTL get_param -n $TEST)
921 local max=$($LCTL get_param -n \
922 llite.$FSNAME-*.max_read_ahead_per_file_mb)
924 orig=${orig%%.[0-9]*}
926 echo "ORIG:$orig MAX:$max"
927 [[ $max -le $orig ]] && orig=$((max - 3))
928 echo "ORIG:$orig MAX:$max"
930 local final=$((orig + 1))
932 set_persistent_param_and_check client "$TEST" "$PARAM" $final
934 set_persistent_param_and_check client "$TEST" "$PARAM" $final
935 umount_client $MOUNT || error "umount_client $MOUNT failed"
936 mount_client $MOUNT || error "mount_client $MOUNT failed"
938 local result=$($LCTL get_param -n $TEST)
940 if [ $result -ne $final ]; then
941 error "New config not seen: wanted $final got $result"
943 echo "New config success: got $result"
945 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
946 cleanup || error "cleanup failed with rc $?"
948 run_test 28A "permanent parameter setting"
950 test_28a() { # LU-4221
951 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
952 skip "Need OST version at least 2.5.52"
953 [ "$ost1_FSTYPE" = zfs ] &&
954 skip "LU-4221: no such proc params for ZFS OSTs"
961 local device="$FSNAME-OST0000"
965 # In this test we will set three kinds of proc parameters with
966 # lctl set_param -P or lctl conf_param:
967 # 1. non-symlink ones in the OFD
968 # 2. non-symlink ones in the OSD
971 # prepare a non-symlink parameter in the OFD
972 name="client_cache_seconds"
973 param="$device.ost.$name"
974 cmd="obdfilter.$device.$name"
976 # permanently setting the parameter in the OFD
977 old=$(do_facet ost1 $LCTL get_param -n $cmd)
979 set_persistent_param_and_check ost1 "$cmd" "$param" $new
980 set_persistent_param_and_check ost1 "$cmd" "$param" $old
983 # prepare a non-symlink parameter in the OSD
985 param="$device.osd.$name"
986 cmd="osd-*.$device.$name"
988 # conf_param the parameter in the OSD
989 old=$(do_facet ost1 $LCTL get_param -n $cmd)
990 new=$(((old + 1) % 2))
991 set_persistent_param_and_check ost1 "$cmd" "$param" $new
992 set_persistent_param_and_check ost1 "$cmd" "$param" $old
994 cleanup || error "cleanup failed with $?"
996 run_test 28a "set symlink parameters permanently with lctl"
1000 stack_trap "cleanup"
1002 # jobid_this_session is not available so use jobid_name when possible
1003 if $LCTL list_param jobid_name &> /dev/null; then
1004 local jobvarname=jobid_name test_val="$TESTNAME-$RANDOM%p"
1006 local jobvarname=jobid_var test_val=$TESTNAME-$RANDOM
1010 local jobid_var_old=$($LCTL get_param -n $jobvarname)
1011 local paramdir=/etc/lustre
1012 local paramfile=$paramdir/mount.client.params
1014 [[ -d $paramdir ]] || mkdir $paramdir
1016 stack_trap "$LCTL set_param $jobvarname=$jobid_var_old"
1018 if [[ -e $paramfile ]]; then
1019 mv $paramfile $paramfile.$TESTNAME
1020 stack_trap "mv $paramfile.$TESTNAME $paramfile"
1022 # leave no traces behind
1023 stack_trap "rm $paramfile"
1026 # if the test param is set in the filesystem params file
1027 # it will override the more general client params
1028 if [[ -e $paramdir/mount.$FSNAME.params ]]; then
1029 echo "disabling $FSNAME specific params file"
1030 local clientfile=$paramdir/mount.$FSNAME.params
1032 mv $clientfile $clientfile.disabled
1033 stack_trap "mv $clientfile.disabled $clientfile"
1035 echo "$jobvarname=$test_val" > $paramfile
1037 remount_client $MOUNT
1039 jobid_var_new=$($LCTL get_param -n $jobvarname)
1041 echo "before mount: $jobid_var_old"
1042 echo "after mount: $jobid_var_new"
1043 [[ "$jobid_var_new" == "$test_val" ]] ||
1044 error "$jobvarname was not $test_val: got $jobid_var_new"
1046 run_test 28b "verify client-side parameters are set upon mount"
1050 stack_trap "cleanup"
1052 # jobid_this_session is not available so use jobid_name when possible
1053 if $LCTL list_param jobid_name > /dev/null 2>&1; then
1054 local jobvarname=jobid_name test_val="$TESTNAME-$RANDOM%p"
1056 local jobvarname=jobid_var test_val=$TESTNAME-$RANDOM
1060 local jobid_var_old=$($LCTL get_param -n $jobvarname)
1061 local paramdir=/etc/lustre
1062 local paramfile=$paramdir/mount.$FSNAME.params
1064 [[ -d $paramdir ]] || mkdir $paramdir
1066 stack_trap "$LCTL set_param $jobvarname=$jobid_var_old"
1068 if [[ -e $paramfile ]]; then
1069 mv $paramfile $paramfile.$testname
1070 stack_trap "mv $paramfile.$testname $paramfile"
1072 # leave no traces behind
1073 stack_trap "rm $paramfile"
1075 echo "$jobvarname=$test_val" > $paramfile
1077 remount_client $MOUNT
1079 jobid_var_new=$($LCTL get_param -n $jobvarname)
1081 echo "before mount: $jobid_var_old"
1082 echo "after mount: $jobid_var_new"
1083 [[ "$jobid_var_new" == "$test_val" ]] ||
1084 error "$jobvarname was not $test_val: got $jobid_var_new"
1086 run_test 28c "verify filesystem parameters are set upon mount"
1089 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1090 setup_noconfig > /dev/null 2>&1
1091 start_ost2 || error "Unable to start OST2"
1094 local PARAM="$FSNAME-OST0001.osc.active"
1095 # With lctl set_param -P the value $PROC_ACT will be sent to
1096 # all nodes. The [!M] filter out the ability to set active
1097 # on the MDS servers which is tested with wait_osp_* below.
1098 # For ost_server_uuid that only exist on client so filtering
1100 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1101 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1103 ACTV=$($LCTL get_param -n $PROC_ACT)
1105 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1106 # also check ost_server_uuid status
1107 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1108 if [ -z "$RESULT" ]; then
1109 error "Client not deactivated: $($LCTL get_param \
1112 echo "Live client success: got $RESULT"
1116 wait_osp_active ost ${FSNAME}-OST0001 1 0
1118 # test new client starts deactivated
1119 umount_client $MOUNT || error "umount_client $MOUNT failed"
1120 mount_client $MOUNT || error "mount_client $MOUNT failed"
1122 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1123 # time when using lctl set_param -P
1124 wait_update_facet client \
1125 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1127 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1129 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1131 # make sure it reactivates
1132 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1134 umount_client $MOUNT
1135 stop_ost2 || error "Unable to stop OST2"
1136 cleanup_nocli || error "cleanup_nocli failed with $?"
1137 #writeconf to remove all ost2 traces for subsequent tests
1138 writeconf_or_reformat
1140 run_test 29 "permanently remove an OST"
1145 echo Big config llog
1146 local path="llite.$FSNAME-*"
1147 local cpath="$FSNAME.llite"
1148 local param="max_read_ahead_whole_mb"
1150 local test="${path}.$param"
1151 local conf="${cpath}.$param"
1153 local orig=$($LCTL get_param -n $test)
1154 local list=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1155 for i in ${list[*]}; do
1156 set_persistent_param_and_check client $test $conf $i
1158 # make sure client restart still works
1159 umount_client $MOUNT
1160 mount_client $MOUNT || error "mount_client $MOUNT failed"
1161 [ "$($LCTL get_param -n $test)" -ne "$i" ] &&
1162 error "Param didn't stick across restart $($test) != $i"
1165 echo Erase parameter setting
1166 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1167 do_facet mgs "$PERM_CMD -d $test" ||
1168 error "Erase param $test failed"
1170 do_facet mgs "$PERM_CMD -d $conf" ||
1171 error "Erase param $conf failed"
1173 umount_client $MOUNT
1174 mount_client $MOUNT || error "mount_client $MOUNT failed"
1175 local final=$($LCTL get_param -n $test)
1176 echo "deleted (default) value=$final, orig=$orig"
1177 orig=${orig%%.[0-9]*}
1178 final=${final%%.[0-9]*}
1179 # assumes this parameter started at the default value
1180 [ "$final" -eq "$orig" ] ||
1181 error "Deleted value=$final -ne orig=$orig"
1183 cleanup || error "cleanup failed with rc $?"
1185 run_test 30a "Big config llog and permanent parameter deletion"
1190 local orignids=$($LCTL get_param -n \
1191 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1192 local orignidcount=$(echo "$orignids" | wc -w)
1194 # Make a fake NID. Use the OST NID, and increase the least significant
1195 # field. Hopefully that's not already a failover address for an existing
1196 # node, but if so try again until it is an unused NID for this cluster.
1197 local ostnid=$(do_facet ost1 "$LCTL list_nids | tail -1")
1198 local origval=$(echo $ostnid | egrep -oi "[0-9a-f]*@")
1199 # this will match on first loop, but keeps fake NID logic in one place
1200 local newnid=$ostnid
1202 echo "Checking peer and local NIDs:"
1203 while { $LNETCTL peer show | awk '/nid/{print $NF}' | sort -u
1204 $LCTL list_nids; } | grep -w $newnid; do
1205 local newval=$(((0x${origval%@} + $RANDOM) % 256))
1206 newnid=${ostnid/$origval/$newval@}
1209 echo "Changing $ostnid to fake NID $newnid"
1211 local test="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1212 grep failover_nids | sed -n 's/.*\($newnid\).*/\1/p'"
1213 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1214 param="osc.$FSNAME-OST0000-osc-[^M]*.import"
1215 echo "Setting $param from $ostnid to $newnid"
1216 do_facet mgs "$PERM_CMD $param='connection=$newnid'" ||
1217 error "$PERM_CMD $param failed"
1219 param="$FSNAME-OST0000.failover.node"
1220 echo "Setting $param from $ostnid to $newnid"
1221 do_facet mgs "$PERM_CMD $param='$newnid'" ||
1222 error "$PERM_CMD $param failed"
1224 wait_update_facet client "$test" "$newnid" || {
1225 $LCTL get_param osc.$FSNAME-OST0000-osc-[^M]*.import
1226 error "check $param for '$newnid' failed!"
1229 local nids=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1231 local nidcount=$(echo "$nids" | wc -w)
1232 echo "should have $((orignidcount + 1)) failover NIDs, have $nidcount"
1233 (( $nidcount == $((orignidcount + 1)) )) || {
1235 error "Failover NID '$newnid' not added"
1238 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1239 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1241 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1242 error "$PERM_CMD delete failed"
1244 umount_client $MOUNT || error "umount_client $MOUNT failed"
1245 mount_client $MOUNT || error "mount_client $MOUNT failed"
1247 nids=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1249 nidcount=$(echo "$nids" | wc -w)
1250 echo "only $orignidcount failover NIDs should be left, have $nidcount"
1251 (( $nidcount == $orignidcount )) || {
1253 error "Failover NID '$newnid' not removed"
1256 cleanup || error "cleanup failed with rc $?"
1258 run_test 30b "Remove failover nids"
1260 test_31() { # bug 10734
1261 # ipaddr must not exist
1262 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1263 cleanup || error "cleanup failed with rc $?"
1265 run_test 31 "Connect to non-existent node (shouldn't crash)"
1269 T32_BLIMIT=40960 # Kbytes
1272 T32_PROLIMIT=$((T32_BLIMIT/10))
1273 T32_POOLLIMIT=$((T32_BLIMIT/2))
1275 # This is not really a test but a tool to create new disk
1276 # image tarballs for the upgrade tests.
1278 # Disk image tarballs should be created on single-node
1279 # clusters by running this test with default configurations
1280 # plus a few mandatory environment settings that are verified
1281 # at the beginning of the test.
1283 test_32newtarball() {
1287 local tmp=$TMP/t32_image_create
1298 local pj_quota_file_old
1301 [[ "$FSNAME" == "t32fs" && ( -n "$MDSDEV" || -n "$MDSDEV1" ) &&
1302 -n "$OSTDEV1" ]] && (( $OSTCOUNT == 2 )) ||
1303 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1304 "MDSDEV1=<nonexistent_file> " \
1305 "MDSDEV2=<nonexistent_file> " \
1306 "(or MDSDEV, in the case of b1_8) " \
1307 "OSTCOUNT=2 OSTDEV1=<nonexistent_file> " \
1308 "OSTDEV2=<nonexistent_file>"
1310 mkdir $tmp || error "Found stale $tmp"
1312 mkdir $tmp/src || return 1
1313 tar cf - -C $src . | tar xf - -C $tmp/src
1315 # format ost with comma-separated NIDs to verify LU-4460
1316 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1317 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1321 (( "$MDS1_VERSION" >= $(version_code 2.3.50) )) ||
1322 $LFS quotacheck -ug /mnt/$FSNAME
1323 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1326 if (( $MDSCOUNT >= 2 )); then
1327 remote_dir=/mnt/$FSNAME/remote_dir
1328 $LFS mkdir -i 1 $remote_dir
1329 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1331 target_dir=$remote_dir
1332 if (( $MDS1_VERSION >= $(version_code 2.7.0) )); then
1333 striped_dir=/mnt/$FSNAME/striped_dir_old
1334 $LFS mkdir -i 1 -c 2 $striped_dir
1335 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1338 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1339 target_dir=/mnt/$FSNAME
1342 # add project quota #
1343 [[ $mds1_FSTYPE == "ldiskfs" &&
1344 $MDS1_VERSION -gt $(version_code 2.9.55) ]] ||
1345 [[ $mds1_FSTYPE == "zfs" &&
1346 $MDS1_VERSION -gt $(version_code 2.10.53) ]] && {
1347 pj_quota_dir=$target_dir/project_quota_dir
1348 pj_quota_file_old=$pj_quota_dir/pj_quota_file_old
1350 enable_project_quota
1351 set_mdt_qtype ugp ||
1352 error "enable mdt quota failed"
1354 set_ost_qtype ugp ||
1355 error "enable ost quota failed"
1357 mkdir -p $pj_quota_dir
1358 $LFS setquota -p $T32_PRJID -b 0 -B $T32_PROLIMIT -i 0 \
1359 -I $T32_ILIMIT $pj_quota_dir ||
1360 error "setquota -p $T32_PRJID failed"
1362 $LFS setstripe $pj_quota_file_old -c 1 ||
1363 error "setstripe $pj_quota_file_old failed"
1365 chown $T32_QID:$T32_QID $pj_quota_file_old ||
1366 error "chown $pj_quota_file_old failed"
1368 change_project -p $T32_PRJID $pj_quota_file_old
1370 mkdir -p $tmp/src/project_quota_dir
1371 cp $pj_quota_file_old $tmp/src/project_quota_dir/
1374 #####################
1377 if (( $MDS1_VERSION >= $(version_code 2.9.51) )); then
1378 pfl_dir=$target_dir/pfl_dir
1379 pfl_file=$pfl_dir/pfl_file
1381 $LFS setstripe -E 2M -c1 -o0 -E -1 -S2M -c1 -o1 $pfl_dir ||
1382 error "Create PFL file failed"
1384 dd if=/dev/urandom of=$pfl_file bs=1M count=3
1385 mkdir -p $tmp/src/pfl_dir
1386 cp $pfl_file $tmp/src/pfl_dir/
1391 if (( $MDS1_VERSION >= $(version_code 2.10.56) )); then
1392 dom_dir=$target_dir/dom_dir
1393 dom_file=$dom_dir/dom_file
1394 flr_dir=$target_dir/flr_dir
1395 flr_file=$flr_dir/flr_file
1398 $LFS setstripe -E 1M -L mdt -E -1 -S 4M $dom_dir
1399 dd if=/dev/urandom of=$dom_file bs=1M count=2 ||
1400 error "create $dom_file failed"
1401 mkdir -p $tmp/src/dom_dir
1402 cp $dom_file $tmp/src/dom_dir
1405 $LFS mirror create -N2 $flr_file
1406 dd if=/dev/urandom of=$flr_file bs=1k count=1 ||
1407 error "create $flr_file failed"
1408 mkdir -p $tmp/src/flr_dir
1409 cp $flr_file $tmp/src/flr_dir
1415 if (( $MDS1_VERSION >= $(version_code 2.13.56) )); then
1416 local qpool=testpool
1417 local pool_name=$FSNAME.$qpool
1418 local pool_dir=$target_dir/pool_dir
1419 local pool_list=$pool_dir/pool_list
1420 local pool_file=$pool_dir/pool_file
1422 $LCTL pool_new $pool_name || error "pool_new $pool_name failed"
1423 $LCTL pool_add $pool_name $FSNAME-OST[0-1/1] ||
1424 error "pool_add $pool_name failed"
1426 mkdir_on_mdt0 $pool_dir || error "mkdir $pool_dir failed"
1427 chmod 0777 $pool_dir || error "chmod $pool_dir failed"
1428 $LFS setstripe -E 1M -c 1 --pool $qpool -E eof -c 2 $pool_dir ||
1429 error "setstripe $pool_dir failed"
1430 touch $pool_file || error "touch $pool_file failed"
1431 chown $T32_QID:$T32_QID $pool_file ||
1432 error "chown $pool_file failed"
1434 $LCTL pool_list $pool_name > $pool_list ||
1435 error "create $pool_list failed"
1437 set_ost_qtype ugp ||
1438 error "enable ost quota failed"
1440 $LFS setquota -u $T32_QID -B $T32_POOLLIMIT --pool $qpool \
1441 $pool_dir || error "set user quota on $pool_dir failed"
1443 mkdir -p $tmp/src/pool_dir
1444 cp -t $tmp/src/pool_dir $pool_file $pool_list
1449 # fscrypt file data #
1450 if (( $MDS1_VERSION >= $(version_code 2.13.55) )) &&
1452 local fscrypt_data_pass=$target_dir/fscrypt_data_pass
1453 local fscrypt_data_dir=$target_dir/fscrypt_data_dir
1454 local fscrypt_data_file=$fscrypt_data_dir/fscrypt_data_file
1455 local fscrypt_data_dom=$fscrypt_data_dir/fscrypt_data_dom
1456 local my_pass="mypass"
1458 yes | fscrypt setup --force --verbose ||
1459 error "fscrypt global setup failed"
1460 sed -i 's/\(.*\)policy_version\(.*\):\(.*\)\"[0-9]*\"\(.*\)/\1policy_version\2:\3"2"\4/' \
1462 yes | fscrypt setup --verbose /mnt/$FSNAME ||
1463 error "fscrypt setup /mnt/$FSNAME failed"
1465 mkdir_on_mdt0 $fscrypt_data_dir ||
1466 error "mkdir $fscrypt_data_dir failed"
1468 echo -e 'mypass\nmypass' |
1469 fscrypt encrypt --verbose --source=custom_passphrase \
1470 --name=protector $fscrypt_data_dir ||
1471 error "fscrypt encrypt $fscrypt_data_dir failed"
1473 echo "$my_pass" > $fscrypt_data_pass ||
1474 error "save $fscrypt_data_pass failed"
1476 dd if=/dev/urandom of=$fscrypt_data_file bs=128k count=1 ||
1477 error "write $fscrypt_data_file failed"
1479 $LFS setstripe -E 64K -L mdt -E eof -c 1 $fscrypt_data_dom ||
1480 error "setstripe $fscrypt_data_dom failed"
1481 dd if=/dev/urandom of=$fscrypt_data_dom bs=128k count=1 ||
1482 error "write $fscrypt_data_dom failed"
1484 ls -R $fscrypt_data_dir ||
1485 error "ls -R $fscrypt_data_dir failed"
1486 local filecount=$(find $fscrypt_data_dir -type f | wc -l)
1487 (( filecount == 2 )) || error "found $filecount files"
1489 mkdir -p $tmp/src/fscrypt_data_dir
1490 cp -t $tmp/src/fscrypt_data_dir \
1491 $fscrypt_data_file $fscrypt_data_dom
1492 cp $fscrypt_data_pass $tmp/src
1497 # fscrypt file name #
1498 if (( $MDS1_VERSION >= $(version_code 2.14.57) )) &&
1500 local fscrypt_name_pass=$target_dir/fscrypt_name_pass
1501 local fscrypt_name_dir=$target_dir/fscrypt_name_dir
1502 local fscrypt_name_file=$fscrypt_name_dir/fscrypt_name_file
1503 local fscrypt_name_dom=$fscrypt_name_dir/fscrypt_name_dom
1505 [[ -s $fscrypt_data_pass ]] &&
1506 my_pass=$(cat $fscrypt_data_pass) ||
1509 mkdir_on_mdt0 $fscrypt_name_dir ||
1510 error "mkdir $fscrypt_name_dir failed"
1512 $LCTL set_param -P llite.*.enable_filename_encryption=1 ||
1513 error "enable filename encryption failed"
1515 wait_update_facet --verbose client \
1516 "$LCTL get_param -n llite.*.enable_filename_encryption \
1518 error "enable_filename_encryption not set on client"
1520 echo -e 'mypass\nmypass' |
1521 fscrypt encrypt --verbose --source=custom_passphrase \
1522 --name=protector2 $fscrypt_name_dir ||
1523 error "fscrypt encrypt $fscrypt_name_dir failed"
1525 echo "$my_pass" > $fscrypt_name_pass ||
1526 error "save $fscrypt_name_pass failed"
1528 dd if=/dev/urandom of=$fscrypt_name_file bs=128k count=1 ||
1529 error "write $fscrypt_name_file failed"
1531 $LFS setstripe -E 64K -L mdt -E eof -c 1 $fscrypt_name_dom ||
1532 error "setstripe $fscrypt_name_dom failed"
1533 dd if=/dev/urandom of=$fscrypt_name_dom bs=128k count=1 ||
1534 error "write $fscrypt_name_dom failed"
1536 ls -R $fscrypt_name_dir ||
1537 error "ls -R $fscrypt_name_dir failed"
1538 local filecount=$(find $fscrypt_name_dir -type f | wc -l)
1539 (( filecount == 2 )) || error "found $filecount files"
1541 mkdir -p $tmp/src/fscrypt_name_dir
1542 cp -t $tmp/src/fscrypt_name_dir \
1543 $fscrypt_name_file $fscrypt_name_dom
1544 cp $fscrypt_name_pass $tmp/src
1548 local large_xattr_dir=/mnt/$FSNAME/large_xattr_test_dir
1549 local xattr_file=$large_xattr_dir/large_xattr_file
1551 mkdir $large_xattr_dir
1553 setfattr -n user.fooattr -v $(printf "%c" {1..4096} ) $xattr_file ||
1556 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1560 mkdir $tmp/img || return 1
1564 if [[ -n $fscrypt_data_pass ]]; then
1565 local unlock_status=$(fscrypt status $fscrypt_data_dir |
1566 awk '/Unlocked:/{print $2}')
1567 [[ $unlock_status == Yes ]] ||
1568 cat $fscrypt_data_pass |
1569 fscrypt unlock --verbose $fscrypt_data_dir ||
1570 error "unlock $fscrypt_data_dir failed"
1573 if [[ -n $fscrypt_name_pass ]]; then
1574 local unlock_status=$(fscrypt status $fscrypt_name_dir |
1575 awk '/Unlocked:/{print $2}')
1576 [[ $unlock_status == Yes ]] ||
1577 cat $fscrypt_name_pass |
1578 fscrypt unlock --verbose $fscrypt_name_dir ||
1579 error "unlock $fscrypt_name_dir failed"
1582 pushd_dir=/mnt/$FSNAME
1583 if [[ $MDSCOUNT -ge 2 ]]; then
1584 pushd_dir=$remote_dir
1585 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1587 BLOCKSIZE=1024 ls -Rni --time-style=+%s >$tmp/img/list2
1593 BLOCKSIZE=1024 ls -Rni --time-style=+%s >$tmp/img/list
1594 find ! -name .lustre -type f -exec sha1sum {} \; |
1595 sort -k 2 >$tmp/img/sha1sums
1597 $LCTL get_param -n version | head -n 1 |
1598 sed -e 's/^lustre: *//' >$tmp/img/commit
1600 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1601 $LFS quotaon -ug /mnt/$FSNAME
1602 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1603 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1604 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1605 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1606 | tr -d "*" > $tmp/img/bspace
1607 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1608 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1609 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1610 | tr -d "*" > $tmp/img/ispace
1611 echo $T32_BLIMIT > $tmp/img/blimit
1612 echo $T32_ILIMIT > $tmp/img/ilimit
1615 if (( $MDS1_VERSION >= $(version_code 2.13.56) )); then
1616 $LFS quota -v -u $T32_QID --pool $qpool $pool_dir
1617 DIR=$pool_dir getquota -u $T32_QID global curspace $qpool \
1618 > $tmp/img/bspace_pool
1619 echo $T32_POOLLIMIT > $tmp/img/blimit_pool
1622 # fscrypt file data #
1623 if [[ -n $fscrypt_data_pass ]]; then
1624 unlock_status=$(fscrypt status $fscrypt_data_dir |
1625 awk '/Unlocked:/{print $2}')
1627 if [[ $unlock_status == Yes ]]; then
1628 fscrypt lock --verbose $fscrypt_data_dir ||
1629 error "fscrypt lock $fscrypt_data_dir failed"
1632 ls -l $fscrypt_data_dir ||
1633 error "ls -l $fscrypt_data_dir failed"
1634 ls $fscrypt_data_file || error "ls $fscrypt_data_file failed"
1635 ls $fscrypt_data_dom || error "ls $fscrypt_data_dom failed"
1638 # fscrypt file name #
1639 if [[ -n $fscrypt_name_pass ]]; then
1640 unlock_status=$(fscrypt status $fscrypt_name_dir |
1641 awk '/Unlocked:/{print $2}')
1643 if [[ $unlock_status == Yes ]]; then
1644 fscrypt lock --verbose $fscrypt_name_dir ||
1645 error "fscrypt lock $fscrypt_name_dir failed"
1648 ls -l $fscrypt_name_dir ||
1649 error "ls -l $fscrypt_name_dir failed"
1650 ! ls $fscrypt_name_file ||
1651 error "ls $fscrypt_name_file should fail"
1652 ! ls $fscrypt_name_dom ||
1653 error "ls $fscrypt_name_dom should fail"
1656 $MULTIOP /mnt/$FSNAME/orph_file Ouw_c&
1660 debugfs -R "ls /PENDING" ${MDSDEV1:-$MDSDEV}
1669 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1672 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1673 echo "Data verification failed"
1676 uname -r >$tmp/img/kernel
1677 uname -m >$tmp/img/arch
1679 for ((num=1; num <= $MDSCOUNT; num++)); do
1680 local devname=$(mdsdevname $num)
1684 [[ num -eq 1 ]] && image_name=mdt || image_name=mdt$num
1685 [[ $(facet_fstype $facet) != zfs ]] ||
1686 devname=$(mdsvdevname $num)
1687 dd conv=sparse bs=4k if=$devname of=$tmp/img/$image_name
1690 for ((num=1; num <= $OSTCOUNT; num++)); do
1691 local devname=$(ostdevname $num)
1695 [[ num -eq 1 ]] && image_name=ost || image_name=ost$num
1696 [[ $(facet_fstype $facet) != zfs ]] ||
1697 devname=$(ostvdevname $num)
1698 dd conv=sparse bs=4k if=$devname of=$tmp/img/$image_name
1701 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1702 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1705 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1710 # run_test 32newtarball "Create new test_32 disk image tarball for this version"
1713 # The list of applicable tarballs is returned via the caller's
1714 # variable "tarballs".
1717 [ "$CLIENTONLY" ] && skip "Client-only testing"
1719 check_versions || skip "do not upgrade with mismatched client/server"
1721 local node=$(facet_active_host $SINGLEMDS)
1722 local r="do_node $node"
1724 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1726 local IMGTYPE="$mds1_FSTYPE"
1728 [[ -n "$T32IMAGE" ]] && tarballs=$T32IMAGE ||
1729 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1730 -name \'disk*-$IMGTYPE.tar.bz2\')
1732 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1735 t32_test_cleanup() {
1737 local facet=$SINGLEMDS
1740 echo "== cleanup with rc=$rc =="
1741 if $shall_cleanup_lustre; then
1742 umount $tmp/mnt/lustre || rc=$?
1744 if $shall_cleanup_mdt; then
1745 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1747 if $shall_cleanup_mdt1; then
1748 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1750 if $shall_cleanup_ost; then
1751 $r $UMOUNT $tmp/mnt/ost || rc=$?
1753 if $shall_cleanup_ost1; then
1754 $r $UMOUNT $tmp/mnt/ost1 || rc=$?
1759 if [[ "$mds1_FSTYPE" == zfs ]]; then
1761 local poolname_list="t32fs-mdt1 t32fs-ost1"
1763 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1765 for poolname in $poolname_list; do
1766 destroy_zpool $facet $poolname
1769 combined_mgs_mds || start_mgs || rc=$?
1773 t32_bits_per_long() {
1775 # Yes, this is not meant to be perfect.
1785 t32_reload_modules() {
1787 local all_removed=false
1790 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1792 while ((i < 20)); do
1793 echo "Unloading modules on $node: Attempt $i"
1794 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1796 do_rpc_nodes $node check_mem_leak || return 1
1797 if $all_removed; then
1798 do_rpc_nodes $node load_modules
1801 if [ "$mds1_FSTYPE" == zfs ]; then
1802 do_rpc_nodes $node "$ZPOOL status -v"
1807 echo "Unloading modules on $node: Given up"
1811 t32_wait_til_devices_gone() {
1817 echo wait for devices to go
1818 while ((i < 20)); do
1819 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1820 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1821 ((devices == 0 && loops == 0)) && return 0
1825 echo "waiting for dev on $node: dev $devices loop $loops given up"
1826 do_rpc_nodes $node "losetup -a"
1827 do_rpc_nodes $node "$LCTL device_list"
1831 t32_verify_quota() {
1838 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1839 # lustre will estimate the object count usage. This fails quota
1840 # verification in 32b. The object quota usage should be accurate after
1841 # zfs-0.7.0 is released.
1842 [ "$mds1_FSTYPE" == zfs ] && {
1843 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1845 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1846 echo "Skip quota verify for zfs: $zfs_version"
1851 $LFS quota -u $T32_QID -v $mnt
1853 qval=$($LFS quota -v -u $T32_QID $mnt |
1854 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1855 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1857 [ $qval -eq $img_bspace ] || {
1858 echo "bspace, act:$qval, exp:$img_bspace"
1862 qval=$($LFS quota -v -u $T32_QID $mnt |
1863 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1864 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1866 [ $qval -eq $img_ispace ] || {
1867 echo "ispace, act:$qval, exp:$img_ispace"
1871 qval=$($LFS quota -v -u $T32_QID $mnt |
1872 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1873 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1875 [ $qval -eq $img_blimit ] || {
1876 echo "blimit, act:$qval, exp:$img_blimit"
1880 qval=$($LFS quota -v -u $T32_QID $mnt |
1881 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1882 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1884 [ $qval -eq $img_ilimit ] || {
1885 echo "ilimit, act:$qval, exp:$img_ilimit"
1889 set_persistent_param_and_check $facet \
1890 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1891 "$fsname.quota.mdt" ug
1893 set_persistent_param_and_check $facet \
1894 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1895 "$fsname.quota.ost" ug
1898 runas -u $T32_QID -g $T32_QID $DD of=$mnt/t32_qf_new \
1899 count=$((img_blimit / 1024)) oflag=sync && {
1900 echo "Write succeed, but expect -EDQUOT"
1903 rm -f $mnt/t32_qf_new
1905 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1907 echo "Create succeed, but expect -EDQUOT"
1910 unlinkmany $mnt/t32_qf_ $img_ilimit
1913 if (( $(version_code $img_commit) >= $(version_code 2.13.56) )) &&
1914 [[ "$pool_quota_upgrade" == "yes" ]]; then
1915 $mdt2_is_available || pool_dir=$mnt/pool_dir
1916 local pool_file_new=$pool_dir/pool_file_new
1918 local qpool=$($LFS getstripe -p $pool_dir)
1919 [[ -n "$qpool" ]] || {
1920 echo "no OST pool on $pool_dir"
1924 $LFS quota -v -u $T32_QID --pool $qpool $pool_dir
1926 qval=$(DIR=$pool_dir getquota -u $T32_QID \
1927 global curspace $qpool)
1928 [[ $qval == $img_bspace_pool ]] || {
1929 echo "bspace_pool, act:$qval, exp:$img_bspace_pool"
1933 qval=$(DIR=$pool_dir getquota -u $T32_QID \
1934 global bhardlimit $qpool)
1935 [[ $qval == $img_blimit_pool ]] || {
1936 echo "blimit_pool, act:$qval, exp:$img_blimit_pool"
1940 touch $pool_file_new || {
1941 echo "touch $pool_file_new failed"
1945 chown $T32_QID:$T32_QID $pool_file_new || {
1946 echo "chown $pool_file_new failed"
1950 runas -u $T32_QID -g $T32_QID $DD of=$pool_file_new \
1951 count=$((img_blimit_pool / 1024)) oflag=sync && {
1952 echo "Write $pool_file_new succeed, but expect -EDQUOT"
1955 rm -f $pool_file_new
1961 get_project_quota() {
1966 sync_all_data > /dev/null 2>&1 || true
1968 [ "$uuid" != "global" ] || uuid=$mnt
1970 $LFS quota -v "$1" "$2" $mnt |
1971 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
1972 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1979 local dne_upgrade=${dne_upgrade:-"no"}
1980 local dom_upgrade=${dom_upgrade:-"no"}
1981 local project_upgrade=${project_upgrade:-"no"}
1982 local ff_convert=${ff_convert:-"no"}
1983 local pfl_upgrade=${pfl_upgrade:-"no"}
1984 local project_quota_upgrade=${project_quota_upgrade:-"no"}
1985 local dom_new_upgrade=${dom_new_upgrade:-"no"}
1986 local flr_upgrade=${flr_upgrade:-"no"}
1987 local pool_quota_upgrade=${pool_quota_upgrade:-"no"}
1988 local fscrypt_data_upgrade=${fscrypt_data_upgrade:-"no"}
1989 local fscrypt_name_upgrade=${fscrypt_name_upgrade:-"no"}
1990 local shall_cleanup_mdt=false
1991 local shall_cleanup_mdt1=false
1992 local shall_cleanup_ost=false
1993 local shall_cleanup_ost1=false
1994 local shall_cleanup_lustre=false
1995 local mdt2_is_available=false
1996 local ost2_is_available=false
1997 local node=$(facet_active_host $SINGLEMDS)
1998 local r="do_node $node"
2004 local img_bspace_pool
2007 local img_blimit_pool
2016 local mdt_dev=$tmp/mdt
2017 local mdt2_dev=$tmp/mdt2
2018 local ost_dev=$tmp/ost
2019 local ost2_dev=$tmp/ost2
2023 local pfl_file=$tmp/mnt/lustre/remote_dir/pfl_dir/pfl_file
2024 local flr_file=$tmp/mnt/lustre/remote_dir/flr_dir/flr_file
2025 local dom_file=$tmp/mnt/lustre/remote_dir/dom_dir/dom_file
2026 local quota_dir=$tmp/mnt/lustre/remote_dir/project_quota_dir
2027 local pool_dir=$tmp/mnt/lustre/remote_dir/pool_dir
2028 local fscrypt_data_dir=$tmp/mnt/lustre/remote_dir/fscrypt_data_dir
2029 local fscrypt_data_pass=$tmp/mnt/lustre/remote_dir/fscrypt_data_pass
2030 local fscrypt_name_dir=$tmp/mnt/lustre/remote_dir/fscrypt_name_dir
2031 local fscrypt_name_pass=$tmp/mnt/lustre/remote_dir/fscrypt_name_pass
2033 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
2034 trap 'trap - RETURN; t32_test_cleanup' RETURN
2037 nid=$($r $LCTL list_nids | head -1)
2039 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
2040 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost,ost1}
2041 $r tar xjvf $tarball -S -C $tmp || {
2042 error_noexit "Unpacking the disk image tarball"
2045 img_commit=$($r cat $tmp/commit)
2046 img_kernel=$($r cat $tmp/kernel)
2047 img_arch=$($r cat $tmp/arch)
2048 img_bspace=$($r cat $tmp/bspace)
2049 img_ispace=$($r cat $tmp/ispace)
2051 if (( $(version_code $img_commit) >= $(version_code 2.13.56) )); then
2052 img_bspace_pool=$($r cat $tmp/bspace_pool)
2053 img_blimit_pool=$($r cat $tmp/blimit_pool)
2055 pool_quota_upgrade="no"
2058 # older images did not have "blimit" and "ilimit" files
2059 # use old values for T32_BLIMIT and T32_ILIMIT
2060 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
2062 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
2065 echo "Upgrading from $(basename $tarball), created with:"
2066 echo " Commit: $img_commit"
2067 echo " Kernel: $img_kernel"
2068 echo " Arch: $img_arch"
2069 echo "OST version: $(lustre_build_version ost1)"
2071 # The conversion can be made only when both of the following
2072 # conditions are satisfied:
2073 # - ost device img version < 2.3.64
2074 # - ost server version >= 2.5
2075 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
2076 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
2079 ! $r test -f $mdt2_dev || mdt2_is_available=true
2080 ! $r test -f $ost2_dev || ost2_is_available=true
2082 if [[ "$mds1_FSTYPE" == zfs ]]; then
2083 echo "== fstype is zfs =="
2086 local poolname_list="t32fs-mdt1 t32fs-ost1"
2088 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
2089 ! $ost2_is_available || poolname_list+=" t32fs-ost2"
2091 for poolname in $poolname_list; do
2093 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2094 $ZPOOL import -f -d $tmp $poolname"
2097 # upgrade zpool to latest supported features, including
2098 # dnode quota accounting in 0.7.0
2099 $r "$ZPOOL upgrade -a"
2101 mdt_dev=t32fs-mdt1/mdt1
2102 ost_dev=t32fs-ost1/ost1
2103 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
2104 ! $ost2_is_available || ost2_dev=t32fs-ost2/ost2
2105 wait_update_facet $SINGLEMDS "$ZPOOL list |
2106 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
2107 error_noexit "import zfs pool failed"
2110 elif [ "$project_upgrade" != "no" ]; then
2111 echo "== project upgrade =="
2112 ! $r tune2fs -O project $mdt_dev &&
2113 error_noexit "enable project on mdt0 failed" &&
2115 $mdt2_is_available && ! $r tune2fs "-O project" $mdt2_dev &&
2116 error_noexit "enable project on mdt failed" &&
2118 ! $r tune2fs -O project $ost_dev &&
2119 error_noexit "enable project on ost failed" &&
2121 $ost2_is_available && ! $r tune2fs -O project $ost2_dev &&
2122 error_noexit "enable project on ost2 failed" &&
2126 $r $LCTL set_param debug="$PTLDEBUG"
2128 $r $TUNEFS --dryrun $mdt_dev || {
2130 error_noexit "tunefs.lustre before mounting the MDT"
2134 if $mdt2_is_available; then
2135 $r $TUNEFS --dryrun $mdt2_dev || {
2137 error_noexit "tunefs.lustre before mounting the MDT"
2142 if [ "$writeconf" ]; then
2143 echo "== writeconf mdt tunefs and quota =="
2145 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2147 $r $TUNEFS --quota $mdt_dev || {
2149 error_noexit "Enable mdt quota feature"
2153 if [ "$project_quota_upgrade" != "no" ]; then
2154 echo "== enable mdt2 project quota =="
2155 $r $TUNE2FS -O project $mdt_dev || {
2157 error_noexit "tune2fs $mdt_dev failed"
2162 if $mdt2_is_available; then
2163 $r $TUNEFS --quota $mdt2_dev || {
2165 error_noexit "Enable mdt2 quota feature"
2168 if [ "$project_quota_upgrade" != "no" ]; then
2169 echo "== enable mdt2 project quota =="
2170 $r $TUNE2FS -O project $mdt2_dev || {
2173 "tune2fs $mdt2_dev failed"
2180 echo "== replace nids =="
2181 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
2182 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
2183 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
2184 "(Need MGS version at least 2.3.59)"
2187 local osthost=$(facet_active_host ost1)
2188 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
2191 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2194 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
2195 $r $LCTL replace_nids $fsname-OST0000 $ostnid || {
2197 error_noexit "replace_nids $fsname-OST0000 $ostnid failed"
2200 if $ost2_is_available; then
2201 $r $LCTL replace_nids $fsname-OST0001 $ostnid || {
2203 error_noexit "replace_nids $fsname-OST0001 $ostnid failed"
2207 $r $LCTL replace_nids $fsname-MDT0000 $nid || {
2209 error_noexit "replace_nids $fsname-MDT0000 $nid failed"
2212 if $mdt2_is_available; then
2213 $r $LCTL replace_nids $fsname-MDT0001 $nid || {
2215 error_noexit "replace_nids $fsname-MDT0001 $nid failed"
2219 $r $UMOUNT $tmp/mnt/mdt
2221 mopts=exclude=$fsname-OST0000
2222 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2227 t32_wait_til_devices_gone $node
2229 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2231 error_noexit "Mounting the MDT"
2234 shall_cleanup_mdt=true
2236 if $mdt2_is_available; then
2237 echo "== mdt2 available =="
2238 mopts=mgsnode=$nid,$mopts
2239 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
2241 error_noexit "Mounting the MDT"
2244 shall_cleanup_mdt1=true
2245 echo "== mount new MDT $mdt2_dev =="
2247 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 || {
2248 error_noexit "enable remote dir create failed"
2252 elif [ "$dne_upgrade" != "no" ]; then
2253 local fs2mdsdev=$(mdsdevname 1_2)
2254 local fs2mdsvdev=$(mdsvdevname 1_2)
2256 echo "== mkfs new MDT on ${fs2mdsdev} =="
2257 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2258 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
2261 add $SINGLEMDS $(mds2failover_HOST="" \
2262 mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
2263 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
2264 error_noexit "Mkfs new MDT failed"
2268 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
2270 $r $TUNEFS --dryrun $fs2mdsdev || {
2271 error_noexit "tunefs.lustre before mounting the MDT"
2275 echo "== mount new MDT....$fs2mdsdev =="
2276 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
2277 error_noexit "mount mdt1 failed"
2281 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
2282 error_noexit "enable remote dir create failed"
2284 shall_cleanup_mdt1=true
2287 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
2288 error_noexit "Getting MDT UUID"
2291 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
2292 error_noexit "Unexpected MDT UUID: \"$uuid\""
2296 $r $TUNEFS --dryrun $ost_dev || {
2297 error_noexit "tunefs.lustre before mounting the OST"
2301 if $ost2_is_available; then
2302 $r $TUNEFS --dryrun $ost2_dev || {
2303 error_noexit "tunefs.lustre before mounting the OST"
2308 if [ "$writeconf" ]; then
2309 echo "== writeconf and ost quota tunefs =="
2310 mopts=mgsnode=$nid,$writeconf
2311 if [ "$ost1_FSTYPE" == ldiskfs ]; then
2313 $r $TUNEFS --quota $ost_dev || {
2315 error_noexit "Enable ost quota feature"
2319 if [ "$project_quota_upgrade" != "no" ]; then
2320 echo "== enable ost project quota =="
2321 $r $TUNE2FS -O project $ost_dev || {
2323 error_noexit "tune2fs $ost_dev failed"
2328 if $ost2_is_available; then
2329 $r $TUNEFS --quota $ost2_dev || {
2331 error_noexit "Enable ost2 quota feature"
2334 if [ "$project_quota_upgrade" != "no" ]; then
2335 echo "== enable ost2 project quota =="
2336 $r $TUNE2FS -O project $ost2_dev || {
2339 "tune2fs $ost2_dev failed"
2347 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2352 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
2353 error_noexit "Mounting the OST"
2357 if $ost2_is_available; then
2358 $r $MOUNT_CMD -onomgs -o$mopts $ost2_dev $tmp/mnt/ost1 || {
2359 error_noexit "Mounting the OST2"
2362 shall_cleanup_ost1=true
2365 shall_cleanup_ost=true
2367 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
2368 error_noexit "Getting OST UUID"
2371 if [ "$uuid" != $fsname-OST0000_UUID ]; then
2372 error_noexit "Unexpected OST UUID: \"$uuid\""
2376 if $ost2_is_available; then
2377 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0001.uuid) ||{
2378 error_noexit "Getting OST1 UUID"
2381 if [ "$uuid" != $fsname-OST0001_UUID ]; then
2382 error_noexit "Unexpected OST1 UUID: \"$uuid\""
2387 if [[ $PERM_CMD =~ "set_param" ]]; then
2388 echo "== perm cmd = '$PERM_CMD' =="
2389 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
2390 error_noexit "Setting OST \"failover.node\""
2393 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
2394 error_noexit "Setting MDT \"failover.node\""
2397 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
2398 error_noexit "Setting \"max_dirty_mb\""
2401 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
2402 error_noexit "Setting \"max_rpcs_in_flight\""
2405 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
2406 error_noexit "Setting \"lov.stripesize\""
2409 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
2410 error_noexit "Setting \"mdd.atime_diff\""
2414 echo "== perm cmd = '$PERM_CMD' =="
2415 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
2416 error_noexit "Setting OST \"failover.node\""
2420 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
2421 error_noexit "Setting MDT \"failover.node\""
2425 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
2426 error_noexit "Setting \"max_dirty_mb\""
2429 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
2430 error_noexit "Setting \"max_rpcs_in_flight\""
2433 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
2434 error_noexit "Setting \"lov.stripesize\""
2437 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
2438 error_noexit "Setting \"mdd.atime_diff\""
2443 $r $LCTL pool_new $fsname.interop || {
2444 error_noexit "Setting \"interop\""
2448 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
2449 echo "== ff convert ($ff_convert) =="
2450 $r $LCTL lfsck_start -M $fsname-OST0000 || {
2451 error_noexit "Start OI scrub on OST0"
2455 # The oi_scrub should be on ost1, but for test_32(),
2456 # all on the SINGLEMDS.
2457 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
2458 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2459 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
2460 error_noexit "Failed to get the expected 'completed'"
2464 local UPDATED=$($r $LCTL get_param -n \
2465 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2466 awk '/^updated/ { print $2 }')
2467 [ $UPDATED -ge 1 ] || {
2468 error_noexit "Only $UPDATED objects have been converted"
2473 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2474 echo "== dne upgrate ($dne_upgrade) or mdt2 available =="
2475 if [[ $PERM_CMD =~ "set_param" ]]; then
2476 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2477 error_noexit "Setting MDT1 \"failover.node\""
2481 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2482 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2485 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2486 error_noexit "Setting MDT1 \"lov.stripesize\""
2490 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2491 error_noexit "Setting MDT1 \"failover.node\""
2494 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2495 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2498 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2499 error_noexit "Setting MDT1 \"lov.stripesize\""
2505 if [ "$writeconf" ]; then
2506 echo "== writeconf and client mount =="
2507 $MOUNT_CMD $nid:/$fsname -o user_xattr $tmp/mnt/lustre || {
2508 error_noexit "Mounting the client"
2512 shall_cleanup_lustre=true
2513 $r $LCTL set_param debug="$PTLDEBUG"
2516 $mdt2_is_available || pool_dir=$tmp/mnt/lustre/pool_dir
2517 local pool_list=$pool_dir/pool_list
2518 if (( $(version_code $img_commit) >=
2519 $(version_code 2.13.56) )) &&
2520 [[ "$pool_quota_upgrade" == "yes" ]] &&
2521 [[ -s $pool_list ]]; then
2522 local pool_name=$(head -1 $pool_list | awk '{print $2}')
2524 $r $LCTL pool_new $pool_name || {
2525 error_noexit "create $pool_name failed"
2529 $r $LCTL pool_add $pool_name $fsname-OST[0-1/1] || {
2530 error_noexit "add $pool_name failed"
2534 $r $LCTL pool_list $pool_name || {
2535 error_noexit "list $pool_name failed"
2540 t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2541 error_noexit "verify quota failed"
2545 # fscrypt file data #
2546 if ! $mdt2_is_available; then
2547 fscrypt_data_dir=$tmp/mnt/lustre/fscrypt_data_dir
2548 fscrypt_data_pass=$tmp/mnt/lustre/fscrypt_data_pass
2550 if (( $MDS1_VERSION >= $(version_code 2.13.55) )) &&
2551 which fscrypt && [[ -s $fscrypt_data_pass ]]; then
2553 yes | fscrypt setup --force --verbose ||
2554 error "fscrypt global setup failed"
2555 sed -i 's/\(.*\)policy_version\(.*\):\(.*\)\"[0-9]*\"\(.*\)/\1policy_version\2:\3"2"\4/' \
2558 local unlock_status=$(fscrypt status $fscrypt_data_dir |
2559 awk '/Unlocked:/{print $2}')
2561 if [[ $unlock_status == No ]]; then
2562 local lockedfiles=( $(find $fscrypt_data_dir/ \
2563 -maxdepth 1 -type f) )
2565 for ((i = 0; i < ${#lockedfiles[@]}; i++)); do
2566 ! md5sum ${lockedfiles[i]} ||
2567 error "read ${lockedfiles[i]} should fail without key"
2570 ! touch $fscrypt_data_dir/nokey ||
2571 error "touch $fscrypt_data_dir/nokey should fail without key"
2573 cat $fscrypt_data_pass |
2574 fscrypt unlock --verbose $fscrypt_data_dir ||
2575 error "unlock $fscrypt_data_dir failed"
2577 for ((i = 0; i < ${#lockedfiles[@]}; i++)); do
2578 md5sum ${lockedfiles[i]} ||
2579 error "read ${lockedfiles[i]} failed"
2584 # fscrypt file name #
2585 if ! $mdt2_is_available; then
2586 fscrypt_name_dir=$tmp/mnt/lustre/fscrypt_name_dir
2587 fscrypt_name_pass=$tmp/mnt/lustre/fscrypt_name_pass
2589 if (( $MDS1_VERSION >= $(version_code 2.14.57) )) &&
2590 which fscrypt && [[ -s $fscrypt_name_pass ]]; then
2592 local unlock_status=$(fscrypt status $fscrypt_name_dir |
2593 awk '/Unlocked:/{print $2}')
2595 if [[ $unlock_status == No ]]; then
2596 ls -l $fscrypt_name_dir ||
2597 error "ls $fscrypt_name_dir failed"
2598 ! ls $fscrypt_name_dir/fscrypt_name_file ||
2599 error "ls $fscrypt_name_dir/fscrypt_name_file should fail"
2600 ! ls $fscrypt_name_dir/fscrypt_name_dom ||
2601 error "ls $fscrypt_name_dir/fscrypt_name_dom should fail"
2603 cat $fscrypt_name_pass |
2604 fscrypt unlock --verbose $fscrypt_name_dir ||
2605 error "unlock $fscrypt_name_dir failed"
2607 ls $fscrypt_name_dir/fscrypt_name_file ||
2608 error "ls $fscrypt_name_dir/fscrypt_name_file failed"
2609 ls $fscrypt_name_dir/fscrypt_name_dom ||
2610 error "ls $fscrypt_name_dir/fscrypt_name_dom failed"
2614 if $r test -f $tmp/list; then
2615 echo "== list verification =="
2617 # There is not a Test Framework API to copy files to or
2618 # from a remote node.
2620 # LU-2393 - do both sorts on same node to ensure locale
2622 local list_file=$tmp/list
2624 if $mdt2_is_available; then
2625 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2626 $r test -f $tmp/list2; then
2627 list_file=$tmp/list2
2628 pushd $tmp/mnt/lustre/striped_dir_old
2630 pushd $tmp/mnt/lustre/remote_dir
2633 pushd $tmp/mnt/lustre
2635 $r cat $list_file | sort -k 6 >$tmp/list.orig
2636 BLOCKSIZE=1024 ls -Rni --time-style=+%s | sort -k 6 |
2637 sed 's/\. / /' >$tmp/list || {
2643 # 32-bit and 64-bit clients use different algorithms to
2644 # convert FIDs into inode numbers. Hence, remove the
2645 # inode numbers from the lists, if the original list was
2646 # created on an architecture with different number of
2649 if [ $(t32_bits_per_long $(uname -m)) != \
2650 $(t32_bits_per_long $img_arch) ]; then
2651 echo "Different number of bits per \"long\"" \
2652 "from the disk image"
2653 for list in list.orig list; do
2654 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2658 if ! diff -ub $tmp/list.orig $tmp/list; then
2659 error_noexit "list verification failed"
2663 echo "== list verification skipped =="
2666 #non-dom upgrade to dom
2667 if [ "$dom_upgrade" != "no" ]; then
2668 echo "== dom upgrade =="
2669 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2670 error_noexit "Verify DoM creation"
2673 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2674 error_noexit "Verify a DoM file"
2677 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2678 count=1 conv=fsync || {
2679 error_noexit "Cannot write to DoM file"
2682 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2683 error_noexit "DoM: bad size after write"
2686 rm $tmp/mnt/lustre/dom
2688 set_persistent_param_and_check mds \
2689 "lod.*MDT0000*.dom_stripesize" \
2690 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2691 error_noexit "Changing \"dom_stripesize\""
2697 #$LFS setstripe -E 1M -L mdt -E -1 -S 4M $dom_file
2698 if [ "$dom_new_upgrade" != "no" ]; then
2699 if ! $mdt2_is_available; then
2700 dom_file=$tmp/mnt/lustre/dom_dir/dom_file
2702 echo "== check DoM file can be accessed =="
2703 [ $($LFS getstripe -I1 -L $dom_file) == "mdt" ] || {
2704 error_noexit "Verify a DoM file"
2707 [ $(stat -c%s $dom_file) == $((2 * 1024 * 1024)) ] || {
2708 error_noexit "DoM: bad size after write"
2713 if [ "$flr_upgrade" != "no" ]; then
2714 if ! $mdt2_is_available; then
2715 flr_file=$tmp/mnt/lustre/flr_dir/flr_file
2717 local mirror_count=$($LFS getstripe -N $flr_file)
2718 echo "== check FLR file =="
2719 [ $mirror_count == 2 ] || {
2720 error_noexit "FLR mirror count wrong"
2725 if [ "$dne_upgrade" != "no" ]; then
2726 echo "== dne upgrade striped_dir =="
2727 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2728 error_noexit "set striped dir failed"
2731 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2733 pushd $tmp/mnt/lustre
2734 tar -c --exclude=./striped_dir \
2735 --exclude=./striped_dir_old \
2736 --exclude=./remote_dir -f - .|
2737 tar -xvf - -C striped_dir 1>/dev/null || {
2738 error_noexit "cp to striped dir failed"
2744 if [ "$pfl_upgrade" != "no" ]; then
2751 echo "== check PFL file =="
2752 if ! $mdt2_is_available; then
2753 pfl_file=$tmp/mnt/lustre/pfl_dir/pfl_file
2755 comp_cnt=$($LFS getstripe --component-count $pfl_file)
2756 [ $comp_cnt == 2 ] || {
2757 error_noexit "wrong comp_cnt $comp_cnt"
2761 comp_size=$($LFS getstripe -I1 -E $pfl_file)
2762 [ $comp_size == 2097152 ] || {
2763 error_noexit "wrong component size $comp_size"
2767 comp_id=$($LFS getstripe -I1 -i $pfl_file)
2768 [ $comp_id == 0 ] || {
2769 error_noexit "wrong comp id $comp_id"
2773 comp_id=$($LFS getstripe -I2 -i $pfl_file)
2774 [ $comp_id -eq 1 ] || {
2775 error_noexit "wrong comp id $comp_id"
2779 stripe_size=$($LFS getstripe -I1 -S $pfl_file)
2780 [ $stripe_size -eq 1048576 ] || {
2781 error_noexit "wrong stripe size $stripe_size"
2785 stripe_size=$($LFS getstripe -I2 -S $pfl_file)
2786 [ $comp_size -eq 2097152 ] || {
2787 error_noexit "wrong component size $comp_size"
2792 local large_xattr_dir=$tmp/mnt/lustre/large_xattr_test_dir
2794 if [[ -d $large_xattr_dir ]]; then
2795 echo "== check Large EA =="
2796 local xattr_file=$large_xattr_dir/large_xattr_file
2798 xattr_val=$(getfattr --only-values\
2799 -n user.fooattr $xattr_file) || {
2800 error_noexit "Large EA cannot be read"
2804 [[ $xattr_val == $(printf "%c" {1..4096}) ]] || {
2805 error_noexit "Wrong large EA value"
2810 if [ "$project_quota_upgrade" != "no" ]; then
2811 if ! $mdt2_is_available; then
2812 quota_dir=$tmp/mnt/lustre/project_quota_dir
2816 echo "== check Project Quota =="
2817 hardlimit=$(get_project_quota -p $T32_PRJID global 3 \
2819 [ $hardlimit == $T32_PROLIMIT ] || {
2820 error_noexit "wrong hardlimit $hardlimit"
2826 $mdt2_is_available || pool_dir=$tmp/mnt/lustre/pool_dir
2827 local pool_list=$pool_dir/pool_list
2828 local pool_file=$pool_dir/pool_file
2829 if (( $(version_code $img_commit) >=
2830 $(version_code 2.13.56) )) &&
2831 [[ "$pool_quota_upgrade" == "yes" ]] &&
2832 [[ -s $pool_list ]]; then
2833 local pool_name=$(head -1 $pool_list | awk '{print $2}')
2834 local act_pool_list=$tmp/pool_list
2836 $r "$LCTL pool_list $pool_name" > $act_pool_list || {
2837 rm -f $act_pool_list
2838 error_noexit "pool_list $pool_name failed"
2842 cmp --verbose $pool_list $act_pool_list || {
2843 rm -f $act_pool_list
2844 error_noexit "OST pool list, act:$act_pool_list, exp:$pool_list"
2847 rm -f $act_pool_list
2849 local exp_qpool=${pool_name##$fsname.}
2850 local act_qpool=$($LFS getstripe -p $pool_file)
2851 [[ -n "$act_qpool" ]] || {
2852 error_noexit "no OST pool on $pool_file"
2856 [[ "$act_qpool" == "$exp_qpool" ]] || {
2857 error_noexit "OST pool name, act:$act_qpool, exp:$exp_qpool"
2862 # If it is upgrade from DNE (2.5), then rename the remote dir,
2863 # which is created in 2.5 to striped dir.
2864 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2865 echo "== rename remote_dir =="
2866 stripe_index=$($LFS getdirstripe -i \
2867 $tmp/mnt/lustre/remote_dir)
2869 [[ $stripe_index -eq 1 ]] || {
2870 error_noexit "get index \"$stripe_index\"" \
2871 "from remote dir failed"
2874 mv $tmp/mnt/lustre/remote_dir \
2875 $tmp/mnt/lustre/striped_dir/ || {
2876 error_noexit "mv remote dir failed"
2881 # If it is upgraded from DNE (2.7), then move the striped dir
2882 # which was created in 2.7 to the new striped dir.
2883 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2884 echo "== rename striped dir =="
2885 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2886 stripe_count=$($LFS getdirstripe -c \
2887 $tmp/mnt/lustre/striped_dir_old)
2888 [[ $stripe_count -eq 2 ]] || {
2889 error_noexit "get count $stripe_count" \
2890 "from striped dir failed"
2893 mv $tmp/mnt/lustre/striped_dir_old \
2894 $tmp/mnt/lustre/striped_dir/ || {
2895 error_noexit "mv striped dir failed"
2901 $r $LCTL set_param -n osd*.*.force_sync=1
2902 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2903 error_noexit "dd failed"
2906 rm -rf $tmp/mnt/lustre/tmp_file || {
2907 error_noexit "rm failed"
2911 if $r test -f $tmp/sha1sums; then
2912 echo "== checking sha1sums =="
2913 # LU-2393 - do both sorts on same node to ensure locale
2915 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2917 sed -i '/fscrypt_.*_dir/d' $tmp/sha1sums.orig
2918 if [[ "$dne_upgrade" != "no" ]]; then
2919 if [[ -d $tmp/mnt/lustre/striped_dir/remote_dir ]]; then
2920 pushd $tmp/mnt/lustre/striped_dir/remote_dir
2922 pushd $tmp/mnt/lustre/striped_dir
2924 elif [[ "$pfl_upgrade" != "no" ]] ||
2925 [[ "$flr_upgrade" != "no" ]] ||
2926 [[ "$dom_new_upgrade" != "no" ]] ||
2927 [[ "$project_quota_upgrade" != "no" ]] ||
2928 [[ -d $tmp/mnt/lustre/remote_dir ]]; then
2929 pushd $tmp/mnt/lustre/remote_dir
2931 pushd $tmp/mnt/lustre
2934 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2935 ! -name .lustre -type f -exec sha1sum {} \; |
2936 sort -k 2 >$tmp/sha1sums || {
2938 error_noexit "sha1sum"
2944 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2945 echo "==** find $save files start **=="
2946 find $save -type f -ls
2947 echo "==** find $save files finish **=="
2948 error_noexit "sha1sum verification failed"
2952 # if upgrade from DNE(2.5), then check remote directory
2953 # if upgrade from DNE(2.7), then check striped directory
2954 if $mdt2_is_available &&
2955 [[ "$dne_upgrade" != "no" ]]; then
2956 echo "== mdt2 upgrade sha1sum check =="
2957 local new_dir="$tmp/mnt/lustre/striped_dir"
2958 local striped_dir_old="$new_dir/striped_dir_old"
2960 local dir_list="$new_dir/remote_dir"
2961 [[ ! -d $triped_dir_old ]] ||
2962 dir_list+=" $striped_dir_old"
2964 for dir in $dir_list; do
2965 echo "== dir = $dir =="
2967 find ! -name .lustre -type f \
2968 -exec sha1sum {} \; |
2969 sort -k 2 >$tmp/sha1sums || {
2972 error_noexit "sha1sum"
2976 if ! diff -ub $tmp/sha1sums.orig \
2979 error_noexit "sha1sum $dir" \
2986 echo "== sha1sum verification skipped =="
2989 # PFL write test after sha1sum check
2990 if [ "$pfl_upgrade" != "no" ]; then
2991 local rw_len=$((3 * 1034 * 1024))
2993 if ! $mdt2_is_available; then
2994 pfl_file=$tmp/mnt/lustre/pfl_dir/pfl_file
2996 small_write $pfl_file $rw_len || {
2997 error_noexit "PFL RW Failed"
3002 if [ "$dne_upgrade" != "no" ]; then
3003 rm -rf $tmp/mnt/lustre/striped_dir || {
3004 error_noexit "remove remote dir failed"
3009 # migrate files/dirs to remote MDT, then move them back
3010 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
3011 $dne_upgrade != "no" ]; then
3012 $r $LCTL set_param -n \
3013 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
3015 echo "== test migration =="
3016 pushd $tmp/mnt/lustre
3017 for dir in $(find ! -name .lustre ! -name . -type d); do
3018 mdt_index=$($LFS getdirstripe -i $dir)
3019 stripe_cnt=$($LFS getdirstripe -c $dir)
3020 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
3021 $LFS migrate -m 1 $dir || {
3023 error_noexit "migrate MDT1 failed"
3029 for dir in $(find ! -name . ! -name .lustre -type d); do
3030 mdt_index=$($LFS getdirstripe -i $dir)
3031 stripe_cnt=$($LFS getdirstripe -c $dir)
3032 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
3033 $LFS migrate -m 0 $dir || {
3035 error_noexit "migrate MDT0 failed"
3044 # When adding new data verification tests, please check for
3045 # the presence of the required reference files first, like
3046 # the "sha1sums" and "list" tests above, to avoid the need to
3047 # regenerate every image for each test addition.
3050 nrpcs_orig=$($LCTL get_param \
3051 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
3052 error_noexit "Getting \"max_rpcs_in_flight\""
3055 nrpcs=$((nrpcs_orig + 5))
3057 set_persistent_param_and_check client \
3058 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
3059 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
3060 error_noexit "Changing \"max_rpcs_in_flight\""
3064 umount $tmp/mnt/lustre || {
3065 error_noexit "Unmounting the client"
3068 shall_cleanup_lustre=false
3070 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
3071 error_noexit "Mounting the client"
3075 if [ "$mds1_FSTYPE" == ldiskfs -a \
3076 "$project_upgrade" != "no" ]; then
3077 ! $LFS project -d -p 1 $tmp/mnt/lustre/* &&
3078 error_noexit "set project failed" &&
3082 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3083 error "MDD orphan cleanup thread not quit"
3085 umount $tmp/mnt/lustre || {
3086 error_noexit "Unmounting the client"
3090 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
3091 $r $UMOUNT $tmp/mnt/mdt1 || {
3092 error_noexit "Unmounting the MDT2"
3095 if [[ "$mds1_FSTYPE" == zfs ]]; then
3096 $r "$ZPOOL export t32fs-mdt2"
3098 shall_cleanup_mdt1=false
3101 $r $UMOUNT $tmp/mnt/mdt || {
3102 error_noexit "Unmounting the MDT"
3105 if [[ "$mds1_FSTYPE" == zfs ]]; then
3106 $r "$ZPOOL export t32fs-mdt1"
3108 shall_cleanup_mdt=false
3110 $r $UMOUNT $tmp/mnt/ost || {
3111 error_noexit "Unmounting the OST"
3114 if $ost2_is_available; then
3115 $r $UMOUNT $tmp/mnt/ost1 || {
3116 error_noexit "Unmounting the OST1"
3119 shall_cleanup_ost1=false
3122 if [[ $ost1_FSTYPE == zfs ]]; then
3123 $r "$ZPOOL export t32fs-ost1"
3124 if $ost2_is_available; then
3125 $r "$ZPOOL export t32fs-ost2"
3128 shall_cleanup_ost=false
3130 t32_reload_modules $node || {
3131 error_noexit "Reloading modules"
3135 if [[ "$mds1_FSTYPE" == zfs ]]; then
3136 local poolname=t32fs-mdt1
3138 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
3139 $ZPOOL import -f -d $tmp $poolname"
3141 # upgrade zpool to latest supported features,
3142 # including dnode quota accounting in 0.7.0
3143 $r "$ZPOOL upgrade $poolname"
3146 # mount a second time to make sure we didnt leave upgrade flag on
3147 $r $TUNEFS --dryrun $mdt_dev || {
3149 error_noexit "tunefs.lustre before remounting the MDT"
3153 mopts=exclude=$fsname-OST0000
3154 if [ "$mds1_FSTYPE" == ldiskfs ]; then
3157 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
3158 error_noexit "Remounting the MDT"
3161 shall_cleanup_mdt=true
3171 for tarball in $tarballs; do
3172 banner "testing $tarball upgrade"
3173 t32_test $tarball || let "rc += $?"
3177 run_test 32a "Upgrade (not live)"
3185 for tarball in $tarballs; do
3186 banner "testing $tarball upgrade with writeconf"
3187 t32_test $tarball writeconf || let "rc += $?"
3191 run_test 32b "Upgrade with writeconf"
3199 for tarball in $tarballs; do
3200 banner "testing $tarball upgrade with DNE"
3202 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
3206 run_test 32c "dne upgrade test"
3214 for tarball in $tarballs; do
3215 banner "testing $tarball with filter_fid upgrade"
3216 ff_convert=yes t32_test $tarball || rc=$?
3220 run_test 32d "convert filter_fid upgrade test"
3223 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
3224 skip "Need MDS version at least 2.10.56"
3231 for tarball in $tarballs; do
3232 [[ "$tarball" =~ "2_9" ]] ||
3233 { echo "skip $(basename $tarball)"; continue; }
3235 banner "testing $tarball upgrade with DoM"
3236 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
3240 run_test 32e "dom upgrade test"
3243 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
3244 skip "Need MDS version at least 2.10.56"
3251 for tarball in $tarballs; do
3252 [[ "$tarball" =~ "2_10" ]] ||
3253 { echo "skip $(basename $tarball)"; continue; }
3254 pfl_upgrade=yes project_quota_upgrade=yes \
3255 t32_test $tarball writeconf || let "rc += $?"
3259 run_test 32f "pfl upgrade test"
3262 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
3263 skip "Need MDS version at least 2.10.56"
3270 for tarball in $tarballs; do
3271 [[ $tarball =~ "2_12" ]] ||
3272 { echo "skip $(basename $tarball)"; continue; }
3273 flr_upgrade=yes dom_new_upgrade=yes \
3274 t32_test $tarball writeconf || let "rc += $?"
3278 run_test 32g "flr/dom upgrade test"
3281 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
3282 skip "Need MDS >= 2.13.56 for OST pool quotas"
3289 for tarball in $tarballs; do
3290 [[ $tarball =~ "2_15" ]] ||
3291 { echo "skip $(basename $tarball)"; continue; }
3292 pool_quota_upgrade=yes t32_test $tarball writeconf ||
3297 run_test 32h "pool quota upgrade test"
3300 (( $MDS1_VERSION >= $(version_code 2.13.55) )) ||
3301 skip "Need MDS >= 2.13.55 for fscrypt data encryption"
3308 for tarball in $tarballs; do
3309 [[ $tarball =~ "2_15" && $tarball =~ "ldiskfs" ]] ||
3310 { echo "skip $(basename $tarball)"; continue; }
3311 fscrypt_data_upgrade=yes t32_test $tarball writeconf ||
3316 run_test 32i "fscrypt data encryption upgrade test"
3319 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
3320 skip "Need MDS >= 2.14.56 for fscrypt filename encryption"
3327 for tarball in $tarballs; do
3328 [[ $tarball =~ "2_15" && $tarball =~ "ldiskfs" ]] ||
3329 { echo "skip $(basename $tarball)"; continue; }
3330 fscrypt_name_upgrade=yes t32_test $tarball writeconf ||
3335 run_test 32j "fscrypt filename encryption upgrade test"
3337 test_33a() { # bug 12333, was test_33
3338 local FSNAME2=test-$testnum
3340 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3343 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
3345 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
3346 local dev=${SINGLEMDS}_dev
3347 local MDSDEV=${!dev}
3349 is_blkdev $SINGLEMDS $MDSDEV &&
3350 skip_env "mixed loopback and real device not working"
3353 local fs2mdsdev=$(mdsdevname 1_2)
3354 local fs2ostdev=$(ostdevname 1_2)
3355 local fs2mdsvdev=$(mdsvdevname 1_2)
3356 local fs2ostvdev=$(ostvdevname 1_2)
3358 if [ "$mds1_FSTYPE" == ldiskfs ]; then
3359 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
3362 if combined_mgs_mds; then
3363 local mgs_flag="--mgs"
3366 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
3367 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
3369 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
3370 --fsname=${FSNAME2} --index=0x1fff --reformat $fs2ostdev \
3371 $fs2ostvdev || exit 10
3373 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
3374 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
3376 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3377 do_facet mgs "$PERM_CMD timeout=200" ||
3378 error "$PERM_CMD timeout=200 failed"
3380 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
3381 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
3383 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
3384 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
3387 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
3388 $LFS getstripe $MOUNT2/hosts ||
3389 error "$LFS getstripe $MOUNT2/hosts failed"
3393 if (( "$MGS_VERSION" >= $(version_code 2.15.51) &&
3394 "$MDS1_VERSION" >= $(version_code 2.15.51) )); then
3395 # test lctl del_ost on large index
3396 do_facet mgs "$LCTL del_ost -t ${FSNAME2}-OST1fff" ||
3397 error "del_ost failed with $?"
3398 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 ||
3399 error "$MOUNT_CMD failed"
3401 $LFS df | grep -q OST1fff &&
3402 error "del_ost did not remove OST1fff!"
3408 cleanup_nocli || error "cleanup_nocli failed with $?"
3410 run_test 33a "Mount ost with a large index number"
3412 test_33b() { # was test_34
3415 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
3416 # Drop lock cancelation reply during umount
3417 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
3418 do_facet client $LCTL set_param fail_loc=0x80000304
3419 #lctl set_param debug=-1
3420 umount_client $MOUNT
3421 cleanup || error "cleanup failed with $?"
3423 run_test 33b "Drop cancel during umount"
3426 (( MDS1_VERSION >= $(version_code 2.15.57) )) ||
3427 skip "Need MDS version at least 2.15.57"
3428 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3429 local tstid=${TSTID:-"$(id -u $TSTUSR)"}
3431 local qpool="qpool1"
3433 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
3435 local fs2mdsdev=$(mdsdevname 1_2)
3436 local fs2ostdev=$(ostdevname 1_2)
3437 local fs2mdsvdev=$(mdsvdevname 1_2)
3438 local fs2ostvdev=$(ostvdevname 1_2)
3440 if [ "$mds1_FSTYPE" == ldiskfs ]; then
3441 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
3444 if combined_mgs_mds; then
3445 local mgs_flag="--mgs"
3449 stack_trap unload_modules_conf
3451 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME} \
3452 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
3454 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
3455 --fsname=${FSNAME} --index=0x7c6 --reformat $fs2ostdev \
3456 $fs2ostvdev || exit 10
3459 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
3460 stack_trap "stop fs2mds -f"
3461 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
3462 stack_trap "stop fs2ost -f"
3464 mount_client $MOUNT || error "client start failed"
3465 stack_trap "umount_client $MOUNT"
3466 mkdir_on_mdt0 $DIR/$tdir || error "cannot create $DIR/$tdir"
3467 chmod 0777 $DIR/$tdir || error "chown failed"
3468 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3469 do_facet mgs $PERM_CMD \
3470 osd-*.$FSNAME-OST*.quota_slave.enable=$QUOTA_TYPE
3472 do_facet mgs $PERM_CMD $FSNAME.quota.ost=$QUOTA_TYPE ||
3473 error "set ost quota type failed"
3476 local old_MDSCOUNT=$MDSCOUNT
3478 stack_trap "MDSCOUNT=$old_MDSCOUNT"
3480 pool_add $qpool || error "pool_add failed"
3481 pool_add_targets $qpool 0x7c6
3483 $LFS setquota -u $tstid -B20M -b 0 $MOUNT
3484 $LFS setquota -g $tstid -B20M -b 0 $MOUNT
3485 $LFS setquota -u $tstid -B20M -b 0 --pool $qpool $MOUNT
3486 $LFS setquota -g $tstid -B20M -b 0 --pool $qpool $MOUNT
3488 for i in {1..10}; do
3489 runas -u $tstid -g $tstid dd if=/dev/zero of=$DIR/$tdir/f1 \
3490 bs=1M count=30 oflag=direct
3496 #umount_client $MOUNT || error "client start failed"
3499 #cleanup_nocli || error "cleanup_nocli failed with $?"
3501 run_test 33c "Mount ost with a large index number"
3507 mkdir_on_mdt0 $DIR/$tdir || error "cannot create $DIR/$tdir"
3509 $LFS setquota -p 1 -I1K $MOUNT
3511 do_facet mgs $LCTL set_param osd*.*.quota_slave.enabled=p
3512 $LFS project -p 1 $DIR/
3514 run_test 33d "Don't panic when enable project quota"
3518 do_facet client "bash runmultiop_bg_pause $DIR/file O_c"
3519 manual_umount_client
3521 do_facet client killall -USR1 multiop
3522 if [ $rc -eq 0 ]; then
3523 error "umount not fail!"
3526 cleanup || error "cleanup failed with rc $?"
3528 run_test 34a "umount with opened file should be fail"
3532 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3533 stop_mds || error "Unable to stop MDS"
3535 manual_umount_client --force || error "mtab after failed umount with $?"
3537 cleanup || error "cleanup failed with $?"
3539 run_test 34b "force umount with failed mds should be normal"
3543 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3544 stop_ost || error "Unable to stop OST1"
3546 manual_umount_client --force || error "mtab after failed umount with $?"
3548 cleanup || error "cleanup failed with $?"
3550 run_test 34c "force umount with failed ost should be normal"
3552 test_35a() { # bug 12459
3555 DBG_SAVE="`$LCTL get_param -n debug`"
3556 $LCTL set_param debug="ha"
3558 log "Set up a fake failnode for the MDS"
3560 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
3561 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
3563 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3564 do_facet mgs "$PERM_CMD \
3565 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
3566 error "Setting mdc.*${device}*.import=connection=\
3567 $(h2nettype $FAKENID) failed."
3569 do_facet mgs "$PERM_CMD \
3570 ${device}.failover.node=$(h2nettype $FAKENID)" ||
3571 error "Setting ${device}.failover.node=\
3572 $(h2nettype $FAKENID) failed."
3574 log "Wait for RECONNECT_INTERVAL seconds (10s)"
3577 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
3580 log "Stopping the MDT: $device"
3581 stop_mdt 1 || error "MDT0 stop fail"
3583 df $MOUNT > /dev/null 2>&1 &
3585 log "Restarting the MDT: $device"
3586 start_mdt 1 || error "MDT0 start fail"
3587 log "Wait for df ($DFPID) ... "
3590 $LCTL set_param debug="$DBG_SAVE"
3592 # retrieve from the log the first server that the client tried to
3593 # contact after the connection loss
3594 $LCTL dk $TMP/lustre-log-$TESTNAME.log
3595 NEXTCONN=`awk "/${MSG}/ {start = 1;}
3596 /import_select_connection.*$device-mdc.* using connection/ {
3598 if (\\\$NF ~ /$FAKENID/)
3604 }" $TMP/lustre-log-$TESTNAME.log`
3605 [ "$NEXTCONN" != "0" ] &&
3606 error "Tried to connect to ${NEXTCONN} not last active server"
3607 cleanup || error "cleanup failed with $?"
3608 # remove nid settings
3609 writeconf_or_reformat
3611 run_test 35a "Reconnect to the last active server first"
3613 test_35b() { # bug 18674
3614 remote_mds || skip "local MDS"
3618 $LCTL set_param debug="ha"
3620 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
3623 log "Set up a fake failnode for the MDS"
3625 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
3626 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
3628 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3629 do_facet mgs "$PERM_CMD \
3630 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
3631 error "Set mdc.*${device}*.import=connection=\
3632 $(h2nettype $FAKENID) failed"
3634 do_facet mgs "$PERM_CMD \
3635 ${device}.failover.node=$(h2nettype $FAKENID)" ||
3636 error "Set ${device}.failover.node=\
3637 $(h2nettype $FAKENID) failed"
3640 local at_max_saved=0
3641 # adaptive timeouts may prevent seeing the issue
3642 if at_is_enabled; then
3643 at_max_saved=$(at_max_get mds)
3644 at_max_set 0 mds client
3648 mkdir_on_mdt0 $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3650 log "Injecting EBUSY on MDS"
3651 # Setting OBD_FAIL_MDS_RESEND=0x136
3652 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
3653 error "unable to set param fail_loc=0x80000136"
3655 $LCTL set_param mdc.${FSNAME}*.stats=clear
3657 log "Creating a test file and stat it"
3658 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
3659 stat $MOUNT/$tdir/$tfile
3661 log "Stop injecting EBUSY on MDS"
3662 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
3663 error "unable to set param fail_loc=0"
3664 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
3667 # restore adaptive timeout
3668 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
3670 $LCTL dk $TMP/lustre-log-$TESTNAME.log
3672 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
3673 awk '/mds_connect/{print $2}')
3675 # retrieve from the log if the client has ever tried to
3676 # contact the fake server after the loss of connection
3677 FAILCONN=`awk "BEGIN {ret = 0;}
3678 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
3680 if (\\\$NF ~ /$FAKENID/) {
3685 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
3687 [ "$FAILCONN" == "0" ] &&
3688 error "The client reconnection has not been triggered"
3689 [ "$FAILCONN" == "2" ] &&
3690 error "Primary server busy, client reconnect to failover failed"
3693 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
3694 # Reconnects are supposed to be rate limited to one every 5s
3695 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
3696 error "Too many reconnects $CONNCNT"
3698 cleanup || error "cleanup failed with $?"
3699 # remove nid settings
3700 writeconf_or_reformat
3702 run_test 35b "Continue reconnection retries, if the active server is busy"
3705 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
3707 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
3711 local FSNAME2=test1234
3712 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3714 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
3716 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
3717 is_blkdev $SINGLEMDS $MDSDEV &&
3718 skip_env "mixed loopback and real device not working"
3721 local fs2mdsdev=$(mdsdevname 1_2)
3722 local fs2ostdev=$(ostdevname 1_2)
3723 local fs3ostdev=$(ostdevname 2_2)
3724 local fs2mdsvdev=$(mdsvdevname 1_2)
3725 local fs2ostvdev=$(ostvdevname 1_2)
3726 local fs3ostvdev=$(ostvdevname 2_2)
3729 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
3730 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
3731 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
3732 # different one than the default value here.
3733 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
3734 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
3735 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
3736 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
3738 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
3739 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
3740 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
3741 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
3742 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
3744 sleep 5 # until 11778 fixed
3746 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
3748 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
3749 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
3750 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
3751 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
3752 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
3753 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
3754 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
3755 DFTOTAL=$(echo $STRING | cut -d, -f1)
3756 DFUSED=$(echo $STRING | cut -d, -f2)
3757 DFAVAIL=$(echo $STRING | cut -d, -f3)
3758 DFFREE=$(($DFTOTAL - $DFUSED))
3760 ALLOWANCE=$((64 * $OSTCOUNT))
3762 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3763 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3764 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3767 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3768 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3769 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
3772 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3773 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3774 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3779 stop fs3ost -f || error "unable to stop OST3"
3780 stop fs2ost -f || error "unable to stop OST2"
3781 stop fs2mds -f || error "unable to stop second MDS"
3782 unload_modules_conf || error "unable unload modules"
3785 run_test 36 "df report consistency on OSTs with different block size"
3788 local mntpt=$(facet_mntpt $SINGLEMDS)
3789 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
3790 local mdsdev_sym="$TMP/sym_mdt.img"
3791 local opts=$MDS_MOUNT_OPTS
3794 if [ "$mds1_FSTYPE" != ldiskfs ]; then
3795 skip "ldiskfs only test"
3798 echo "MDS : $mdsdev"
3799 echo "SYMLINK : $mdsdev_sym"
3800 do_facet $SINGLEMDS rm -f $mdsdev_sym
3802 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
3804 echo "mount symlink device - $mdsdev_sym"
3806 if ! do_facet $SINGLEMDS test -b $mdsdev; then
3807 opts=$(csa_add "$opts" -o loop)
3811 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
3812 $mdsdev_sym $mntpt 2>&1)
3815 echo mount_op=$mount_op
3817 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
3819 if $(echo $mount_op | grep -q "unable to set tunable"); then
3820 error "set tunables failed for symlink device"
3823 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
3825 run_test 37 "verify set tunables works for symlink device"
3827 test_38() { # bug 14222
3828 local mntpt=$(facet_mntpt $SINGLEMDS)
3833 local SRC="/etc /bin"
3834 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
3836 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
3838 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3839 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
3840 error "copying $SRC to $DIR/$tdir"
3842 umount_client $MOUNT || error "umount_client $MOUNT failed"
3843 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
3844 stop_mds || error "Unable to stop MDS"
3845 log "delete lov_objid file on MDS"
3847 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
3849 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
3851 unmount_fstype $SINGLEMDS || error "umount failed (1)"
3853 # check create in mds_lov_connect
3854 start_mds || error "unable to start MDS"
3855 mount_client $MOUNT || error "mount_client $MOUNT failed"
3857 [ $V ] && log "verifying $DIR/$tdir/$f"
3858 diff -q $f $DIR/$tdir/$f || ERROR=y
3860 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
3861 if [ "$ERROR" = "y" ]; then
3862 # check it's updates in sync
3863 umount_client $MOUNT
3865 mount_fstype $SIGNLEMDS
3866 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
3867 unmount_fstype $SINGLEMDS
3868 error "old and new files are different after connect" || true
3870 touch $DIR/$tdir/f2 || error "f2 file create failed"
3872 # check it's updates in sync
3873 umount_client $MOUNT || error "second umount_client $MOUNT failed"
3876 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
3878 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
3879 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
3881 unmount_fstype $SINGLEMDS || error "umount failed (3)"
3883 start_mds || error "unable to start MDS"
3884 mount_client $MOUNT || error "mount_client $MOUNT failed"
3886 [ $V ] && log "verifying $DIR/$tdir/$f"
3887 diff -q $f $DIR/$tdir/$f || ERROR=y
3889 touch $DIR/$tdir/f3 || error "f3 file create failed"
3890 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
3891 umount_client $MOUNT || error "third umount_client $MOUNT failed"
3893 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
3894 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
3895 unmount_fstype $SINGLEMDS || error "umount failed (4)"
3897 [[ "$ERROR" != "y" ]] ||
3898 error "old and new files are different after sync"
3900 log "files compared the same"
3901 cleanup || error "cleanup failed with $?"
3903 run_test 38 "MDS recreates missing lov_objid file from OST data"
3906 [[ -n "$(type -p perl)" ]] || skip_env "need perl for leak_finder.pl"
3910 cleanup || error "cleanup failed with $?"
3911 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
3912 error "memory leak detected" || true
3914 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
3916 test_40() { # bug 15759
3917 start_ost || error "Unable to start OST1"
3918 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
3919 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
3921 cleanup || error "cleanup failed with rc $?"
3923 run_test 40 "race during service thread startup"
3925 test_41a() { #bug 14134
3926 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3927 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3928 skip "Loop devices does not work with nosvc option"
3931 combined_mgs_mds || skip "needs combined MGT and MDT device"
3933 start_mdt 1 -o nosvc -n
3934 if [ $MDSCOUNT -ge 2 ]; then
3935 for num in $(seq 2 $MDSCOUNT); do
3936 start_mdt $num || return
3939 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
3940 start_mdt 1 -o nomgs,force
3941 mount_client $MOUNT || error "mount_client $MOUNT failed"
3944 echo "blah blah" > $MOUNT/$tfile
3947 umount_client $MOUNT || error "umount_client $MOUNT failed"
3948 stop ost1 -f || error "unable to stop OST1"
3949 stop_mds || error "Unable to stop MDS"
3950 stop_mds || error "Unable to stop MDS on second try"
3952 run_test 41a "mount mds with --nosvc and --nomgs"
3955 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3956 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3957 skip "Loop devices does not work with nosvc option"
3960 ! combined_mgs_mds && skip "needs combined mgs device"
3964 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3966 start_mdt 1 -o nosvc -n
3967 if [ $MDSCOUNT -ge 2 ]; then
3968 for num in $(seq 2 $MDSCOUNT); do
3969 start_mdt $num || return
3972 start_ost || error "Unable to start OST1"
3973 start_mdt 1 -o nomgs,force
3974 mount_client $MOUNT || error "mount_client $MOUNT failed"
3977 echo "blah blah" > $MOUNT/$tfile
3978 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
3980 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
3981 stop_ost || error "Unable to stop OST1"
3982 stop_mds || error "Unable to stop MDS"
3983 stop_mds || error "Unable to stop MDS on second try"
3985 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3988 local osts=$(osts_nodes)
3990 (( "$MDS1_VERSION" >= $(version_code 2.15.62.4) )) ||
3991 skip "Need MDS >= 2.15.62.4 for parallel device locking"
3993 # ensure mds1 ost1 have been created even if running sub-test standalone
3996 cleanup || error "cleanup failed"
3998 # using directly mount command instead of start() function to avoid
3999 # any side effect of // with others/externals tools/features
4000 # ("zpool import", ...)
4002 # MDT concurrent start
4004 LOAD_MODULES_REMOTE=true load_modules
4005 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
4006 error "MDT concurrent start: libcfs module not loaded"
4008 local mds1dev=$(mdsdevname 1)
4009 local mds1mnt=$(facet_mntpt mds1)
4010 local mds1opts=$MDS_MOUNT_OPTS
4012 if [[ "$mds1_FSTYPE" == ldiskfs ]] &&
4013 ! do_facet mds1 test -b $mds1dev; then
4014 mds1opts=$(csa_add "$mds1opts" -o loop)
4016 if [[ "$mds1_FSTYPE" == zfs ]]; then
4017 import_zpool mds1 || return ${PIPESTATUS[0]}
4020 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
4021 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
4023 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
4026 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
4031 do_facet mds1 "$LCTL set_param fail_loc=0x0"
4032 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
4033 echo "1st MDT start succeed"
4034 echo "2nd MDT start failed with $rc2"
4035 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
4036 echo "1st MDT start failed with $rc"
4037 echo "2nd MDT start succeed"
4040 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
4043 if [ $MDSCOUNT -ge 2 ]; then
4044 for num in $(seq 2 $MDSCOUNT); do
4045 start_mdt $num || return
4049 # OST concurrent start
4051 do_rpc_nodes $osts "lsmod | grep -q libcfs" ||
4052 error "OST concurrent start: libcfs module not loaded"
4054 local ost1dev=$(ostdevname 1)
4055 local ost1mnt=$(facet_mntpt ost1)
4056 local ost1opts=$OST_MOUNT_OPTS
4058 if [ "$ost1_FSTYPE" == ldiskfs ] &&
4059 ! do_facet ost1 test -b $ost1dev; then
4060 ost1opts=$(csa_add "$ost1opts" -o loop)
4062 if [[ "$ost1_FSTYPE" == zfs ]]; then
4063 import_zpool ost1 || return ${PIPESTATUS[0]}
4066 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
4067 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
4069 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
4072 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
4076 do_facet ost1 "$LCTL set_param fail_loc=0x0"
4077 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
4078 echo "1st OST start succeed"
4079 echo "2nd OST start failed with $rc2"
4080 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
4081 echo "1st OST start failed with $rc"
4082 echo "2nd OST start succeed"
4086 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
4092 # verify everything ok
4097 error "MDT(s) start failed"
4105 error "OST(s) start failed"
4113 error "client start failed"
4120 error "client mount failed"
4124 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
4126 test_42() { #bug 14693
4130 check_mount || error "client was not mounted"
4132 if [[ $PERM_CMD == *"set_param -P"* ]]; then
4133 PARAM="llite.$FSNAME-*.some_wrong_param"
4135 PARAM="$FSNAME.llite.some_wrong_param"
4138 do_facet mgs $PERM_CMD $PARAM=10
4139 umount_client $MOUNT ||
4140 error "unmounting client failed with invalid llite param"
4141 mount_client $MOUNT ||
4142 error "mounting client failed with invalid llite param"
4144 do_facet mgs $PERM_CMD $PARAM=20
4145 cleanup || error "stopping $FSNAME failed with invalid sys param"
4147 check_mount || error "client was not mounted with invalid sys param"
4148 cleanup || error "stopping $FSNAME failed with invalid sys param"
4150 run_test 42 "allow client/server mount/unmount with invalid config param"
4152 test_43a_check_nosquash_nids() {
4155 set_persistent_param_and_check mds1 \
4156 "mdt.$FSNAME-MDT0000.nosquash_nids" \
4157 "$FSNAME-MDTall.mdt.nosquash_nids" \
4159 wait_update $HOSTNAME \
4160 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
4162 error "check llite nosquash_nids failed!"
4164 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
4165 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
4166 error "$ST: root read permission is denied"
4167 echo "$ST: root read permission is granted - ok"
4170 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
4171 error "$ST: root write permission is denied"
4172 echo "$ST: root write permission is granted - ok"
4174 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
4175 rm $DIR/$tdir-rootdir/tfile-1 ||
4176 error "$ST: root unlink permission is denied"
4177 echo "$ST: root unlink permission is granted - ok"
4178 touch $DIR/$tdir-rootdir/tfile-2 ||
4179 error "$ST: root create permission is denied"
4180 echo "$ST: root create permission is granted - ok"
4182 # Re-create test file deleted above in case this function is called
4184 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
4188 [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
4189 skip "Need MDS version at least 2.5.58"
4190 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
4193 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
4194 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
4197 chmod ugo+x $DIR || error "chmod 0 failed"
4198 set_persistent_param_and_check mds1 \
4199 "mdt.$FSNAME-MDT0000.root_squash" \
4200 "$FSNAME.mdt.root_squash" \
4202 wait_update $HOSTNAME \
4203 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
4205 error "check llite root_squash failed!"
4206 set_persistent_param_and_check mds1 \
4207 "mdt.$FSNAME-MDT0000.nosquash_nids" \
4208 "$FSNAME.mdt.nosquash_nids" \
4210 wait_update $HOSTNAME \
4211 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
4213 error "check llite nosquash_nids failed!"
4216 # create set of test files
4218 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
4219 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
4220 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
4222 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
4223 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
4225 mkdir_on_mdt0 $DIR/$tdir-rootdir || error "mkdir failed"
4226 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
4227 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
4229 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
4230 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
4231 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
4234 # check root_squash:
4235 # set root squash UID:GID to RUNAS_ID
4236 # root should be able to access only files owned by RUNAS_ID
4238 set_persistent_param_and_check mds1 \
4239 "mdt.$FSNAME-MDT0000.root_squash" \
4240 "$FSNAME.mdt.root_squash" \
4241 "$RUNAS_ID:$RUNAS_ID"
4242 wait_update $HOSTNAME \
4243 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
4244 "$RUNAS_ID:$RUNAS_ID" ||
4245 error "check llite root_squash failed!"
4247 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
4248 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
4249 error "$ST: root read permission is denied"
4250 echo "$ST: root read permission is granted - ok"
4253 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
4254 error "$ST: root write permission is denied"
4255 echo "$ST: root write permission is granted - ok"
4257 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
4258 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
4259 error "$ST: root read permission is granted"
4260 echo "$ST: root read permission is denied - ok"
4263 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
4264 error "$ST: root write permission is granted"
4265 echo "$ST: root write permission is denied - ok"
4267 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
4268 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
4269 error "$ST: root unlink permission is granted"
4270 echo "$ST: root unlink permission is denied - ok"
4272 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
4273 error "$ST: root create permission is granted"
4274 echo "$ST: root create permission is denied - ok"
4277 # check root_squash is enforced independently
4278 # of client cache content
4280 # access file by USER1, keep access open
4281 # root should be denied access to user file
4283 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
4287 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
4288 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
4289 { kill $pid; error "$ST: root read permission is granted"; }
4290 echo "$ST: root read permission is denied - ok"
4293 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
4294 { kill $pid; error "$ST: root write permission is granted"; }
4295 echo "$ST: root write permission is denied - ok"
4301 # check nosquash_nids:
4302 # put client's NID into nosquash_nids list,
4303 # root should be able to access root file after that
4305 local nidlist=$($LCTL list_nids all | tr '\n' ' ')
4306 nidlist="2@gni $nidlist 192.168.0.[2,10]@tcp"
4307 nidlist=$(echo $nidlist | tr -s ' ' ' ')
4309 test_43a_check_nosquash_nids "$nidlist"
4311 if ! [[ $NETTYPE =~ ^(tcp|o2ib) ]]; then
4312 log "Skip nidmask test for NETTYPE = $NETTYPE"
4313 cleanup || error "cleanup failed with $?"
4317 # check nosquash_nids:
4318 # create a nidmask that contains the client's NID and place it
4319 # into nosquash_nids list.
4320 # root should be able to access root file after that
4321 local interfaces=( $(lnet_if_list) )
4322 local intf netmasks nm
4324 for intf in ${interfaces[@]}; do
4325 nm=$(ip -o -4 a s ${intf} | awk '{print $4}')
4326 [[ -n $nm ]] && netmasks+=" $nm@${NETTYPE}"
4327 nm=$(ip -o -6 a s ${intf} | grep -v 'fe80::' | awk '{print $4}')
4328 [[ -n $nm ]] && netmasks+=" $nm@${NETTYPE}"
4331 netmasks="${netmasks/ }"
4333 if [[ -z $netmasks ]]; then
4334 error "Unable to determine netmasks for ${interfaces[@]}"
4337 test_43a_check_nosquash_nids "$netmasks"
4339 # cleanup test dir/files
4340 rm -rf $DIR/$tfile-* $DIR/$tdir-rootdir ||
4341 error "Failed to remove test files/dir rc = $?"
4343 cleanup || error "cleanup failed with $?"
4345 run_test 43a "check root_squash and nosquash_nids"
4347 test_43b() { # LU-5690
4348 [[ "$MGS_VERSION" -ge $(version_code 2.7.62) ]] ||
4349 skip "Need MGS version 2.7.62+"
4351 if [[ -z "$fs2mds_DEV" ]]; then
4352 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
4353 skip_env "mixed loopback and real device not working"
4356 local fs2mdsdev=$(mdsdevname 1_2)
4357 local fs2mdsvdev=$(mdsvdevname 1_2)
4359 # temporarily use fs2mds as fs2mgs
4361 local fs2mgsdev=$fs2mdsdev
4362 local fs2mgsvdev=$fs2mdsvdev
4364 local fsname=test1234
4366 load_module llite/lustre
4367 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
4368 local host=${client_ip//*./}
4369 local net=${client_ip/%$host/}
4370 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
4372 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
4373 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
4374 --param mdt.nosquash_nids=$nosquash_nids \
4375 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
4376 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
4377 stop $fs2mgs -f || error "stop fs2mgs failed"
4378 cleanup || error "cleanup failed with $?"
4380 run_test 43b "parse nosquash_nids with commas in expr_list"
4384 check_mount || error "check_mount"
4385 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
4387 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
4388 for VAL in $UUIDS; do
4389 NID=$(echo $VAL | cut -d= -f1)
4390 CLUUID=$(echo $VAL | cut -d= -f2)
4391 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
4393 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
4394 cleanup || error "cleanup failed with $?"
4396 run_test 44 "mounted client proc entry exists"
4400 check_mount || error "check_mount"
4401 stop_mds || error "Unable to stop MDS"
4405 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
4406 do_facet client "$LCTL set_param fail_loc=0x8000050f"
4409 manual_umount_client --force || error "manual_umount_client failed"
4410 do_facet client "$LCTL set_param fail_loc=0x0"
4411 start_mds || error "unable to start MDS"
4412 mount_client $MOUNT || error "mount_client $MOUNT failed"
4413 cleanup || error "cleanup failed with $?"
4415 run_test 45 "long unlink handling in ptlrpcd"
4422 umount_client $MOUNT2 || rc=$?
4423 umount_client $MOUNT || rc=$?
4424 while [ $count -gt 0 ]; do
4425 stop ost${count} -f || rc=$?
4429 cleanup_nocli || rc=$?
4430 #writeconf to remove all ost2 traces for subsequent tests
4431 writeconf_or_reformat
4436 echo "Testing with $OSTCOUNT OSTs"
4438 start_mds || error "unable to start MDS"
4439 #first client should see only one ost
4440 start_ost || error "Unable to start OST1"
4441 wait_osc_import_state mds ost FULL
4443 mount_client $MOUNT || error "mount_client $MOUNT failed"
4444 trap "cleanup_46a $OSTCOUNT" EXIT ERR
4447 for (( i=2; i<=$OSTCOUNT; i++ )); do
4448 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
4449 error "start_ost$i $(ostdevname $i) failed"
4452 # wait until osts in sync
4453 for (( i=2; i<=$OSTCOUNT; i++ )); do
4454 wait_osc_import_state mds ost$i FULL
4455 wait_osc_import_ready client ost$i
4458 #second client see all ost's
4460 mount_client $MOUNT2 || error "mount_client failed"
4461 $LFS setstripe -c -1 $MOUNT2 ||
4462 error "$LFS setstripe -c -1 $MOUNT2 failed"
4463 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
4465 echo "ok" > $MOUNT2/widestripe
4466 $LFS getstripe $MOUNT2/widestripe ||
4467 error "$LFS getstripe $MOUNT2/widestripe failed"
4468 # fill acl buffer for avoid expand lsm to them
4469 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
4471 setfacl -m $acl $MOUNT2/widestripe
4475 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
4477 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
4479 run_test 46a "handle ost additional - wide striped file"
4484 check_mount || error "check_mount failed"
4485 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
4489 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
4490 if echo $ns | grep "MDT[[:digit:]]*"; then
4493 lrs=$(echo $ns | sed 's/.*lru_size=//')
4494 lru_size[count]=$lrs
4499 facet_failover $SINGLEMDS
4500 client_up || error "client_up failed"
4503 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
4504 if echo $ns | grep "MDT[[:digit:]]*"; then
4507 lrs=$(echo $ns | sed 's/.*lru_size=//')
4508 if ! test "$lrs" -eq "${lru_size[count]}"; then
4509 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
4510 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
4514 cleanup || error "cleanup failed with $?"
4516 run_test 47a "server restart does not lose lru_resize"
4519 local create_simple_link=false
4523 check_mount || error "check_mount failed"
4525 [[ -e /usr/sbin/lctl ]] || {
4526 # Unfortunately set_param -P rely on the hardcoded path
4528 ln -s /usr/sbin/lctl $LCTL ||
4529 skip_env "Can not create symlink /usr/sbin/lctl"
4530 stack_trap "rm -f /usr/sbin/lctl"
4533 do_facet mgs $LCTL \
4534 set_param -P ldlm.namespaces.$FSNAME-*-mdc-*.lru_size=200
4535 wait_update $HOSTNAME \
4536 "$LCTL get_param -n ldlm.namespaces.$FSNAME-MDT0000-mdc-*.lru_size" \
4538 umount $MOUNT || error "Unable to umount client"
4539 mount_client $MOUNT || error "mount failed"
4540 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME*mdc*.lru_size); do
4541 (( ${ns/*=/} == 200)) ||
4542 error "${ns/=*/} is ${ns/*=/}, expect 200"
4544 cleanup || error "cleanup failed with $?"
4546 run_test 47b "client restart does not lose lru_resize"
4551 # reformat after this test is needed - if the test fails,
4552 # we will have unkillable file at FS
4556 test_48() { # bz-17636 LU-7473
4560 check_mount || error "check_mount failed"
4563 stack_trap "debugrestore"
4564 $LCTL set_param debug=0
4565 do_facet $SINGLEMDS $LCTL set_param debug=0
4567 $LFS setstripe -c -1 $MOUNT ||
4568 error "$LFS setstripe -c -1 $MOUNT failed"
4569 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
4571 echo "ok" > $MOUNT/widestripe
4572 $LFS getstripe $MOUNT/widestripe ||
4573 error "$LFS getstripe $MOUNT/widestripe failed"
4575 # In the future, we may introduce more EAs, such as selinux, enlarged
4576 # LOV EA, and so on. These EA will use some EA space that is shared by
4577 # ACL entries. So here we only check some reasonable ACL entries count,
4578 # instead of the max number that is calculated from the max_ea_size.
4579 if (( $MDS1_VERSION < $(version_code 2.8.57) )); then
4580 count=28 # hard coded of RPC protocol
4581 elif large_xattr_enabled; then
4582 count=4500 # max_num 8187 max_ea_size = 65452
4583 # not create too many (4500) to save test time
4585 count=450 # max_num 497 max_ea_size = 4012
4588 echo "It is expected to hold at least $count ACL entries"
4589 trap cleanup_48 EXIT ERR
4590 for ((i = 0; i < $count; i++)) do
4591 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
4592 error "Fail to setfacl for $MOUNT/widestripe at $i"
4595 cancel_lru_locks mdc
4596 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
4597 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
4599 count=$((count + 1)) # for the entry "user::rw-"
4601 (( $count == $r_count )) ||
4602 error "Expected ACL entries $count, but got $r_count"
4606 run_test 48 "too many acls on file"
4608 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
4609 test_49a() { # bug 17710
4610 local timeout_orig=$TIMEOUT
4611 local ldlm_timeout_orig=$LDLM_TIMEOUT
4612 local LOCAL_TIMEOUT=20
4614 LDLM_TIMEOUT=$LOCAL_TIMEOUT
4615 TIMEOUT=$LOCAL_TIMEOUT
4619 check_mount || error "client mount failed"
4621 echo "check ldlm_timout..."
4622 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
4623 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
4624 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
4626 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
4627 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
4630 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
4631 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
4634 umount_client $MOUNT || error "umount_client $MOUNT failed"
4635 stop_ost || error "problem stopping OSS"
4636 stop_mds || error "problem stopping MDS"
4638 LDLM_TIMEOUT=$ldlm_timeout_orig
4639 TIMEOUT=$timeout_orig
4641 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
4643 test_49b() { # bug 17710
4644 local timeout_orig=$TIMEOUT
4645 local ldlm_timeout_orig=$LDLM_TIMEOUT
4646 local LOCAL_TIMEOUT=20
4648 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
4649 TIMEOUT=$LOCAL_TIMEOUT
4653 check_mount || error "client mount failed"
4655 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
4656 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
4657 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
4659 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
4660 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
4663 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
4664 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
4667 cleanup || error "cleanup failed"
4669 LDLM_TIMEOUT=$ldlm_timeout_orig
4670 TIMEOUT=$timeout_orig
4672 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
4675 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
4677 # Test both statfs and lfs df and fail if either one fails
4678 multiop_bg_pause $1 f_
4681 killall -USR1 multiop
4682 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
4683 wait $PID || { RC=$?; log "multiop return error "; }
4685 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
4690 if kill -s 0 $PID; then
4693 log "lazystatfs lfs df failed to complete in 5s"
4701 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4702 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4704 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
4706 cleanup || error "cleanup failed with rc $?"
4708 run_test 50a "lazystatfs all servers available"
4712 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4713 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4715 # Wait for client to detect down OST
4716 stop_ost || error "Unable to stop OST1"
4717 wait_osc_import_state client ost DISCONN
4719 log "OSCs should all be DISCONN"
4721 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
4723 umount_client $MOUNT || error "Unable to unmount client"
4724 stop_mds || error "Unable to stop MDS"
4726 run_test 50b "lazystatfs all servers down"
4729 start_mds || error "Unable to start MDS"
4730 start_ost || error "Unable to start OST1"
4731 start_ost2 || error "Unable to start OST2"
4732 mount_client $MOUNT || error "Unable to mount client"
4733 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4734 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4736 # Wait for client to detect down OST
4737 stop_ost || error "Unable to stop OST1"
4738 wait_osc_import_state mds ost DISCONN
4739 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
4741 umount_client $MOUNT || error "Unable to unmount client"
4742 stop_ost2 || error "Unable to stop OST2"
4743 stop_mds || error "Unable to stop MDS"
4744 #writeconf to remove all ost2 traces for subsequent tests
4745 writeconf_or_reformat
4747 run_test 50c "lazystatfs one server down"
4750 start_mds || error "Unable to start MDS"
4751 start_ost || error "Unable to start OST1"
4752 start_ost2 || error "Unable to start OST2"
4753 mount_client $MOUNT || error "Unable to mount client"
4754 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4755 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4757 # Issue the statfs during the window where the client still
4758 # belives the OST to be available but it is in fact down.
4759 # No failure just a statfs which hangs for a timeout interval.
4760 stop_ost || error "Unable to stop OST1"
4761 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
4763 umount_client $MOUNT || error "Unable to unmount client"
4764 stop_ost2 || error "Unable to stop OST2"
4765 stop_mds || error "Unable to stop MDS"
4766 #writeconf to remove all ost2 traces for subsequent tests
4767 writeconf_or_reformat
4769 run_test 50d "lazystatfs client/server conn race"
4776 start_mds || error "Unable to start MDS"
4777 #first client should see only one ost
4778 start_ost || error "Unable to start OST1"
4779 wait_osc_import_state mds ost FULL
4781 # Wait for client to detect down OST
4782 stop_ost || error "Unable to stop OST1"
4783 wait_osc_import_state mds ost DISCONN
4785 mount_client $MOUNT || error "Unable to mount client"
4786 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
4788 multiop_bg_pause $MOUNT _f
4792 if [ $RC1 -ne 0 ]; then
4793 log "multiop failed $RC1"
4796 sleep $(( $TIMEOUT+1 ))
4798 [ $? -ne 0 ] && error "process isn't sleep"
4799 start_ost || error "Unable to start OST1"
4800 wait $pid || error "statfs failed"
4803 umount_client $MOUNT || error "Unable to unmount client"
4804 stop_ost || error "Unable to stop OST1"
4805 stop_mds || error "Unable to stop MDS"
4807 run_test 50e "normal statfs all servers down"
4812 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
4814 start_mds || error "Unable to start mds"
4815 #first client should see only one ost
4816 start_ost || error "Unable to start OST1"
4817 wait_osc_import_state mds ost FULL
4819 start_ost2 || error "Unable to start OST2"
4820 wait_osc_import_state mds ost2 FULL
4822 # Wait for client to detect down OST
4823 stop_ost2 || error "Unable to stop OST2"
4825 wait_osc_import_state mds ost2 DISCONN
4826 mount_client $MOUNT || error "Unable to mount client"
4827 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
4829 multiop_bg_pause $MOUNT _f
4833 if [ $RC1 -ne 0 ]; then
4834 log "lazystatfs multiop failed $RC1"
4837 sleep $(( $TIMEOUT+1 ))
4839 [ $? -ne 0 ] && error "process isn't sleep"
4840 start_ost2 || error "Unable to start OST2"
4841 wait $pid || error "statfs failed"
4842 stop_ost2 || error "Unable to stop OST2"
4845 umount_client $MOUNT -f || error "Unable to unmount client"
4846 stop_ost || error "Unable to stop OST1"
4847 stop_mds || error "Unable to stop MDS"
4848 #writeconf to remove all ost2 traces for subsequent tests
4849 writeconf_or_reformat
4851 run_test 50f "normal statfs one server in down"
4854 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
4856 start_ost2 || error "Unable to start OST2"
4857 wait_osc_import_state mds ost2 FULL
4858 wait_osc_import_ready client ost2
4860 if [[ $PERM_CMD == *"set_param -P"* ]]; then
4861 local PARAM="osc.${FSNAME}-OST0001*.active"
4863 local PARAM="${FSNAME}-OST0001.osc.active"
4866 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
4867 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
4869 umount_client $MOUNT || error "Unable to unmount client"
4870 mount_client $MOUNT || error "Unable to mount client"
4871 # This df should not cause a panic
4874 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
4875 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
4876 umount_client $MOUNT || error "Unable to unmount client"
4877 stop_ost2 || error "Unable to stop OST2"
4878 stop_ost || error "Unable to stop OST1"
4879 stop_mds || error "Unable to stop MDS"
4880 #writeconf to remove all ost2 traces for subsequent tests
4881 writeconf_or_reformat
4883 run_test 50g "deactivated OST should not cause panic"
4887 # prepare MDT/OST, make OSC inactive for OST1
4888 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
4890 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4891 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
4892 error "tunefs OST1 failed"
4893 start_mds || error "Unable to start MDT"
4894 start_ost || error "Unable to start OST1"
4895 start_ost2 || error "Unable to start OST2"
4896 mount_client $MOUNT || error "client start failed"
4898 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4900 # activatate OSC for OST1
4901 set_persistent_param_and_check client \
4902 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
4903 "${FSNAME}-OST0000.osc.active" 1
4905 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
4906 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
4907 error "$LFS setstripe $DIR/$tdir/2 failed"
4908 sleep 1 && echo "create a file after OST1 is activated"
4909 # doing some io, shouldn't crash
4910 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
4912 # check OSC import is working
4913 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
4914 error "some OSC imports are still not connected"
4918 umount_client $MOUNT || error "Unable to umount client"
4919 stop_ost2 || error "Unable to stop OST2"
4920 cleanup_nocli || error "cleanup_nocli failed with $?"
4922 run_test 50h "LU-642: activate deactivated OST"
4925 # prepare MDT/OST, make OSC inactive for OST1
4926 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
4929 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
4930 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
4931 error "tunefs MDT2 failed"
4932 start_mds || error "Unable to start MDT"
4933 start_ost || error "Unable to start OST1"
4934 start_ost2 || error "Unable to start OST2"
4935 mount_client $MOUNT || error "client start failed"
4937 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4939 if [[ $PERM_CMD == *"set_param -P"* ]]; then
4940 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
4941 error "deactive MDC0 succeeds"
4943 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
4944 error "deactive MDC0 succeeds"
4947 # activate MDC for MDT2
4948 set_persistent_param_and_check client \
4949 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
4950 "${FSNAME}-MDT0001.mdc.active" 1
4952 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
4953 if [ "$MDS1_VERSION" -ge $(version_code 2.7.60) ]
4955 wait_dne_interconnect
4957 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
4959 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
4961 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
4963 # deactivate MDC for MDT2
4964 set_persistent_param_and_check client \
4965 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
4966 "${FSNAME}-MDT0001.mdc.active" 0
4968 wait_osp_active mds ${FSNAME}-MDT0001 1 0
4970 $LFS mkdir -i1 $DIR/$tdir/2 &&
4971 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
4973 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4974 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
4976 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
4977 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
4978 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
4981 umount_client $MOUNT || error "Unable to umount client"
4986 run_test 50i "activate deactivated MDT"
4989 local LOCAL_TIMEOUT=20
4993 check_mount || error "check_mount failed"
4995 mkdir_on_mdt0 $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
4996 $LFS setstripe -c -1 $MOUNT/$tdir ||
4997 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
4998 #define OBD_FAIL_MDS_REINT_DELAY 0x142
4999 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
5000 touch $MOUNT/$tdir/$tfile &
5003 start_ost2 || error "Unable to start OST1"
5005 stop_ost2 || error "Unable to stop OST1"
5006 umount_client $MOUNT -f || error "unmount $MOUNT failed"
5007 cleanup_nocli || error "stop server failed"
5008 #writeconf to remove all ost2 traces for subsequent tests
5009 writeconf_or_reformat
5011 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
5020 do_node $node mkdir -p $dest
5021 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
5023 do_node $node 'tar cf - '$*' | tar xf - -C '$dest';
5024 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
5025 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
5027 do_node $node 'getfattr -d -m "[a-z]*\\." '$*' > '$xattrs
5028 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
5038 local backup2=${TMP}/backup2
5040 do_node $node mkdir -p $backup2
5041 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
5043 do_node $node 'tar cf - '$*' | tar xf - -C '$backup2';
5044 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
5045 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
5047 do_node $node "diff -rq $backup $backup2"
5048 [ $? -eq 0 ] || { error "contents differ"; return 3; }
5050 local xattrs2=${TMP}/xattrs2
5051 do_node $node 'getfattr -d -m "[a-z]*\\." '$*' > '$xattrs2
5052 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
5054 do_node $node "diff $xattrs $xattrs2"
5055 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
5057 do_node $node "rm -rf $backup2 $xattrs2"
5058 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
5062 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5063 skip "ldiskfs only test"
5066 start_mds || error "Unable to start MDS"
5067 start_ost || error "Unable to start OST1"
5068 mount_client $MOUNT || error "Unable to mount client"
5071 local ost1mnt=$(facet_mntpt ost1)
5072 local ost1node=$(facet_active_host ost1)
5073 local ost1tmp=$TMP/conf52
5076 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
5077 touch $TMP/modified_first || error "Unable to create temporary file"
5078 local mtime=$(stat -c %Y $TMP/modified_first)
5079 do_node $ost1node "mkdir -p $ost1tmp &&
5080 touch -m -d @$mtime $ost1tmp/modified_first" ||
5081 error "Unable to create temporary file"
5084 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
5086 for (( i=0; i < nrfiles; i++ )); do
5087 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
5088 error "multiop failed"
5093 # sync all the data and make sure no pending data on the client,
5094 # thus the SOM xattr would not be changed any more.
5095 cancel_lru_locks osc
5098 echo backup files to $TMP/$tdir
5099 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
5100 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
5101 error "Unable to copy files"
5103 umount_client $MOUNT || error "Unable to umount client"
5104 stop_ost || error "Unable to stop ost1"
5106 echo mount ost1 as ldiskfs
5107 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
5108 if ! do_node $ost1node test -b $ost1_dev; then
5111 do_node $ost1node mount -t "$ost1_FSTYPE" $loop $ost1_dev \
5113 error "Unable to mount ost1 as ldiskfs"
5116 echo backup objects to $ost1tmp/objects
5117 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
5118 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
5119 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
5121 error "Unable to copy objects"
5123 # move objects to lost+found
5124 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
5125 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
5127 do_node $ost1node "umount $ost1mnt" ||
5128 error "Unable to umount ost1 as ldiskfs"
5130 start_ost || error "Unable to start OST1"
5131 mount_client $MOUNT || error "Unable to mount client"
5133 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
5134 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
5135 awk '/^lf_repa[ri]*ed/ { print $2 }')
5136 [ $REPAIRED -gt 0 ] ||
5137 error "Some entry under /lost+found should be repaired"
5140 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
5141 error "Unable to diff files"
5143 rm -rf $TMP/$tdir $TMP/file_xattrs ||
5144 error "Unable to delete temporary files"
5145 do_node $ost1node "rm -rf $ost1tmp" ||
5146 error "Unable to delete temporary files"
5147 cleanup || error "cleanup failed with $?"
5149 run_test 52 "check recovering objects from lost+found"
5151 # Checks threads_min/max/started for some service
5153 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
5154 # parameter pattern prefix like 'ost.*.ost'.
5167 local msg="Insane $modname thread counts"
5168 local ncpts=$(check_cpt_number $facet)
5172 check_mount || return 41
5174 # We need to expand $parampat, but it may match multiple parameters, so
5175 # we'll pick the first one
5176 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
5177 error "Couldn't expand ${parampat}.threads_min parameter name"
5181 # Remove the .threads_min part
5182 paramp=${paramp%.threads_min}
5184 # Check for sanity in defaults
5185 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
5187 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
5189 tstarted=$(do_facet $facet "$LCTL get_param \
5190 -n ${paramp}.threads_started" || echo 0)
5191 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
5193 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
5195 nthrs=$(expr $tmax - $tmin)
5196 if [ $nthrs -lt $ncpts ]; then
5202 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
5203 skip_env "module parameter forced $facet thread count"
5205 # Check that we can change min/max
5206 do_facet $facet "$LCTL set_param \
5207 ${paramp}.threads_min=$((tmin + nthrs))"
5208 do_facet $facet "$LCTL set_param \
5209 ${paramp}.threads_max=$((tmax - nthrs))"
5210 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
5212 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
5214 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
5215 $tmax2 == ($tmax - $nthrs)))' || return $?
5217 # Check that we can set min/max to the same value
5218 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
5220 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
5221 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
5223 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
5225 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
5227 # Check that we can't set max < min
5228 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
5229 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
5231 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
5233 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
5235 # We need to ensure that we get the module options desired; to do this
5236 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
5237 LOAD_MODULES_REMOTE=true
5240 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
5242 setmodopts -a $modname "$newvalue" oldvalue
5245 check_mount || return 41
5247 # Restore previous setting of MODOPTS_*
5248 setmodopts $modname "$oldvalue"
5250 (( $MDS1_VERSION > $(version_code 2.12.52.91) )) || {
5251 echo "skip interop for MDS < v2_12_52-91-g183cb1e3cdd2"
5255 # Check that $opts took
5256 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
5258 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
5260 tstarted=$(do_facet $facet \
5261 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
5262 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
5268 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
5269 cleanup || error "cleanup failed with rc $?"
5271 run_test 53a "check OSS thread count params"
5275 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
5276 cleanup || error "cleanup failed with $?"
5278 run_test 53b "check MDS thread count params"
5281 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5282 skip "ldiskfs only test"
5285 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
5286 error "llverdev failed with rc=$?"
5289 run_test 54a "test llverdev and partial verify of device"
5292 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5293 skip "ldiskfs only test"
5297 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
5298 cleanup || error "cleanup failed with rc=$?"
5300 run_test 54b "test llverfs and partial verify of filesystem"
5304 local max_ost_index=$1
5306 echo -n $(((max_ost_index + 1) * 8))
5310 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5311 skip "ldiskfs only test"
5314 local mdsdev=$(mdsdevname 1)
5315 local mdsvdev=$(mdsvdevname 1)
5319 if ! combined_mgs_mds; then
5320 stop_mgs || error "stopping MGS service failed"
5321 format_mgs || error "formatting MGT failed"
5323 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
5325 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
5326 --reformat $(ostdevname 1) $(ostvdevname 1)
5332 echo checking size of lov_objid for ost index $i
5333 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
5334 grep ^User | awk -F 'Size: ' '{print $2}')
5335 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
5336 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
5338 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
5345 run_test 55 "check lov_objid size"
5348 local mds_journal_size_orig=$MDSJOURNALSIZE
5354 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
5355 $(ostdevname 1) $(ostvdevname 1)
5356 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
5357 $(ostdevname 2) $(ostvdevname 2)
5360 start_ost || error "Unable to start first ost (idx 10000)"
5361 start_ost2 || error "Unable to start second ost (idx 1000)"
5362 mount_client $MOUNT || error "Unable to mount client"
5366 # test instantiating PFL components with sparse index LU-15513
5367 mkdir -p $MOUNT/$tdir
5368 $LFS setstripe -E 4M -c 1 -E 1G -c 4 -S4M -E eof -c -1 $MOUNT/$tdir
5369 dd if=/dev/zero of=$MOUNT/$tdir/$tfile bs=4K count=1 seek=10k ||
5370 error "dd to second component failed"
5372 if [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5373 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
5374 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]]; then
5375 wait_osc_import_state mds ost1 FULL
5376 wait_osc_import_state mds ost2 FULL
5377 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
5378 error "Unable to setstripe $DIR/$tfile"
5379 n=$($LFS getstripe --stripe-count $DIR/$tfile)
5380 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
5385 MDSJOURNALSIZE=$mds_journal_size_orig
5388 run_test 56a "check big OST indexes and out-of-index-order start"
5393 umount_client $MOUNT -f || error "unmount client failed"
5402 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
5404 trap cleanup_56b EXIT RETURN ERR
5407 if ! combined_mgs_mds ; then
5412 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
5413 $(mdsdevname 1) $(mdsvdevname 1)
5414 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
5415 $(mdsdevname 2) $(mdsvdevname 2)
5416 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
5417 $(mdsdevname 3) $(mdsvdevname 3)
5421 start_mdt 1 || error "MDT 1 (idx 0) start failed"
5422 start_mdt 2 || error "MDT 2 (idx 1) start failed"
5423 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
5424 start_ost || error "Unable to start first ost"
5425 start_ost2 || error "Unable to start second ost"
5427 do_nodes $(mdts_nodes) "$LCTL set_param mdt.*.enable_remote_dir=1 \
5428 mdt.*.enable_remote_dir_gid=-1"
5430 mount_client $MOUNT || error "Unable to mount client"
5432 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
5434 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
5435 error "failed to make test file 1"
5436 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
5437 error "failed to make test file 2"
5438 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
5439 error "failed to make test file 1000"
5441 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
5443 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
5444 error "create remote dir at idx 1000 failed"
5447 echo "=== START lfs df OUTPUT ==="
5449 echo "==== END lfs df OUTPUT ===="
5451 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
5452 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
5454 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
5455 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
5456 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
5458 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
5459 error "failed to make test file 1"
5460 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
5461 error "failed to make test file 2"
5462 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
5463 error "failed to make test file 1000"
5464 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
5467 echo "=== START lfs mdts OUTPUT ==="
5469 echo "==== END lfs mdts OUTPUT ===="
5471 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
5472 sed 's/://g' > $TMP/mdts-actual.txt
5473 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
5475 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
5477 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
5480 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
5482 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
5484 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
5486 test_57a() { # bug 22656
5487 do_rpc_nodes $(facet_active_host ost1) load_modules_local
5488 local NID=$(do_facet ost1 "$LCTL get_param nis" |
5489 tail -1 | awk '{print $1}')
5490 writeconf_or_reformat
5491 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5492 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
5493 error "tunefs failed"
5495 start_ost && error "OST registration from failnode should fail"
5498 run_test 57a "initial registration from failnode should fail (should return errs)"
5501 do_rpc_nodes $(facet_active_host ost1) load_modules_local
5502 local NID=$(do_facet ost1 "$LCTL get_param nis" |
5503 tail -1 | awk '{print $1}')
5504 writeconf_or_reformat
5505 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5506 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
5507 error "tunefs failed"
5509 start_ost || error "OST registration from servicenode should not fail"
5512 run_test 57b "initial registration from servicenode should not fail"
5515 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
5518 test_58() { # bug 22658
5519 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5521 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5522 createmany -o $DIR/$tdir/$tfile-%d 100
5523 unlinkmany $DIR/$tdir/$tfile-%d 100
5524 stop_mds || error "Unable to stop MDS"
5526 local MNTDIR=$(facet_mntpt $SINGLEMDS)
5527 local devname=$(mdsdevname ${SINGLEMDS//mds/})
5529 # remove all files from the OBJECTS dir
5530 mount_fstype $SINGLEMDS
5532 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
5534 unmount_fstype $SINGLEMDS
5535 # restart MDS with missing llog files
5536 start_mds || error "unable to start MDS"
5537 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
5540 run_test 58 "missing llog files must not prevent MDT from mounting"
5543 start_mgsmds >> /dev/null
5544 local C1=$(count_osts)
5545 if [ $C1 -eq 0 ]; then
5546 start_ost >> /dev/null
5550 echo "original ost count: $C1 (expect > 0)"
5551 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
5552 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
5553 local C2=$(count_osts)
5554 echo "after mdt writeconf count: $C2 (expect 0)"
5555 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
5556 echo "OST start without writeconf should fail:"
5557 start_ost >> /dev/null &&
5558 error "OST start without writeconf didn't fail"
5559 echo "OST start with writeconf should succeed:"
5560 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
5561 local C3=$(count_osts)
5562 echo "after ost writeconf count: $C3 (expect 1)"
5563 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
5564 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
5565 local C4=$(count_osts)
5566 echo "after ost2 writeconf count: $C4 (expect 2)"
5567 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
5568 stop_ost2 >> /dev/null
5569 cleanup_nocli >> /dev/null
5570 #writeconf to remove all ost2 traces for subsequent tests
5571 writeconf_or_reformat
5573 run_test 59 "writeconf mount option"
5575 test_60a() { # LU-471
5576 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5577 skip "ldiskfs only test"
5582 for num in $(seq $MDSCOUNT); do
5583 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
5584 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
5585 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
5589 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
5590 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
5592 # MDT default has dirdata feature
5593 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
5594 # we disable uninit_bg feature
5595 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
5596 # we set stride extended options
5597 echo $dump | grep stride > /dev/null || error "stride is not set"
5601 run_test 60a "check mkfs.lustre --mkfsoptions -E -O options setting"
5604 [[ "$mds1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
5606 local features=$(do_facet $SINGLEMDS $DUMPE2FS $(mdsdevname 1) |
5608 [ ${PIPESTATUS[0]} -eq 0 ] || error "$DUMPE2FS $(mdsdevname 1) failed"
5611 # ea_inode feature should be enabled by default for MDTs
5612 [[ "$features" =~ "ea_inode" ]] || error "ea_inode is not set"
5613 # large_dir feature should be enabled by default for MDTs
5614 [[ "$features" =~ "large_dir" ]] || error "large_dir is not set"
5616 run_test 60b "check mkfs.lustre MDT default features"
5618 test_61a() { # LU-80
5619 local lxattr=$(large_xattr_enabled)
5621 (( "$MDS1_VERSION" >= $(version_code 2.1.53) )) ||
5622 skip "Need MDS version at least 2.1.53 for large_xattr"
5624 if [[ "$mds1_FSTYPE" == ldiskfs ]] && ! large_xattr_enabled; then
5627 for ((num=1; num <= $MDSCOUNT; num++)); do
5628 do_facet mds${num} $TUNE2FS -O ea_inode \
5629 $(mdsdevname $num) ||
5630 error "tune2fs on mds $num failed"
5634 setup || error "setting up the filesystem failed"
5635 client_up || error "starting client failed"
5637 local file=$DIR/$tfile
5638 touch $file || error "touch $file failed"
5640 local large_value="$(generate_string $(max_xattr_size))"
5641 local small_value="bar"
5643 local name="trusted.big"
5644 log "save large xattr of $(max_xattr_size) bytes on $name on $file"
5645 setfattr -n $name -v $large_value $file ||
5646 error "saving $name on $file failed"
5648 local new_value=$(get_xattr_value $name $file)
5649 [[ "$new_value" != "$large_value" ]] &&
5650 error "$name different after saving"
5652 log "shrink value of $name on $file"
5653 setfattr -n $name -v $small_value $file ||
5654 error "shrinking value of $name on $file failed"
5656 new_value=$(get_xattr_value $name $file)
5657 [[ "$new_value" != "$small_value" ]] &&
5658 error "$name different after shrinking"
5660 log "grow value of $name on $file"
5661 setfattr -n $name -v $large_value $file ||
5662 error "growing value of $name on $file failed"
5664 new_value=$(get_xattr_value $name $file)
5665 [[ "$new_value" != "$large_value" ]] &&
5666 error "$name different after growing"
5668 log "check value of $name on $file after remounting MDS"
5670 new_value=$(get_xattr_value $name $file)
5671 [[ "$new_value" != "$large_value" ]] &&
5672 error "$name different after remounting MDS"
5674 log "remove large xattr $name from $file"
5675 setfattr -x $name $file || error "removing $name from $file failed"
5677 if $lxattr && [ "$mds1_FSTYPE" == ldiskfs ]; then
5678 stopall || error "stopping for e2fsck run"
5679 for num in $(seq $MDSCOUNT); do
5680 run_e2fsck $(facet_active_host mds$num) \
5681 $(mdsdevname $num) "-y" ||
5682 error "e2fsck MDT$num failed"
5684 setup_noconfig || error "remounting the filesystem failed"
5687 # need to delete this file to avoid problems in other tests
5689 cleanup || error "stopping systems failed"
5691 run_test 61a "large xattr"
5693 test_61b() { # LU-80
5694 local lxattr=$(large_xattr_enabled)
5696 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
5697 skip "Need MDS version at least 2.15.51 for large_xattr fix"
5699 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs specific bug"
5701 if ! large_xattr_enabled; then
5704 for (( num=1; num <= $MDSCOUNT; num++ )); do
5705 do_facet mds${num} $TUNE2FS -O ea_inode \
5706 $(mdsdevname $num) ||
5707 error "tune2fs on mds $num failed"
5711 setup || error "setting up the filesystem failed"
5712 client_up || error "starting client failed"
5714 local _file=$MOUNT/panda
5715 local large_value="$(generate_string $(max_xattr_size))"
5716 local name="trusted.big"
5718 touch ${_file} || error "touch ${_file} failed"
5719 setfattr -n $name -v $large_value ${_file} ||
5720 error "saving $name on $file failed"
5722 MDT_DEV="${FSNAME}-MDT0000"
5723 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
5725 stopall || error "stopping for e2fsck run"
5728 ino=$(do_facet $SINGLEMDS "$DEBUGFS -R 'stat /ROOT/panda' \
5729 ${MDT_DEVNAME} | grep trusted.big")
5730 ino=$(echo "${ino}" | awk '{print $2;}')
5731 echo "large ea "${ino}
5733 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"ln $ino /lost+found\\\" \
5736 setup_noconfig || error "remounting the filesystem failed"
5738 do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV} -t namespace || {
5739 error "can't start lfsck namespace"
5743 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
5744 mdd.${MDT_DEV}.lfsck_namespace |
5745 awk '/^status/ { print \\\$2 }'" "completed" 32 || {
5746 error "(2) unexpected status"
5749 stopall || error "stopping for e2fsck run"
5750 for num in $(seq $MDSCOUNT); do
5751 run_e2fsck $(facet_active_host mds$num) \
5752 $(mdsdevname $num) "-y" ||
5753 error "e2fsck MDT$num failed"
5755 setup_noconfig || error "remounting the filesystem failed"
5757 # need to delete this file to avoid problems in other tests
5759 cleanup || error "stopping systems failed"
5761 run_test 61b "large xattr"
5764 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5765 skip "ldiskfs only test"
5767 [[ "$MDS1_VERSION" -ge $(version_code 2.2.51) ]] ||
5768 skip "Need MDS version at least 2.2.51"
5771 local mdsdev=$(mdsdevname 1)
5772 local ostdev=$(ostdevname 1)
5774 echo "disable journal for mds"
5775 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
5776 start_mds && error "MDT start should fail"
5777 echo "disable journal for ost"
5778 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
5779 start_ost && error "OST start should fail"
5780 cleanup || error "cleanup failed with rc $?"
5783 run_test 62 "start with disabled journal"
5786 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5787 skip "ldiskfs only test"
5790 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
5791 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
5792 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
5793 if [ -z "$inode_slab" ]; then
5794 skip "ldiskfs module has not been loaded"
5797 if grep -q "CONFIG_DEBUG_LOCK_ALLOC=y" /boot/config-$(uname -r); then
5798 skip "test is not compatible with CONFIG_DEBUG_LOCK_ALLOC=y"
5801 echo "$inode_slab ldiskfs inodes per page"
5802 [ "${inode_slab%.*}" -ge "3" ] && return 0
5804 # If kmalloc-128 is also 1 per page - this is a debug kernel
5805 # and so this is not an error.
5806 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
5807 awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
5808 # 32 128-byte chunks in 4k
5809 [ "${kmalloc128%.*}" -lt "32" ] ||
5810 error "ldiskfs inode too big, only $inode_slab objs/page, " \
5811 "kmalloc128 = $kmalloc128 objs/page"
5813 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
5816 start_mds || error "unable to start MDS"
5817 start_ost || error "Unable to start OST1"
5818 start_ost2 || error "Unable to start second ost"
5819 mount_client $MOUNT || error "Unable to mount client"
5820 stop_ost2 || error "Unable to stop second ost"
5823 umount_client $MOUNT -f || error "unmount $MOUNT failed"
5824 cleanup_nocli || error "cleanup_nocli failed with $?"
5825 #writeconf to remove all ost2 traces for subsequent tests
5826 writeconf_or_reformat
5828 run_test 64 "check lfs df --lazy "
5830 test_65() { # LU-2237
5831 # Currently, the test is only valid for ldiskfs backend
5832 [ "$mds1_FSTYPE" != ldiskfs ] &&
5833 skip "ldiskfs only test"
5835 local devname=$(mdsdevname ${SINGLEMDS//mds/})
5836 local brpt=$(facet_mntpt brpt)
5839 if ! do_facet $SINGLEMDS "test -b $devname"; then
5843 stop_mds || error "Unable to stop MDS"
5844 local obj=$(do_facet $SINGLEMDS \
5845 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
5847 if [ -z "$obj" ]; then
5848 # The MDT may be just re-formatted, mount the MDT for the
5849 # first time to guarantee the "last_rcvd" file is there.
5850 start_mds || error "fail to mount the MDS for the first time"
5851 stop_mds || error "Unable to stop MDS"
5854 # remove the "last_rcvd" file
5855 do_facet $SINGLEMDS "mkdir -p $brpt"
5856 do_facet $SINGLEMDS \
5857 "mount -t $mds1_FSTYPE $opts $devname $brpt"
5858 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
5859 do_facet $SINGLEMDS "$UMOUNT $brpt"
5861 # restart MDS, the "last_rcvd" file should be recreated.
5862 start_mds || error "fail to restart the MDS"
5863 stop_mds || error "Unable to stop MDS"
5864 obj=$(do_facet $SINGLEMDS \
5865 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
5866 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
5868 run_test 65 "re-create the lost last_rcvd file when server mount"
5871 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
5872 skip "Need MGS version at least 2.3.59"
5874 check_versions || skip "do not replace_nids with mismatched versions"
5877 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
5878 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
5880 # add EXCLUDE records to config log, they are not to be
5881 # removed by lctl replace_nids
5882 set_conf_param_and_check mds \
5883 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
5884 "$FSNAME-OST0000.osc.active" \
5887 echo "replace_nids should fail if MDS, OSTs and clients are UP"
5888 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
5889 error "replace_nids fail"
5891 umount_client $MOUNT || error "unmounting client failed"
5892 echo "replace_nids should fail if MDS and OSTs are UP"
5893 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
5894 error "replace_nids fail"
5896 stop_ost || error "Unable to stop OST1"
5897 echo "replace_nids should fail if MDS is UP"
5898 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
5899 error "replace_nids fail"
5901 stop_mds || error "stopping mds failed"
5903 if combined_mgs_mds; then
5904 start_mdt 1 "-o nosvc" ||
5905 error "starting mds with nosvc option failed"
5908 echo "command should accept two parameters"
5909 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
5910 error "command should accept two params"
5912 echo "correct device name should be passed"
5913 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
5914 error "wrong devname"
5916 echo "wrong nids list should not destroy the system"
5917 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
5919 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
5922 echo "replace OST nid"
5923 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
5924 error "replace nids failed"
5926 echo "command should accept two parameters"
5927 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
5928 error "command should accept two params"
5930 echo "wrong nids list should not destroy the system"
5931 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
5934 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
5935 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
5936 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
5937 echo "set NIDs with failover"
5938 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
5939 error "replace nids failed"
5942 echo "replace MDS nid"
5943 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
5944 error "replace nids failed"
5946 if ! combined_mgs_mds ; then
5949 stop_mds || error "Unable to stop MDS"
5952 start_mgsmds || error "start mgsmds failed"
5953 set_conf_param_and_check mds \
5954 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
5955 "$FSNAME-OST0000.osc.active" \
5957 start_ost || error "unable to start OST"
5958 mount_client $MOUNT || error "mount client failed"
5960 check_mount || error "error after nid replace"
5961 cleanup || error "cleanup failed"
5964 run_test 66 "replace nids"
5966 test_67() { #LU-2950
5967 local legacy="$TMP/legacy_lnet_config"
5968 local new="$TMP/new_routes_test"
5969 local out="$TMP/config_out_file"
5970 local verify="$TMP/conv_verify"
5971 local verify_conf="$TMP/conf_verify"
5973 # Create the legacy file that will be run through the
5974 # lustre_routes_conversion script
5975 cat <<- LEGACY_LNET_CONFIG > $legacy
5976 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
5977 tcp2 54 10.1.3.2@tcp;
5978 tcp3 10.3.4.3@tcp:3;
5982 # Create the verification file to verify the output of
5983 # lustre_routes_conversion script against.
5984 cat <<- VERIFY_LNET_CONFIG > $verify
5985 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
5986 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
5987 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
5988 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
5989 tcp4: { gateway: 10.3.3.4@tcp }
5992 # Create the verification file to verify the output of
5993 # lustre_routes_config script against
5994 cat <<- VERIFY_LNET_CONFIG > $verify_conf
5995 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
5996 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
5997 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
5998 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
5999 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
6002 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
6003 if [ -f $new ]; then
6004 # verify the conversion output
6005 cmp -s $new $verify > /dev/null
6006 if [ $? -eq 1 ]; then
6007 error "routes conversion failed"
6010 lustre_routes_config --dry-run --verbose $new > $out
6011 # check that the script succeeded
6012 cmp -s $out $verify_conf > /dev/null
6013 if [ $? -eq 1 ]; then
6014 error "routes config failed"
6017 error "routes conversion test failed"
6019 # remove generated files
6020 rm -f $new $legacy $verify $verify_conf $out
6022 run_test 67 "test routes conversion and configuration"
6030 [ "$MDS1_VERSION" -ge $(version_code 2.4.53) ] ||
6031 skip "Need MDS version at least 2.4.53"
6033 umount_client $MOUNT || error "umount client failed"
6038 # START-END - the sequences we'll be reserving
6039 START=$(do_facet $SINGLEMDS \
6040 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
6041 END=$((START + (1 << 30)))
6042 do_facet $SINGLEMDS \
6043 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
6045 # reset the sequences MDT0000 has already assigned
6046 do_facet $SINGLEMDS \
6047 $LCTL set_param seq.srv*MDT0000.space=clear
6049 # remount to let the client allocate new sequence
6050 mount_client $MOUNT || error "mount client failed"
6052 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
6053 do_facet $SINGLEMDS \
6054 $LCTL get_param seq.srv*MDT0000.space
6055 $LFS path2fid $DIR/$tfile
6057 local old_ifs="$IFS"
6059 fid=($($LFS path2fid $DIR/$tfile))
6063 if [[ $seq < $END ]]; then
6064 error "used reserved sequence $seq?"
6066 cleanup || error "cleanup failed with $?"
6068 run_test 68 "be able to reserve specific sequences in FLDB"
6070 # Test 69: is about the total number of objects ever created on an OST.
6071 # so that when it is reformatted the normal MDS->OST orphan recovery won't
6072 # just "precreate" the missing objects. In the past it might try to recreate
6073 # millions of objects after an OST was reformatted
6075 [[ "$MDS1_VERSION" -lt $(version_code 2.4.2) ]] &&
6076 skip "Need MDS version at least 2.4.2"
6078 [[ "$MDS1_VERSION" -ge $(version_code 2.4.50) ]] &&
6079 [[ "$MDS1_VERSION" -lt $(version_code 2.5.0) ]] &&
6080 skip "Need MDS version at least 2.5.0"
6083 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6084 do_nodes $(osts_nodes) \
6085 $LCTL set_param seq.*OST*-super.width=$DATA_SEQ_MAX_WIDTH
6087 # use OST0000 since it probably has the most creations
6088 local OSTNAME=$(ostname_from_index 0)
6089 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
6090 local last_id=$(do_facet mds1 $LCTL get_param -n \
6091 osp.$mdtosc_proc1.prealloc_last_id)
6093 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
6094 # verify that the LAST_ID recovery is working properly. If
6095 # not, then the OST will refuse to allow the MDS connect
6096 # because the LAST_ID value is too different from the MDS
6097 #define OST_MAX_PRECREATE=20000
6098 local ost_max_pre=20000
6099 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
6101 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
6102 # need to create any files. So, skip this section.
6103 if [ $num_create -gt 0 ]; then
6104 # Check the number of inodes available on OST0
6106 local ifree=$($LFS df -i $MOUNT |
6107 awk '/OST0000/ { print $4 }'; exit ${PIPESTATUS[0]})
6108 log "On OST0, $ifree inodes available. Want $num_create. rc=$?"
6110 $LFS setstripe -i 0 $DIR/$tdir ||
6111 error "$LFS setstripe -i 0 $DIR/$tdir failed"
6112 if [ $ifree -lt 10000 ]; then
6113 files=$(( ifree - 50 ))
6118 local j=$((num_create / files + 1))
6119 for i in $(seq 1 $j); do
6120 createmany -o $DIR/$tdir/$tfile-$i- $files ||
6121 error "createmany fail create $files files: $?"
6122 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
6123 error "unlinkmany failed unlink $files files"
6127 # delete all of the files with objects on OST0 so the
6128 # filesystem is not inconsistent later on
6129 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
6131 umount_client $MOUNT || error "umount client failed"
6132 stop_ost || error "OST0 stop failure"
6133 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
6134 $(ostdevname 1) $(ostvdevname 1) ||
6135 error "reformat and replace $ostdev failed"
6136 start_ost || error "OST0 restart failure"
6137 wait_osc_import_state mds ost FULL
6139 mount_client $MOUNT || error "mount client failed"
6140 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
6141 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
6142 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
6144 local iused=$($LFS df -i $MOUNT |
6145 awk '/OST0000/ { print $3 }'; exit ${PIPESTATUS[0]})
6146 log "On OST0, $iused used inodes rc=$?"
6147 [ $iused -ge $((ost_max_pre + 1000)) ] &&
6148 error "OST replacement created too many inodes; $iused"
6149 cleanup || error "cleanup failed with $?"
6151 run_test 69 "replace an OST with the same index"
6154 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6157 cleanup || error "cleanup failed with $?"
6159 start_mdt 1 || error "MDT0 start fail"
6161 start_ost || error "OST0 start fail"
6162 for num in $(seq 2 $MDSCOUNT); do
6163 start_mdt $num || return
6166 mount_client $MOUNT || error "mount client fails"
6168 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
6170 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6171 error "create remote dir fail"
6173 rm -rf $DIR/$tdir || error "delete dir fail"
6174 cleanup || error "cleanup failed with $?"
6176 run_test 70a "start MDT0, then OST, then MDT1"
6179 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6182 start_ost || error "OST0 start fail"
6184 start_mds || error "MDS start fail"
6186 mount_client $MOUNT || error "mount client fails"
6188 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
6190 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6191 error "create remote dir fail"
6193 rm -rf $DIR/$tdir || error "delete dir fail"
6195 cleanup || error "cleanup failed with $?"
6197 run_test 70b "start OST, MDT1, MDT0"
6200 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6203 start_mds || error "MDS start fail"
6204 start_ost || error "OST0 start fail"
6206 mount_client $MOUNT || error "mount client fails"
6207 stop_mdt 1 || error "MDT1 start fail"
6209 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
6210 echo "deactivate $mdc_for_mdt1"
6211 $LCTL --device $mdc_for_mdt1 deactivate ||
6212 error "set $mdc_for_mdt1 deactivate failed"
6214 mkdir $DIR/$tdir && error "mkdir succeed"
6216 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
6217 error "create remote dir succeed"
6219 cleanup || error "cleanup failed with $?"
6221 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
6224 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6227 start_mds || error "MDS start fail"
6228 start_ost || error "OST0 start fail"
6230 mount_client $MOUNT || error "mount client fails"
6232 stop_mdt 2 || error "MDT1 start fail"
6234 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
6236 echo "deactivate $mdc_for_mdt2"
6237 $LCTL --device $mdc_for_mdt2 deactivate ||
6238 error "set $mdc_for_mdt2 deactivate failed"
6240 mkdir $DIR/$tdir || error "mkdir fail"
6241 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
6242 error "create remote dir succeed"
6244 rm -rf $DIR/$tdir || error "delete dir fail"
6246 cleanup || error "cleanup failed with $?"
6248 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
6251 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6253 [ "$MDS1_VERSION" -ge $(version_code 2.7.62) ] ||
6254 skip "Need MDS version at least 2.7.62"
6256 reformat || error "reformat failed with $?"
6260 local mdsdev=$(mdsdevname 1)
6261 local ostdev=$(ostdevname 1)
6262 local mdsvdev=$(mdsvdevname 1)
6263 local ostvdev=$(ostvdevname 1)
6264 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
6265 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
6267 if ! combined_mgs_mds ; then
6271 add mds1 $opts_mds || error "add mds1 failed"
6272 start_mdt 1 || error "start mdt1 failed"
6273 add ost1 $opts_ost || error "add ost1 failed"
6274 start_ost || error "start ost failed"
6275 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6277 local soc=$(do_facet mds1 "$LCTL get_param -n \
6278 mdt.*MDT0000.sync_lock_cancel")
6279 [ $soc == "never" ] || error "SoC enabled on single MDS"
6281 for i in $(seq 2 $MDSCOUNT); do
6282 mdsdev=$(mdsdevname $i)
6283 mdsvdev=$(mdsvdevname $i)
6284 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
6286 add mds$i $opts_mds || error "add mds$i failed"
6287 start_mdt $i || error "start mdt$i fail"
6290 wait_dne_interconnect
6292 for i in $(seq $MDSCOUNT); do
6293 soc=$(do_facet mds$i "$LCTL get_param -n \
6294 mdt.*MDT000$((i - 1)).sync_lock_cancel")
6295 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
6298 for i in $(seq 2 $MDSCOUNT); do
6299 stop_mdt $i || error "stop mdt$i fail"
6301 soc=$(do_facet mds1 "$LCTL get_param -n \
6302 mdt.*MDT0000.sync_lock_cancel")
6303 [ $soc == "never" ] || error "SoC enabled on single MDS"
6304 umount_client $MOUNT -f > /dev/null
6306 cleanup || error "cleanup failed with $?"
6308 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
6311 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6312 if combined_mgs_mds; then
6313 skip "needs separate MGS/MDT"
6317 start_mdt 1 || error "MDT0 start fail"
6318 start_ost || error "OST0 start fail"
6319 for num in $(seq 2 $MDSCOUNT); do
6320 start_mdt $num || return
6323 start_ost2 || error "OST1 start fail"
6325 mount_client $MOUNT || error "mount client fails"
6327 mkdir $DIR/$tdir || error "mkdir fail"
6328 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6329 error "create remote dir succeed"
6331 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
6332 rm -rf $DIR/$tdir || error "delete dir fail"
6334 umount_client $MOUNT || error "umount_client failed"
6335 stop_mds || error "MDS stop fail"
6336 stop_ost || error "OST0 stop fail"
6337 stop_ost2 || error "OST1 stop fail"
6339 run_test 71a "start MDT0 OST0, MDT1, OST1"
6342 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6343 if combined_mgs_mds; then
6344 skip "needs separate MGS/MDT"
6348 for num in $(seq 2 $MDSCOUNT); do
6349 start_mdt $num || return
6351 start_ost || error "OST0 start fail"
6352 start_mdt 1 || error "MDT0 start fail"
6353 start_ost2 || error "OST1 start fail"
6355 mount_client $MOUNT || error "mount client fails"
6357 mkdir $DIR/$tdir || error "mkdir fail"
6358 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6359 error "create remote dir succeed"
6361 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
6362 rm -rf $DIR/$tdir || error "delete dir fail"
6364 umount_client $MOUNT || error "umount_client failed"
6365 stop_mds || error "MDT0 stop fail"
6366 stop_ost || error "OST0 stop fail"
6367 stop_ost2 || error "OST1 stop fail"
6369 run_test 71b "start MDT1, OST0, MDT0, OST1"
6372 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6373 combined_mgs_mds && skip "needs separate MGS/MDT"
6377 start_ost || error "OST0 start fail"
6378 start_ost2 || error "OST1 start fail"
6379 for num in $(seq 2 $MDSCOUNT); do
6380 start_mdt $num || return
6382 start_mdt 1 || error "MDT0 start fail"
6384 mount_client $MOUNT || error "mount client fails"
6386 mkdir $DIR/$tdir || error "mkdir fail"
6387 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6388 error "create remote dir succeed"
6390 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
6391 rm -rf $DIR/$tdir || error "delete dir fail"
6393 umount_client $MOUNT || error "umount_client failed"
6394 stop_mds || error "MDS stop fail"
6395 stop_ost || error "OST0 stop fail"
6396 stop_ost2 || error "OST1 stop fail"
6399 run_test 71c "start OST0, OST1, MDT1, MDT0"
6402 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6403 combined_mgs_mds && skip "needs separate MGS/MDT"
6407 start_ost || error "OST0 start fail"
6408 for num in $(seq 2 $MDSCOUNT); do
6409 start_mdt $num || return
6411 start_mdt 1 || error "MDT0 start fail"
6412 start_ost2 || error "OST1 start fail"
6414 mount_client $MOUNT || error "mount client fails"
6416 mkdir $DIR/$tdir || error "mkdir fail"
6417 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6418 error "create remote dir succeed"
6420 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
6421 rm -rf $DIR/$tdir || error "delete dir fail"
6423 umount_client $MOUNT || error "umount_client failed"
6424 stop_mds || error "MDS stop fail"
6425 stop_ost || error "OST0 stop fail"
6426 stop_ost2 || error "OST1 stop fail"
6429 run_test 71d "start OST0, MDT1, MDT0, OST1"
6432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6433 combined_mgs_mds && skip "needs separate MGS/MDT"
6437 start_ost || error "OST0 start fail"
6438 for num in $(seq 2 $MDSCOUNT); do
6439 start_mdt $num || return
6441 start_ost2 || error "OST1 start fail"
6442 start_mdt 1 || error "MDT0 start fail"
6444 mount_client $MOUNT || error "mount client fails"
6446 mkdir $DIR/$tdir || error "mkdir fail"
6447 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6448 error "create remote dir succeed"
6450 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
6451 rm -rf $DIR/$tdir || error "delete dir fail"
6453 umount_client $MOUNT || error "umount_client failed"
6454 stop_mds || error "MDS stop fail"
6455 stop_ost || error "OST0 stop fail"
6456 stop_ost2 || error "OST1 stop fail"
6459 run_test 71e "start OST0, MDT1, OST1, MDT0"
6461 test_72() { #LU-2634
6462 [ "$mds1_FSTYPE" != ldiskfs ] &&
6463 skip "ldiskfs only test"
6465 local mdsdev=$(mdsdevname 1)
6466 local ostdev=$(ostdevname 1)
6467 local cmd="$E2FSCK -fnvd $mdsdev"
6474 if combined_mgs_mds; then
6475 add_options='--reformat'
6477 add_options='--reformat --replace'
6480 #tune MDT with "-O extents"
6482 for num in $(seq $MDSCOUNT); do
6483 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
6484 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
6485 error "add mds $num failed"
6486 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
6487 error "$TUNE2FS failed on mds${num}"
6490 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
6491 error "add $ostdev failed"
6492 start_mds || error "start mds failed"
6493 start_ost || error "start ost failed"
6494 mount_client $MOUNT || error "mount client failed"
6496 #create some short symlinks
6497 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6498 createmany -o $DIR/$tdir/$tfile-%d $fn
6499 echo "create $fn short symlinks"
6500 for i in $(seq -w 1 $fn); do
6501 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
6506 umount_client $MOUNT || error "umount client failed"
6507 stop_mds || error "stop mds failed"
6508 stop_ost || error "stop ost failed"
6511 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
6513 run_test 72 "test fast symlink with extents flag enabled"
6515 test_73a() { #LU-3006
6516 [[ "$ost1_FSTYPE" == zfs ]] && import_zpool ost1
6517 local ostdev=$(ostdevname 1)
6519 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $ostdev" ||
6520 error "1st tunefs failed"
6521 start_mgsmds || error "start mds failed"
6522 start_ost || error "start ost failed"
6523 mount_client $MOUNT || error "mount client failed"
6524 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import |
6525 grep "failover_nids.*1.2.3.4@$NETTYPE" ||
6526 error "failover nids haven't changed"
6527 umount_client $MOUNT || error "umount client failed"
6529 do_facet ost1 "$TUNEFS --erase-param failover.node $ostdev"
6532 run_test 73a "failnode to update from mountdata properly"
6535 (( $OST1_VERSION >= $(version_code 2.16.50) )) ||
6536 skip "need OST >= 2.16.50 for many NID support"
6537 [[ "$ost1_FSTYPE" == zfs ]] && import_zpool ost1
6539 local ostdev=$(ostdevname 1)
6540 local nids="111.222.173._@$NETTYPE,111.222.142._@$NETTYPE"
6544 do_facet ost1 "$TUNEFS --comment='just a comment for tail' $ostdev" ||
6545 error "1st tunefs failed"
6547 # 4K can fit ~200 IPv4 NIDs, try more for checking failure case too
6548 # add in pairs in both mgsnode and failnode to reduce test time
6549 for ((i = 1; i <= $iter; i++)); do
6550 local cmd="--failnode=${nids//_/$i} --mgsnode=${nids//_/$i}"
6551 do_facet ost1 "$TUNEFS $cmd $ostdev" >/dev/null ||
6555 start_mgsmds || error "Fail to start mds"
6556 start_ost || error "Fail to mount ost"
6558 local zkeeper=${KEEP_ZPOOL}
6559 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
6564 # count the actual number of failover NIDs configured in failover.node
6565 # there may be some previously configured, so they should also count
6566 local count=$(do_facet ost1 "$TUNEFS --erase-params $ostdev" |
6567 grep "^Param" | grep -Fo '@' | wc -l)
6568 echo "Found total $count NIDs in parameters"
6570 KEEP_ZPOOL="${zkeeper}"
6573 # expect to fit more that 32 mgsnode and 4*32 failover NIDs at least
6574 ((count >= 160)) || error "Only $count NIDs found, need >= (128+32)"
6576 run_test 73b "Large failnode NID list in mountdata"
6579 LOAD_MODULES_REMOTE=true cleanup
6583 (( $OST1_VERSION >= $(version_code 2.16.54) )) ||
6584 skip "Need OST version at least 2.16.54 to don't LBUG"
6587 LOAD_MODULES_REMOTE=true load_modules
6589 INTERFACES=( $(lnet_if_list) )
6590 local inf=${INTERFACES[0]}
6592 do_facet ost1 "$LNETCTL lnet configure" ||
6593 error "unable to configure lnet on ost1"
6595 stack_trap "cleanup_73c"
6597 for ((n = 100; n <= 135; n++)); do
6598 do_facet ost1 "$LNETCTL net add --net ${NETTYPE}$n --if $inf" ||
6599 skip "unable to configure net #$n on ost1"
6602 echo "restart with 35 nets"
6604 start_ost || error "unable to start ost1"
6606 run_test 73c "Server mount doesn't fail with > 32 nets"
6608 test_73d() { #LU-18896
6609 (( $OST1_VERSION >= $(version_code 2.16.53) )) ||
6610 skip "need OST >= 2.16.53 for LU-18896 fix"
6611 [[ "$ost1_FSTYPE" == zfs ]] && import_zpool ost1
6613 local ostdev=$(ostdevname 1)
6615 # add bogus param to mountdata
6616 do_facet ost1 "$TUNEFS --erase-params \
6617 --param=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=1 $ostdev"
6618 do_facet ost1 "$TUNEFS --erase-params --mgsnode=10.23.7.1@tcp \
6619 --mgsnode=10.23.7.2@tcp $ostdev"
6620 bad=$(do_facet ost1 "$TUNEFS --erase-params" $ostdev | grep -c "xx=1")
6623 (( bad == 0 )) || error "garbage in params"
6625 run_test 73d "erase + new parameter doesn't corrupt mountdata"
6629 (( $MDS1_VERSION >= $(version_code 2.15.57.16) )) ||
6630 skip "need MDS version >= 2.15.57.16 for per-device timeouts"
6633 stack_trap "cleanup"
6635 # Prepare fs2, share the mgs of fs
6636 local FSNAME2=fs15246
6637 local fs2mdsdev=$(mdsdevname 1_2)
6638 local fs2ostdev=$(ostdevname 1_2)
6639 local fs2mdsvdev=$(mdsvdevname 1_2)
6640 local fs2ostvdev=$(ostvdevname 1_2)
6642 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --fsname=$FSNAME2 \
6643 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
6644 add fs2ost $(mkfs_opts ost1 $fs2ostdev) --fsname=$FSNAME2 \
6645 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
6647 stack_trap "cleanup_fs2"
6649 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
6650 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
6652 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
6653 $MOUNT_CMD $MGSNID:/$FSNAME2 $MOUNT2 || error "mount $MOUNT2 failed"
6655 echo "========== All mounted lustre fs ===================="
6656 mount | grep 'type lustre'
6657 echo "====================================================="
6659 # Set and check osc/ldlm_enqueue_min
6660 $LCTL set_param osc.${FSNAME}-*.ldlm_enqueue_min=99 ||
6661 error "failed to set per-device adaptive parameters on client"
6662 stack_trap "$LCTL set_param osc.${FSNAME}-*.ldlm_enqueue_min=0"
6664 local ldlm_enqueue_min
6665 ldlm_enqueue_min=$($LCTL get_param -n osc.${FSNAME}-*.ldlm_enqueue_min \
6667 (( $ldlm_enqueue_min == 99 )) ||
6668 error "wrong ldlm_enqueue_min value for osc.${FSNAME}-*"
6670 # Check fs2 as reference
6671 ldlm_enqueue_min=$($LCTL get_param -n osc.${FSNAME2}-*.ldlm_enqueue_min\
6673 (( $ldlm_enqueue_min == 0 )) ||
6674 error "wrong ldlm_enqueue_min value for osc.${FSNAME2}-*"
6676 # Set and check obdfilter/at_min
6677 do_facet ost1 $LCTL set_param obdfilter.${FSNAME}-*.at_min=1 ||
6678 error "failed to set per-device adaptive parameters on ost"
6679 stack_trap "do_facet ost1 $LCTL set_param obdfilter.${FSNAME}-*.at_min=0"
6682 at_min=$(do_facet ost1 $LCTL get_param -n obdfilter.${FSNAME}-*.at_min \
6684 (( $at_min == 1 )) ||
6685 error "wrong at_min value for obdfilter.${FSNAME}-*"
6687 # set and check mdc/at_max
6688 $LCTL set_param mdc.${FSNAME}-*.at_max=599 ||
6689 error "failed to set per-device adaptive parameters on client"
6690 stack_trap "$LCTL set_param mdc.${FSNAME}-*.at_max=0"
6693 at_max=$($LCTL get_param -n mdc.${FSNAME}-*.at_max | uniq)
6694 (( $at_max == 599 )) ||
6695 error "wrong at_max value for osc.${FSNAME}-*"
6697 # Check fs2 as reference
6698 at_max=$($LCTL get_param -n mdc.${FSNAME2}-*.at_max | uniq)
6699 (( $at_max == 0 )) ||
6700 error "wrong at_max value for osc.${FSNAME2}-*"
6702 # Set and check mds/at_max
6703 do_facet mds1 $LCTL set_param *.${FSNAME}-*.at_max=599 ||
6704 error "failed to set per-device adaptive parameters on mds"
6705 stack_trap "do_facet mds1 $LCTL set_param *.${FSNAME}-*.at_max=0"
6708 at_max=$(do_facet mds1 $LCTL get_param -n mdt.${FSNAME}-*.at_max | uniq)
6709 (( at_max == 599 )) ||
6710 error "wrong at_max value for mdt.${FSNAME}-*"
6712 # Set and check mgs&mgc/at_history
6713 local mgs_nid=$(do_facet $SINGLEMDS $LCTL list_nids | tail -1)
6714 $LCTL set_param mgc.MGC$mgs_nid.at_history=588
6715 stack_trap "$LCTL set_param mgc.MGC$mgs_nid.at_history=0"
6718 at_history=$($LCTL get_param -n mgc.MGC$mgs_nid.at_history)
6719 (( $at_history == 588 )) ||
6720 error "wrong at_history value for mgc.MGC$mgs_nid"
6722 do_facet mgs $LCTL set_param mgs.MGS.at_history=588
6723 stack_trap "do_facet mgs $LCTL set_param mgs.MGS.at_history=0"
6724 at_history=$(do_facet mgs $LCTL get_param -n mgs.MGS.at_history)
6725 (( $at_history == 588 )) ||
6726 error "wrong at_history value for mgs.MGS"
6728 run_test 74 "Test per-device adaptive timeout parameters"
6730 test_75() { # LU-2374
6731 [[ "$MDS1_VERSION" -lt $(version_code 2.4.1) ]] &&
6732 skip "Need MDS version at least 2.4.1"
6735 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
6736 --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
6737 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
6738 --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
6741 #check with default parameters
6742 add mds1 $opts_mds || error "add mds1 failed for default params"
6743 add ost1 $opts_ost || error "add ost1 failed for default params"
6745 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
6746 opts_mds=$(echo $opts_mds |
6747 sed -e "s/--index=$index/--index=$index --mdt/")
6748 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
6749 opts_ost=$(echo $opts_ost |
6750 sed -e "s/--index=$index/--index=$index --ost/")
6752 add mds1 $opts_mds || error "add mds1 failed for new params"
6753 add ost1 $opts_ost || error "add ost1 failed for new params"
6758 run_test 75 "The order of --index should be irrelevant"
6761 [[ "$MGS_VERSION" -ge $(version_code 2.4.52) ]] ||
6762 skip "Need MDS version at least 2.4.52"
6765 local MDMB_PARAM="osc.*.max_dirty_mb"
6766 echo "Change MGS params"
6767 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
6769 echo "max_dirty_mb: $MAX_DIRTY_MB"
6770 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
6771 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
6772 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
6773 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
6774 head -1" $NEW_MAX_DIRTY_MB
6775 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
6776 echo "$MAX_DIRTY_MB"
6777 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
6778 error "error while apply max_dirty_mb"
6780 echo "Check the value is stored after remount"
6783 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
6784 head -1" $NEW_MAX_DIRTY_MB
6785 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
6786 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
6787 error "max_dirty_mb is not saved after remount"
6789 echo "Change OST params"
6790 CLIENT_PARAM="obdfilter.*.client_cache_count"
6791 local CLIENT_CACHE_COUNT
6792 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
6794 echo "client_cache_count: $CLIENT_CACHE_COUNT"
6795 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
6796 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
6797 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
6798 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
6799 head -1" $NEW_CLIENT_CACHE_COUNT
6800 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
6802 echo "$CLIENT_CACHE_COUNT"
6803 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
6804 error "error while apply client_cache_count"
6806 echo "Check the value is stored after remount"
6809 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
6810 head -1" $NEW_CLIENT_CACHE_COUNT
6811 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
6813 echo "$CLIENT_CACHE_COUNT"
6814 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
6815 error "client_cache_count is not saved after remount"
6818 run_test 76a "set permanent params with lctl across mounts"
6820 test_76b() { # LU-4783
6821 [[ "$MGS_VERSION" -ge $(version_code 2.5.57) ]] ||
6822 skip "Need MGS version at least 2.5.57"
6825 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
6826 error "start params log failed"
6829 run_test 76b "verify params log setup correctly"
6832 [[ "$MGS_VERSION" -ge $(version_code 2.8.54) ]] ||
6833 skip "Need MDS version at least 2.4.52"
6835 local MASK_PARAM="mdd.*.changelog_mask"
6836 echo "Change changelog_mask"
6837 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
6838 error "Can't change changlog_mask"
6839 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
6842 echo "Check the value is stored after mds remount"
6843 stop_mds || error "Failed to stop MDS"
6844 start_mds || error "Failed to start MDS"
6845 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
6846 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
6847 error "changelog_mask is not changed"
6851 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
6853 test_76d() { #LU-9399
6856 local xattr_cache='llite.$inst.xattr_cache'
6857 local inst=($(lfs getname $MOUNT))
6858 local cmd="$LCTL get_param -n $xattr_cache"
6859 local new=$((($(eval $cmd) + 1) % 2))
6861 echo "lctl set_param -P llite.*.xattr_cache=$new"
6862 do_facet mgs $LCTL set_param -P llite.*.xattr_cache=$new ||
6863 error "Can't change xattr_cache"
6864 stack_trap "do_facet mgs $LCTL set_param -P -d llite.*.xattr_cache || true"
6865 wait_update $HOSTNAME "$cmd" "$new" ||
6866 error "$xattr_cache != $new on original client $MOUNT"
6868 echo "Check $xattr_cache on client $MOUNT"
6869 umount_client $MOUNT || error "umount $MOUNT failed"
6870 mount_client $MOUNT || error "mount $MOUNT failed"
6871 inst=($(lfs getname $MOUNT))
6872 wait_update $HOSTNAME "$cmd" "$new" ||
6873 error "$xattr_cache != $new on remount client $MOUNT"
6875 echo "Check $xattr_cache on the new client $MOUNT2"
6876 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6877 inst=($(lfs getname $MOUNT2))
6878 wait_update $HOSTNAME "$cmd" "$new" ||
6879 error "$xattr_cache != $new on second client $MOUNT2"
6880 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
6882 do_facet mgs $LCTL set_param -P -d llite.*.xattr_cache
6885 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
6887 test_77() { # LU-3445
6888 [[ "$MDS1_VERSION" -ge $(version_code 2.8.55) ]] ||
6889 skip "Need MDS version 2.8.55+ "
6891 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
6892 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
6893 skip_env "mixed loopback and real device not working"
6896 local fs2mdsdev=$(mdsdevname 1_2)
6897 local fs2ostdev=$(ostdevname 1_2)
6898 local fs2mdsvdev=$(mdsvdevname 1_2)
6899 local fs2ostvdev=$(ostvdevname 1_2)
6900 local fsname=test1234
6902 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
6904 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
6906 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
6907 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
6908 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
6909 error "start fs2mds failed"
6911 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
6912 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
6914 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
6915 --failnode=$failnid --fsname=$fsname \
6916 --reformat $fs2ostdev $fs2ostvdev ||
6917 error "add fs2ost failed"
6918 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
6920 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
6921 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
6922 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
6925 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
6928 [[ "$mds1_FSTYPE" != ldiskfs ||
6929 "$ost1_FSTYPE" != ldiskfs ]] &&
6930 skip "ldiskfs only test"
6932 # reformat the Lustre filesystem with a smaller size
6933 local saved_MDSCOUNT=$MDSCOUNT
6934 local saved_MDSSIZE=$MDSSIZE
6935 local saved_OSTCOUNT=$OSTCOUNT
6936 local saved_OSTSIZE=$OSTSIZE
6939 MDSSIZE=$((MDSSIZE - 20000))
6940 OSTSIZE=$((OSTSIZE - 20000))
6941 reformat || error "(1) reformat Lustre filesystem failed"
6942 MDSSIZE=$saved_MDSSIZE
6943 OSTSIZE=$saved_OSTSIZE
6945 # mount the Lustre filesystem
6946 setup_noconfig || error "(2) setup Lustre filesystem failed"
6949 log "create test files"
6954 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
6956 for i in $(seq $num_files); do
6957 file=$MOUNT/$tdir/$tfile-$i
6958 dd if=/dev/urandom of=$file count=1 bs=1M || {
6959 $LCTL get_param osc.*.cur*grant*
6960 $LFS df; $LFS df -i;
6961 # stop creating files if there is no more space
6962 if [ ! -e $file ]; then
6963 num_files=$((i - 1))
6967 $LFS getstripe -v $file
6968 local ost_idx=$(LFS getstripe -i $file)
6969 do_facet ost$((ost_idx + 1)) \
6970 $LCTL get_param obdfilter.*.*grant*
6971 error "(4) create $file failed"
6975 # unmount the Lustre filesystem
6976 cleanup || error "(5) cleanup Lustre filesystem failed"
6978 # run e2fsck on the MDT and OST devices
6979 local mds_host=$(facet_active_host $SINGLEMDS)
6980 local ost_host=$(facet_active_host ost1)
6981 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6982 local ost_dev=$(ostdevname 1)
6984 run_e2fsck $mds_host $mds_dev "-y"
6985 run_e2fsck $ost_host $ost_dev "-y"
6987 # get the original block count of the MDT and OST filesystems
6988 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
6989 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
6991 # expand the MDT and OST filesystems to the device size
6992 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
6993 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
6995 # run e2fsck on the MDT and OST devices again
6996 run_e2fsck $mds_host $mds_dev "-y"
6997 run_e2fsck $ost_host $ost_dev "-y"
6999 # mount the Lustre filesystem
7003 log "check files after expanding the MDT and OST filesystems"
7004 for i in $(seq $num_files); do
7005 file=$MOUNT/$tdir/$tfile-$i
7006 $CHECKSTAT -t file -s 1048576 $file ||
7007 error "(6) checkstat $file failed"
7011 log "create more files after expanding the MDT and OST filesystems"
7012 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
7013 file=$MOUNT/$tdir/$tfile-$i
7014 dd if=/dev/urandom of=$file count=1 bs=1M ||
7015 error "(7) create $file failed"
7018 # unmount the Lustre filesystem
7019 cleanup || error "(8) cleanup Lustre filesystem failed"
7021 # run e2fsck on the MDT and OST devices
7022 run_e2fsck $mds_host $mds_dev "-y"
7023 run_e2fsck $ost_host $ost_dev "-y"
7025 # get the maximum block count of the MDT and OST filesystems
7026 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
7027 local ost_max_blks=$(get_block_count ost1 $ost_dev)
7029 # get the minimum block count of the MDT and OST filesystems
7030 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
7031 grep minimum | sed -e 's/^.*filesystem: //g')
7032 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
7033 grep minimum | sed -e 's/^.*filesystem: //g')
7035 # shrink the MDT and OST filesystems to a smaller size
7039 if [[ $mds_max_blks -gt $mds_min_blks &&
7040 $mds_max_blks -gt $mds_orig_blks ]]; then
7041 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
7042 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
7043 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
7044 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
7045 error "shrink $SINGLEMDS to $new_blks failed"
7049 if [[ $ost_max_blks -gt $ost_min_blks &&
7050 $ost_max_blks -gt $ost_orig_blks ]]; then
7051 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
7052 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
7053 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
7054 run_resize2fs ost1 $ost_dev $new_blks ||
7055 error "shrink ost1 to $new_blks failed"
7059 # check whether the MDT or OST filesystem was shrunk or not
7061 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
7062 reformat_and_config ||
7063 error "(10) reformat Lustre filesystem failed"
7067 # run e2fsck on the MDT and OST devices again
7068 run_e2fsck $mds_host $mds_dev "-y"
7069 run_e2fsck $ost_host $ost_dev "-y"
7071 # mount the Lustre filesystem again
7075 log "check files after shrinking the MDT and OST filesystems"
7076 for i in $(seq $((num_files + 10))); do
7077 file=$MOUNT/$tdir/$tfile-$i
7078 $CHECKSTAT -t file -s 1048576 $file ||
7079 error "(11) checkstat $file failed"
7082 # unmount and reformat the Lustre filesystem
7083 cleanup || error "(12) cleanup Lustre filesystem failed"
7084 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
7086 MDSCOUNT=$saved_MDSCOUNT
7087 OSTCOUNT=$saved_OSTCOUNT
7088 reformat_and_config || error "(14) reformat Lustre filesystem failed"
7090 run_test 78 "run resize2fs on MDT and OST filesystems"
7092 test_79() { # LU-4227
7093 [[ "$MDS1_VERSION" -ge $(version_code 2.5.59) ]] ||
7094 skip "Need MDS version at least 2.5.59"
7096 local mdsdev1=$(mdsdevname 1)
7097 local mdsvdev1=$(mdsvdevname 1)
7098 local mdsdev2=$(mdsdevname 2)
7099 local mdsvdev2=$(mdsvdevname 2)
7100 local ostdev1=$(ostdevname 1)
7101 local ostvdev1=$(ostvdevname 1)
7102 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
7103 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
7104 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
7107 # remove --mgs/--mgsnode from mkfs.lustre options
7108 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
7110 mgsnode_opt=$(echo $opts_mds2 |
7111 awk '{ for ( i = 1; i < NF; i++ )
7112 if ( $i ~ "--mgsnode" ) { print $i; break } }')
7113 [ -n "$mgsnode_opt" ] &&
7114 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
7116 mgsnode_opt=$(echo $opts_ost1 |
7117 awk '{ for ( i = 1; i < NF; i++ )
7118 if ( $i ~ "--mgsnode" ) { print $i; break } }')
7119 [ -n "$mgsnode_opt" ] &&
7120 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
7122 # -MGS, format a mdt without --mgs option
7123 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
7124 error "Must specify --mgs when formatting mdt combined with mgs"
7126 # +MGS, format a mdt/ost without --mgsnode option
7127 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
7128 > /dev/null || error "start mds1 failed"
7129 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
7130 error "Must specify --mgsnode when formatting a mdt"
7131 add ost1 $opts_ost1 $ostdev1 $ostvdev1 &&
7132 error "Must specify --mgsnode when formatting an ost"
7136 run_test 79 "format MDT/OST without mgs option (should return errors)"
7139 start_mds || error "Failed to start MDT"
7140 start_ost || error "Failed to start OST1"
7141 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
7142 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
7143 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
7144 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
7145 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
7147 start_ost2 || error "Failed to start OST2"
7149 do_facet ost1 "$LCTL set_param fail_loc=0"
7154 run_test 80 "mgc import reconnect race"
7156 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
7158 local new_ostcount=$1
7159 saved_ostcount=$OSTCOUNT
7160 OSTCOUNT=$new_ostcount
7164 for ((i = 1; i <= $OSTCOUNT; i++ )); do
7166 eval saved_ostindex$i=${!index}
7171 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
7172 restore_ostindex() {
7176 echo "restoring OSTCOUNT=$saved_ostcount and OSTINDEXn"
7178 for ((i = 1; i <= $OSTCOUNT; i++ )); do
7179 index=saved_ostindex$i
7180 eval OSTINDEX$i=${!index}
7182 OSTCOUNT=$saved_ostcount
7185 if ! combined_mgs_mds ; then
7190 max_lov_stripe_index() {
7193 if [[ $(lustre_version_code $facet) -lt $(version_code 2.15.64) ]]; then
7200 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
7201 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
7202 # assigned index and ensures we can mount such a formatted file system
7203 test_81() { # LU-4665
7204 (( MDS1_VERSION >= $(version_code 2.6.54) )) ||
7205 skip "Need MDS version at least 2.6.54"
7206 (( OSTCOUNT >= 3 )) || skip_env "needs >= 3 OSTs"
7210 # Each time RANDOM is referenced, a random integer between 0 and 32767
7213 local saved_ostindex1=$OSTINDEX1
7214 local LOV_V1_INSANE_STRIPE_INDEX=$(max_lov_stripe_index ost1)
7215 local invalid_index=$((LOV_V1_INSANE_STRIPE_INDEX+4))
7217 for i in $((LOV_V1_INSANE_STRIPE_INDEX + 3)) $((RANDOM + invalid_index)); do
7218 echo -e "\nFormat ost1 with --index=$i, should fail"
7220 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
7221 $(ostdevname 1) $(ostvdevname 1); then
7222 OSTINDEX1=$saved_ostindex1
7223 error "format ost1 with --index=$i should fail"
7226 OSTINDEX1=$saved_ostindex1
7229 stack_trap restore_ostindex
7231 # Format OSTs with random sparse indices.
7232 LOV_V1_INSANE_STRIPE_INDEX=$(max_lov_stripe_index ost2)
7233 local rand_ost=$((RANDOM * 2 % (LOV_V1_INSANE_STRIPE_INDEX - 1) + 1))
7234 LOV_V1_INSANE_STRIPE_INDEX=$(max_lov_stripe_index ost3)
7235 echo "Format $OSTCOUNT OSTs with OST_INDEX_LIST=[0,$rand_ost,$LOV_V1_INSANE_STRIPE_INDEX]"
7236 OST_INDEX_LIST=[0,$rand_ost,$LOV_V1_INSANE_STRIPE_INDEX] formatall ||
7237 error "formatall failed with $?"
7239 # Setup and check Lustre filesystem.
7240 start_mgsmds || error "start_mgsmds failed"
7241 for ((i = 1; i <= $OSTCOUNT; i++ )); do
7242 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
7243 error "start ost$i failed"
7246 mount_client $MOUNT || error "mount client $MOUNT failed"
7247 check_mount || error "check client $MOUNT failed"
7251 local max_easize=$($LCTL get_param -n llite.*.max_easize)
7252 local xattr_size_max=$((4096 - 84)) # 4096 less ldiskfs ea overhead
7254 # XATTR_SIZE_MAX less ldiskfs ea overhead
7255 large_xattr_enabled && xattr_size_max=$((65536 - 84))
7256 (( max_easize >= xattr_size_max )) ||
7257 error "max_easize $max_easize < $xattr_size_max bytes"
7259 test_mkdir $DIR/$tdir
7260 $LFS setstripe -i $rand_ost $DIR/$tdir/$tfile ||
7261 error "error creating $tfile on ost$rand_ost"
7262 $LFS getstripe $DIR/$tdir/$tfile
7269 cmd="getstripe -i $DIR/$tdir/$tfile"
7272 (( $found == $rand_ost )) || error "index $found is not $rand_ost"
7274 cmd="find $DIR/$tdir -i $rand_ost"
7278 [[ "$found" == "$DIR/$tdir/$tfile" ]] ||
7279 error "'lfs find' returned '$found', not '$tfile' by index"
7282 uuid=$(ostuuid_from_index $rand_ost)
7284 cmd="find $DIR/$tdir -O $uuid"
7289 [[ "$found" == "$DIR/$tdir/$tfile" ]] ||
7290 error "'lfs find' returned '$found', not '$tfile' by UUID"
7292 run_test 81 "sparse OST indexing"
7294 random_ost_indices() {
7296 local LOV_V1_INSANE_STRIPE_INDEX
7301 while ((i < num)); do
7304 LOV_V1_INSANE_STRIPE_INDEX=$(max_lov_stripe_index ost$((i+1)))
7305 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_INDEX))
7306 for k in $ost_indices; do
7307 ((index == k)) && skip=true
7310 ost_indices+=" $index"
7316 # Here we exercise the stripe placement functionality on a file system that
7317 # has formatted the OST with a random index. With the file system the following
7318 # functionality is tested:
7320 # 1. Creating a new file with a specific stripe layout.
7322 # 2. Modifiy a existing empty file with a specific stripe layout.
7324 # 3. Ensure we fail to set the stripe layout of a file that already has one.
7326 # 4. If ost-index is defined we need to ensure it is the first entry in the
7327 # ost index list returned by lfs getstripe.
7329 # 5. Lastly ensure this functionality fails with directories.
7330 test_82a() { # LU-4665
7331 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
7332 skip "Need MDS version at least 2.6.54"
7333 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
7339 # Format OSTs with random sparse indices.
7343 ost_indices=$(comma_list $(random_ost_indices 3))
7345 stack_trap "restore_ostindex" EXIT
7346 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
7347 OST_INDEX_LIST=[$ost_indices] formatall
7349 # Setup Lustre filesystem.
7350 start_mgsmds || error "start_mgsmds failed"
7351 for i in $(seq $OSTCOUNT); do
7352 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
7353 error "start ost$i failed"
7356 # Collect debug information - start of test
7357 do_nodes $(mdts_nodes) "$LCTL get_param osp.*.prealloc_*_id"
7359 mount_client $MOUNT || error "mount client $MOUNT failed"
7363 check_lfs_df_ret_val $? || error "$LFS df $MOUNT failed"
7364 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
7366 stack_trap "do_nodes $(mdts_nodes) $LCTL get_param osp.*.prealloc_*_id"
7368 # 1. If the file does not exist, new file will be created
7369 # with specified OSTs.
7370 local file=$DIR/$tdir/$tfile-1
7371 local cmd="$LFS setstripe -o $ost_indices $file"
7373 eval $cmd || error "$cmd failed"
7374 check_stripe_count $file $OSTCOUNT
7375 check_obdidx $file $ost_indices
7376 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
7377 error "write $file failed"
7379 # 2. If the file already exists and is an empty file, the file
7380 # will be attached with specified layout.
7381 file=$DIR/$tdir/$tfile-2
7382 mcreate $file || error "mcreate $file failed"
7383 cmd="$LFS setstripe -o $ost_indices $file"
7385 eval $cmd || error "$cmd failed"
7386 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
7387 error "write $file failed"
7388 check_stripe_count $file $OSTCOUNT
7389 check_obdidx $file $ost_indices
7391 # 3. If the file already has a valid layout attached, the command
7392 # should fail with EBUSY.
7394 eval $cmd && error "stripe is already set on $file, $cmd should fail"
7396 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
7397 # be in the OST indices list.
7398 local start_ost_idx=${ost_indices##*,}
7399 file=$DIR/$tdir/$tfile-3
7400 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
7402 eval $cmd || error "$cmd failed"
7403 check_stripe_count $file $OSTCOUNT
7404 check_obdidx $file $ost_indices
7405 check_start_ost_idx $file $start_ost_idx
7407 file=$DIR/$tdir/$tfile-4
7408 cmd="$LFS setstripe"
7409 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
7410 cmd+=" -i $start_ost_idx $file"
7412 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
7414 # 5. Specifying OST indices for directory should succeed.
7415 local dir=$DIR/$tdir/$tdir
7416 mkdir $dir || error "mkdir $dir failed"
7417 cmd="$LFS setstripe -o $ost_indices $dir"
7418 if [ "$MDS1_VERSION" -gt $(version_code 2.11.53) ] &&
7419 [ "$CLIENT_VERSION" -gt $(version_code 2.11.53) ]; then
7421 eval $cmd || error "unable to specify OST indices on directory"
7423 echo "need MDS+client version at least 2.11.53"
7426 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
7428 # Test 82b is run to ensure that if the user supplies a pool with a specific
7429 # stripe layout that it behaves proprerly. It should fail in the case that
7430 # the supplied OST index list points to OSTs not contained in the user
7432 test_82b() { # LU-4665
7433 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
7434 skip "Need MDS version at least 2.6.54"
7435 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
7441 # Format OSTs with random sparse indices.
7445 ost_indices=$(comma_list $(random_ost_indices 4))
7447 stack_trap "restore_ostindex" EXIT
7448 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
7449 OST_INDEX_LIST=[$ost_indices] formatall
7451 # Setup Lustre filesystem.
7452 start_mgsmds || error "start_mgsmds failed"
7453 for i in $(seq $OSTCOUNT); do
7454 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
7455 error "start ost$i failed"
7458 mount_client $MOUNT || error "mount client $MOUNT failed"
7462 check_lfs_df_ret_val $? || error "$LFS df $MOUNT failed"
7463 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
7465 # Create a new pool and add OSTs into it.
7466 local ost_pool=$FSNAME.$TESTNAME
7467 create_pool $ost_pool || error "create OST pool $ost_pool failed"
7469 local ost_idx_in_list=${ost_indices##*,}
7470 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
7473 local ost_targets="$FSNAME-OST["
7474 for i in ${ost_idx_in_pool//,/ }; do
7475 ost_targets=$ost_targets$(printf "%04x," $i)
7477 ost_targets="${ost_targets%,}]"
7479 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
7480 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
7481 sort -u | tr '\n' ' ')
7483 local cmd="$LCTL pool_add $ost_pool $ost_targets"
7484 do_facet mgs $cmd || error "$cmd failed"
7485 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
7486 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
7487 error "wait_update $ost_pool failed"
7488 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
7489 error "wait_update pool_list $ost_pool failed"
7491 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
7492 # then the OSTs must be the members of the pool.
7493 local file=$DIR/$tdir/$tfile
7494 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
7496 eval $cmd && error "OST with index $ost_idx_in_list should be" \
7497 "in OST pool $ost_pool"
7499 # Only select OST $ost_idx_in_list from $ost_pool for file.
7500 ost_idx_in_list=${ost_idx_in_pool#*,}
7501 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
7503 eval $cmd || error "$cmd failed"
7504 cmd="$LFS getstripe $file"
7506 eval $cmd || error "$cmd failed"
7507 check_stripe_count $file 2
7508 check_obdidx $file $ost_idx_in_list
7509 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
7510 error "write $file failed"
7512 run_test 82b "specify OSTs for file with --pool and --ost-list options"
7515 [[ "$OST1_VERSION" -ge $(version_code 2.6.91) ]] ||
7516 skip "Need OST version at least 2.6.91"
7517 if [ "$ost1_FSTYPE" != ldiskfs ]; then
7518 skip "ldiskfs only test"
7527 ostmnt=$(facet_mntpt ost1)
7529 # Mount the OST as an ldiskfs filesystem.
7530 log "mount the OST $dev as a $ost1_FSTYPE filesystem"
7531 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
7532 --reformat $dev > /dev/null ||
7533 error "format ost1 error"
7535 if ! test -b $dev; then
7536 mnt_opts=$(csa_add "$OST_MOUNT_FS_OPTS" -o loop)
7538 echo "mnt_opts $mnt_opts"
7539 do_facet ost1 mount -t "$ost1_FSTYPE" $dev \
7541 # Run llverfs on the mounted ldiskfs filesystem.
7542 # It is needed to get ENOSPACE.
7543 log "run llverfs in partial mode on the OST $ost1_FSTYPE $ostmnt"
7544 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
7545 "no" || error "run_llverfs error on $ost1_FSTYPE"
7548 log "unmount the OST $dev"
7551 # Delete file IO_scrub. Later osd_scrub_setup will try to
7552 # create "IO_scrub" but will get ENOSPACE.
7554 echo "start ost1 service on `facet_active_host ost1`"
7555 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
7558 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
7559 echo "string err $err"
7560 [ -z "$err" ] || error $err
7563 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
7564 Busy inodes after unmount ..."
7567 local facet=$SINGLEMDS
7568 local num=$(echo $facet | tr -d "mds")
7569 local dev=$(mdsdevname $num)
7570 local time_min=$(recovery_time_min)
7571 local recovery_duration
7572 local completed_clients
7573 local correct_clients
7576 echo "start mds service on $(facet_active_host $facet)"
7577 start_mds "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" ||
7578 error "start MDS failed"
7580 start_ost || error "start OST0000 failed"
7581 wait_osc_import_state mds ost1 FULL
7582 start_ost2 || error "start OST0001 failed"
7583 wait_osc_import_state mds ost2 FULL
7585 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
7587 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
7588 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
7589 # make sure new superblock labels are sync'd before disabling writes
7593 replay_barrier $SINGLEMDS
7594 createmany -o $DIR1/$tfile-%d 1000
7596 # We need to catch the end of recovery window to extend it.
7597 # Skip 5 requests and add delay to request handling.
7598 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
7599 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
7601 facet_failover --fsck $SINGLEMDS || error "failover: $?"
7604 echo "recovery status"
7605 do_facet $SINGLEMDS \
7606 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
7608 recovery_duration=$(do_facet $SINGLEMDS \
7609 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
7610 awk '/recovery_duration/ { print $2 }')
7611 (( $recovery_duration > $time_min + $wrap_up )) &&
7612 error "recovery_duration > recovery_time_hard + wrap up"
7613 completed_clients=$(do_facet $SINGLEMDS \
7614 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
7615 awk '/completed_clients/ { print $2 }')
7617 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
7618 [ "$completed_clients" = "${correct_clients}" ] ||
7619 error "$completed_clients != $correct_clients"
7621 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
7622 umount_client $MOUNT1
7623 umount_client $MOUNT2
7629 run_test 84 "check recovery_hard_time"
7632 [[ "$OST1_VERSION" -ge $(version_code 2.7.55) ]] ||
7633 skip "Need OST version at least 2.7.55"
7634 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
7635 do_facet ost1 "lctl set_param fail_loc=0x197"
7639 run_test 85 "osd_ost init: fail ea_fid_set"
7644 # ost1 has already registered to the MGS before the reformat.
7645 # So after reformatting it with option "-G", it could not be
7646 # mounted to the MGS. Cleanup the system for subsequent tests.
7651 [ "$ost1_FSTYPE" = zfs ] &&
7652 skip "LU-6442: no such mkfs params for ZFS OSTs"
7653 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
7654 skip "Need server version newer than 2.7.55"
7657 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
7658 awk '/Flex block group size: / { print $NF; exit; }')
7660 [ "$OLDSIZE" == "$NEWSIZE" ] && skip "$NEWSIZE groups already"
7662 local opts=" -O flex_bg -G $NEWSIZE"
7663 opts=$(OST_FS_MKFS_OPTS+="$opts" mkfs_opts ost1 $(ostdevname 1))
7664 opts+=" --reformat $(ostdevname 1) $(ostvdevname 1)"
7665 echo "params: $opts"
7667 trap cleanup_86 EXIT ERR
7670 add ost1 $opts || error "add ost1 failed with new params"
7672 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
7673 awk '/Flex block group size: / { print $NF; exit; }')
7675 [[ $FOUNDSIZE == $NEWSIZE ]] ||
7676 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
7680 run_test 86 "Replacing mkfs.lustre -G option"
7682 test_87() { #LU-6544
7683 [[ "$MDS1_VERSION" -ge $(version_code 2.9.51) ]] ||
7684 skip "Need MDS version at least 2.9.51"
7685 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
7686 skip "ldiskfs only test"
7687 [[ $OSTCOUNT -gt 59 ]] &&
7688 skip "Ignore wide striping situation"
7689 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7691 local mdsdev=$(mdsdevname 1)
7692 local mdsvdev=$(mdsvdevname 1)
7693 local file=$DIR/$tfile
7694 local mntpt=$(facet_mntpt $SINGLEMDS)
7695 local used_xattr_blk=0
7696 local inode_size=${1:-1024}
7698 local xtest="trusted.test"
7702 local stripe_cnt=$(($OSTCOUNT + 2))
7704 #Please see ldiskfs_make_lustre() for MDT inode size calculation
7705 if [ $stripe_cnt -gt 16 ]; then
7708 left_size=$(expr $inode_size - \
7711 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
7713 24 - 18 - $(expr length $tfile) - 16 - 4)
7714 if [ $left_size -le 0 ]; then
7715 echo "No space($left_size) is expected in inode."
7716 echo "Try 1-byte xattr instead to verify this."
7719 echo "Estimate: at most $left_size-byte space left in inode."
7725 if ! combined_mgs_mds ; then
7729 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
7730 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
7731 start_mdt 1 > /dev/null || error "start mdt1 failed"
7732 for i in $(seq $OSTCOUNT); do
7733 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
7734 error "start ost$i failed"
7736 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
7737 check_mount || error "check client $MOUNT failed"
7740 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
7741 error "Create file with 3 components failed"
7742 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
7743 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
7744 if [ $i -ne $OSTCOUNT ]; then
7745 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
7746 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
7747 echo -n "the expected left space is changed to "
7748 echo "$left_size bytes at most."
7750 value=$(generate_string $left_size)
7751 setfattr -n $xtest -v $value $file
7752 orig=$(get_xattr_value $xtest $file)
7753 [[ "$orig" != "$value" ]] && error "$xtest changed"
7755 #Verify if inode has some expected space left
7756 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
7757 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
7758 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
7760 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
7761 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
7763 [[ $used_xattr_blk -eq 0 ]] &&
7764 error "Please check MDS inode size calculation: \
7765 more than $left_size-byte space left in inode."
7766 echo "Verified: at most $left_size-byte space left in inode."
7768 unmount_ldiskfs $SINGLEMDS
7770 for i in $(seq $OSTCOUNT); do
7771 stop ost$i -f || error "stop ost$i failed"
7774 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
7777 [ "$mds1_FSTYPE" == zfs ] &&
7778 skip "LU-6662: no implementation for ZFS"
7782 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
7783 --reformat $(mdsdevname 1) || error "add mds1 failed"
7785 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
7786 grep -e \".*opts:.*errors=remount-ro.*\"" ||
7787 error "default mount options is missing"
7789 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
7790 --mountfsoptions="user_xattr,errors=panic" \
7791 --reformat $(mdsdevname 1) || error "add mds1 failed"
7793 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
7794 grep -e \".*opts:.*errors=panic.*\"" ||
7795 error "user can't override default mount options"
7797 run_test 88 "check the default mount options can be overridden"
7799 test_89() { # LU-7131
7800 [[ "$MDS1_VERSION" -ge $(version_code 2.9.54) ]] ||
7801 skip "Need MDT version at least 2.9.54"
7803 local key=failover.node
7804 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
7805 local val2=192.0.2.255@tcp0
7806 local mdsdev=$(mdsdevname 1)
7811 if [[ "$mds1_FSTYPE" == zfs ]]; then
7812 import_zpool mds1 || return ${PIPESTATUS[0]}
7815 # Check that parameters are added correctly
7816 echo "tunefs --param $key=$val1"
7817 do_facet mds1 "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
7818 error "tunefs --param $key=$val1 failed"
7819 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7820 error "tunefs --dryrun failed"
7821 params=${params##*Parameters:}
7822 params=${params%%exiting*}
7823 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
7824 error "on-disk parameter not added correctly via tunefs"
7826 # Check that parameters replace existing instances when added
7827 echo "tunefs --param $key=$val2"
7828 do_facet mds1 "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
7829 error "tunefs --param $key=$val2 failed"
7830 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7831 error "tunefs --dryrun failed"
7832 params=${params##*Parameters:}
7833 params=${params%%exiting*}
7834 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
7835 error "on-disk parameter not replaced via tunefs"
7836 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
7837 error "on-disk parameter not replaced correctly via tunefs"
7839 # Check that a parameter is erased properly
7840 echo "tunefs --erase-param $key"
7841 do_facet mds1 "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
7842 error "tunefs --erase-param $key failed"
7843 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7844 error "tunefs --dryrun failed"
7845 params=${params##*Parameters:}
7846 params=${params%%exiting*}
7847 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
7848 error "on-disk parameter not erased correctly via tunefs"
7850 # Check that all the parameters are erased
7851 do_facet mds1 "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
7852 error "tunefs --param $key=$val1 failed"
7853 echo "tunefs --erase-params"
7854 do_facet mds1 "$TUNEFS --erase-params $mdsdev >/dev/null" ||
7855 error "tunefs --erase-params failed"
7856 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7857 error "tunefs --dryrun failed"
7858 params=${params##*Parameters:}
7859 params=${params%%exiting*}
7860 params=$(echo $params | tr ' ' '\n')
7862 error "all on-disk parameters not erased correctly via tunefs $params"
7864 # Check the order of options --erase-params and --param
7865 echo "tunefs --param $key=$val1 --erase-params"
7867 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
7868 error "tunefs --param $key=$val1 --erase-params failed"
7869 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7870 error "tunefs --dryrun failed"
7871 params=${params##*Parameters:}
7872 params=${params%%exiting*}
7873 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
7874 error "on-disk param not added correctly with --erase-params"
7878 run_test 89 "check tunefs --param and --erase-param{s} options"
7881 # $2 (optional) value of max_mod_rpcs_in_flight to set
7882 check_max_mod_rpcs_in_flight() {
7890 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
7891 facet="mds$((0x$idx + 1))"
7893 if [ -z "$mmr" ]; then
7894 # get value of max_mod_rcps_in_flight
7895 mmr=$($LCTL get_param -n \
7896 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
7897 error "Unable to get max_mod_rpcs_in_flight"
7898 echo "max_mod_rcps_in_flight is $mmr"
7900 # set value of max_mod_rpcs_in_flight
7902 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
7903 error "Unable to set max_mod_rpcs_in_flight to $mmr"
7904 echo "max_mod_rpcs_in_flight set to $mmr"
7907 # create mmr+1 files
7908 echo "creating $((mmr + 1)) files ..."
7910 for i in $(seq $((mmr + 1))); do
7916 # consumes mmr-1 modify RPC slots
7917 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
7918 # drop requests on MDT so that RPC slots are consumed
7919 # during all the request resend interval
7920 do_facet $facet "$LCTL set_param fail_loc=0x159"
7921 echo "launch $((mmr - 1)) chmod in parallel ..."
7922 for i in $(seq $((mmr - 1))); do
7923 chmod 0600 $dir/file-$i &
7927 # send one additional modify RPC
7928 do_facet $facet "$LCTL set_param fail_loc=0"
7929 echo "launch 1 additional chmod in parallel ..."
7930 chmod 0600 $dir/file-$mmr &
7933 # check this additional modify RPC get a modify RPC slot
7934 # and succeed its operation
7935 checkstat -vp 0600 $dir/file-$mmr ||
7936 error "Unable to send $mmr modify RPCs in parallel"
7941 # consumes mmr modify RPC slots
7942 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
7943 # drop requests on MDT so that RPC slots are consumed
7944 # during all the request resend interval
7945 do_facet $facet "$LCTL set_param fail_loc=0x159"
7946 echo "launch $mmr chmod in parallel ..."
7947 for i in $(seq $mmr); do
7948 chmod 0666 $dir/file-$i &
7952 # send one additional modify RPC
7953 do_facet $facet "$LCTL set_param fail_loc=0"
7954 echo "launch 1 additional chmod in parallel ..."
7955 chmod 0666 $dir/file-$((mmr + 1)) &
7958 # check this additional modify RPC blocked getting a modify RPC slot
7959 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
7960 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
7964 get_mdt_max_mod_rpcs_in_flight_val() {
7968 # It will be enough to get one value from one MDT
7969 max_mrif=$(do_facet $facet \
7970 "$LCTL get_param -n \
7971 mdt.$FSNAME-MDT*.max_mod_rpcs_in_flight | head -n 1")
7972 if [[ $max_mrif ]]; then
7975 max_mrif=$(do_facet $facet \
7976 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
7981 set_mdt_max_mod_rpcs_in_flight() {
7986 lctl_op=$($LCTL get_param \
7987 mdt.*.max_mod_rpcs_in_flight)
7988 if [[ $lctl_op ]]; then
7991 mdt.$FSNAME-MDT*.max_mod_rpcs_in_flight=$max_mrif"
7995 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
7996 echo "the deprecated max_mod_rpcs_per_client \
7997 parameter was involved"
8004 [[ $($LCTL get_param mdc.*.import |
8005 grep "connect_flags:.*multi_mod_rpc") ]] ||
8006 skip "Need MDC with 'multi_mod_rpcs' feature"
8008 # check default value
8009 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
8010 check_max_mod_rpcs_in_flight $DIR/$tdir
8014 run_test 90a "check max_mod_rpcs_in_flight is enforced"
8024 [[ $($LCTL get_param mdc.*.import |
8025 grep "connect_flags:.*multi_mod_rpc") ]] ||
8026 skip "Need MDC with 'multi_mod_rpcs' feature"
8029 # update max_mod_rpcs_in_flight
8030 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
8031 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
8034 # check client is able to send multiple modify RPCs in paralell
8035 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
8036 grep -c "multi_mod_rpcs")
8037 if [ "$tmp" -ne $MDSCOUNT ]; then
8039 skip "Client not able to send multiple modify RPCs in parallel"
8042 # update max_mod_rpcs_in_flight
8043 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
8044 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
8047 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
8048 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
8049 facet="mds$((0x$idx + 1))"
8051 mmrpc=$(get_mdt_max_mod_rpcs_in_flight_val $facet)
8052 echo "mdt_max_mod_rpcs_in_flight is $mmrpc"
8053 # update max_mod_rpcs_in_flight
8054 umount_client $MOUNT
8055 set_mdt_max_mod_rpcs_in_flight 16 $facet
8057 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
8058 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
8060 # restore MDT max_mod_rpcs_in_flight initial value
8061 set_mdt_max_mod_rpcs_in_flight $mmrpc $facet
8063 rm -rf $DIR/${tdir}?
8066 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
8069 # get max_rpcs_in_flight value
8070 mrif_90c=$($LCTL get_param -n \
8071 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
8072 echo "max_rpcs_in_flight is $mrif_90c"
8074 # get MDC max_mod_rpcs_in_flight value
8075 mmrif_90c=$($LCTL get_param -n \
8076 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight)
8077 echo "MDC max_mod_rpcs_in_flight is $mmrif_90c"
8079 # get MDT max_mod_rpcs_in_flight value
8080 mmrpc_90c=$(get_mdt_max_mod_rpcs_in_flight_val "mds1")
8081 echo "mdt_max_mod_rpcs_in_flight is $mmrpc_90c"
8084 restore_params_90c() {
8087 # restore max_rpcs_in_flight value
8088 do_facet mgs $LCTL set_param -P \
8089 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
8091 # restore max_mod_rpcs_in_flight value
8092 do_facet mgs $LCTL set_param -P \
8093 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mmrif_90c
8095 # restore MDT max_mod_rpcs_in_flight value
8096 set_mdt_max_mod_rpcs_in_flight $mmrpc_90c "mds1"
8104 [[ $($LCTL get_param mdc.*.import |
8105 grep "connect_flags:.*multi_mod_rpc") ]] ||
8106 skip "Need MDC with 'multi_mod_rpcs' feature"
8108 # check client is able to send multiple modify RPCs in paralell
8109 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
8110 grep -c "multi_mod_rpcs")
8111 if [ "$tmp" -ne $MDSCOUNT ]; then
8113 skip "Client not able to send multiple modify RPCs in parallel"
8117 stack_trap restore_params_90c
8120 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
8121 # prerequisite: set MDT max_mod_rpcs_in_flight to
8122 # max_rpcs_in_flight value
8123 set_mdt_max_mod_rpcs_in_flight $mrif_90c "mds1"
8125 # if max_mod_rpcs_in_flight is set to be equal to or larger than
8126 # max_rpcs_in_flight, then max_rpcs_in_flight will be increased
8127 if [[ "$CLIENT_VERSION" -ge $(version_code 2.13.53) ]]; then
8129 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c ||
8130 error "set max_mod_rpcs_in_flight to $mrif_90c failed"
8132 local new_mrif=$($LCTL get_param -n \
8133 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
8134 ((new_mrif == mrif_90c + 1)) ||
8135 error "max_rpcs_in_flight was not increased"
8138 umount_client $MOUNT
8139 set_mdt_max_mod_rpcs_in_flight $mmrpc_90c "mds1"
8143 # attempt to set max_mod_rpcs_in_flight to MDT max_mod_rpcs_in_flight+1
8144 # prerequisite: set max_rpcs_in_flight to MDT max_mod_rpcs_in_flight+2
8146 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc_90c + 2))
8149 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc_90c + 1)) &&
8150 error "set max_mod_rpcs_in_flight to $((mmrpc_90c + 1)) should fail"
8153 # attempt to set max_mod_rpcs_in_flight permanently
8154 do_facet mgs $LCTL set_param -P \
8155 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
8157 do_facet mgs $LCTL set_param -P \
8158 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c
8160 remount_client $MOUNT
8162 wait_update_facet --verbose client "$LCTL get_param -n \
8163 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
8164 "$((mrif_90c + 1))" ||
8165 error "expected '$((mrif_90c + 1))' for max_rpcs_in_flight"
8167 wait_update_facet --verbose client "$LCTL get_param -n \
8168 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight" \
8170 error "expected '$mrif_90c' for max_mod_rpcs_in_flight"
8175 run_test 90c "check max_mod_rpcs_in_flight update limits"
8186 [[ $($LCTL get_param mdc.*.import |
8187 grep "connect_flags:.*multi_mod_rpc") ]] ||
8188 skip "Need MDC with 'multi_mod_rpcs' feature"
8190 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
8191 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
8192 facet="mds$((0x$idx + 1))"
8194 # check client version supports multislots
8195 tmp=$($LCTL get_param -N \
8196 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
8197 if [ -z "$tmp" ]; then
8199 skip "Client does not support multiple modify RPCs in flight"
8202 # get current value of max_mod_rcps_in_flight
8203 mmr=$($LCTL get_param -n \
8204 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
8205 echo "max_mod_rcps_in_flight is $mmr"
8208 echo "creating $mmr files ..."
8210 for i in $(seq $mmr); do
8211 touch $DIR/$tdir/file-$i
8214 # prepare for close RPC
8215 multiop_bg_pause $DIR/$tdir/file-close O_c
8218 # consumes mmr modify RPC slots
8219 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
8220 # drop requests on MDT so that RPC slots are consumed
8221 # during all the request resend interval
8222 do_facet $facet "$LCTL set_param fail_loc=0x159"
8223 echo "launch $mmr chmod in parallel ..."
8224 for i in $(seq $mmr); do
8225 chmod 0600 $DIR/$tdir/file-$i &
8228 # send one additional close RPC
8229 do_facet $facet "$LCTL set_param fail_loc=0"
8230 echo "launch 1 additional close in parallel ..."
8232 cancel_lru_locks mdc
8235 # check this additional close RPC get a modify RPC slot
8236 # and multiop process completed
8237 [ -d /proc/$pid ] &&
8238 error "Unable to send the additional close RPC in parallel"
8243 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
8245 check_uuid_on_ost() {
8247 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
8250 check_uuid_on_mdt() {
8252 do_facet $SINGLEMDS "$LCTL get_param mdt.${mds1_svc}*.exports.'$nid'.uuid"
8260 [[ "$OST1_VERSION" -ge $(version_code 2.7.63) ]] ||
8261 skip "Need OST version at least 2.7.63"
8262 [[ "$MDS1_VERSION" -ge $(version_code 2.7.63) ]] ||
8263 skip "Need MDT version at least 2.7.63"
8265 start_mds || error "MDS start failed"
8266 start_ost || error "unable to start OST"
8267 mount_client $MOUNT || error "client start failed"
8268 check_mount || error "check_mount failed"
8271 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
8275 uuid=$(get_client_uuid $MOUNT)
8277 echo "list nids on mdt:"
8278 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
8279 echo "uuid from $nid:"
8280 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
8282 found=$(check_uuid_on_mdt $nid | grep $uuid)
8283 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
8284 found=$(check_uuid_on_ost $nid | grep $uuid)
8285 [ -z "$found" ] && error "can't find $uuid $nid on OST"
8287 # umount the client so it won't reconnect
8288 manual_umount_client --force || error "failed to umount $?"
8289 # shouldn't disappear on MDS after forced umount
8290 found=$(check_uuid_on_mdt $nid | grep $uuid)
8291 [ -z "$found" ] && error "can't find $uuid $nid"
8294 do_facet $SINGLEMDS \
8295 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
8296 sleep 1 # eviction above is async, give it some time to proceed
8298 found=$(check_uuid_on_mdt $nid | grep $uuid)
8299 [ -n "$found" ] && error "found $uuid $nid on MDT"
8300 found=$(check_uuid_on_ost $nid | grep $uuid)
8301 [ -n "$found" ] && error "found $uuid $nid on OST"
8303 # check it didn't reconnect (being umounted)
8304 sleep $((TIMEOUT+1))
8305 found=$(check_uuid_on_mdt $nid | grep $uuid)
8306 [ -n "$found" ] && error "found $uuid $nid on MDT"
8307 found=$(check_uuid_on_ost $nid | grep $uuid)
8308 [ -n "$found" ] && error "found $uuid $nid on OST"
8312 run_test 91 "evict-by-nid support"
8314 generate_ldev_conf() {
8315 # generate an ldev.conf file
8316 local ldevconfpath=$1
8318 local fsldevformat=""
8321 local facets="mgs,$(get_facets OST),$(get_facets MDS)"
8322 for facet in ${facets//,/ }; do
8324 fstype=$(facet_fstype $facet)
8325 [ "$fstype" = zfs ] && fsldevformat="$fstype:"
8326 local host=$(facet_host $facet)
8328 local varfo=${facet}failover_HOST
8329 if [ $facet == mgs ] && combined_mgs_mds; then
8330 varfo=mds1failover_HOST
8332 [ -n "${!varfo}" ] && fo=${!varfo}
8333 local type=$(echo $facet | tr -d "[:digit:]" | \
8334 tr "[:lower:]" "[:upper:]" | sed s/MDS/MDT/ )
8336 [ ${facet} == mgs ] ||
8337 num=$(facet_number $facet)
8338 printf "%s\t%s\t%s-%s%04x\t%s%s\n" \
8345 $(facet_device $facet) >> $ldevconfpath
8348 echo "----- $ldevconfpath -----"
8350 echo "--- END $ldevconfpath ---"
8355 # generate a nids file (mapping between hostname to nid)
8356 # looks like we only have the MGS nid available to us
8357 # so just echo that to a file
8359 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
8361 echo "----- $nidspath -----"
8363 echo "--- END $nidspath ---"
8366 compare_ldev_output() {
8367 local ldev_output=$1
8368 local expected_output=$2
8370 sort $expected_output -o $expected_output
8371 sort $ldev_output -o $ldev_output
8373 echo "-- START OF LDEV OUTPUT --"
8375 echo "--- END OF LDEV OUTPUT ---"
8377 echo "-- START OF EXPECTED OUTPUT --"
8378 cat $expected_output
8379 echo "--- END OF EXPECTED OUTPUT ---"
8381 diff $expected_output $ldev_output
8386 if [ -z "$LDEV" ]; then
8387 error "ldev is missing!"
8390 local LDEVCONFPATH=$TMP/ldev.conf
8391 local NIDSPATH=$TMP/nids
8393 echo "Host is $(hostname)"
8395 generate_ldev_conf $LDEVCONFPATH
8396 generate_nids $NIDSPATH
8398 # echo the mgs nid and compare it to environment variable MGSNID
8399 local facets="$(get_facets OST),$(get_facets MDS),mgs"
8400 for facet in ${facets//,/ }; do
8401 local host=$(facet_host $facet)
8402 local output=$($LDEV -c $LDEVCONFPATH -H $host -n $NIDSPATH echo %m)
8404 echo "-- START OF LDEV OUTPUT --"
8406 echo "--- END OF LDEV OUTPUT ---"
8409 error "ldev failed to execute!"
8411 # need to process multiple lines because of
8412 # several targets on host
8413 echo -e $output | awk '{ print $2 }' | while read -r line ; do
8414 [ "$line" = "$MGSNID" ] ||
8415 error "ldev failed mgs nid '$line', \
8419 rm -f $LDEVCONFPATH $NIDSPATH
8421 run_test 92 "ldev returns MGS NID correctly in command substitution"
8424 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
8427 #start mgs or mgs/mdt0
8428 if ! combined_mgs_mds ; then
8435 start_ost || error "OST0 start fail"
8437 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
8438 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
8439 for num in $(seq 2 $MDSCOUNT); do
8443 mount_client $MOUNT || error "mount client fails"
8444 wait_osc_import_state mds ost FULL
8445 wait_osc_import_ready client ost
8446 check_mount || error "check_mount failed"
8448 cleanup || error "cleanup failed with $?"
8450 run_test 93 "register mulitple MDT at the same time"
8453 if [ -z "$LDEV" ]; then
8454 error "ldev is missing!"
8457 local LDEVCONFPATH=$TMP/ldev.conf
8458 local NIDSPATH=$TMP/nids
8460 generate_ldev_conf $LDEVCONFPATH
8461 generate_nids $NIDSPATH
8463 local LDEV_OUTPUT=$TMP/ldev-output.txt
8464 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
8466 # ldev failed, error
8467 if [ $? -ne 0 ]; then
8468 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
8469 error "ldev failed to execute!"
8473 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
8475 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
8477 for num in $(seq $MDSCOUNT); do
8478 printf "%s-MDT%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
8481 for num in $(seq $OSTCOUNT); do
8482 printf "%s-OST%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
8485 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8487 if [ $? -ne 0 ]; then
8488 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8489 error "ldev failed to produce the correct hostlist!"
8492 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8494 run_test 94 "ldev outputs correct labels for file system name query"
8497 if [ -z "$LDEV" ]; then
8498 error "ldev is missing!"
8501 local LDEVCONFPATH=$TMP/ldev.conf
8502 local NIDSPATH=$TMP/nids
8504 generate_ldev_conf $LDEVCONFPATH
8505 generate_nids $NIDSPATH
8509 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
8510 if [ $? -ne 0 ]; then
8511 rm $LDEVCONFPATH $NIDSPATH
8512 error "ldev label filtering w/ -F failed!"
8516 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
8517 if [ $? -ne 0 ]; then
8518 rm $LDEVCONFPATH $NIDSPATH
8519 error "ldev label filtering w/ -l failed!"
8523 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
8524 if [ $? -ne 0 ]; then
8525 rm $LDEVCONFPATH $NIDSPATH
8526 error "ldev label filtering w/ -f failed!"
8530 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
8531 if [ $? -ne 0 ]; then
8532 rm $LDEVCONFPATH $NIDSPATH
8533 error "ldev label filtering w/ -a failed!"
8538 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
8539 if [ $? -eq 0 ]; then
8540 rm $LDEVCONFPATH $NIDSPATH
8541 error "ldev label filtering w/ -a and -F incorrectly succeeded"
8545 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
8546 if [ $? -eq 0 ]; then
8547 rm $LDEVCONFPATH $NIDSPATH
8548 error "ldev label filtering w/ -a and -f incorrectly succeeded"
8552 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
8553 if [ $? -eq 0 ]; then
8554 rm $LDEVCONFPATH $NIDSPATH
8555 error "ldev label filtering w/ -a and -l incorrectly succeeded"
8559 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
8560 if [ $? -eq 0 ]; then
8561 rm $LDEVCONFPATH $NIDSPATH
8562 error "ldev label filtering w/ -f and -l incorrectly succeeded"
8566 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
8567 if [ $? -eq 0 ]; then
8568 rm $LDEVCONFPATH $NIDSPATH
8569 error "ldev label filtering w/ -F and -l incorrectly succeeded"
8572 # file sys & foreign
8573 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
8574 if [ $? -eq 0 ]; then
8575 rm $LDEVCONFPATH $NIDSPATH
8576 error "ldev label filtering w/ -F and -f incorrectly succeeded"
8579 rm $LDEVCONFPATH $NIDSPATH
8581 run_test 95 "ldev should only allow one label filter"
8584 if [ -z "$LDEV" ]; then
8585 error "ldev is missing!"
8588 local LDEVCONFPATH=$TMP/ldev.conf
8589 local NIDSPATH=$TMP/nids
8591 generate_ldev_conf $LDEVCONFPATH
8592 generate_nids $NIDSPATH
8594 local LDEV_OUTPUT=$TMP/ldev-output.txt
8595 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
8597 awk '{print $2}' > $LDEV_OUTPUT
8599 # ldev failed, error
8600 if [ $? -ne 0 ]; then
8601 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
8602 error "ldev failed to execute!"
8606 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
8608 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
8610 local facets="$(get_facets OST),$(get_facets MDS)"
8611 for facet in ${facets//,/ }; do
8612 local host=$(facet_host $facet)
8613 [ "$mgs_HOST" == "$host" ] &&
8614 echo "$host-$(facet_fstype $facet)" \
8618 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8620 if [ $? -ne 0 ]; then
8621 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8622 error "ldev failed to produce the correct output!"
8625 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8627 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
8630 if [ -z "$LDEV" ]; then
8631 error "ldev is missing!"
8634 local LDEVCONFPATH=$TMP/ldev.conf
8635 local NIDSPATH=$TMP/nids
8637 generate_ldev_conf $LDEVCONFPATH
8638 generate_nids $NIDSPATH
8640 local LDEV_OUTPUT=$TMP/ldev-output.txt
8641 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
8643 echo -e "\nMDT role"
8644 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
8646 if [ $? -ne 0 ]; then
8647 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
8648 error "ldev failed to execute for mdt role!"
8651 for num in $(seq $MDSCOUNT); do
8652 printf "%s-MDT%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
8655 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8657 if [ $? -ne 0 ]; then
8658 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8659 error "ldev failed to produce the correct output for mdt role!"
8662 echo -e "\nOST role"
8663 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
8665 if [ $? -ne 0 ]; then
8666 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
8667 error "ldev failed to execute for ost role!"
8671 for num in $(seq $OSTCOUNT); do
8672 printf "%s-OST%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
8675 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8677 if [ $? -ne 0 ]; then
8678 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8679 error "ldev failed to produce the correct output for ost role!"
8682 echo -e "\nMGS role"
8683 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
8685 if [ $? -ne 0 ]; then
8686 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
8687 error "ldev failed to execute for mgs role!"
8690 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
8692 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8694 if [ $? -ne 0 ]; then
8695 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8696 error "ldev failed to produce the correct output for mgs role!"
8699 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8701 run_test 97 "ldev returns correct ouput when querying based on role"
8708 check_mount || error "mount failed"
8709 mountopt="user_xattr"
8710 for ((x = 1; x <= PAGE_SIZE/10; x++)); do
8711 mountopt="$mountopt,user_xattr"
8713 mount.lustre -o remount,$mountopt -v $MGSNID:/$FSNAME $MOUNT 2>&1 |
8715 grep "too long" $TMP/$tfile.out ||
8716 error "Buffer overflow check failed"
8718 cleanup || error "cleanup failed"
8720 run_test 98 "Buffer-overflow check while parsing mount_opts"
8724 [[ "$ost1_FSTYPE" != ldiskfs ]] &&
8725 skip "ldiskfs only test"
8726 [[ "$OST1_VERSION" -ge $(version_code 2.8.57) ]] ||
8727 skip "Need OST version at least 2.8.57"
8729 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8730 --reformat $(ostdevname 1) $(ostvdevname 1)"
8731 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
8732 skip "meta_bg already set"
8735 if [[ ${!opts} != *mkfsoptions* ]]; then
8736 eval opts=\"${!opts} \
8737 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
8739 local val=${!opts//--mkfsoptions=\\\"/ \
8740 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
8744 echo "params: $opts"
8747 add ost1 $opts || error "add ost1 failed with new params"
8749 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
8750 error "meta_bg is not set"
8752 run_test 99 "Adding meta_bg option"
8757 start_mgsmds || error "MDS start failed"
8758 start_ost || error "unable to start OST"
8759 mount_client $MOUNT || error "client start failed"
8760 check_mount || error "check_mount failed"
8769 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
8770 END {exit rc}' || error "lshowmount have no output MGS"
8772 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
8773 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
8775 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
8776 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
8778 cleanup || error "cleanup failed with $?"
8780 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
8783 local createmany_pid
8784 local dev=$FSNAME-OST0000-osc-MDT0000
8787 mkdir_on_mdt0 $DIR1/$tdir
8788 do_nodes $(osts_nodes) \
8789 $LCTL set_param seq.*OST*-super.width=$DATA_SEQ_MAX_WIDTH
8790 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
8792 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
8793 # via osp_precreate_cleanup_orphans.
8794 for ((i = 0; i < 100; i++)); do
8795 for ((k = 0; k < 10; k++)); do
8796 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
8797 "$LCTL --device $dev activate"
8800 ls -asl $MOUNT | grep '???' &&
8801 { kill -9 $createmany_pid &>/dev/null;
8802 error "File has no object on OST"; }
8804 kill -s 0 $createmany_pid || break
8806 wait $createmany_pid
8808 unlinkmany $DIR1/$tdir/$tfile-%d 50000
8811 run_test 101a "Race MDT->OST reconnection with create"
8814 local dev=$FSNAME-OST0000-osc-MDT0000
8815 local dir=$DIR1/$tdir
8819 $LFS setstripe -c 1 -i 0 $dir
8820 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;"
8821 #define OBD_FAIL_OSP_CON_EVENT_DELAY 0x2107
8822 do_facet mds1 "$LCTL set_param fail_loc=0x80002107 fail_val=20"
8823 do_facet $SINGLEMDS "$LCTL --device $dev activate;"
8828 wait_osc_import_ready client ost1
8829 touch $dir/$tfile || error "Can't create file"
8833 run_test 101b "Race events DISCONNECT and ACTIVE in osp"
8836 [[ "$MDS1_VERSION" -gt $(version_code 2.9.53) ]] ||
8837 skip "Need server version greater than 2.9.53"
8838 [[ "$(mdsdevname 1)" != "$(mgsdevname)" ]] &&
8839 [[ "$(facet_host mds1)" == "$(facet_host mgs)" ]] &&
8840 skip "MGS must be on different node or combined"
8842 cleanup || error "cleanup failed with $?"
8844 local mds1dev=$(mdsdevname 1)
8845 local mds1mnt=$(facet_mntpt mds1)
8846 local mds1opts=$MDS_MOUNT_OPTS
8848 if [ "$mds1_FSTYPE" == ldiskfs ] &&
8849 ! do_facet mds1 test -b $mds1dev; then
8850 mds1opts=$(csa_add "$mds1opts" -o loop)
8852 if [[ "$mds1_FSTYPE" == zfs ]]; then
8853 import_zpool mds1 || return ${PIPESTATUS[0]}
8856 # unload all and only load libcfs to allow fail_loc setting
8857 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
8858 do_rpc_nodes $(facet_active_host mds1) load_module ../libcfs/libcfs/libcfs
8859 do_facet mds1 lsmod | grep libcfs || error "libcfs not loaded"
8861 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
8862 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
8864 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
8865 error "mdt start must fail" || log "mount failed as expected"
8866 do_facet mds1 lsmod | grep obdclass && error "obdclass must not load" ||
8867 log "obdclass not loaded as expected"
8869 do_facet mds1 "$LCTL set_param fail_loc=0x0"
8871 do_rpc_nodes $(facet_active_host mds1) load_modules
8872 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
8873 log "mds1 mounted properly" ||
8874 error "mdt start must not fail"
8876 cleanup || error "cleanup failed with $?"
8878 run_test 102 "obdclass module cleanup upon error"
8883 echo "rename $FSNAME to $newname"
8885 if ! combined_mgs_mds ; then
8886 local dev=$(mgsdevname)
8889 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
8890 error "(7) Fail to rename MGS"
8891 if [ "$(facet_fstype mgs)" = "zfs" ]; then
8892 reimport_zpool mgs $newname-mgs
8896 for num in $(seq $MDSCOUNT); do
8897 local dev=$(mdsdevname $num)
8899 do_facet mds${num} \
8900 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
8901 error "(8) Fail to rename MDT $num"
8902 if [ "$(facet_fstype mds${num})" = "zfs" ]; then
8903 reimport_zpool mds${num} $newname-mdt${num}
8907 for num in $(seq $OSTCOUNT); do
8908 local dev=$(ostdevname $num)
8910 do_facet ost${num} \
8911 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
8912 error "(9) Fail to rename OST $num"
8913 if [ "$(facet_fstype ost${num})" = "zfs" ]; then
8914 reimport_zpool ost${num} $newname-ost${num}
8919 test_103_set_pool() {
8923 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
8924 error "Fail to add $ost_x to $FSNAME.$pname"
8925 wait_update $HOSTNAME \
8926 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
8927 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
8928 error "$ost_x is NOT in pool $FSNAME.$pname"
8931 test_103_check_pool() {
8932 local save_fsname=$1
8935 stat $DIR/$tdir/test-framework.sh ||
8936 error "($errno) Fail to stat"
8937 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
8938 error "($errno) Fail to list $FSNAME.pool1"
8939 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
8940 error "($errno) Fail to list $FSNAME.$save_fsname"
8941 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
8942 grep ${FSNAME}-OST0000 ||
8943 error "($errno) List $FSNAME.$save_fsname is invalid"
8945 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
8946 [ "$pname" = "$save_fsname" ] ||
8947 error "($errno) Unexpected pool name $pname"
8951 check_mount_and_prep
8953 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
8954 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
8955 error "(2) Fail to copy test-framework.sh"
8957 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
8958 error "(3) Fail to create $FSNAME.pool1"
8959 # name the pool name as the fsname
8960 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
8961 error "(4) Fail to create $FSNAME.$FSNAME"
8963 test_103_set_pool $FSNAME OST0000
8965 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
8966 error "(6) Fail to setstripe on $DIR/$tdir/d0"
8971 test_renamefs mylustre
8973 local save_fsname=$FSNAME
8977 test_103_check_pool $save_fsname 7
8979 if [ $OSTCOUNT -ge 2 ]; then
8980 test_103_set_pool $save_fsname OST0001
8983 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
8984 error "(16) Fail to setstripe on $DIR/$tdir/f0"
8993 test_103_check_pool $save_fsname 17
8997 test_renamefs $save_fsname
9003 run_test 103 "rename filesystem name"
9005 test_104a() { # LU-6952
9006 local mds_mountopts=$MDS_MOUNT_OPTS
9007 local ost_mountopts=$OST_MOUNT_OPTS
9008 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
9009 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
9012 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
9013 skip "this test needs utils above 2.9.55"
9015 # specify "acl" in mount options used by mkfs.lustre
9016 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
9017 MDS_MOUNT_FS_OPTS="acl,user_xattr"
9020 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
9023 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
9025 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
9027 if ! combined_mgs_mds ; then
9031 if [ -z "$MDS_MOUNT_OPTS" ]; then
9032 MDS_MOUNT_OPTS="-o noacl"
9034 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
9037 for num in $(seq $MDSCOUNT); do
9038 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
9039 error "Failed to start MDS"
9042 for num in $(seq $OSTCOUNT); do
9043 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
9044 error "Failed to start OST"
9048 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
9049 error "ACL is applied when FS is mounted with noacl."
9051 MDS_MOUNT_OPTS=$mds_mountopts
9052 OST_MOUNT_OPTS=$ost_mountopts
9053 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
9055 run_test 104a "Make sure user defined options are reflected in mount"
9057 test_104b() { # LU-12859
9058 mount_client $MOUNT3 flock,localflock
9059 stack_trap "umount_client $MOUNT3" EXIT
9060 mount | grep "$MOUNT3 .*,flock" && error "flock is still set"
9061 mount | grep "$MOUNT3 .*,localflock" || error "localflock is not set"
9062 umount_client $MOUNT3
9063 mount_client $MOUNT3 localflock,flock
9064 mount | grep "$MOUNT3 .*,localflock" && error "localflock is still set"
9065 mount | grep "$MOUNT3 .*,flock" || error "flock is not set"
9066 umount_client $MOUNT3
9067 mount_client $MOUNT3 localflock,flock,noflock
9068 flock_is_enabled $MOUNT3 && error "some flock is still enabled" || true
9070 run_test 104b "Mount uses last flock argument"
9072 error_and_umount() {
9083 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
9084 rm -f $TMP/$tdir/$tfile
9085 rm -f $TMP/$tdir/${tfile}1
9087 # Files should not be created in ro bind mount point
9088 # remounting from rw to ro
9089 mount -o remount,ro $TMP/$tdir ||
9090 error_and_umount "readonly remount of bind mnt pt failed"
9091 touch $TMP/$tdir/$tfile &&
9092 error_and_umount "touch succeeds on ro bind mnt pt"
9093 [ -e $TMP/$tdir/$tfile ] &&
9094 error_and_umount "file created on ro bind mnt pt"
9096 # Files should be created in rw bind mount point
9097 # remounting from ro to rw
9098 mount -o remount,rw $TMP/$tdir ||
9099 error_and_umount "read-write remount of bind mnt pt failed"
9100 touch $TMP/$tdir/${tfile}1 ||
9101 error_and_umount "touch fails on rw bind mnt pt"
9102 [ -e $TMP/$tdir/${tfile}1 ] ||
9103 error_and_umount "file not created on rw bind mnt pt"
9104 umount $TMP/$tdir || error "umount of bind mnt pt failed"
9106 cleanup || error "cleanup failed with $?"
9108 run_test 105 "check file creation for ro and rw bind mnt pt"
9112 local creates=64768 # one full plain llog
9114 # ensure there are enough inodes in the filesystem
9115 (( OSTSIZE < (creates + 1024) * 16)) && OSTSIZE=$(((creates + 1024) * 16))
9119 mkdir -p $DIR/$tdir || error "create $tdir failed"
9120 do_nodes $(osts_nodes) \
9121 $LCTL set_param seq.*OST*-super.width=$DATA_SEQ_MAX_WIDTH
9122 lfs setstripe -c 1 -i 0 $DIR/$tdir
9123 #define OBD_FAIL_CAT_RECORDS 0x1312
9124 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
9126 for ((i = 1; i <= $repeat; i++)); do
9127 createmany -o $DIR/$tdir/f- $creates || lfs df -i
9128 createmany -u $DIR/$tdir/f- $creates
9129 wait_delete_completed $((TIMEOUT * 7))
9131 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
9132 #shows that osp code is buggy
9133 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
9137 run_test 106 "check osp llog processing when catalog is wrapped"
9140 [[ "$MDS1_VERSION" -ge $(version_code 2.10.50) ]] ||
9141 skip "Need MDS version > 2.10.50"
9144 start_mgsmds || error "start_mgsmds failed"
9145 start_ost || error "unable to start OST"
9147 # add unknown configuration parameter.
9148 if [[ $PERM_CMD == *"set_param -P"* ]]; then
9149 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
9151 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
9153 do_facet mgs "$cmd=50"
9154 cleanup_nocli || error "cleanup_nocli failed with $?"
9157 # unknown param should be ignored while mounting.
9158 start_ost || error "unable to start OST after unknown param set"
9160 cleanup || error "cleanup failed with $?"
9162 run_test 107 "Unknown config param should not fail target mounting"
9167 $rcmd rm -rf $tmp > /dev/null 2>&1
9168 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
9170 for facet in $facets; do
9171 [ "$mds1_FSTYPE" = zfs ] &&
9172 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
9173 $rcmd mkdir $tmp/mnt/$facet ||
9174 error "failed to mkdir $tmp/mnt/$facet"
9175 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
9176 seek=199 bs=1M count=1 ||
9177 error "failed to create $tmp/images/$facet"
9186 local facet=${role}$((idx + 1))
9188 [ $# -eq 5 ] && pool=$5
9190 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
9191 --$role --index=$idx --replace --backfstype=$bkfs \
9192 --device-size=200000 --reformat $pool $tmp/images/$facet ||
9193 error "failed to mkfs for $facet"
9197 echo "mounting client..."
9198 mount -t lustre ${nid}:/lustre $MOUNT ||
9199 error "failed to mount lustre"
9202 ls -l $MOUNT/local_dir || error "failed to list"
9204 echo "check truncate && write"
9205 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
9206 error "failed to tuncate & write"
9209 touch $MOUNT/foooo ||
9210 error "failed to create"
9212 echo "check read && write && append"
9213 sha1sum $MOUNT/conf-sanity.sh |
9214 awk '{ print $1 }' > $MOUNT/checksum.new ||
9215 error "failed to read(1)"
9216 sha1sum $MOUNT/remote_dir/unlinkmany.c |
9217 awk '{ print $1 }' >> $MOUNT/checksum.new ||
9218 error "failed to read(2)"
9219 sha1sum $MOUNT/striped_dir/lockahead_test.o |
9220 awk '{ print $1 }' >> $MOUNT/checksum.new ||
9221 error "failed to read(3)"
9224 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
9225 error "failed to verify data"
9235 umount -f $MOUNT || error "failed to umount client"
9236 for facet in $facets; do
9237 $rcmd umount -f $tmp/mnt/$facet ||
9238 error "failed to umount $facet"
9239 if [ "$mds1_FSTYPE" = zfs ]; then
9240 $rcmd $ZPOOL export -f lustre-$facet ||
9241 error "failed to export lustre-$facet"
9245 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
9249 [ "$CLIENTONLY" ] && skip "Client-only testing"
9250 [ "$mds1_FSTYPE" != zfs ] && skip "zfs only test"
9251 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
9252 skip "Need server version at least 2.10.58"
9257 local tmp=$TMP/$tdir
9258 local rcmd="do_facet $SINGLEMDS"
9259 local facets="mdt1 mdt2 ost1 ost2"
9260 local nid=$($rcmd $LCTL list_nids | head -1)
9263 trap t_108_cleanup EXIT ERR
9266 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
9267 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
9268 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
9269 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
9271 for facet in $facets; do
9272 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
9273 lustre-$facet/$facet ||
9274 error "failed to zfs set for $facet (1)"
9275 $rcmd zfs mount lustre-$facet/$facet ||
9276 error "failed to local mount $facet"
9277 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
9278 --xattrs --xattrs-include="trusted.*" \
9279 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
9280 error "failed to untar image for $facet"
9281 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
9282 error "failed to cleanup for $facet"
9283 $rcmd zfs umount lustre-$facet/$facet ||
9284 error "failed to local umount $facet"
9285 $rcmd zfs set canmount=off lustre-$facet/$facet ||
9286 error "failed to zfs set $facet (2)"
9289 echo "changing server nid..."
9290 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
9291 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
9292 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
9293 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
9294 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
9295 $rcmd umount $tmp/mnt/mdt1
9297 for facet in $facets; do
9298 echo "mounting $facet from backup..."
9299 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
9300 $tmp/mnt/$facet || error "failed to mount $facet"
9303 # ZFS backend can detect migration and trigger OI scrub automatically
9304 # sleep 3 seconds for scrub done
9310 run_test 108a "migrate from ldiskfs to ZFS"
9313 [ "$CLIENTONLY" ] && skip "Client-only testing"
9314 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
9315 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
9316 skip "Need server version at least 2.10.58"
9321 local tmp=$TMP/$tdir
9322 local rcmd="do_facet $SINGLEMDS"
9323 local facets="mdt1 mdt2 ost1 ost2"
9324 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
9325 local nid=$($rcmd $LCTL list_nids | head -1)
9328 trap t_108_cleanup EXIT ERR
9331 t_108_mkfs mdt 0 ldiskfs mgs
9332 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
9333 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
9334 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
9336 for facet in $facets; do
9337 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
9339 error "failed to local mount $facet"
9341 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
9342 --xattrs --xattrs-include="*.*" \
9343 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
9344 error "failed to untar image for $facet"
9345 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
9346 error "failed to cleanup for $facet"
9347 $rcmd umount $tmp/mnt/$facet ||
9348 error "failed to local umount $facet"
9351 echo "changing server nid..."
9352 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
9353 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
9354 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
9355 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
9356 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
9357 $rcmd umount $tmp/mnt/mdt1
9359 for facet in $facets; do
9360 echo "mounting $facet from backup..."
9361 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
9362 $tmp/mnt/$facet || error "failed to mount $facet"
9365 for facet in $scrub_list; do
9366 $rcmd $LCTL lfsck_start -M $FSNAME-$facet -t scrub ||
9367 error "failed to start OI scrub on $facet"
9370 # sleep 3 seconds for scrub done
9376 run_test 108b "migrate from ZFS to ldiskfs"
9379 # set number of permanent parameters
9381 test_109_set_params() {
9384 set_persistent_param_and_check mds \
9385 "mdd.$fsname-MDT0000.atime_diff" \
9386 "$fsname-MDT0000.mdd.atime_diff" \
9388 set_persistent_param_and_check mds \
9389 "mdd.$fsname-MDT0000.atime_diff" \
9390 "$fsname-MDT0000.mdd.atime_diff" \
9392 set_persistent_param_and_check client \
9393 "llite.$fsname*.max_read_ahead_mb" \
9394 "$fsname.llite.max_read_ahead_mb" \
9396 set_persistent_param_and_check client \
9397 "llite.$fsname*.max_read_ahead_mb" \
9398 "$fsname.llite.max_read_ahead_mb" \
9400 create_pool $fsname.pool1 || error "create pool failed"
9401 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
9402 error "pool_add failed"
9403 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
9404 error "pool_remove failed"
9405 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
9406 error "pool_add failed"
9410 # check permanent parameters
9412 test_109_test_params() {
9415 local atime_diff=$(do_facet mds $LCTL \
9416 get_param -n mdd.$fsname-MDT0000.atime_diff)
9417 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
9418 local max_read_ahead_mb=$(do_facet client $LCTL \
9419 get_param -n llite.$fsname*.max_read_ahead_mb)
9420 [ $max_read_ahead_mb == 64 ] ||
9421 error "wrong llite parameter after clear_conf"
9422 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
9423 grep -v "^Pool:" | sed 's/_UUID//')
9424 [ $ost_in_pool = "$fsname-OST0000" ] ||
9425 error "wrong pool after clear_conf"
9429 # run lctl clear_conf, store CONFIGS before and after that
9431 test_109_clear_conf()
9433 local clear_conf_arg=$1
9436 if ! combined_mgs_mds ; then
9437 mgsdev=$(mgsdevname)
9438 stop_mgs || error "stop_mgs failed"
9439 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
9441 mgsdev=$(mdsdevname 1)
9442 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
9445 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
9446 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
9450 # the command being tested
9452 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
9453 error "clear_conf failed"
9454 if ! combined_mgs_mds ; then
9455 stop_mgs || error "stop_mgs failed"
9457 stop_mdt 1 || error "stop_mdt 1 failed"
9460 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
9461 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
9465 test_109_file_shortened() {
9467 local sizes=($(do_facet mgs "stat -c %s " \
9468 "$TMP/${tdir}/conf1/CONFIGS/$file" \
9469 "$TMP/${tdir}/conf2/CONFIGS/$file"))
9470 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
9476 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
9477 skip "Needs MDS version 2.10.59 or later."
9478 [ "$(facet_fstype mgs)" == zfs ] &&
9479 skip "LU-8727: no implementation for ZFS"
9484 client_up || error "client_up failed"
9487 # set number of permanent parameters
9489 test_109_set_params $FSNAME
9491 umount_client $MOUNT || error "umount_client failed"
9492 stop_ost || error "stop_ost failed"
9493 stop_mds || error "stop_mds failed"
9495 test_109_clear_conf $FSNAME
9497 # make sure that all configs are cleared
9499 test_109_file_shortened $FSNAME-MDT0000 ||
9500 error "failed to clear MDT0000 config"
9501 test_109_file_shortened $FSNAME-client ||
9502 error "failed to clear client config"
9507 # check that configurations are intact
9509 test_109_test_params $FSNAME
9514 destroy_test_pools || error "destroy test pools failed"
9518 run_test 109a "test lctl clear_conf fsname"
9522 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
9523 skip "Needs MDS version 2.10.59 or later."
9524 [ "$(facet_fstype mgs)" == zfs ] &&
9525 skip "LU-8727: no implementation for ZFS"
9530 client_up || error "client_up failed"
9533 # set number of permanent parameters
9535 test_109_set_params $FSNAME
9537 umount_client $MOUNT || error "umount_client failed"
9538 stop_ost || error "stop_ost failed"
9539 stop_mds || error "stop_mds failed"
9541 test_109_clear_conf $FSNAME-MDT0000
9543 # make sure that only one config is cleared
9545 test_109_file_shortened $FSNAME-MDT0000 ||
9546 error "failed to clear MDT0000 config"
9547 test_109_file_shortened $FSNAME-client &&
9548 error "failed to clear client config"
9552 # check that configurations are intact
9554 test_109_test_params $FSNAME
9559 destroy_test_pools || error "destroy test pools failed"
9563 run_test 109b "test lctl clear_conf one config"
9567 [[ "$mds1_FSTYPE" == ldiskfs ]] ||
9568 skip "Only applicable to ldiskfs-based MDTs"
9569 do_facet mds1 $DEBUGFS -w -R supported_features |grep large_dir ||
9570 skip "large_dir option is not supported on MDS"
9572 # stop all targets before modifying the target counts
9573 local old_mdscount=$MDSCOUNT
9574 local old_ostcount=$OSTCOUNT
9575 stack_trap "MDSCOUNT=$old_mdscount OSTCOUNT=$old_ostcount \
9576 reformat_and_config"
9580 # ext4_dir_entry_2 struct size:264
9581 # dx_root struct size:8
9582 # dx_node struct size:8
9583 # dx_entry struct size:8
9584 # For 1024 bytes block size.
9585 # First level directory entries: 126
9586 # Second level directory entries: 127
9587 # Entries in leaf: 3
9588 # For 2 levels limit: 48006
9589 # For 3 levels limit : 6096762
9590 # Create enough files to safely exceed 2-level htree limit.
9591 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-60000}
9593 # can fit at most 3 filenames per 1KB leaf block, but each
9594 # leaf/index block will only be 3/4 full before split at each level
9595 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
9596 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
9598 local dev=$(mdsdevname 1)
9599 local opts="$(mkfs_opts mds1 $dev) --reformat $dev $(mdsvdevname 1)"
9601 if [[ $opts != *large_dir* ]]; then
9602 if [[ $opts != *mkfsoptions* ]]; then
9603 opts+=" --mkfsoptions=\\\"-O large_dir\\\""
9605 if [[ $opts != *-O* ]]; then
9606 opts="${opts//--mkfsoptions=\\\"/ \
9607 --mkfsoptions=\\\"-O large_dir }"
9609 opts="${opts/-O /-O large_dir,}"
9614 # Use INDEX_UNASSIGNED for index for --mkfsoptions
9615 if [[ $opts != *mkfsoptions* ]]; then
9616 opts+=" --mkfsoptions=\\\"-b 1024 -i 65536\\\""
9618 opts="${opts//--mkfsoptions=\\\"/ \
9619 --mkfsoptions=\\\"-b 1024 -i 65536 }"
9622 echo "MDT params: $opts"
9624 combined_mgs_mds || start_mgs
9625 add mds1 $opts || error "add mds1 failed with new params"
9626 start mds1 $dev $MDS_MOUNT_OPTS || error "start mds1 failed"
9627 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
9628 MOUNT_2=yes mountcli || error "mount clients failed"
9630 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
9631 local pids count=0 group=0
9633 echo "creating $CONF_SANITY_110_LINKS in total"
9634 while (( count < CONF_SANITY_110_LINKS )); do
9635 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
9636 local dir=DIR$((group % 2 + 1))
9637 local target=${!dir}/$tdir/$tfile-$group
9638 local long=$target-$(generate_name $len)-
9639 local create=$((CONF_SANITY_110_LINKS - count))
9641 (( create > 40000 )) && create=40000
9642 touch $target || error "creating $target failed"
9643 echo "creating $create hard links to $target"
9644 createmany -l $target $long $create &
9647 count=$((count + create))
9648 group=$((group + 1))
9650 echo "waiting for PIDs$pids to complete"
9651 wait $pids || error "createmany failed after $group groups"
9655 run_e2fsck $(facet_active_host mds1) $dev -n
9657 run_test 110 "Adding large_dir with 3-level htree"
9660 [[ "$mds1_FSTYPE" = ldiskfs ]] ||
9661 skip "Only applicable to ldiskfs-based MDTs"
9662 do_facet mds1 $DEBUGFS -w -R supported_features |grep large_dir ||
9663 skip "large_dir option is not supported on MDS"
9665 # cleanup before changing target counts
9666 local old_mdscount=$MDSCOUNT
9667 local old_ostcount=$OSTCOUNT
9668 local old_mdssize=$MDSSIZE
9669 stack_trap "MDSSIZE=$old_mdssize MDSCOUNT=$old_mdscount \
9670 OSTCOUNT=$old_ostcount reformat_and_config"
9675 # cannot enlarge a block device, so skip the test if size not enough
9676 local dev=$(mdsdevname 1)
9678 if is_blkdev mds1 $dev; then
9679 is_blkdev mds1 $dev $min ||
9680 skip "$dev too small for ${min}kB MDS"
9682 (( MDSSIZE < min )) && MDSSIZE=$min # need at least 2.4GB
9683 local opts="$(mkfs_opts mds1 $dev) --reformat $dev $(mdsvdevname 1)"
9684 if [[ $opts != *large_dir* ]]; then
9685 if [[ $opts != *mkfsoptions* ]]; then
9686 opts+=" --mkfsoptions=\\\"-O large_dir\\\""
9688 if [[ $opts != *-O* ]]; then
9689 opts="${opts//--mkfsoptions=\\\"/ \
9690 --mkfsoptions=\\\"-O large_dir }"
9692 opts="${opts/-O /-O large_dir,}"
9697 echo "MDT params: $opts"
9699 combined_mgs_mds || start_mgs
9700 add mds1 $opts || error "add mds1 failed with new params"
9701 start mds1 $dev $MDS_MOUNT_OPTS ||
9702 error "start mds1 failed"
9703 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
9704 error "start ost1 failed"
9706 MOUNT_2=yes mountcli
9707 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
9709 $LFS df -i $DIR/$tdir
9713 local start=$SECONDS
9715 local dirmax=$((2 << 30))
9721 while (( !needskip & dirsize < dirmax )); do
9724 for cli in ${CLIENTS//,/ }; do
9725 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
9726 local target=$cli-$group
9727 local long=$DIR/$tdir/$target-$(generate_name $len)-
9729 RPWD=$DIR/$tdir do_node $cli touch $target ||
9730 error "creating $target failed"
9731 echo "creating 60000 hardlinks to $target"
9732 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
9735 group=$((group + 1))
9737 long=$DIR2/$tdir/$target-$(generate_name $len)-
9739 RPWD=$DIR2/$tdir do_node $cli touch $target ||
9740 error "creating $target failed"
9741 echo "creating 60000 hardlinks to $target"
9742 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
9745 group=$((group + 1))
9747 echo "waiting for PIDs$pids to complete"
9748 wait $pids || error "createmany failed after $group groups"
9750 dirsize=$(stat -c %s $DIR/$tdir)
9751 taken=$((SECONDS - start))
9752 rate=$((dirsize / taken))
9753 left=$(((dirmax - dirsize) / rate))
9754 num=$((group * 60000))
9755 echo "estimate ${left}s left after $num files / ${taken}s"
9756 echo "Reached $dirsize of $dirmax directory size"
9759 $LFS df -i $DIR/$tdir
9761 $FORCE_TEST_111 && continue
9762 # if the estimated time remaining is too large (it may change
9763 # over time as the create rate is not constant) then exit
9764 # without declaring a failure.
9765 (( left > 1200 )) && needskip=1
9768 umount_client $MOUNT2 -f
9771 skip "ETA ${left}s after $num files / ${taken}s is too long"
9772 run_e2fsck $(facet_active_host mds1) $dev -n
9774 run_test 111 "Adding large_dir with over 2GB directory"
9777 local param="no_create"
9779 (( $OST1_VERSION > $(version_code 2.14.0) )) ||
9780 skip "need OSS at least 2.14.0"
9781 (( $OST1_VERSION >= $(version_code 2.15.56.125) )) ||
9782 param="no_precreate"
9784 start_mds || error "MDS start failed"
9785 start_ost || error "OSS start failed"
9786 echo "start ost2 service on $(facet_active_host ost2)"
9787 start ost2 $(ostdevname 2) $(csa_add "$OST_MOUNT_OPTS" -o $param) ||
9788 error "start ost2 facet failed"
9789 local val=$(do_facet ost2 \
9790 "$LCTL get_param -n obdfilter.$FSNAME-OST0001*.$param")
9791 (( $val == 1 )) || error "obdfilter.$FSNAME-OST0001*.$param=$val"
9793 mount_client $MOUNT || error "mount client failed"
9794 wait_osc_import_state mds1 ost1 FULL
9795 wait_osc_import_ready client ost1
9796 wait_osc_import_ready client ost2
9798 $LFS setstripe -i 0 $DIR/$tfile.0 ||
9799 error "problem creating $tfile.0 on OST0000"
9800 $LFS setstripe -i 1 $DIR/$tfile.1 && $LFS getstripe $DIR/$tfile.1 &&
9801 (( $($LFS getstripe -i $DIR/$tfile.1) == 1 )) &&
9802 error "allowed to create $tfile.1 on OST0001"
9804 $LFS df -v $MOUNT | grep -q "OST:1.*N" ||
9805 error "NOCREATE not in 'lfs df'"
9807 do_facet ost2 $LCTL set_param obdfilter.$FSNAME-OST0001*.$param=0
9809 $LFS setstripe -i 1 $DIR/$tfile.2 ||
9810 error "failed to create $tfile.2 on ost1 facet"
9811 # files not cleaned with ONLY_REPEAT because of client unmount below
9812 rm -f $DIR/$tfile.[012]
9813 stop_ost2 || error "stop ost2 facet failed"
9816 run_test 112a "mount OST with no_create option"
9819 (( MDSCOUNT >= 2 )) || skip "need at least 2 MDTs"
9820 (( $MDS1_VERSION >= $(version_code 2.15.56.125) )) ||
9821 skip "need MDS >= 2.15.56.125"
9822 local mdsnum=$MDSCOUNT
9823 local facet=mds$mdsnum
9824 local mdtidx=$((mdsnum - 1))
9825 local mdtname=$FSNAME-MDT$(printf %04x $mdtidx)
9827 start_mds --mdscount $((mdsnum - 1)) || error "MDS start failed"
9828 start_mdt $mdsnum -o no_create || error "start $facet failed"
9829 local val=$(do_facet $facet \
9830 "$LCTL get_param -n mdt.$mdtname*.no_create")
9831 (( $val == 1 )) || error "mdt.$mdtname*.no_create=$val"
9832 start_ost || error "ost1 start failed"
9833 start_ost2 || error "ost1 start failed"
9835 mount_client $MOUNT || error "mount client failed"
9836 wait_osc_import_ready $facet ost2
9839 $LFS df -v $MOUNT | grep -q "MDT:$mdtidx.*N" ||
9840 error "NOCREATE not in 'lfs df'"
9842 $LFS mkdir -i $mdtidx $DIR/$tdir ||
9843 $LFS setdirstripe -D -c 1 -i -1 --max-inherit-rr 2 $DIR/$tdir ||
9844 error "error creating $tdir on $mdtname"
9845 stack_trap "rm -rf $DIR/$tdir"
9847 mkdir $DIR/$tdir/d1.{1..100} || error "mkdir $tdir/d1.{1..100} failed"
9848 $LFS getdirstripe -i $DIR/$tdir/d1.* | sort | uniq -c
9849 do_facet $facet $LCTL set_param mdt.$mdtname*.no_create=0
9850 # allow one initial create for delayed statfs on client
9851 (( $($LFS getdirstripe -i $DIR/$tdir/d1.* | grep -c $mdtidx) < 2 )) ||
9852 error "allowed create on $mdtname"
9855 mkdir $DIR/$tdir/d2.{1..100} || error "mkdir $tdir/d2.{1..100} failed"
9856 $LFS getdirstripe -i $DIR/$tdir/d2.{1..100} | sort | uniq -c
9857 (( $($LFS getdirstripe -i $DIR/$tdir/d2.* | grep -c $mdtidx) > 10 )) ||
9858 error "no create on $mdtname"
9859 # files not cleaned with ONLY_REPEAT because of client unmount below
9861 stop_ost2 || error "ost1 start failed"
9864 run_test 112b "mount MDT with no_create option"
9867 SAVE_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
9868 SAVE_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
9869 SAVE_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
9875 MGS_MOUNT_OPTS=$SAVE_MGS_MOUNT_OPTS
9876 MDS_MOUNT_OPTS=$SAVE_MDS_MOUNT_OPTS
9877 OST_MOUNT_OPTS=$SAVE_OST_MOUNT_OPTS
9878 # Revert old mount options back
9880 # Subsequent following test requires
9881 # conf-sanity to be in stopall state.
9882 # Force 'stopall' so others following
9887 # Error out with mount info
9891 echo "--Client Mount Info--"
9892 mount | grep -i lustre
9893 echo "--Server Mount Info--"
9894 do_nodes $(tgts_nodes) mount | grep -i lustre
9900 local ost_version="2.15.51" # Minimum version required
9902 (( OST1_VERSION >= $(version_code $ost_version) )) ||
9903 skip "Need server version at least $ost_version"
9905 stack_trap cleanup_113 EXIT
9907 # Reset before starting
9911 # Verify MDS's should start with "rw"
9912 do_facet $SINGLEMDS mount | grep "lustre.*rw,.*MDT" ||
9913 error_113 "$SINGLEMDS should be read-write"
9915 # Verify OST's should start with "rw"
9916 for (( i=1; i <= OSTCOUNT; i++ )); do
9917 do_facet ost$i mount | grep "lustre.*rw,.*OST" ||
9918 error_113 "ost$i should be read-write"
9921 # rdonly_dev does not currently work for ldiskfs
9922 # We skip the rdonly_dev check until then.
9923 if [[ $ost1_FSTYPE == ldiskfs ]]; then
9924 echo "Shadow Mountpoint correctly reports rw for ldiskfs"
9929 # Only ZFS specific tests below.
9932 # Must stop all (server+client) and restart to verify new
9936 # add rdonly_dev to mount option
9937 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
9938 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
9939 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
9941 # Only restart server(mds/ost). Sufficient for test
9942 setupall server_only || error "Fail to start servers"
9944 # Verify MDS's should be "ro"
9945 do_facet $SINGLEMDS mount | grep "lustre.*ro,.*MDT.*rdonly_dev" ||
9946 error_113 "$SINGLEMDS should be read-only"
9948 # Verify OST's should be "ro"
9949 for (( i=1; i <= OSTCOUNT; i++ )); do
9950 do_facet ost$i mount | grep "lustre.*ro,.*OST.*rdonly_dev" ||
9951 error_113 "ost$i should be read-only"
9954 run_test 113 "Shadow mountpoint correctly report ro/rw for mounts"
9957 # Purpose: To verify dynamic thread (OSS) creation.
9958 # (This was sanity/115)
9961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9962 remote_ost_nodsh && skip "remote OST with nodsh"
9964 # Lustre does not stop service threads once they are started.
9965 # Reset number of running threads to default.
9970 local save_params="$TMP/sanity-$TESTNAME.parameters"
9972 # Get ll_ost_io count before I/O
9973 OSTIO_pre=$(do_facet ost1 \
9974 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9975 # Exit if lustre is not running (ll_ost_io not running).
9976 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9978 echo "Starting with $OSTIO_pre threads"
9979 local thread_max=$((OSTIO_pre * 2))
9980 local rpc_in_flight=$((thread_max * 2))
9982 # this is limited to OSC_MAX_RIF_MAX (256)
9983 [ $rpc_in_flight -gt 256 ] && rpc_in_flight=256
9984 thread_max=$((rpc_in_flight / 2))
9985 [ $thread_max -le $OSTIO_pre ] && skip "Too many ost_io threads" &&
9988 # Number of I/O Process proposed to be started.
9990 local facets=$(get_facets OST)
9992 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9993 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9995 # Set in_flight to $rpc_in_flight
9996 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9997 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9998 nfiles=${rpc_in_flight}
9999 # Set ost thread_max to $thread_max
10000 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
10002 # 5 Minutes should be sufficient for max number of OSS
10003 # threads(thread_max) to be created.
10007 local wtl=${WTL:-"$LUSTRE/tests/write_time_limit"}
10009 test_mkdir $DIR/$tdir
10010 for ((i = 1; i <= nfiles; i++)); do
10011 local file=$DIR/$tdir/${tfile}-$i
10013 $LFS setstripe -c -1 -i 0 $file
10014 ($wtl $file $timeout)&
10017 # I/O Started - Wait for thread_started to reach thread_max or report
10018 # error if thread_started is more than thread_max.
10019 echo "Waiting for thread_started to reach thread_max"
10020 local thread_started=0
10021 local end_time=$((SECONDS + timeout))
10023 while [ $SECONDS -le $end_time ] ; do
10025 # Get ost i/o thread_started count.
10026 thread_started=$(do_facet ost1 \
10028 ost.OSS.ost_io.threads_started | cut -d= -f2")
10029 # Break out if thread_started is equal/greater than thread_max
10030 if (( $thread_started >= $thread_max )); then
10031 echo ll_ost_io thread_started $thread_started, \
10032 equal/greater than thread_max $thread_max
10038 # Cleanup - We have the numbers, Kill i/o jobs if running.
10039 jobcount=($(jobs -p))
10041 for ((i=0; i < ${#jobcount[*]}; i++)); do
10042 kill -9 ${jobcount[$i]}
10043 if [ $? -ne 0 ] ; then
10044 echo "warning: cannot kill WTL pid ${jobcount[$i]}"
10048 # Cleanup files left by WTL binary.
10049 for ((i = 1; i <= nfiles; i++)); do
10050 local file=$DIR/$tdir/${tfile}-$i
10053 if [ $? -ne 0 ] ; then
10054 echo "Warning: Failed to delete file $file"
10058 restore_lustre_params <$save_params
10059 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
10061 # Error out if no new thread has started or Thread started is greater
10063 if (( $thread_started <= $OSTIO_pre ||
10064 $thread_started > $thread_max )); then
10065 error "ll_ost_io: thread_started $thread_started" \
10066 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
10067 "No new thread started or thread started greater " \
10071 run_test 114 "verify dynamic thread creation===================="
10077 do_facet mds1 rm -f $1
10081 if [ "$mds1_FSTYPE" != ldiskfs ]; then
10082 skip "Only applicable to ldiskfs-based MDTs"
10084 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
10086 local dbfs_ver=$(do_facet mds1 $DEBUGFS -V 2>&1)
10088 echo "debugfs version: $dbfs_ver"
10089 echo "$dbfs_ver" | egrep -w "1.44.3.wc1|1.44.5.wc1|1.45.2.wc1" &&
10090 skip_env "This version of debugfs doesn't show inode number"
10092 local IMAGESIZE=$((3072 << 30)) # 3072 GiB
10100 mount | grep lustre
10102 do_facet mds1 "hostname; $LCTL dl; mount"
10104 do_facet ost1 "hostname; $LCTL dl; mount"
10105 # We need MDT size 3072GB, because it is smallest
10106 # partition that can store 2B inodes
10107 do_facet mds1 "mkdir -p $TMP/$tdir"
10108 local mdsimgname=$TMP/$tdir/lustre-mdt
10110 do_facet mds1 "rm -f $mdsimgname"
10111 do_facet mds1 "touch $mdsimgname"
10112 stack_trap "cleanup_115 $mdsimgname" EXIT
10113 do_facet mds1 "$TRUNCATE $mdsimgname $IMAGESIZE" ||
10114 skip "Backend FS doesn't support sparse files"
10115 local mdsdev=$(do_facet mds1 "losetup -f")
10117 do_facet mds1 "losetup $mdsdev $mdsimgname"
10119 local mds_opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
10120 --mkfsoptions='-O ea_inode,^resize_inode,meta_bg \
10121 -N 2247484000 -E lazy_itable_init' --device-size=$IMAGESIZE"
10122 add mds1 $mds_opts --mgs --reformat $mdsdev || {
10123 do_facet $SINGLEMDS \
10124 "losetup -d $mdsdev && rm -f $mdsimgname"
10125 skip_env "format large MDT failed"
10128 local ostdev=$(ostdevname 1)
10130 local opts="$(mkfs_opts ost1 $ostdev) \
10131 --reformat $ostdev $ostdev"
10132 add ost1 $opts || error "add ost1 failed with new params"
10133 start mds1 $mdsdev $MDS_MOUNT_OPTS || error "start MDS failed"
10134 start_ost || error "start OSS failed"
10135 mount_client $MOUNT || error "mount client failed"
10137 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
10138 local goal="/sys/fs/ldiskfs/$(basename $mdsdev)/inode_goal"
10140 # 2147483648 is 0x80000000
10141 do_facet mds1 "echo 2147483648 >> $goal; grep . $goal"
10142 touch $DIR/$tdir/$tfile
10144 # attrs from 1 to 16 go to block, 17th - to inode
10147 for i in {1..17}; do
10148 local nm="trusted.ea$i"
10149 setfattr -n $nm -v $(printf "xattr%0250d" $i) $DIR/$tdir/$tfile
10152 do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev"
10154 # inode <2147483649> trusted.ea16 (255)
10155 local inode_num=$(do_facet mds1 \
10156 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev" |
10157 awk '/ea17/ { print $2 }' |
10158 sed -e 's/>//' -e 's/<//' -e 's/\"//')
10159 echo "inode num: $inode_num"
10160 [ $inode_num -ge 2147483648 ] || error "inode $inode_num too small"
10161 do_facet mds1 "losetup -d $mdsdev"
10163 run_test 115 "Access large xattr with inodes number over 2TB"
10166 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
10167 [ "$MDS1_VERSION" -lt $(version_code 2.10.59) ] &&
10168 skip "Need server version at least 2.10.59"
10169 do_facet $SINGLEMDS which mkfs.xfs ||
10170 skip_env "No mkfs.xfs installed"
10175 local tmpmnt=$TMP/$tdir
10176 local mdtimg=$tfile-mdt0
10178 do_facet $SINGLEMDS mkdir -p $tmpmnt
10179 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
10181 do_facet $SINGLEMDS touch $TMP/$mdtimg
10182 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
10183 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
10184 error "mkfs temporary xfs image"
10186 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
10187 error "mount temporary xfs image"
10188 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
10189 local old_mdssize=$MDSSIZE
10190 local old_mdsisize=$MDSISIZE
10192 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
10193 MDSISIZE=$((16 << 20))
10194 local opts17t="$(mkfs_opts $SINGLEMDS)"
10196 MDSSIZE=$old_mdssize
10197 MDSISIZE=$old_mdsisize
10199 do_facet $SINGLEMDS $MKFS \
10200 ${opts17t/-E /-E lazy_itable_init,lazy_journal_init,} \
10202 error "failed to mkfs for $tmpmnt/$mdtimg"
10204 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
10205 grep -qw 'features.*extent' || error "extent should be enabled"
10206 reformat_and_config
10208 run_test 116 "big size MDT support"
10211 # Call setup only if LustreFS is not mounted
10212 check_mount || setup
10214 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
10215 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
10216 error "get_param should fail"
10217 cleanup || error "cleanup failed with rc $?"
10219 run_test 117 "lctl get_param return errors properly"
10225 [[ "$MDSCOUNT" -ge 2 ]] || skip "Need more at least 2 MDTs"
10227 had_config=$(do_facet mds1 "$LCTL get_param debug | grep config")
10228 do_facet mds1 "$LCTL set_param debug=+config"
10229 do_facet mds1 "$LCTL clear"
10232 do_facet mds2 "$TUNEFS --writeconf $(mdsdevname 2)" &>/dev/null
10233 # mount after writeconf will make "add osp" added to mdt0 config:
10234 # 53 (224)marker 60 (flags=0x01, v2.5.1.0) lustre-MDT0001 'add osp'
10235 # 54 (080)add_uuid nid=... 0: 1:...
10236 # 55 (144)attach 0:lustre-MDT0001-osp-MDT0000 1:osp 2:...
10237 # 56 (144)setup 0:lustre-MDT0001-osp-MDT0000 1:... 2:...
10238 # 57 (136)modify_mdc_tgts add 0:lustre-MDT0000-mdtlov 1:... 2:1 3:1
10239 # duplicate modify_mdc_tgts caused crashes
10242 # using larger debug_mb size to avoid lctl dk log truncation
10243 size_mb=$((DEBUG_SIZE_SAVED * 4))
10244 for i in {1..3}; do
10246 # though config processing stops after failed attach and setup
10247 # it will proceed after the failed command after each writeconf
10248 # this is the original scenario of the issue
10249 do_facet mds2 "$TUNEFS --writeconf $(mdsdevname 2)" &>/dev/null
10250 do_facet mds1 "$LCTL set_param debug_mb=$size_mb"
10253 wait_update_facet_cond mds1 \
10254 "$LCTL dk | grep -c Processed.log.$FSNAME-MDT0000" \
10259 [[ -z "$had_config" ]] && do_facet mds1 lctl set_param debug=-config
10263 run_test 119 "writeconf on slave mdt shouldn't duplicate mdc/osp and crash"
10265 test_120() { # LU-11130
10266 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
10267 [ "$mds1_FSTYPE" != ldiskfs ] &&
10268 skip "ldiskfs only test"
10269 [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] &&
10270 skip "Need DNE2 capable MD target with LU-11130 fix"
10274 local mds1host=$(facet_active_host mds1)
10275 local mds1dev=$(mdsdevname 1)
10277 $LFS mkdir -i 1 $DIR/$tdir
10278 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
10280 ln -s foo $DIR/$tdir/bar
10281 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
10282 error "cross-target rename failed"
10286 run_e2fsck $mds1host $mds1dev "-n"
10288 run_test 120 "cross-target rename should not create bad symlinks"
10292 start_mgsmds || error "MGS MDS Start failed"
10294 stop_mds || error "Stopping MDSes failed"
10298 stop_mds || error "Stopping MDSes failed"
10300 run_test 121 "failover MGS"
10303 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
10304 [[ "$OST1_VERSION" -ge $(version_code 2.11.53) ]] ||
10305 skip "Need OST version at least 2.11.53"
10308 LOAD_MODULES_REMOTE=true load_modules
10309 #define OBD_FAIL_OFD_SET_OID 0x1e0
10310 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
10313 $LFS mkdir -i1 -c1 $DIR/$tdir
10314 $LFS setstripe -i0 -c1 $DIR/$tdir
10315 do_facet ost1 $LCTL set_param fail_loc=0
10316 createmany -o $DIR/$tdir/file_ 1000 ||
10317 error "Fail to create a new sequence"
10321 run_test 122a "Check OST sequence update"
10324 remote_mgs_nodsh && skip "remote MGS with nodsh"
10325 [ -d $MOUNT/.lustre ] || setup
10327 # test old logid format until removal from llog_ioctl.c::str2logid()
10328 if (( $MGS_VERSION < $(version_code 2.99.53) )); then
10329 do_facet mgs $LCTL dl | grep MGS
10330 do_facet mgs "$LCTL --device %MGS llog_print \
10331 \\\\\\\$$FSNAME-client 1 10" ||
10332 error "old llog_print failed"
10335 # test new logid format
10336 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
10337 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
10338 error "new llog_print failed"
10341 run_test 123aa "llog_print works with FIDs and simple names"
10344 remote_mgs_nodsh && skip "remote MGS with nodsh"
10345 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
10346 skip "Need server with working llog_print support"
10348 [ -d $MOUNT/.lustre ] || setup
10354 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
10355 mgs_arg="--device MGS"
10357 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
10358 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME"
10360 yaml=$(do_facet mgs $LCTL $mgs_arg llog_print params |
10361 grep jobid_name | tail -n 1)
10363 local param=$(awk '{ print $10 }' <<< "$yaml")
10364 local val=$(awk '{ print $12 }' <<< "$yaml")
10365 #return to the default
10366 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
10367 [ $val = "TESTNAME" ] || error "bad value: $val"
10368 [ $param = "jobid_name," ] || error "Bad param: $param"
10370 run_test 123ab "llog_print params output values from set_param -P"
10372 test_123ac() { # LU-11566
10373 remote_mgs_nodsh && skip "remote MGS with nodsh"
10374 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
10375 skip "Need 'lctl llog_print --start' on MGS"
10381 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
10382 mgs_arg="--device MGS"
10384 [ -d $MOUNT/.lustre ] || setup
10386 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
10387 # node: 192.168.20.1@tcp }
10388 do_facet mgs $LCTL $mgs_arg \
10389 llog_print --start $start --end $end $FSNAME-client | tr -d , |
10390 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
10391 (( idx >= start )) || error "llog_print index $idx < $start"
10392 (( idx <= end )) || error "llog_print index $idx > $end"
10395 run_test 123ac "llog_print with --start and --end"
10397 test_123ad() { # LU-11566
10398 remote_mgs_nodsh && skip "remote MGS with nodsh"
10399 if (( $MDS1_VERSION >= $(version_code 2.16.50) )); then
10400 llog_info="llog info"
10401 llog_print="llog print"
10403 llog_info="llog_info"
10404 llog_print="llog_print"
10406 # older versions of lctl may not print all records properly
10407 (( MGS_VERSION >= $(version_code 2.15.90) )) ||
10408 skip "Need MGS version at least 2.15.90"
10410 [ -d $MOUNT/.lustre ] || setup
10412 # append a new record, to avoid issues if last record was cancelled
10413 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
10414 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
10415 stack_trap "do_facet mgs $LCTL conf_param -d $FSNAME-OST0000.osc.max_dirty_mb"
10417 # logid: [0x3:0xa:0x0]:0
10419 # records_count: 72
10421 local num=$(do_facet mgs $LCTL --device MGS $llog_info $FSNAME-client |
10422 awk '/last_index:/ { print $2 }')
10424 do_facet mgs $LCTL --device MGS $llog_print $FSNAME-client |
10425 grep -q "$FSNAME-OST0000.*osc\.max_dirty_mb=$old" ||
10426 error "ocs.max_dirty_mb=$old not found in $FSNAME-client"
10428 # - { index: 72, event: marker, flags: 0x06, ... }
10429 local last=$(do_facet mgs $LCTL --device MGS $llog_print -r $FSNAME-client |
10430 tail -1 | awk '{ print $4 }' | tr -d , )
10431 (( last == num )) || error "$llog_print only showed $last/$num records"
10433 run_test 123ad "llog_print shows all records"
10435 test_123ae() { # LU-11566
10443 remote_mgs_nodsh && skip "remote MGS with nodsh"
10444 [ -d $MOUNT/.lustre ] || setupall
10446 max=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
10447 pgs=$($LCTL get_param -n osc.*-OST0000-*.max_pages_per_rpc | head -1)
10448 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
10449 mgs_arg="--device MGS"
10451 if do_facet mgs "$LCTL help llog_cancel" 2>&1| grep -q -- --log_id; then
10452 # save one set_param -P record in case none exist
10454 do_facet mgs $LCTL set_param -P osc.*.max_pages_per_rpc=$pgs
10455 stack_trap "do_facet mgs $LCTL set_param -P -d \
10456 osc.*.max_pages_per_rpc"
10459 orig=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
10460 tail -1 | awk '{ print $4 }' | tr -d , )
10461 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
10462 do_facet mgs $LCTL $mgs_arg llog_print $log | tail -1 |
10463 grep "parameter: osc.*.max_dirty_mb" ||
10464 error "new set_param -P wasn't stored in params log"
10466 # - { index: 71, event: set_param, device: general,
10467 # param: osc.*.max_dirty_mb, value: 256 }
10468 id=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
10469 tail -1 | awk '{ print $4 }' | tr -d , )
10470 do_facet mgs $LCTL $mgs_arg llog_cancel $log --log_idx=$id
10471 local new=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
10472 tail -1 | awk '{ print $4 }' | tr -d , )
10473 (( new == orig )) ||
10474 error "new llog_cancel now $new, not at $orig records"
10477 # test old positional parameters for a while still
10478 if [ "$MGS_VERSION" -le $(version_code 3.1.53) ]; then
10481 do_facet mgs $LCTL conf_param \
10482 $FSNAME-OST0000.osc.max_pages_per_rpc=$pgs
10483 stack_trap "do_facet mgs $LCTL conf_param -d \
10484 $FSNAME-OST0000.osc.max_pages_per_rpc"
10486 orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
10487 tail -1 | awk '{ print $4 }' | tr -d , )
10488 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$max
10489 do_facet mgs $LCTL --device MGS llog_print $log |
10490 tail -1 | grep "parameter: osc.max_dirty_mb" ||
10491 error "old conf_param wasn't stored in params log"
10492 do_facet mgs $LCTL --device MGS llog_print $log
10493 # - { index: 71, event: conf_param, device: testfs-OST0000-osc,
10494 # param: osc.max_dirty_mb=256 }
10495 id=$(do_facet mgs $LCTL --device MGS llog_print $log |
10496 tail -1 | awk '{ print $4 }' | tr -d , )
10497 do_facet mgs $LCTL --device MGS llog_cancel $log $id
10498 do_facet mgs $LCTL --device MGS llog_print $log
10499 new=$(do_facet mgs $LCTL --device MGS llog_print $log |
10500 tail -1 | awk '{ print $4 }' | tr -d , )
10501 (( new == orig )) ||
10502 error "old llog_cancel now $new, not at $orig records"
10505 run_test 123ae "llog_cancel can cancel requested record"
10507 test_123af() { #LU-13609
10508 [ "$MGS_VERSION" -ge $(version_code 2.13.54) -a \
10509 "$MDS1_VERSION" -ge $(version_code 2.13.54) ] ||
10510 skip "Need both MGS and MDS version at least 2.13.54"
10512 [ -d $MOUNT/.lustre ] || setupall
10513 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0" EXIT
10523 for device in "MGS" "$FSNAME-MDT0000"; do
10524 cmd="--device $device llog_catlist"
10525 echo "lctl $cmd ..."
10526 if [ "$device" = "MGS" ]; then
10531 orig_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
10532 orig_count=${#orig_clist[@]}
10533 echo "orig_clist: ${orig_clist[*]}"
10535 #define OBD_FAIL_CATLIST 0x131b
10536 #fetch to llog records from the second one
10537 do_facet $facet $LCTL set_param fail_loc=0x131b fail_val=2
10539 new_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
10540 new_count=${#new_clist[@]}
10541 echo "new_clist: ${new_clist[*]}"
10543 [ $new_count -eq $((orig_count - 1)) ] ||
10544 error "$new_count != $orig_count - 1"
10545 for i in $(seq 0 $new_count); do
10547 [ "${orig_clist[$j]}" = "${new_clist[$i]}" ] ||
10548 error "${orig_clist[$j]} != ${new_clist[$i]}"
10550 do_facet mds1 $LCTL set_param fail_loc=0
10554 run_test 123af "llog_catlist can show all config files correctly"
10556 test_123ag() { # LU-15142
10560 remote_mgs_nodsh && skip "remote MGS with nodsh"
10561 (( $MGS_VERSION >= $(version_code 2.14.55) )) ||
10562 skip "Need server version least 2.14.55"
10564 [ -d $MOUNT/.lustre ] || setup
10566 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
10567 stack_trap "do_facet mgs $LCTL set_param -P jobid_name=$orig_val"
10569 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME1"
10570 do_facet mgs $LCTL set_param -P -d jobid_name
10571 rec=$(do_facet mgs $LCTL --device MGS llog_print params |
10572 grep -c jobid_name)
10573 (( rec == 0 )) || error "parameter was not deleted, check #1"
10574 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME1"
10575 rec=$(do_facet mgs $LCTL --device MGS llog_print params |
10576 grep -c jobid_name)
10577 (( rec == 1)) || error "parameter is not set"
10578 # usage with ordinary set_param format works too
10579 do_facet mgs $LCTL set_param -P -d jobid_name="TESTNAME1"
10580 rec=$(do_facet mgs $LCTL --device MGS llog_print params |
10581 grep -c jobid_name)
10582 (( rec == 0 )) || error "parameter was not deleted, check #2"
10584 run_test 123ag "llog_print skips values deleted by set_param -P -d"
10586 test_123ah() { #LU-7668 del_ost
10587 (( "$MGS_VERSION" >= $(version_code 2.15.51) &&
10588 "$MDS1_VERSION" >= $(version_code 2.15.51) )) ||
10589 skip "Need MGS/MDS version >= 2.15.51 for del_ost"
10591 [ -d $MOUNT/.lustre ] || setupall
10592 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0" EXIT
10594 local cmd="--device MGS llog_print"
10596 cli_llogcnt_orig=$(do_facet mgs $LCTL $cmd $FSNAME-client |
10597 grep -c $FSNAME-OST0000)
10598 mds1_llogcnt_orig=$(do_facet mgs $LCTL $cmd $FSNAME-MDT0000 |
10599 grep -c $FSNAME-OST0000)
10601 [ $cli_llogcnt_orig -gt 0 ] ||
10602 error "$FSNAME-OST0000 not found (client)"
10603 [ $mds1_llogcnt_orig -gt 0 ] || error "$FSNAME-OST0000 not found (MDT)"
10605 # -n/--dryrun should NOT modify catalog
10606 do_facet mgs "$LCTL del_ost -n -t $FSNAME-OST0000" ||
10607 error "del_ost --dryrun failed with $?"
10609 local cli_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-client |
10610 grep -c $FSNAME-OST0000)
10611 local mds1_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-MDT0000 |
10612 grep -c $FSNAME-OST0000)
10614 [ $cli_llogcnt -eq $cli_llogcnt_orig ] ||
10615 error "--dryrun error: $cli_llogcnt != $cli_llogcnt_orig"
10616 [ $mds1_llogcnt -eq $mds1_llogcnt_orig ] ||
10617 error "--dryrun error: $mds1_llogcnt != $mds1_llogcnt_orig"
10620 do_facet mgs "$LCTL del_ost --target $FSNAME-OST0000" ||
10621 error "del_ost failed with $?"
10623 local cli_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-client |
10624 grep -c $FSNAME-OST0000)
10625 local mds1_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-MDT0000 |
10626 grep -c $FSNAME-OST0000)
10628 # every catalog entry for OST0000 should have been cancelled
10629 [ $cli_llogcnt -eq 0 ] || error "$FSNAME-OST0000 not cancelled (cli)"
10630 [ $mds1_llogcnt -eq 0 ] || error "$FSNAME-OST0000 not cancelled (MDT)"
10632 umount_client $MOUNT
10633 mount_client $MOUNT
10635 $LFS df | grep -q OST0000 && error "del_ost did not remove OST0000!"
10637 reformat_and_config
10639 run_test 123ah "del_ost cancels config log entries correctly"
10644 echo "cleanup test 123ai"
10646 # cancel last timeout record
10647 do_facet mgs "$LCTL set_param -P -d timeout"
10649 # restore timeout value
10650 do_nodes $(comma_list $(all_nodes)) "$LCTL set_param timeout=$timeout"
10653 test_123ai() { #LU-16167
10659 remote_mgs_nodsh && skip "remote MGS with nodsh"
10660 (( MDS1_VERSION >= $(version_code 2.15.51) )) ||
10661 skip "Need MDS version at least 2.15.51"
10663 [ -d $MOUNT/.lustre ] || setup
10665 old_count=$(do_facet mgs "$LCTL --device MGS llog_print -r params" |
10666 grep -c "parameter: timeout")
10668 old_timeout=$($LCTL get_param -n timeout)
10669 stack_trap "cleanup_123ai $old_timeout" EXIT
10671 # add and cancel params (2 * MAX_IOC_BUFLEN / 128 + 1 = 129)
10672 for i in {1..129}; do
10673 do_facet mgs "$LCTL set_param -P timeout=$i" ||
10674 error "fail to set timeout=$i on MGS"
10677 count=$(do_facet mgs "$LCTL --device MGS llog_print -r params" |
10678 grep -c "parameter: timeout")
10680 ((count - old_count == 129)) ||
10681 error "number timeout record missmatch ($count - $old_count != 129)"
10683 do_facet mgs "$LCTL --device MGS llog_print params" |
10684 tail -1 | grep "timeout, value: 129" ||
10685 error "llog_print could not display the last record (timeout=129)"
10688 run_test 123ai "llog_print display all non skipped records"
10693 echo "cleanup test 123aj"
10695 # cancel last TBF parameter records
10696 do_facet mgs "$LCTL set_param -P -d ${svc}.nrs_tbf_rule" || true
10697 do_facet mgs "$LCTL set_param -P -d ${svc}.nrs_policies" || true
10699 # restore old NRS policy
10700 do_nodes $(comma_list $(osts_nodes)) \
10701 "$LCTL set_param ${svc}.nrs_policies=fifo"
10704 check_compound_param_val() {
10705 local value llog_print
10709 llog_print=$(do_facet mgs "$LCTL llog_print params") ||
10710 error "fail to read CONFIG/params"
10712 for value in "$@"; do
10713 local n=$(grep -c "${svc}.*$value }$" <<< "$llog_print")
10715 (( n > 0 )) || error "fail to found '$value' in params config"
10716 (( n == 1 )) || error "several records found ($n) for '$value'"
10720 add_random_spaces()
10723 local spaces=$(printf '%*s' $(($RANDOM % 4)) '')
10727 spaces=$(printf '%*s' $(($RANDOM % 4)) '')
10728 str+="$word $spaces"
10734 test_123aj() { #LU-17920
10739 local ost_io="ost.OSS.ost_io"
10741 tbf_rules[rule1]="start rule1 uid={500 502 } rate=1000"
10742 tbf_rules[rule2]="start rule2 nid={10.10.2.20@tcp} rate=1000"
10743 tbf_rules[rule3]="start rule3 jobid={cat.0.0} rate=1000"
10744 tbf_rules[rule4]="start rule4 jobid={fio.0.0} rate=500"
10745 tbf_rules[change4_1]="change rule4 rate=50"
10746 tbf_rules[change4_2]="change rule4 rate=5000"
10748 remote_mgs_nodsh && skip "remote MGS with nodsh"
10749 (( MGS_VERSION >= $(version_code v2_16_54-23) )) ||
10750 skip "need MGS >= v2_16_54-23 for compound llog records"
10752 [ -d $MOUNT/.lustre ] || setup
10754 stack_trap "cleanup_123aj $ost_io"
10756 do_facet mgs "$LCTL set_param -P ${ost_io}.nrs_policies=tbf" ||
10757 error "fail to set nrs_policies=tbf on MGS"
10759 for rule in "${tbf_rules[@]}"; do
10760 do_facet mgs "$LCTL set_param -P ${ost_io}.nrs_tbf_rule='$rule'" ||
10761 error "fail to set nrs_tbf_rule='$rule' on MGS"
10763 # the rec should be added only the first time
10764 rule="$(add_random_spaces "$rule")"
10765 do_facet mgs "$LCTL set_param -P ${ost_io}.nrs_tbf_rule='$rule'" ||
10766 error "fail to set nrs_tbf_rule='$rule' on MGS"
10768 check_compound_param_val $ost_io "${tbf_rules[@]}"
10770 # remove all the rules
10771 do_facet mgs "$LCTL set_param -P -d ${ost_io}.nrs_tbf_rule" ||
10772 error "fail to remove all the TBF rules"
10774 llog_print=$(do_facet mgs "$LCTL llog_print params") ||
10775 error "fail to read CONFIG/params"
10776 ! grep -q nrs_tbf_rule <<< "$llog_print" ||
10777 error "fail to remove all the TBF rules"
10780 for rule in "${tbf_rules[@]}"; do
10781 do_facet mgs "$LCTL set_param -P ${ost_io}.nrs_tbf_rule='$rule'" ||
10782 error "fail to set nrs_tbf_rule='$rule' on MGS"
10784 check_compound_param_val $ost_io "${tbf_rules[@]}"
10786 # shuffle and remove the rule one by one
10787 printf "%s\n" "${!tbf_rules[@]}" | sort -R |
10789 rule="${tbf_rules[$key]}"
10790 unset tbf_rules[$key]
10791 do_facet mgs "$LCTL set_param -P -d ${ost_io}.nrs_tbf_rule='$rule'" ||
10792 error "fail to set nrs_tbf_rule='$rule' on MGS"
10793 check_compound_param_val $ost_io "${tbf_rules[@]}"
10796 run_test 123aj "check permanent TBF rules"
10799 remote_mgs_nodsh && skip "remote MGS with nodsh"
10801 [ -d $MOUNT/.lustre ] || setup
10802 yaml_file="$TMP/$tfile.yaml"
10804 do_facet mgs rm "$yaml_file"
10805 cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
10806 sed 's/config_log://')
10808 # set jobid_var to a different value for test
10809 orig_val=$(do_facet mgs $LCTL get_param jobid_var)
10811 do_facet mgs $LCTL set_param -P jobid_var="TESTNAME"
10813 for i in $cfgfiles params; do
10814 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
10817 echo "Unmounting FS"
10825 test_123_restore() {
10826 set_val=$(do_facet mgs $LCTL get_param jobid_var)
10828 do_facet mgs $LCTL set_param -P $orig_val
10830 [ $set_val == "jobid_var=TESTNAME" ] ||
10831 error "$set_val is not TESTNAME"
10833 do_facet mgs rm "$yaml_file"
10845 # Reapply the config from before
10846 echo "Setting configuration parameters"
10847 do_facet mgs "$LCTL set_param -F $yaml_file" ||
10848 error "'set_param -F $yaml_file' failed"
10852 run_test 123F "clear and reset all parameters using set_param -F"
10862 # Reapply the config from before
10863 echo "Setting configuration parameters"
10864 do_facet mgs "$LCTL apply_yaml $yaml_file" ||
10865 error "'apply_yaml $yaml_file' failed"
10869 run_test 123G "clear and reset all parameters using apply_yaml"
10871 test_123H() { #LU-18170
10875 (( MGS_VERSION >= $(version_code 2.16.51) )) ||
10876 skip "Need MGS version at least 2.16.51"
10878 [ -d $MOUNT/.lustre ] || setup
10880 old=$(do_facet mgs $LCTL get_param jobid_var)
10881 stack_trap "do_facet mgs $LCTL set_param -d jobid_var"
10882 stack_trap "do_facet mgs $LCTL set_param -P jobid_var=$old"
10884 # fill the "params" llog file
10885 for i in {1..50}; do
10886 do_facet mgs $LCTL set_param -P jobid_var=TEST_123H
10887 do_facet mgs $LCTL set_param -P jobid_var=$old
10892 llog_str=$(do_facet mgs $LCTL llog_print -r params) ||
10893 error "'lctl llog_print -r params' failed"
10894 num=$(wc -l <<< "$llog_str")
10896 # llog_print parallel executions
10897 do_facet mgs "seq 1 20 | "\
10898 "xargs -P20 -I{} bash -c '$LCTL llog_print -r params | wc -l' | "\
10900 awk '$2 == "'$num'" { print $0; if ($1 != 20) exit 1; }' ||
10901 error "'corrupted output for 'lctl llog_print -r params'"
10903 run_test 123H "check concurent accesses with 'lctl llog_print"
10907 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
10908 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
10911 do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
10912 grep 1.2.3.4@tcp && error "Should not be fake nid"
10913 do_facet mgs $LCTL conf_param $FSNAME-MDT0001.failover.node=1.2.3.4@tcp\
10914 || error "Set params error"
10915 do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
10916 grep 1.2.3.4@tcp || error "Fake nid should be added"
10920 if combined_mgs_mds; then
10921 start_mdt 1 "-o nosvc" ||
10922 error "starting mds with nosvc option failed"
10924 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
10925 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
10927 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
10928 error "replace_nids execution error"
10930 if combined_mgs_mds; then
10936 echo "lfs setdirstripe"
10937 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
10940 run_test 124 "check failover after replace_nids"
10942 get_max_sectors_kb() {
10945 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10946 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
10948 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
10949 cat ${max_sectors_path}"
10952 get_max_hw_sectors_kb() {
10955 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10956 local max_hw_path="/sys/block/${dev_base}/queue/max_hw_sectors_kb"
10958 do_facet ${facet} "[[ -e ${max_hw_path} ]] && cat ${max_hw_path}"
10961 set_max_sectors_kb() {
10965 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10966 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
10968 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
10969 echo ${value} > ${max_sectors_path}"
10972 [[ $rc -ne 0 ]] && echo "Failed to set ${max_sectors_path} to ${value}"
10977 # Return 0 if all slave devices have max_sectors_kb == max_hw_sectors_kb
10978 # Otherwise return > 0
10979 check_slaves_max_sectors_kb()
10983 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10984 local slaves_dir=/sys/block/${dev_base}/slaves
10985 local slave_devices=$(do_facet ${facet} "ls ${slaves_dir} 2>/dev/null")
10986 [[ -z ${slave_devices} ]] && return 0
10988 local slave max_sectors new_max_sectors max_hw_sectors path
10991 for slave in ${slave_devices}; do
10992 path="/dev/${slave}"
10993 ! is_blkdev ${facet} ${path} && continue
10994 max_sectors=$(get_max_sectors_kb ${facet} ${path})
10995 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${path})
10996 new_max_sectors=${max_hw_sectors}
10997 [[ ${new_max_sectors} -gt ${RQ_SIZE_LIMIT} ]] &&
10998 new_max_sectors=${RQ_SIZE_LIMIT}
11000 if [[ ${max_sectors} -ne ${new_max_sectors} ]]; then
11001 echo "${path} ${max_sectors} ${new_max_sectors}"
11004 check_slaves_max_sectors_kb ${facet} ${path}
11012 [[ "$MDS1_VERSION" -ge $(version_code 2.13.52) ]] ||
11013 skip "Need MDS version at least 2.13.52"
11016 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ../libcfs/libcfs/libcfs
11017 #define OBD_FAIL_OBD_SETUP 0x60d
11018 do_facet mds1 $LCTL set_param fail_loc=0x60d
11019 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules &
11020 for i in {1..40}; do
11021 do_facet mds1 lsmod | grep -q osd_$mds1_FSTYPE && break
11024 clear_failloc $SINGLEMDS 20 &
11025 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
11027 run_test 126 "mount in parallel shouldn't cause a crash"
11030 [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
11034 zconf_umount_clients $RCLIENTS $MOUNT
11036 wait_osp_active ost ${FSNAME}-OST0000 0 1
11037 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
11038 local avail1=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
11040 wait_delete_completed
11041 $LFS setstripe -i 0 -c1 $DIR/$tfile || {
11043 $LCTL get_param osc.*.*grant_bytes
11044 error "failed creating $DIR/$tfile"
11046 dd if=/dev/zero of=$DIR/$tfile bs=1M oflag=direct || true
11049 local avail2=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
11051 if ((avail2 * 100 / avail1 > 1)); then
11054 error "more than 1% space left: before=$avail1 after=$avail2"
11057 local mbs=$(($(stat -c %s $DIR/$tfile) / (1024 * 1024)))
11059 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$mbs conv=notrunc \
11060 oflag=direct || error "overwrite failed"
11062 run_test 127 "direct io overwrite on full ost"
11066 combined_mgs_mds && skip "need separate mgs device"
11067 [ "$ost2_FSTYPE" == zfs ] && import_zpool ost2
11070 # Try to apply nolocallogs to the virgin OST. Should fail.
11071 do_facet ost2 "$TUNEFS --nolocallogs $(ostdevname 2)" &&
11072 error "nolocallogs should not be allowed on the virgin target"
11077 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
11078 # Start OST without MGS (local configs)
11079 do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)"
11080 start_ost || error "unable to start OST1"
11081 stop_ost || error "Unable to stop OST1"
11083 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
11084 # Do not allow reading local configs, should fail
11085 do_facet ost1 "$TUNEFS --nolocallogs $(ostdevname 1)" ||
11086 error "Can not set nolocallogs"
11087 start_ost && error "OST1 started, but should fail"
11089 # Connect to MGS successfully, reset nolocallogs flag
11090 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
11091 start_mgs || error "unable to start MGS"
11092 start_ost || error "unable to start OST1"
11094 do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)" | grep "nolocallogs" &&
11095 error "nolocallogs expected to be reset"
11097 stop_ost || error "Unable to stop OST1"
11099 run_test 128 "Force using remote logs with --nolocallogs"
11103 (( MDS1_VERSION >= $(version_code 2.14.57) )) ||
11104 skip "Need MDS version at least 2.14.57"
11106 start_mgsmds || error "MGS/MDS start failed"
11108 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &&
11109 error "start ost1 should fail" || true
11110 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &&
11111 error "second start ost1 should fail" || true
11112 do_facet ost1 "$TUNEFS --writeconf $(ostdevname 1)"
11113 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
11114 error "start ost1 failed"
11118 run_test 129 "attempt to connect an OST with the same index should fail"
11122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
11124 stop_mdt 2 || error "mdt2 stop failed"
11125 do_facet mds2 "$TUNEFS --writeconf $(mdsdevname 2)"
11126 start_mdt 2 || error "mdt2 start failed"
11127 do_facet mds2 "$LCTL dl" | grep MDT0001-osp-MDT0001 &&
11128 error "Illegal OSP device created" || true
11130 run_test 130 "re-register an MDT after writeconf"
11133 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
11134 (( $MDS1_VERSION >= $(version_code 2.14.56.35) )) ||
11135 skip "Need MDS version at least 2.14.56.35"
11136 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
11137 grep -q project || skip "skip project quota not supported"
11142 test_mkdir -c $MDSCOUNT -p $DIR/$tdir
11143 $LFS project -p 1000 $DIR/$tdir || error "set dir project id failed"
11144 createmany -o $DIR/$tdir/f 512
11145 for ((i = 0; i < 512; ++i)); do
11146 $LFS project -p $i $DIR/$tdir/f${i} ||
11147 error "set f${i} project id failed"
11150 test_mkdir -c $MDSCOUNT -p $DIR/$tdir.inherit
11151 $LFS project -p 1001 -s $DIR/$tdir.inherit
11152 createmany -o $DIR/$tdir.inherit/f 128
11153 (( $($LFS project $DIR/$tdir.inherit/f* |
11154 awk '$1 == 1001 { print }' | wc -l) == 128 )) ||
11155 error "files did not inherit projid 1001"
11159 for i in $(seq $MDSCOUNT); do
11160 mds_backup_restore mds$i ||
11161 error "Backup/restore on mds$i failed"
11166 projid=($($LFS project -d $DIR/$tdir))
11167 [ ${projid[0]} == "1000" ] ||
11168 error "projid expected 1000 not ${projid[0]}"
11169 for ((i = 0; i < 512; ++i)); do
11170 projid=($($LFS project $DIR/$tdir/f${i}))
11171 [ ${projid[0]} == "$i" ] ||
11172 error "projid expected $i not ${projid[0]}"
11175 (( $($LFS project $DIR/$tdir.inherit/f* |
11176 awk '$1 == 1001 { print }' | wc -l) == 128 )) ||
11177 error "restore did not copy projid 1001"
11179 run_test 131 "MDT backup restore with project ID"
11185 (( MDS1_VERSION >= $(version_code 2.14.57) )) ||
11186 skip "Need MDS version at least 2.14.57"
11188 combined_mgs_mds || start_mgs || error "unable to start MGS"
11189 start_mdt 1 || error "unable to start mdt1"
11191 err_cnt=$(do_facet mds1 dmesg | grep -c "cannot take the layout locks")
11192 stop_mdt 1 || error "stop mdt1 failed"
11194 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
11195 do_facet mds1 $TUNEFS --param mdt.hsm_control=enabled $(mdsdevname 1) ||
11196 error "tunefs failed"
11197 start_mdt 1 || error "cannot start mdt1"
11199 err_cnt2=$(do_facet mds1 dmesg | grep -c "cannot take the layout locks")
11200 [ $err_cnt -eq $err_cnt2 ] || error "Can not take the layout lock"
11201 stop_mdt 1 || error "stop mdt1 failed"
11203 run_test 132 "hsm_actions processed after failover"
11205 # This test verifies we do RR allocation within a pool even if there is a
11206 # significant imbalance vs an OST outside the pool
11208 [[ $OSTCOUNT -lt 4 ]] && skip_env "needs >= 4 OSTs"
11209 [[ "$OST1_VERSION" -ge $(version_code 2.15.51) ]] ||
11210 skip "Need OST version at least 2.15.51"
11211 # This is the easiest way to ensure OSTs start out balanced
11212 reformat_and_config
11215 check_set_fallocate_or_skip
11217 local testfile=$DIR/$tdir/$tfile
11218 local pool="testpool"
11219 local ostrange=$((OSTCOUNT - 1))
11220 # Select all but the last OST to add to the pool
11221 local poolostrange=$((OSTCOUNT - 2))
11229 [ $MINV -eq 0 ] && error "no free space in OST$MINI"
11230 [ $MAXV -gt $((2 * $MINV)) ] &&
11231 error "OSTs badly unbalanced after reformat"
11233 create_pool $FSNAME.$pool || error "failed to create a pool"
11234 do_facet mgs $LCTL pool_add $FSNAME.$pool OST[0-$poolostrange] ||
11235 error "failed to add OST[0-$poolostrange] to the pool"
11237 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
11238 # Consume space on the OSTs in the pool so they are unbalanced with the
11239 # OST outside of the pool
11240 # fill each OST 90% with fallocate so they are widely
11242 local size=$(((MINV * 9 / 10) * 1024))
11243 for ((i = 0; i <= poolostrange; i++)); do
11244 $LFS setstripe -c 1 -i $i $testfile$i ||
11245 error "failed to setstripe $testfile$i"
11246 fallocate -l $size $testfile$i || error "fallocate failed"
11252 # Create files in the pool now that there is an imbalance
11253 filecount=$(((OSTCOUNT - 1) * filenum))
11254 for ((i = 0; i < filecount; i++)); do
11255 $LFS setstripe -p $pool $testfile-$i ||
11256 error "failed to setstripe -p $pool $testfile-$i"
11258 $LFS getstripe -i $testfile-* > /tmp/$tfile.log
11259 # Count the number of files with a stripe on each OST to verify the
11260 # pool allocated with round-robin
11261 for ((i = 0; i <= poolostrange; i++)); do
11262 stripecount=$(grep -c $i /tmp/$tfile.log)
11263 # Allow a little leeway
11264 if (( stripecount < filenum - 1 ||
11265 stripecount > filenum + 1 )); then
11266 cat /tmp/$tfile.log
11267 error "$stripecount != $filenum files on OST$i"
11271 # Create files across the system now that there is an imbalance
11272 filecount=$((OSTCOUNT * filenum))
11273 for ((i = 1; i < filecount; i++)); do
11274 $LFS setstripe $testfile-$i.2 ||
11275 error "failed to setstripe $testfile-$i.2"
11277 $LFS getstripe -i $testfile-*.2 > /tmp/$tfile.log
11279 # Count the number of files with a stripe on each OST to verify the
11280 # files are *NOT* allocated with round-robin
11281 for ((i = 0; i <= ostrange; i++)); do
11282 stripecount=$(grep -c $i /tmp/$tfile.log)
11283 if [[ $stripecount -ne $filenum ]]; then
11285 echo "QOS: $stripecount != $filenum files on OST$i"
11288 if [ -z "$qos_used" ]; then
11289 error "QOS not used on imbalanced OSTs!"
11292 rm -rf /tmp/$tfile.log $DIR/$tdir
11293 do_facet mgs $LCTL pool_remove $FSNAME.$pool OST[0-$poolostrange] ||
11294 "failed to remove OST[0-$poolostrange] from the pool"
11295 do_facet mgs $LCTL pool_destroy $FSNAME.$pool ||
11296 error "failed to destroy pool"
11298 run_test 133 "stripe QOS: free space balance in a pool"
11301 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
11303 local rc rc_corrupted
11304 local mdt_dev=$(facet_device mds1)
11305 local tmp_dir=$TMP/$tdir
11306 local dir=$DIR/$tdir
11307 local out=$tmp_dir/check_iam.txt
11308 local CHECK_IAM=${CHECK_IAM:-$(do_facet mds1 "which check_iam 2> /dev/null || true")}
11309 local iam_files=$(printf "oi.16.%d " {0..63})
11311 [[ -n "$CHECK_IAM" ]] || skip "check_iam not found"
11315 # Fill the iam files
11316 test_mkdir -p $dir || error "failed to mkdir $DIR/$tdir"
11317 stack_trap "rm -rf $dir"
11319 touch $dir/$tfile.{0..1000} || error "failed to touch files"
11320 stack_trap "find $dir -type f | xargs -P10 -n1 unlink"
11323 for f in $dir/$tfile.{0..10}; do
11324 printf "%s\n" $f.ln.{0..500} | xargs -P10 -n1 ln $f ||
11325 error "failed to create 500 hard links of $f"
11328 local nm_name=${TESTNAME:0:15}
11330 do_facet mgs "$LCTL nodemap_add $nm_name"
11331 stack_trap "do_facet mgs $LCTL nodemap_del $nm_name"
11332 do_facet mgs "$LCTL nodemap_add_range --name $nm_name --range '121.23.2.[100-120]@tcp'"
11334 do_facet mds1 "$LCTL lfsck_start -A && $LCTL lfsck_query -w > /dev/null"
11336 if (( MDS1_VERSION >= $(version_code 2.16.0) )); then
11338 iam_files+=$(printf "LFSCK/lfsck_layout_%02u " {0..15})
11339 iam_files+=$(printf "LFSCK/lfsck_namespace_%02u " {0..15})
11340 iam_files+="CONFIGS/nodemap "
11344 for f in $iam_files; do
11345 #cmd introduce a random corruption to IAM file
11346 local tmp_file=$tmp_dir/$(basename $f)
11347 local cmd="dd if=/dev/urandom of=$tmp_file bs=2 conv=notrunc count=1 seek=$((RANDOM % 36))"
11350 [[ "$f" =~ nodemap ]] && facet=mgs || facet=mds1
11351 do_facet $facet "mkdir -p $tmp_dir; \
11352 $DEBUGFS -c -R 'dump $f $tmp_file' $mdt_dev 2>&1; \
11353 $CHECK_IAM -rv $tmp_file 2>&1; \
11354 echo $cmd; eval $cmd 2>/dev/null;
11355 $CHECK_IAM -v $tmp_file 2>&1; \
11356 rc=\\\$?; echo \\\$rc; exit \\\$rc;" >> $out 2>&1 ||
11357 (( rc_corrupted += ($? == 255) )) || true
11362 stack_trap "rm -rf $tmp_dir && do_facet mds1 rm -rf $tmp_dir" EXIT
11364 rc=$(grep -c "\<fault\>\|\<except" $out)
11365 (( rc == 0 )) || { cat $out &&
11366 error "check_iam failed with fault or exception $rc"; }
11368 errors=$(grep -c "FINISHED WITH ERRORS" $out)
11370 (( rc_corrupted == errors )) || { cat $out &&
11371 error "check_iam errcode does not fit with errors $rc $errors"; }
11373 run_test 134 "check_iam works without faults"
11375 cleanup_test_135(){
11378 printf "\nCleanup test_135\n" >&2
11379 do_facet mds1 "$LCTL set_param -n $oldgc"
11380 rm -rf $DIR/$tdir &> /dev/null
11384 __test_135_file_thread() {
11386 local init_time=$(awk '{print $1}' /proc/uptime)
11387 local awkcmd="/crosses index zero/ {if (\$1 > $init_time) exit(1);}"
11389 #Generate a full plain llogs
11390 while dmesg | sed -r 's/(\[|\])//g' | awk "$awkcmd" ; do
11391 createmany -o $DIR/$tdir/f 4500 >&2
11392 createmany -u $DIR/$tdir/f 4500 >&2
11396 __test_135_reader() {
11399 local firstidx=$(changelog_user_rec mds1 $cl_user)
11400 local oldidx=$firstidx
11405 while read -t10 -u$fd newidx other; do
11406 (( (newidx - oldidx) == 1 )) ||
11407 error "changelog jump detected (last: $oldidx, current: $newidx)"
11409 if (( (newidx - firstidx + 1) % 13000 == 0 )); then
11410 [[ $pid -eq 0 ]] ||
11411 wait $pid || error "changelog_clear failed"
11412 changelog_clear $((newidx - 1)) mds1 >&2 & pid=$!
11417 [[ $pid -eq 0 ]] ||
11418 wait $pid || error "changelog_clear failed"
11424 (( MDS1_VERSION >= $(version_code 2.15.52) )) ||
11425 skip "need MDS version at least 2.15.52"
11427 local service=$(facet_svc mds1)
11429 local lastread lastidx
11430 local files_pid reader_pid
11435 # Need to reformat because we are changing llog catalog sizes to 5.
11436 # Otherwise, processing could fail with existing catalogs (last_idx>5).
11440 # Disable changelog garbage colector
11441 local oldgc=$(do_facet mds1 "$LCTL get_param mdd.${service}.changelog_gc")
11442 do_facet mds1 "$LCTL set_param -n mdd.${service}.changelog_gc=0"
11443 stack_trap "cleanup_test_135 $oldgc" EXIT INT
11445 # change the changelog_catalog size to 5 entries for everybody
11446 #define OBD_FAIL_CAT_RECORDS 0x1312
11447 do_node $(comma_list $(all_nodes)) $LCTL set_param fail_loc=0x1312 fail_val=5
11449 # disable console ratelimit
11450 local rl=$(cat /sys/module/libcfs/parameters/libcfs_console_ratelimit)
11451 echo 0 > /sys/module/libcfs/parameters/libcfs_console_ratelimit
11452 stack_trap "echo $rl > /sys/module/libcfs/parameters/libcfs_console_ratelimit" EXIT
11454 test_mkdir -c 1 -i 0 $DIR/$tdir || error "Failed to create directory"
11455 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param \
11456 seq.*OST*-super.width=$DATA_SEQ_MAX_WIDTH
11458 changelog_chmask "ALL" || error "changelog_chmask failed"
11459 changelog_register || error "changelog_register failed"
11461 cl_user="${CL_USERS[mds1]%% *}"
11462 changelog_users mds1 | grep -q $cl_user ||
11463 error "User $cl_user not found in changelog_users"
11465 # Start reader thread
11466 coproc $LFS changelog --follow $service
11469 stack_trap "echo kill changelog reader; kill $reader_pid" EXIT
11471 echo -e "\nWrap arround changelog catalog"
11473 # Start file writer thread
11474 __test_135_file_thread "$service" & files_pid=$!
11475 stack_trap "(pkill -P$files_pid; kill $files_pid) &> /dev/null || true" EXIT
11477 # Check changelog entries
11478 lastread=$(__test_135_reader $fd $cl_user) || exit $?
11480 ! kill -0 $files_pid 2>/dev/null ||
11481 error "creation thread is running. Is changelog reader stuck?"
11483 lastidx=$(changelog_users mds1 | awk '/current_index/ {print $NF}' )
11484 [[ "$lastread" -eq "$lastidx" ]] ||
11485 error "invalid changelog lastidx (read: $lastread, mds: $lastidx)"
11487 run_test 135 "check the behavior when changelog is wrapped around"
11490 do_facet mds2 "$LCTL --device ec cleanup" || true
11491 do_facet mds2 "$LCTL --device ec detach" || true
11494 reformat_and_config
11498 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
11499 (( $MDS1_VERSION >= $(version_code v2_15_61-43-g55c143a66d) )) ||
11500 skip "Need MDS >= 2.15.61.43 for obdecho on second MDT"
11505 do_rpc_nodes $(facet_active_host mds2) "load_module obdecho/obdecho"
11506 do_facet mds2 "$LCTL attach echo_client ec ec_uuid" ||
11507 error "echo attach fail"
11509 stack_trap cleanup_136 EXIT
11511 do_facet mds2 "$LCTL --device ec setup lustre-MDT0001 mdt" &&
11512 error "attach to MDT should fail!"
11514 do_facet mds2 "$LCTL --device ec setup lustre-MDT0001 mdd" ||
11515 error "attach to MDD should OK"
11516 do_facet mds2 "$LCTL --device ec test_mkdir /tt" &&
11517 error "mkdir test should fail with remote object"
11521 run_test 136 "don't panic with bad obdecho setup"
11524 (( MDS1_VERSION >= $(version_code 2.15.61) )) ||
11525 skip "need MDS version at least 2.15.61"
11527 (( $MDSCOUNT >= 3 )) || skip "needs >= 3 MDTs"
11529 local failnode=1.2.3.4@$NETTYPE
11530 local keep_zpool=$KEEP_ZPOOL
11533 #start mgs or mgs/mdt0
11534 if ! combined_mgs_mds ; then
11535 start_mgs || error "Fail to register mgs"
11536 start_mdt 1 || error "Fail to register mds1"
11538 start_mdt 1 || error "Fail to register mds1"
11541 start_ost || error "OST0 start fail"
11543 mount_client $MOUNT || error "mount client fails"
11544 wait_osc_import_ready client ost
11545 check_mount || error "check_mount failed"
11547 # Add failover node on OST0000
11549 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
11550 do_facet ost1 "$TUNEFS --failnode=$failnode $(ostdevname 1)" ||
11551 error "ost1 tunefs failed"
11552 start_ost || error "OST0 start fail"
11554 # Add pool and parameters on MDT0000 to check the inheritance
11555 do_facet mgs $LCTL pool_new $FSNAME.pool1 || error "pool_new failed"
11556 do_facet mgs $LCTL pool_add $FSNAME.pool1 OST0000 ||
11557 error "pool_add failed"
11559 set_conf_param_and_check mds1 \
11560 "$LCTL get_param -n lod.$FSNAME-MDT0000*.dom_stripesize" \
11561 "$FSNAME-MDT0000.lod.dom_stripesize" \
11564 start_mdt 2 || error "Fail to register mds2"
11566 wait_osp_import mds1 mds2 FULL
11567 wait_osp_import mds2 mds1 FULL
11568 wait_osp_import mds2 ost1 FULL
11570 # Add failover node on MDT0001
11571 stop_mdt 2 || error "Fail to umount mds2"
11572 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds2
11573 do_facet mds2 "$TUNEFS --failnode=$failnode $(mdsdevname 2)" ||
11574 error "mds2 tunefs failed"
11575 start_mdt 2 || error "Fail to mount mds2"
11577 wait_osp_import mds1 mds2 FULL
11578 wait_osp_import mds2 mds1 FULL
11579 wait_osp_import mds2 ost1 FULL
11582 for ((i=3; i <= MDSCOUNT; i++)); do
11583 start_mdt $i || error "Fail to register mds$i"
11586 wait_osc_import_state mds ost FULL
11588 for ((i=2; i <= MDSCOUNT; i++)); do
11591 local tgt=$(facet_svc $facet)
11592 local lod="lod.$tgt*"
11594 wait_osp_active mds $tgt $(( i - 1 )) 1
11596 do_facet $facet $LCTL get_param -n $lod.pools.pool1 |
11597 grep -q "OST0000" || error "pool1 should be inherited"
11599 val=$(do_facet $facet $LCTL get_param -n $lod.dom_stripesize)
11600 (( val == (2<<20) )) ||
11601 error "dom_stripesize should be inherited"
11603 import="osc.$FSNAME-OST0000-osc-${tgt#*-}.import"
11604 do_facet $facet $LCTL get_param -n $import |
11605 grep -q "failover_nids:.*$failnode" ||
11606 error "$failnode not found in $import"
11608 [[ "${tgt#*-}" != MDT0001 ]] || continue
11610 import="osp.$FSNAME-MDT0001-osp-${tgt#*-}.import"
11611 do_facet $facet $LCTL get_param -n $import |
11612 grep -q "failover_nids:.*$failnode" ||
11613 error "$failnode not found in $import"
11616 cleanup || error "cleanup failed with rc $?"
11617 reformat_and_config
11619 run_test 137 "a new MDT should inherit pools, parameters and failnode"
11622 (( MDS1_VERSION >= $(version_code 2.15.55) )) ||
11623 skip "need MDS version at least 2.15.55"
11624 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
11626 RM_UPDATELOG=$(do_facet mds2 "which remove_updatelog 2> /dev/null")
11627 RM_UPDATELOG=${RM_UPDATELOG:-"$LUSTRE/scripts/remove_updatelog"}
11629 [ -f "$RM_UPDATELOG" ] ||
11630 skip_env "remove_updatelog is not found on mds2"
11632 local mntpt=$(facet_mntpt mds2)
11635 test_mkdir -c $MDSCOUNT -p $DIR/$tdir ||
11636 error "mkdir $DIR/$tdir failed"
11637 mkdir $DIR/$tdir/d{1..256}
11642 mount_fstype mds2 || error "mount as fstype mds2 failed"
11643 do_facet mds2 $RM_UPDATELOG -n $mntpt
11644 MDTS=($(do_facet mds2 $RM_UPDATELOG -n $mntpt |
11645 grep -o "Processing MDT[0-9]*" | awk -F'MDT' '{print $2}'))
11646 (( ${#MDTS[@]} == MDSCOUNT )) ||
11647 error "Processed ${#MDTS[@]} from $MDSCOUNT"
11649 do_facet mds2 $RM_UPDATELOG -n -m 1,0 $mntpt
11650 MDTS=($(do_facet mds2 $RM_UPDATELOG -n -m 1,0 $mntpt |
11651 grep -o "Processing MDT[0-9]*" | awk -F'MDT' '{print $2}'))
11652 (( ${#MDTS[@]} == 2 )) ||
11653 error "Processed ${#MDTS[@]} instead of 2"
11654 (( ${MDTS[0]} == 1 && ${MDTS[1]} == 0 )) ||
11655 error "Processed: ${MDTS[*]}, expected: 1 0"
11657 do_facet mds2 $RM_UPDATELOG -m 0 $mntpt
11658 unmount_fstype mds2
11659 start_mdt 2 || error "mds2 start fail"
11660 start_mdt 1 || error "mds1 start fail"
11661 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds1 FULL
11662 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
11664 rm -rf $DIR/$tdir || error "Can't remove $tdir"
11666 reformat_and_config
11668 run_test 140 "remove_updatelog script actions"
11673 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11674 awk '/^max_cached_mb/ { print $2 }')
11675 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
11677 $LCTL set_param llite.*.max_cached_mb='100%'
11679 local new_max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11680 awk '/^max_cached_mb/ { print $2 }')
11681 local total_ram_mb=$(free -m | grep 'Mem:' | awk '{print $2}')
11683 $LCTL get_param llite.*.max_cached_mb
11684 echo "total ram mb: $total_ram_mb"
11685 (( new_max_cached_mb == total_ram_mb )) ||
11686 error "setting cache to 100% not equal to total RAM"
11688 $LCTL set_param llite.*.max_cached_mb='50%'
11689 new_max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11690 awk '/^max_cached_mb/ { print $2 }')
11692 $LCTL get_param llite.*.max_cached_mb
11693 (( new_max_cached_mb == $((total_ram_mb / 2)) )) ||
11694 error "setting cache to 50% not equal to 50% of RAM"
11696 $LCTL set_param llite.*.max_cached_mb='105%' &&
11697 error "should not be able to set insane value"
11699 $LCTL set_param llite.*.max_cached_mb='0%'
11700 new_max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11701 awk '/^max_cached_mb/ { print $2 }')
11702 # Minimum cache size is 64 MiB
11703 $LCTL get_param llite.*.max_cached_mb
11704 (( new_max_cached_mb == 64 )) ||
11705 error "setting cache to 0% != minimum cache size"
11707 run_test 150 "test setting max_cached_mb to a %"
11710 (( MDS1_VERSION >= $(version_code 2.15.58) )) ||
11711 skip "need MDS version at least 2.15.58"
11712 [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
11715 if ! combined_mgs_mds ; then
11719 echo "Damage ost1 local config log"
11720 do_facet ost1 "$DEBUGFS -w -R 'punch CONFIGS/$FSNAME-OST0000 0 1' \
11721 $(ostdevname 1) || return \$?" ||
11722 error "do_facet ost1 failed with $?"
11724 # expect OST to fail mount with no MGS and bad local config
11725 start_ost && error "OST start should fail"
11727 if ! combined_mgs_mds ; then
11730 start_mds || error "MDS start failed"
11731 # now it should start with MGS config
11732 start_ost || error "OST start failed"
11733 reformat_and_config
11735 run_test 151a "damaged local config doesn't prevent mounting"
11738 (( MDS1_VERSION >= $(version_code 2.15.63) )) ||
11739 skip "need MDS version at least 2.15.63"
11740 [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
11743 if ! combined_mgs_mds ; then
11747 start_mgsmds || error "MDS start failed"
11749 # start despite -ENOSPC errors
11750 #define OBD_FAIL_LLOG_BACKUP_ENOSPC 0x131e
11751 do_facet ost1 $LCTL set_param fail_loc=0x131e
11752 start_ost || error "OST start failed"
11753 reformat_and_config
11755 run_test 151b "-ENOSPC doesn't affect mount"
11758 (( MDS1_VERSION >= $(version_code 2.15.59.53) )) ||
11759 skip "need MDS >= 2.15.59.53 for sequence allocation retry"
11760 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
11761 local tf=$DIR/$tdir/$tfile
11762 local nost=$((OSTCOUNT+1))
11763 local nostdevname=$(ostdevname $nost)
11766 stack_trap "reformat_and_config"
11767 test_mkdir -i 1 -c1 $DIR/$tdir || error "can't mkdir"
11770 add ost$nost $(mkfs_opts ost1 $nostdevname) --index=$nost \
11771 --reformat $nostdevname $(ostvdevname $nost)
11772 [[ -d "$nostdevname" ]] || stack_trap "do_facet mds1 rm -f $nostdevname"
11774 #define OBD_FAIL_OPS_FAIL_SEQ_ALLOC 0x2109
11775 do_facet mds1 $LCTL set_param fail_loc=0x80002109 fail_val=2
11776 echo "START OST$nost"
11777 stack_trap "stop ost$nost"
11778 start ost$nost $nostdevname $OST_MOUNT_OPTS &
11782 $LFS setstripe -c -1 $tf &
11786 log "STOP OST$nost"
11787 # probably mount hasn't completed yet, so stop races with it
11790 jobs -pr | grep -E "^$PID\$" && sleep 0.5 && continue
11795 do_facet mds1 $LCTL set_param fail_loc=0
11796 log "START OST$nost again"
11797 start ost$nost $nostdevname $OST_MOUNT_OPTS ||
11798 error "can't start ost$nost"
11800 $LFS setstripe -c -1 $tf-2 || error "can't touch $tf-2"
11801 $LFS getstripe -v $tf-2
11802 local stripes=$($LFS getstripe -c $tf-2)
11803 (( stripes == $nost )) || error "$tf-2 $stripes != $nost"
11805 run_test 152 "seq allocation error in OSP"
11808 reformat_and_config
11810 start_mds || error "MDS start failed"
11811 start_ost || error "OST start failed"
11813 local nid=$($LCTL list_nids | grep ${NETTYPE} | head -n1)
11814 local net=${nid#*@}
11815 local mgs_nid=$(do_facet mgs $LCTL list_nids | head -1)
11816 local ost1_nid=$(do_facet ost1 $LCTL list_nids | head -1)
11817 local fake_pnid="192.168.252.112@${net}"
11818 local fake_nids="${fake_pnid},${fake_pnid}2"
11819 local fake_failover="10.252.252.113@${net},10.252.252.113@${net}2"
11820 local nids_and_failover="$fake_nids:$fake_failover:$ost1_nid:$mgs_nid"
11825 mount -t lustre $nids_and_failover:/lustre $MOUNT &
11827 while (( period < 30 )); do
11828 [[ -n "$(ps -p $pid -o pid=)" ]] || break
11829 echo "waiting for mount ..."
11831 period=$((period + 5))
11833 $LCTL get_param mgc.MGC${fake_pnid}.import | grep "uptodate:"
11834 check_mount || error "check_mount failed"
11836 cleanup || error "cleanup failed with rc $?"
11838 run_test 153a "bypass invalid NIDs quickly"
11842 reformat_and_config
11845 local IPv6_1="6699:7654::1234:1234:d84@tcp"
11846 local IPv6_2="2001:0db8:85a3:0000:0000:8a2e:0370:7334@tcp"
11847 local IPv6_3="5031:db8:85a3:8d3:1319:8a2e:370:7348@tcp"
11848 local IPv4_1="127.0.0.5"
11849 local IPv4_2="193.168.0.240@tcp"
11850 local IPv4_3="162.32.0.100"
11856 mgslist="$IPv6_1:$mgs_HOST"
11857 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11858 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11861 mgslist="$mgs_HOST:$mgs_HOST:$mgs_HOST"
11862 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11863 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11866 mgslist="$mgs_HOST:$IPv6_1"
11867 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11868 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11871 mgslist="$mgs_HOST:$IPv4_1"
11872 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11873 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11876 mgslist="$IPv4_1:$mgs_HOST"
11877 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11878 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11881 mgslist="$IPv4_2:$IPv4_1:$mgs_HOST"
11882 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11883 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11886 mgslist="$IPv6_1,$IPv4_2,$IPv4_1:$mgs_HOST"
11887 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11888 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11891 mgslist="$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1\
11892 :$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1\
11893 :$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1\
11894 :$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1\
11895 :$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1:$IPv4_1\
11896 :$IPv4_1:$IPv4_1:$mgs_HOST"
11897 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11898 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11901 mgslist="$IPv6_1,$IPv4_2,$IPv4_1:$IPv6_3,$IPv4_3,$IPv6_2:$mgs_HOST"
11902 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11903 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11906 mgslist="$IPv4_2,$IPv6_1,$IPv4_2,$IPv4_1:$IPv6_3,$IPv4_3:$IPv6_2\
11907 ,$IPv6_1,$IPv4_2,$IPv4_1:$IPv6_3,$IPv4_3:$IPv6_2,$IPv6_1,$IPv4_2\
11908 ,$IPv4_1:$IPv6_3,$IPv4_3:$IPv6_2,$IPv6_1,$IPv4_2,$IPv4_1:$IPv6_3\
11909 ,$IPv4_3:$IPv6_2,$IPv6_1,$IPv4_2,$IPv4_1:$IPv6_3,$IPv4_3:$IPv6_2\
11911 mount -t lustre $mgslist:/$FSNAME $MOUNT ||
11912 error "mount failed with $mgslist:/$FSNAME $MOUNT"
11915 run_test 153b "added IPv6 NID support"
11918 reformat_and_config
11920 start_mds || error "MDS start failed"
11921 start_ost || error "OST start failed"
11923 local nid=$($LCTL list_nids | grep ${NETTYPE} | head -n1)
11924 local net=${nid#*@}
11925 local fake_pnid="192.168.252.112@${net}"
11926 local fake_failover="192.168.252.113@${net}:192.168.252.115@${net}"
11927 local nids_and_failover="$fake_pnid:$fake_failover"
11932 umount_client $MOUNT
11933 mount -t lustre $nids_and_failover:/lustre $MOUNT &
11935 while (( period < 30 )); do
11936 [[ -n "$(ps -p $pid -o pid=)" ]] || break
11937 echo "waiting for mount ..."
11939 period=$((period + 5))
11941 $LCTL get_param mgc.MGC${fake_pnid}.import | grep "sec_ago"
11942 conn=$($LCTL get_param mgc.MGC${fake_pnid}.import |
11943 awk '/connection_attempts:/ {print $2}')
11944 echo "connection attempts: $conn"
11945 (( conn > 2)) || error "too few connection attempts"
11946 echo "Waiting for mount to fail"
11948 cleanup || error "cleanup failed with rc $?"
11950 run_test 153c "don't stuck on unreached NID"
11953 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
11954 (( $MDS1_VERSION >= $(version_code 2.15.63.1) )) ||
11955 skip "Need MDS version at least 2.15.63.1"
11956 local mdt1=$(mdsdevname 1)
11965 # create rename test dir on MDT0000 to simplify later debugfs checks
11966 test_mkdir -c 1 -i 0 $DIR/$tdir || error "mkdir $tdir failed"
11967 test_mkdir -c 1 -i 0 $DIR/$tdir.tgt || error "mkdir $tdir.tgt failed"
11969 for name in dx_dir dirent empty; do
11970 test_mkdir -c 1 -i 0 $DIR/$tdir.$name ||
11971 error "mkdir $tdir.$name failed"
11974 # make this directory large enough to htree split
11975 createmany -o $DIR/$tdir.dx_dir/$tfile.longfilename 128
11976 # put 2 entries after dotdot in this directory
11977 createmany -o $DIR/$tdir.dirent/$tfile.longfilename 2
11979 for name in dx_dir dirent empty; do
11980 mv $DIR/$tdir.$name $DIR/$tdir || error "mv $tdir.$name failed"
11983 parentfid="fid:$($LFS path2fid $DIR/$tdir)"
11984 echo "==target parent FID: $parentfid=="
11988 # check that ".." FID is updated during normal operation
11989 echo "==debugfs before backup=="
11990 for name in dx_dir dirent empty; do
11991 cmd="debugfs -c -R 'stat ROOT/$tdir/$tdir.$name' $mdt1"
11992 do_facet mds1 "$cmd" ||
11993 error "debugfs stat before backup failed"
11994 cmd="debugfs -c -R 'ls -lD ROOT/$tdir/$tdir.$name' $mdt1"
11995 do_facet mds1 "$cmd" ||
11996 error "debugfs before backup $name failed"
11997 dotdotfid=$(do_facet mds1 "$cmd" |& awk '/fid:.+\.\./ { print $9 }')
11998 [[ "$dotdotfid" == "$parentfid" ]] ||
11999 error "parent '$parentfid' != dotdot '$dotdotfid' on $name"
12002 for ((i = 1; i <= $MDSCOUNT; i++ )); do
12003 mds_backup_restore mds$i ||
12004 error "Backup/restore on mds$i failed"
12009 # verify that rename of the restored directory updates the
12010 # ".." entry in the directory with the parent FID
12011 echo "==pre-rename parent/.. inodes=="
12012 for name in dx_dir dirent empty; do
12013 ls -dial $DIR/$tdir $DIR/$tdir/$tdir.$name/.. ||
12014 error "ls on original dirs failed"
12015 ino=($(stat -c "%i" $DIR/$tdir $DIR/$tdir/$tdir.$name/..))
12016 (( ${ino[0]} == ${ino[1]} )) ||
12017 error "ino $DIR/$tdir ${ino[0]} != $tdir.$name/.. ${ino[1]}"
12020 for name in dx_dir dirent empty; do
12021 mv $DIR/$tdir/$tdir.$name $DIR/$tdir.tgt ||
12022 error "mv $tdir.$name failed"
12025 echo "==post-rename parent/.. inodes=="
12026 for name in dx_dir dirent empty; do
12027 ls -dial $DIR/$tdir.tgt $DIR/$tdir.tgt/$tdir.$name/.. ||
12028 error "ls on renamed dirs failed"
12029 ino=($(stat -c "%i" $DIR/$tdir.tgt $DIR/$tdir.tgt/$tdir.$name/..))
12030 (( ${ino[0]} == ${ino[1]} )) ||
12031 error "ino $DIR/$tdir.tgt ${ino[0]} != $tdir.$name/.. ${ino[1]}"
12034 parentfid="fid:$($LFS path2fid $DIR/$tdir.tgt)"
12035 echo "==target parent FID: $parentfid=="
12039 for name in dx_dir dirent empty; do
12040 echo "==post-rename .$name should have '$parentfid ..'=="
12041 cmd="debugfs -c -R 'stat ROOT/$tdir.tgt/$tdir.$name' $mdt1"
12042 do_facet mds1 "$cmd" ||
12043 error "debugfs stat after rename failed"
12044 cmd="debugfs -c -R 'ls -lD ROOT/$tdir.tgt/$tdir.$name' $mdt1"
12045 do_facet mds1 "$cmd" ||
12046 error "debugfs ls .$name after rename failed"
12047 dotdotfid=$(do_facet mds1 "$cmd" |& awk '/fid:.+\.\./ { print $9 }')
12048 [[ "$dotdotfid" == "$parentfid" ]] ||
12049 error "parent '$parentfid' != dotdot '$dotdotfid' on $name"
12052 FSCK_MAX_ERR=0 run_e2fsck $(facet_active_host mds1) $mdt1 -n ||
12053 error "e2fsck returned $?"
12055 run_test 154 "expand .. on rename after MDT backup restore"
12058 (( OST1_VERSION >= $(version_code 2.16.50.134) )) ||
12059 skip "Need OST version at least 2.16.50.134"
12061 reformat_and_config
12065 mkdir_on_mdt0 $DIR/$tdir
12066 $LFS setstripe -c 1 -i 0 $DIR/$tdir
12069 touch $DIR/$tdir/$tfile
12070 local seq1=$($LFS getstripe --yaml $DIR/$tdir/$tfile |
12071 awk -F ':' '/l_fid:/ {print $2}' | tr -d [:blank:])
12077 touch $DIR/$tdir/${tfile}2
12078 local seq2=$($LFS getstripe --yaml $DIR/$tdir/${tfile}2 |
12079 awk -F ':' '/l_fid:/ {print $2}' | tr -d [:blank:])
12081 (( seq2 == seq1 + 1 )) || error "gap in seq: old $seq1 new $seq2"
12083 run_test 155 "gap in seq allocation from ofd after restarting"
12086 ((OST1_VERSION >= $(version_code 2.16.55) )) ||
12087 skip "need OST >= 2.16.55 to have MGC with all failovers"
12092 local mgs_nid=$(do_facet mgs $LCTL list_nids | head -1)
12093 local failover_nid="192.168.252.160@${NETTYPE}"
12094 local mgs_nodes=$mgs_nid:$failover_nid
12095 local tmp_mnt="$TMP/lmount"
12101 stack_trap "cleanup; reformat"
12103 do_facet mgs "mkdir -p $tmp_mnt"
12104 do_facet mgs "$MOUNT_CMD $mgs_nodes:/$FSNAME $tmp_mnt" ||
12105 error "Fail to mount local client on MGS"
12106 do_facet mgs "umount $tmp_mnt"
12108 do_facet mgs "$LCTL get_param mgc.MGC${mgs_nid}.import"
12109 count=$(do_facet mgs "$LCTL get_param mgc.MGC${mgs_nid}.import" |
12110 grep -c "$failover_nid")
12112 error "MGC misses failover MGS nid"
12114 run_test 160 "MGC updates failnodes from all participants"
12120 [[ -z $modopts ]] || MODOPTS_LIBCFS=$modopts
12126 local cpus=$(lscpu | awk '/^CPU.s.:/ {print $NF}')
12127 local old_modopts=$MODOPTS_LIBCFS
12128 stack_trap "cleanup_200 $old_modopts"
12130 MODOPTS_LIBCFS="cpu_npartitions=$cpus"
12132 load_modules_local libcfs
12133 $LCTL get_param -n cpu_partition_table
12135 local expected=$(cat /sys/module/libcfs/parameters/cpu_npartitions)
12136 local result=$($LCTL get_param -n cpu_partition_table | wc -l)
12138 (( $result == $expected )) ||
12139 error "CPU partitions not $expected, found: $result"
12141 run_test 200a "check CPU partitions"
12146 local cpus=$(lscpu | awk '/^CPU.s.:/ {print $NF}')
12147 local nodes=$(lscpu | awk '/NUMA node.s.:/ {print $NF}')
12148 local old_modopts=$MODOPTS_LIBCFS
12149 stack_trap "cleanup_200 $old_modopts"
12151 local pattern="0[$(lscpu | awk '/CPU.s. list:/ {print $NF}')]"
12152 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12154 load_modules_local libcfs
12155 grep . /sys/module/libcfs/parameters/cpu*
12156 $LCTL get_param -n cpu_partition_table
12157 local expected=cpus
12158 local table=$($LCTL get_param -n cpu_partition_table)
12159 # ignore partition num and ':'
12160 local actual=$(( $(awk '{print NF; exit}' <<< $table) - 2 ))
12162 (( expected == actual )) || {
12163 echo -e "layout wrong:\n$table"
12164 error "partition 0 is missing CPUs from pattern: '$pattern'"
12167 (( $(echo $table | wc -l) == 1 )) || {
12168 echo -e "layout wrong\n$table"
12169 error "layout has too many partitions from pattern: '$pattern'"
12172 (( cpus >= 4 )) || skip "need at least 4 cpu cores"
12176 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12178 load_modules_local libcfs
12179 $LCTL get_param -n cpu_partition_table
12181 table=$($LCTL get_param -n cpu_partition_table)
12183 [[ $table == $expected ]] ||
12184 error "CPU pattern not $expected, found: $table"
12186 run_test 200b "set CPU pattern using core selection"
12191 local cpus=$(lscpu | awk '/^CPU.s.:/ {print $NF}')
12192 local nodes=$(lscpu | awk '/NUMA node.s.:/ {print $NF}')
12194 local old_modopts=$MODOPTS_LIBCFS
12195 stack_trap "cleanup_200 $old_modopts"
12198 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12200 load_modules_local libcfs
12201 grep . /sys/module/libcfs/parameters/cpu*
12202 $LCTL get_param -n cpu_partition_table
12203 local expected=$nodes
12204 local table=$($LCTL get_param -n cpu_partition_table)
12205 local actual=$(echo $table | wc -l)
12207 (( actual == expected )) ||
12208 error "CPU partitions not $expected, found: $actual"
12212 pattern="0[$(lscpu | awk '/^NUMA node0 CPU.s.:/ {print $NF}')]"
12213 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12215 load_modules_local libcfs
12216 expected=$($LCTL get_param -n cpu_partition_table)
12221 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12223 load_modules_local libcfs
12224 $LCTL get_param -n cpu_partition_table
12225 local table=$($LCTL get_param -n cpu_partition_table)
12227 [[ $table == $expected ]] ||
12228 error "CPU pattern not $expected, found: $table"
12230 run_test 200c "set CPU pattern using NUMA node layout"
12235 local cpus=$(lscpu | awk '/^CPU.s.:/ {print $NF}')
12236 local nodes=$(lscpu | awk '/NUMA node.s.:/ {print $NF}')
12237 local parts=$((cpus / 2))
12239 local old_modopts=$MODOPTS_LIBCFS
12240 stack_trap "cleanup_200 $old_modopts"
12242 local full_cpu_count=0
12243 local excluded_count=0
12245 # First, get the full table
12246 MODOPTS_LIBCFS="cpu_npartitions=$parts"
12248 load_modules_local libcfs
12250 $LCTL get_param -n cpu_partition_table
12252 local full_table=()
12253 while read -r line; do
12254 full_table+=("$line")
12255 full_cpu_count=$((full_cpu_count + $(echo $line | wc -w) - 2))
12256 done < <($LCTL get_param -n cpu_partition_table)
12260 # Now, set the pattern to exclude CPU 1
12262 MODOPTS_LIBCFS="cpu_npartitions=$parts cpu_pattern=\"$pattern\""
12264 load_modules_local libcfs
12265 echo "table with CPU 1 excluded:"
12266 grep . /sys/module/libcfs/parameters/cpu*
12267 $LCTL get_param -n cpu_partition_table
12270 while read -r line; do
12272 excluded_count=$((excluded_count + $(echo $line | wc -w) - 2))
12273 done < <($LCTL get_param -n cpu_partition_table)
12275 # Check if CPU 1 is excluded
12276 for line in "${table[@]}"; do
12277 ! [[ "$line" =~ " 1 " ]] ||
12278 error "CPU 1 was not excluded with pattern: $pattern"
12281 # Check if only CPU 1 is excluded
12282 (( excluded_count == full_cpu_count - 1 )) ||
12283 error "More than one CPU was excluded with pattern: $pattern"
12290 # First, get the full table
12292 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12294 load_modules_local libcfs
12296 $LCTL get_param -n cpu_partition_table
12299 while read -r line; do
12300 full_table+=("$line")
12301 full_cpu_count=$((full_cpu_count + $(echo $line | wc -w) - 2))
12302 done < <($LCTL get_param -n cpu_partition_table)
12306 # Now, set the pattern to exclude CPU 1
12308 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12310 load_modules_local libcfs
12311 echo "table with CPU 1 excluded:"
12312 grep . /sys/module/libcfs/parameters/cpu*
12313 $LCTL get_param -n cpu_partition_table
12316 while read -r line; do
12318 excluded_count=$((excluded_count + $(echo $line | wc -w) - 2))
12319 done < <($LCTL get_param -n cpu_partition_table)
12321 # Check if CPU 1 is excluded
12323 for line in "${table[@]}"; do
12324 [[ "$line" =~ " 1 " ]] && cpu_1_found=true
12326 $cpu_1_found && error "CPU 1 was not excluded with pattern: $pattern"
12328 # Check if only CPU 1 is excluded
12329 (( excluded_count == full_cpu_count - 1 )) ||
12330 error "More than one CPU was excluded with pattern: $pattern"
12332 run_test 200d "set CPU pattern to exclude only CPU 1"
12337 local cpus=$(lscpu | awk '/^CPU.s.:/ {print $NF}')
12338 local nodes=$(lscpu | awk '/NUMA node.s.:/ {print $NF}')
12339 local npartitions=$((cpus / 2))
12345 local old_modopts=$MODOPTS_LIBCFS
12346 stack_trap "cleanup_200 $old_modopts"
12350 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12352 load_modules_local libcfs
12354 $LCTL get_param -n cpu_partition_table
12356 local full_table=()
12357 while read -r line; do
12358 full_table+=("$line")
12359 done < <($LCTL get_param -n cpu_partition_table)
12360 (( $($LCTL get_param -n cpu_partition_table |\
12361 awk '/\<0\>.*:/ {print NF - 3; exit}') > 0 )) ||
12362 skip "need at least 2 cores in each CPT to exclude one"
12367 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\""
12369 load_modules_local libcfs
12370 grep . /sys/module/libcfs/parameters/cpu*
12371 echo "table with npartitions=$npartitions:"
12372 $LCTL get_param -n cpu_partition_table
12375 while read -r line; do
12377 done < <($LCTL get_param -n cpu_partition_table)
12379 for (( i = 0; i < ${#table[@]}; i++ )); do
12380 expected=$(echo ${full_table[$i]} | awk '{print NF - 3; exit}')
12381 actual=$(echo ${table[$i]} | awk '{print NF - 2; exit}')
12383 (( actual == expected )) ||
12384 error "CPU count not $expected, found: $actual"
12386 excluded=$(echo ${full_table[$i]} | awk '{print $3; exit}')
12387 partition=$(echo ${table[$i]} | awk '{print $3; exit}')
12389 ! [[ "$partition" =~ "$excluded" ]] || {
12390 echo -e "layout wrong:\n$table"
12391 error "excluded the wrong CPU with pattern: $pattern"
12397 # C[0] with npartitions
12398 MODOPTS_LIBCFS="cpu_npartitions=$npartitions"
12400 load_modules_local libcfs
12402 $LCTL get_param -n cpu_partition_table
12405 while read -r line; do
12406 full_table+=("$line")
12407 done < <($LCTL get_param -n cpu_partition_table)
12408 (( $($LCTL get_param -n cpu_partition_table |\
12409 awk '/\<0\>.*:/ {print NF - 3; exit}') > 0 )) ||
12410 skip "need at least 2 cores in each CPT to exclude one"
12415 MODOPTS_LIBCFS="cpu_pattern=\"$pattern\" cpu_npartitions=$npartitions"
12417 load_modules_local libcfs
12418 grep . /sys/module/libcfs/parameters/cpu*
12419 echo "table with npartitions=$npartitions:"
12420 $LCTL get_param -n cpu_partition_table
12423 while read -r line; do
12425 done < <($LCTL get_param -n cpu_partition_table)
12427 for (( i = 0; i < ${#table[@]}; i++ )); do
12428 expected=$(echo ${full_table[$i]} | awk '{print NF - 3; exit}')
12429 actual=$(echo ${table[$i]} | awk '{print NF - 2; exit}')
12431 (( actual == expected )) ||
12432 error "CPU count not $expected, found: $actual"
12434 excluded=$(echo ${full_table[$i]} | awk '{print $3; exit}')
12435 partition=$(echo ${table[$i]} | awk '{print $3; exit}')
12437 ! [[ "$partition" =~ "$excluded" ]] || {
12438 echo -e "layout wrong:\n$table"
12439 error "excluded the wrong CPU with pattern: $pattern"
12443 run_test 200e "set CPU pattern using relative core exclusion"
12446 # (This was sanity/802a)
12448 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
12449 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
12450 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
12451 saved_MOUNT_OPTS=$MOUNT_OPTS
12455 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
12456 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
12457 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
12458 MOUNT_OPTS=$saved_MOUNT_OPTS
12463 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
12464 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
12465 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
12466 skip "Need server version at least 2.9.55"
12468 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
12470 # Reset before starting
12474 mkdir $DIR/$tdir || error "(1) fail to mkdir"
12476 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
12477 error "(2) Fail to copy"
12479 stack_trap cleanup_802a EXIT
12481 # sync by force before remount as readonly
12482 sync; sync_all_data; sleep 3; sync_all_data
12486 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
12487 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
12488 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
12490 echo "Mount the server as read only"
12491 setupall server_only || error "(3) Fail to start servers"
12493 echo "Mount client without ro should fail"
12494 mount_client $MOUNT &&
12495 error "(4) Mount client without 'ro' should fail"
12497 echo "Mount client with ro should succeed"
12498 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
12499 mount_client $MOUNT ||
12500 error "(5) Mount client with 'ro' should succeed"
12502 echo "Modify should be refused"
12503 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
12505 echo "Read should be allowed"
12506 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
12507 error "(7) Read should succeed under ro mode"
12509 run_test 802a "simulate readonly device"
12511 if ! combined_mgs_mds ; then
12517 # restore the values of MDSSIZE and OSTSIZE
12518 MDSSIZE=$STORED_MDSSIZE
12519 OSTSIZE=$STORED_OSTSIZE
12522 complete_test $SECONDS
12523 check_and_cleanup_lustre