3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
11 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/utils:$PATH:/sbin:/usr/sbin
14 # bug number for skipped test:
15 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 # skip test cases failed before landing - Jinshan
17 ALWAYS_EXCEPT="$SANITY_HSM_EXCEPT 12a 12b 12n 13 24 30a 31a 34 35 36 58 59"
18 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110a 200 201 221 222a 223a 223b 225"
20 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
22 . $LUSTRE/tests/test-framework.sh
24 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
27 MULTIOP=${MULTIOP:-multiop}
28 OPENFILE=${OPENFILE:-openfile}
29 MCREATE=${MCREATE:-mcreate}
30 MOUNT_2=${MOUNT_2:-"yes"}
33 if [[ $MDSCOUNT -ge 2 ]]; then
34 skip_env "Only run with single MDT for now" && exit
37 check_and_setup_lustre
39 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ]]; then
40 skip_env "Need MDS version at least 2.4.53" && exit
43 # $RUNAS_ID may get set incorrectly somewhere else
44 if [[ $UID -eq 0 && $RUNAS_ID -eq 0 ]]; then
45 skip_env "\$RUNAS_ID set to 0, but \$UID is also 0!" && exit
47 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
52 # In order to test multiple remote HSM agents, a new facet type named "AGT" and
53 # the following associated variables are added:
55 # AGTCOUNT: number of agents
56 # AGTDEV{N}: target HSM mount point (root path of the backend)
57 # agt{N}_HOST: hostname of the agent agt{N}
58 # SINGLEAGT: facet of the single agent
60 # The number of agents is initialized as the number of remote client nodes.
61 # By default, only single copytool is started on a remote client/agent. If there
62 # was no remote client, then the copytool will be started on the local client.
68 export AGTCOUNT=${AGTCOUNT:-$((CLIENTCOUNT - 1))}
69 [[ $AGTCOUNT -gt 0 ]] || AGTCOUNT=1
71 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-$TMP}
72 if [[ $CLIENTCOUNT -gt 1 ]] &&
73 ! check_shared_dir $SHARED_DIRECTORY $CLIENTS; then
74 skip_env "SHARED_DIRECTORY should be accessible"\
79 for n in $(seq $AGTCOUNT); do
80 eval export AGTDEV$n=\$\{AGTDEV$n:-"$SHARED_DIRECTORY/arc$n"\}
81 agent=CLIENT$((n + 1))
82 if [[ -z "${!agent}" ]]; then
83 [[ $CLIENTCOUNT -eq 1 ]] && agent=CLIENT1 ||
86 eval export agt${n}_HOST=\$\{agt${n}_HOST:-${!agent}\}
89 export SINGLEAGT=${SINGLEAGT:-agt1}
91 export HSMTOOL=${HSMTOOL:-"lhsmtool_posix"}
92 export HSMTOOL_VERBOSE=${HSMTOOL_VERBOSE:-""}
93 export HSMTOOL_BASE=$(basename "$HSMTOOL" | cut -f1 -d" ")
94 HSM_ARCHIVE=$(copytool_device $SINGLEAGT)
97 MDT_PARAM="mdt.$FSNAME-MDT0000"
98 HSM_PARAM="$MDT_PARAM.hsm"
100 # archive is purged at copytool setup
101 HSM_ARCHIVE_PURGE=true
104 # Get the backend root path for the given agent facet.
107 local dev=AGTDEV$(facet_number $facet)
112 # Stop copytool and unregister an existing changelog user.
118 search_and_kill_copytool() {
119 local agents=${1:-$(facet_active_host $SINGLEAGT)}
121 echo "Killing existing copytools on $agents"
122 do_nodesv $agents "killall -q $HSMTOOL_BASE" || true
126 local facet=${1:-$SINGLEAGT}
127 local lustre_mntpnt=${2:-$MOUNT}
129 local hsm_root=$(copytool_device $facet)
130 local agent=$(facet_active_host $facet)
132 if [[ -z "$arc_id" ]] &&
133 do_facet $facet "pkill -CONT -x $HSMTOOL_BASE"; then
134 echo "Wakeup copytool $facet on $agent"
138 if $HSM_ARCHIVE_PURGE; then
139 echo "Purging archive on $agent"
140 do_facet $facet "rm -rf $hsm_root/*"
143 echo "Starting copytool $facet on $agent"
144 do_facet $facet "mkdir -p $hsm_root" || error "mkdir '$hsm_root' failed"
145 # bandwidth is limited to 1MB/s so the copy time is known and
146 # independent of hardware
147 local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --hsm-root $hsm_root"
148 [[ -z "$arc_id" ]] || cmd+=" --archive $arc_id"
149 cmd+=" --bandwidth 1 $lustre_mntpnt"
151 # Redirect the standard output and error to a log file which
152 # can be uploaded to Maloo.
153 local prefix=$TESTLOG_PREFIX
154 [[ -z "$TESTNAME" ]] || prefix=$prefix.$TESTNAME
155 local copytool_log=$prefix.copytool${arc_id}_log.$agent.log
157 do_facet $facet "$cmd < /dev/null > $copytool_log 2>&1" ||
158 error "start copytool $facet on $agent failed"
164 local agents=${1:-$(facet_active_host $SINGLEAGT)}
166 do_nodesv $agents "pkill -INT -x $HSMTOOL_BASE" || return 0
168 echo "Copytool is stopped on $agents"
172 local agents=${1:-$(facet_active_host $SINGLEAGT)}
174 do_nodesv $agents "pkill -STOP -x $HSMTOOL_BASE" || return 0
175 echo "Copytool is suspended on $agents"
178 copytool_remove_backend() {
180 local be=$(find $HSM_ARCHIVE -name $fid)
181 echo "Remove from backend: $fid = $be"
186 do_facet $SINGLEAGT \
187 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
188 --import $1 $2 $MOUNT" ||
189 error "import of $1 to $2 failed"
193 local file=$HSM_ARCHIVE/$1
194 mkdir -p $(dirname $file)
195 dd if=/dev/urandom of=$file count=32 bs=1000000 ||
196 error "cannot create $file"
200 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0\
201 changelog_register -n)
202 do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog_mask="+hsm"
203 $LFS changelog_clear $MDT0 $CL_USER 0
206 changelog_cleanup() {
207 # $LFS changelog $MDT0
208 [[ -n "$CL_USER" ]] || return 0
210 $LFS changelog_clear $MDT0 $CL_USER 0
211 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
215 changelog_get_flags() {
220 $LFS changelog $mdt | awk "/$cltype/ && /t=\[$fid\]/ {print \$5}"
225 local val=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.$param)
232 do_facet $SINGLEMDS $LCTL set_param -n $HSM_PARAM.$param=$value
239 do_facet $SINGLEMDS $LCTL set_param $MDT_PARAM.hsm_control=$cmd
240 wait_result $SINGLEMDS "$LCTL get_param -n $MDT_PARAM.hsm_control"\
241 $target 10 || error "cdt state is not $target"
244 cdt_set_sanity_policy() {
246 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nra
247 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nbr
248 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-gc
252 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+nra
255 cdt_clear_no_retry() {
256 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nra
259 cdt_set_no_blocking_restore() {
260 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+nbr
263 cdt_clear_no_blocking_restore() {
264 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nbr
267 cdt_clear_mount_state() {
268 # /!\ conf_param and set_param syntax differ +> we cannot use
270 do_facet $SINGLEMDS $LCTL conf_param -d $FSNAME-MDT0000.mdt.hsm_control
273 cdt_set_mount_state() {
274 # /!\ conf_param and set_param syntax differ +> we cannot use
276 do_facet $SINGLEMDS $LCTL conf_param $FSNAME-MDT0000.mdt.hsm_control=$1
281 wait_result $SINGLEMDS\
282 "$LCTL get_param -n $MDT_PARAM.hsm_control" "$target" 20 ||
283 error "cdt state is not $target"
287 set_test_state disabled disabled
291 set_test_state enabled enabled
295 set_test_state shutdown stopped
299 set_test_state purge enabled
305 cdt_set_sanity_policy
309 if [[ $CLIENTCOUNT -lt 2 ]]; then
310 skip "Need two or more clients, have $CLIENTCOUNT"
317 $LFS path2fid $1 | tr -d '[]'
324 if [[ $u == "user" ]]
326 local st=$($RUNAS $LFS hsm_state $f)
328 local st=$($LFS hsm_state $f)
332 [[ $? == 0 ]] || error "$LFS hsm_state $f failed (run as $u)"
334 st=$(echo $st | cut -f 2 -d" " | tr -d "()," )
338 get_hsm_archive_id() {
340 local st=$($LFS hsm_state $f)
341 [[ $? == 0 ]] || error "$LFS hsm_state $f failed"
343 local ar=$(echo $st | grep "archive_id" | cut -f5 -d" " |
352 local st=$(get_hsm_flags $f)
353 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
356 check_hsm_flags_user() {
360 local st=$(get_hsm_flags $f user)
361 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
379 cp $1 $f || error "cannot copy $1 to $f"
380 path2fid $f || error "cannot get fid on $f"
384 local file2=${1/$DIR/$DIR2}
385 dd if=/dev/urandom of=$file2 count=2 bs=1M conv=fsync ||
386 error "cannot create $file2"
387 path2fid $1 || error "cannot get fid on $1"
390 make_large_for_striping() {
391 local file2=${1/$DIR/$DIR2}
392 local sz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -1)
393 dd if=/dev/urandom of=$file2 count=5 bs=$sz conv=fsync ||
394 error "cannot create $file2"
395 path2fid $1 || error "cannot get fid on $1"
398 make_large_for_progress() {
399 local file2=${1/$DIR/$DIR2}
400 # big file is large enough, so copy time is > 30s
401 # so copytool make 1 progress
402 # size is not a multiple of 1M to avoid stripe
404 dd if=/dev/urandom of=$file2 count=39 bs=1000000 conv=fsync ||
405 error "cannot create $file2"
406 path2fid $1 || error "cannot get fid on $1"
409 make_large_for_progress_aligned() {
410 local file2=${1/$DIR/$DIR2}
411 # big file is large enough, so copy time is > 30s
412 # so copytool make 1 progress
413 # size is a multiple of 1M to have stripe
415 dd if=/dev/urandom of=$file2 count=33 bs=1M conv=fsync ||
416 error "cannot create $file2"
417 path2fid $1 || error "cannot get fid on $1"
420 make_large_for_cancel() {
421 local file2=${1/$DIR/$DIR2}
422 # Copy timeout is 100s. 105MB => 105s
423 dd if=/dev/urandom of=$file2 count=103 bs=1M conv=fsync ||
424 error "cannot create $file2"
425 path2fid $1 || error "cannot get fid on $1"
431 wait_update --verbose $(facet_active_host $facet) "$@"
434 wait_request_state() {
439 local cmd="$LCTL get_param -n $HSM_PARAM.agent_actions"
440 cmd+=" | awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
442 wait_result $SINGLEMDS "$cmd" $state 100 ||
443 error "request on $fid is not $state"
446 get_request_state() {
450 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.agent_actions |"\
451 "awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
454 get_request_count() {
458 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.agent_actions |"\
459 "awk -vn=0 '/'$fid'.*action='$request'/ {n++}; END {print n}'"
465 local cmd="$LCTL get_param -n $HSM_PARAM.agent_actions"
466 cmd+=" | egrep 'WAITING|STARTED'"
468 wait_result $SINGLEMDS "$cmd" "" $timeout ||
469 error "requests did not complete"
472 wait_for_grace_delay() {
473 local val=$(get_hsm_param grace_delay)
477 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
478 awk '{gsub(/_UUID/,""); print $1}' | head -1)
483 # cleanup from previous bad setup
484 search_and_kill_copytool
486 # for recovery tests, coordinator needs to be started at mount
488 # the lustre conf must be without hsm on (like for sanity.sh)
489 echo "Set HSM on and start"
490 cdt_set_mount_state enabled
491 cdt_check_state enabled
493 echo "Start copytool"
496 # finished requests are quickly removed from list
497 set_hsm_param grace_delay 10
503 local f=$DIR/$tdir/$tfile
507 check_hsm_flags_user $f "0x00000000"
509 $RUNAS $LFS hsm_set --norelease $f ||
510 error "user could not change hsm flags"
511 check_hsm_flags_user $f "0x00000010"
513 $RUNAS $LFS hsm_clear --norelease $f ||
514 error "user could not clear hsm flags"
515 check_hsm_flags_user $f "0x00000000"
517 # User could not change those flags...
518 $RUNAS $LFS hsm_set --exists $f &&
519 error "user should not set this flag"
520 check_hsm_flags_user $f "0x00000000"
523 $LFS hsm_set --exists $f ||
524 error "root could not change hsm flags"
525 check_hsm_flags_user $f "0x00000001"
527 $LFS hsm_clear --exists $f ||
528 error "root could not clear hsm state"
529 check_hsm_flags_user $f "0x00000000"
532 run_test 1 "lfs hsm flags root/non-root access"
536 local f=$DIR/$tdir/$tfile
538 # New files are not dirty
539 check_hsm_flags $f "0x00000000"
541 # For test, we simulate an archived file.
542 $LFS hsm_set --exists $f || error "user could not change hsm flags"
543 check_hsm_flags $f "0x00000001"
545 # chmod do not put the file dirty
546 chmod 600 $f || error "could not chmod test file"
547 check_hsm_flags $f "0x00000001"
549 # chown do not put the file dirty
550 chown $RUNAS_ID $f || error "could not chown test file"
551 check_hsm_flags $f "0x00000001"
553 # truncate put the file dirty
554 $TRUNCATE $f 1 || error "could not truncate test file"
555 check_hsm_flags $f "0x00000003"
557 $LFS hsm_clear --dirty $f || error "could not clear hsm flags"
558 check_hsm_flags $f "0x00000001"
560 run_test 2 "Check file dirtyness when doing setattr"
566 # New files are not dirty
568 check_hsm_flags $f "0x00000000"
570 # For test, we simulate an archived file.
571 $LFS hsm_set --exists $f ||
572 error "user could not change hsm flags"
573 check_hsm_flags $f "0x00000001"
575 # Reading a file, does not set dirty
576 cat $f > /dev/null || error "could not read file"
577 check_hsm_flags $f "0x00000001"
579 # Open for write without modifying data, does not set dirty
580 openfile -f O_WRONLY $f || error "could not open test file"
581 check_hsm_flags $f "0x00000001"
583 # Append to a file sets it dirty
584 cp -p /etc/passwd $f.append || error "could not create file"
585 $LFS hsm_set --exists $f.append ||
586 error "user could not change hsm flags"
587 dd if=/etc/passwd of=$f.append bs=1 count=3\
588 conv=notrunc oflag=append status=noxfer ||
589 error "could not append to test file"
590 check_hsm_flags $f.append "0x00000003"
592 # Modify a file sets it dirty
593 cp -p /etc/passwd $f.modify || error "could not create file"
594 $LFS hsm_set --exists $f.modify ||
595 error "user could not change hsm flags"
596 dd if=/dev/zero of=$f.modify bs=1 count=3\
597 conv=notrunc status=noxfer ||
598 error "could not modify test file"
599 check_hsm_flags $f.modify "0x00000003"
601 # Open O_TRUNC sets dirty
602 cp -p /etc/passwd $f.trunc || error "could not create file"
603 $LFS hsm_set --exists $f.trunc ||
604 error "user could not change hsm flags"
605 cp /etc/group $f.trunc || error "could not override a file"
606 check_hsm_flags $f.trunc "0x00000003"
608 # Mmapped a file sets dirty
609 cp -p /etc/passwd $f.mmap || error "could not create file"
610 $LFS hsm_set --exists $f.mmap ||
611 error "user could not change hsm flags"
612 multiop $f.mmap OSMWUc || error "could not mmap a file"
613 check_hsm_flags $f.mmap "0x00000003"
615 run_test 3 "Check file dirtyness when opening for write"
619 local f=$DIR/$tdir/$tfile
620 local fid=$(make_small $f)
623 local st=$(get_request_state $fid CANCEL)
624 [[ -z "$st" ]] || error "hsm_cancel must not be registered (state=$st)"
626 run_test 4 "Useless cancel must not be registered"
629 # test needs a running copytool
633 local f=$DIR/$tdir/$tfile
634 local fid=$(copy_file /etc/passwd $f)
636 wait_request_state $fid ARCHIVE SUCCEED
638 check_hsm_flags $f "0x00000009"
642 run_test 8 "Test default archive number"
646 local f=$DIR/$tdir/$tfile
647 local fid=$(copy_file /etc/passwd $f)
648 # we do not use the default one to be sure
649 local new_an=$((HSM_ARCHIVE_NUMBER + 1))
651 copytool_setup $SINGLEAGT $MOUNT $new_an
652 $LFS hsm_archive --archive $new_an $f
653 wait_request_state $fid ARCHIVE SUCCEED
655 check_hsm_flags $f "0x00000009"
659 run_test 9 "Use of explict archive number, with dedicated copytool"
662 [[ $CLIENTCOUNT -ge 3 ]] ||
663 { skip "Need three or more clients"; return 0; }
669 copytool_cleanup $(comma_list $(agts_nodes))
671 # start all of the copytools
672 for n in $(seq $AGTCOUNT); do
676 trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
679 for n in $(seq $AGTCOUNT); do
680 file=$DIR/$tdir/$tfile.$n
681 fid=$(make_small $file)
683 $LFS hsm_archive $file || error "could not archive file $file"
684 wait_request_state $fid ARCHIVE SUCCEED
685 check_hsm_flags $file "0x00000001"
689 copytool_cleanup $(comma_list $(agts_nodes))
691 run_test 9a "Multiple remote agents"
694 # test needs a running copytool
697 mkdir -p $DIR/$tdir/d1
698 local f=$DIR/$tdir/$tfile
699 local fid=$(copy_file /etc/hosts $f)
700 $LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f ||
701 error "hsm_archive failed"
702 wait_request_state $fid ARCHIVE SUCCEED
704 local AFILE=$(ls $HSM_ARCHIVE/*/*/*/*/*/*/$fid) ||
705 error "fid $fid not in archive $HSM_ARCHIVE"
706 echo "Verifying content"
707 diff $f $AFILE || error "archived file differs"
708 echo "Verifying hsm state "
709 check_hsm_flags $f "0x00000009"
711 echo "Verifying archive number is $HSM_ARCHIVE_NUMBER"
712 local st=$(get_hsm_archive_id $f)
713 [[ $st == $HSM_ARCHIVE_NUMBER ]] ||
714 error "Wrong archive number, $st != $HSM_ARCHIVE_NUMBER"
719 run_test 10a "Archive a file"
722 # test needs a running copytool
725 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
726 local f=$DIR/$tdir/$tfile
727 local fid=$(copy_file /etc/hosts $f)
728 $LFS hsm_archive $f || error "archive request failed"
729 wait_request_state $fid ARCHIVE SUCCEED
731 $LFS hsm_archive $f || error "archive of non dirty file failed"
732 local cnt=$(get_request_count $fid ARCHIVE)
733 [[ "$cnt" == "1" ]] ||
734 error "archive of non dirty file must not make a request"
738 run_test 10b "Archive of non dirty file must work without doing request"
741 # test needs a running copytool
744 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
745 local f=$DIR/$tdir/$tfile
746 local fid=$(copy_file /etc/hosts $f)
747 $LFS hsm_set --noarchive $f
748 $LFS hsm_archive $f && error "archive a noarchive file must fail"
752 run_test 10c "Check forbidden archive"
755 # test needs a running copytool
759 local f=$DIR/$tdir/$tfile
760 local fid=$(copy_file /etc/hosts $f)
761 $LFS hsm_archive $f || error "cannot archive $f"
762 wait_request_state $fid ARCHIVE SUCCEED
764 local ar=$(get_hsm_archive_id $f)
765 local dflt=$(get_hsm_param archive_id)
766 [[ $ar == $dflt ]] ||
767 error "archived file is not on default archive: $ar != $dflt"
771 run_test 10d "Archive a file on the default archive id"
774 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
775 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
776 local f=$DIR/$tdir/$tfile
778 import_file $tdir/$tfile $f
779 echo -n "Verifying released state: "
780 check_hsm_flags $f "0x0000000d"
782 local LSZ=$(stat -c "%s" $f)
783 local ASZ=$(stat -c "%s" $HSM_ARCHIVE/$tdir/$tfile)
785 echo "Verifying imported size $LSZ=$ASZ"
786 [[ $LSZ -eq $ASZ ]] || error "Incorrect size $LSZ != $ASZ"
787 echo -n "Verifying released pattern: "
788 local PTRN=$($GETSTRIPE -L $f)
790 [[ $PTRN == 80000001 ]] || error "Is not released"
791 local fid=$(path2fid $f)
792 echo "Verifying new fid $fid in archive"
794 local AFILE=$(ls $HSM_ARCHIVE/*/*/*/*/*/*/$fid) ||
795 error "fid $fid not in archive $HSM_ARCHIVE"
797 run_test 11 "Import a file"
800 # test needs a running copytool
803 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
804 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
805 local f=$DIR/$tdir/$tfile
806 import_file $tdir/$tfile $f
807 local f=$DIR2/$tdir/$tfile
808 echo "Verifying released state: "
809 check_hsm_flags $f "0x0000000d"
811 local fid=$(path2fid $f)
813 wait_request_state $fid RESTORE SUCCEED
815 echo "Verifying file state: "
816 check_hsm_flags $f "0x00000009"
818 diff -q $HSM_ARCHIVE/$tdir/$tfile $f
820 [[ $? -eq 0 ]] || error "Restored file differs"
824 run_test 12a "Restore an imported file explicitly"
827 # test needs a running copytool
830 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
831 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
832 local f=$DIR/$tdir/$tfile
833 import_file $tdir/$tfile $f
834 echo "Verifying released state: "
835 check_hsm_flags $f "0x0000000d"
837 cat $f > /dev/null || error "File read failed"
839 echo "Verifying file state after restore: "
840 check_hsm_flags $f "0x00000009"
842 diff -q $HSM_ARCHIVE/$tdir/$tfile $f
844 [[ $? -eq 0 ]] || error "Restored file differs"
848 run_test 12b "Restore an imported file implicitly"
851 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
853 # test needs a running copytool
857 local f=$DIR/$tdir/$tfile
858 $LFS setstripe -c 2 $f
859 local fid=$(make_large_for_striping $f)
860 local FILE_CRC=$(md5sum $f)
862 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
863 wait_request_state $fid ARCHIVE SUCCEED
864 $LFS hsm_release $f || error "release $f failed"
866 echo "$FILE_CRC" | md5sum -c
868 [[ $? -eq 0 ]] || error "Restored file differs"
872 run_test 12c "Restore a file with stripe of 2"
875 # test needs a running copytool
878 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
879 local f=$DIR/$tdir/$tfile
880 local fid=$(copy_file /etc/hosts $f)
881 $LFS hsm_restore $f || error "restore of non archived file failed"
882 local cnt=$(get_request_count $fid RESTORE)
883 [[ "$cnt" == "0" ]] ||
884 error "restore non archived must not make a request"
885 $LFS hsm_archive $f ||
886 error "archive request failed"
887 wait_request_state $fid ARCHIVE SUCCEED
888 $LFS hsm_restore $f ||
889 error "restore of non released file failed"
890 local cnt=$(get_request_count $fid RESTORE)
891 [[ "$cnt" == "0" ]] ||
892 error "restore a non dirty file must not make a request"
896 run_test 12d "Restore of a non archived, non released file must work"\
897 " without doing request"
900 # test needs a running copytool
903 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
904 local f=$DIR/$tdir/$tfile
905 local fid=$(copy_file /etc/hosts $f)
906 $LFS hsm_archive $f || error "archive request failed"
907 wait_request_state $fid ARCHIVE SUCCEED
914 $LFS hsm_restore $f && error "restore a dirty file must fail"
918 run_test 12e "Check forbidden restore"
921 # test needs a running copytool
925 local f=$DIR/$tdir/$tfile
926 local fid=$(copy_file /etc/hosts $f)
928 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
929 wait_request_state $fid ARCHIVE SUCCEED
930 $LFS hsm_release $f || error "release of $f failed"
932 wait_request_state $fid RESTORE SUCCEED
934 echo -n "Verifying file state: "
935 check_hsm_flags $f "0x00000009"
937 diff -q /etc/hosts $f
939 [[ $? -eq 0 ]] || error "Restored file differs"
943 run_test 12f "Restore a released file explicitly"
946 # test needs a running copytool
950 local f=$DIR/$tdir/$tfile
951 local fid=$(copy_file /etc/hosts $f)
953 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
954 wait_request_state $fid ARCHIVE SUCCEED
955 $LFS hsm_release $f || error "release of $f failed"
957 diff -q /etc/hosts $f
960 # we check we had a restore done
961 wait_request_state $fid RESTORE SUCCEED
963 [[ $st -eq 0 ]] || error "Restored file differs"
967 run_test 12g "Restore a released file implicitly"
970 need2clients || return 0
972 # test needs a running copytool
976 local f=$DIR/$tdir/$tfile
977 local fid=$(copy_file /etc/hosts $f)
979 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
980 wait_request_state $fid ARCHIVE SUCCEED
981 $LFS hsm_release $f || error "release of $f failed"
983 do_node $CLIENT2 diff -q /etc/hosts $f
986 # we check we had a restore done
987 wait_request_state $fid RESTORE SUCCEED
989 [[ $st -eq 0 ]] || error "Restored file differs"
993 run_test 12h "Restore a released file implicitly from a second node"
996 # test needs a running copytool
1000 local f=$DIR/$tdir/$tfile
1001 local fid=$(copy_file /etc/passwd $f)
1002 $LFS hsm_archive $f || error "archive of $f failed"
1003 wait_request_state $fid ARCHIVE SUCCEED
1005 $LFS hsm_release $f || error "release of $f failed"
1009 [[ $? -eq 0 ]] || error "Restored file differs"
1013 run_test 12m "Archive/release/implicit restore"
1016 # test needs a running copytool
1019 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1020 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
1021 local f=$DIR/$tdir/$tfile
1022 import_file $tdir/$tfile $f
1024 cmp /etc/hosts $f || error "Restored file differs"
1026 $LFS hsm_release $f || error "release of $f failed"
1030 run_test 12n "Import/implicit restore/release"
1033 # test needs a running copytool
1036 local ARC_SUBDIR="import.orig"
1040 # populate directory to be imported
1041 for d in $(seq 1 10); do
1042 local CURR_DIR="$HSM_ARCHIVE/$ARC_SUBDIR/dir.$d"
1043 mkdir -p "$CURR_DIR"
1044 for f in $(seq 1 10); do
1045 CURR_FILE="$CURR_DIR/$tfile.$f"
1046 # write file-specific data
1047 echo "d=$d, f=$f, dir=$CURR_DIR, file=$CURR_FILE"\
1052 import_file "$ARC_SUBDIR" $DIR/$tdir
1053 # diff lustre content and origin (triggers file restoration)
1054 # there must be 10x10 identical files, and no difference
1055 local cnt_ok=$(diff -rs $HSM_ARCHIVE/$ARC_SUBDIR \
1056 $DIR/$tdir/$ARC_SUBDIR |
1057 grep identical | wc -l)
1058 local cnt_diff=$(diff -r $HSM_ARCHIVE/$ARC_SUBDIR \
1059 $DIR/$tdir/$ARC_SUBDIR |
1062 [ $cnt_diff -eq 0 ] ||
1063 error "$cnt_diff imported files differ from read data"
1064 [ $cnt_ok -eq 100 ] ||
1065 error "not enough identical files ($cnt_ok != 100)"
1069 run_test 13 "Recursively import and restore a directory"
1072 # test needs a running copytool
1077 local f=$DIR/$tdir/$tfile
1078 local fid=$(make_small $f)
1079 local sum=$(md5sum $f | awk '{print $1}')
1080 $LFS hsm_archive $f || error "could not archive file"
1081 wait_request_state $fid ARCHIVE SUCCEED
1085 # create released file (simulate llapi_hsm_import call)
1087 local fid2=$(path2fid $f)
1088 $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
1089 $LFS hsm_release $f || error "could not release file"
1091 # rebind the archive to the newly created file
1092 echo "rebind $fid to $fid2"
1094 do_facet $SINGLEAGT \
1095 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1096 --rebind $fid $fid2 $DIR" || error "could not rebind file"
1098 # restore file and compare md5sum
1099 local sum2=$(md5sum $f | awk '{print $1}')
1101 [[ $sum == $sum2 ]] || error "md5sum mismatch after restore"
1105 run_test 14 "Rebind archived file to a new fid"
1108 # test needs a running copytool
1113 local f=$DIR/$tdir/$tfile
1115 local tmpfile=$SHARED_DIRECTORY/tmp.$$
1119 for i in $(seq 1 $count); do
1120 fids[$i]=$(make_small $f.$i)
1121 sums[$i]=$(md5sum $f.$i | awk '{print $1}')
1122 $LFS hsm_archive $f.$i || error "could not archive file"
1124 wait_all_done $(($count*60))
1128 for i in $(seq 1 $count); do
1131 local fid2=$(path2fid $f.$i)
1132 # add the rebind operation to the list
1133 echo ${fids[$i]} $fid2 >> $tmpfile
1135 # set it released (simulate llapi_hsm_import call)
1136 $LFS hsm_set --archived --exists $f.$i ||
1137 error "could not force hsm flags"
1138 $LFS hsm_release $f.$i || error "could not release file"
1140 nl=$(wc -l < $tmpfile)
1141 [[ $nl == $count ]] || error "$nl files in list, $count expected"
1143 echo "rebind list of files"
1144 do_facet $SINGLEAGT \
1145 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1146 --rebind $tmpfile $DIR" || error "could not rebind file list"
1148 # restore files and compare md5sum
1149 for i in $(seq 1 $count); do
1150 local sum2=$(md5sum $f.$i | awk '{print $1}')
1151 [[ $sum2 == ${sums[$i]} ]] ||
1152 error "md5sum mismatch after restore ($sum2 != ${sums[$i]})"
1158 run_test 15 "Rebind a list of files"
1161 # test needs a running copytool
1165 # create a known size file so we can verify transfer speed
1168 dd if=/dev/zero of=$ref bs=1M count=20
1171 local f=$DIR/$tdir/$tfile
1172 local fid=$(copy_file $ref $f)
1174 local start=$(date +%s)
1176 wait_request_state $fid ARCHIVE SUCCEED
1177 local end=$(date +%s)
1178 local duration=$((end - start))
1180 [[ $duration -ge $goal ]] ||
1181 error "Transfer is too fast $duration < $goal"
1185 run_test 16 "Test CT bandwith control option"
1190 local f=$DIR/$tdir/$tfile
1191 touch $f || error "touch $f failed"
1193 # Could not release a non-archived file
1194 $LFS hsm_release $f && error "release should not succeed"
1196 # For following tests, we must test them with HS_ARCHIVED set
1197 $LFS hsm_set --exists --archived $f || error "could not add flag"
1199 # Could not release a file if no-release is set
1200 $LFS hsm_set --norelease $f || error "could not add flag"
1201 $LFS hsm_release $f && error "release should not succeed"
1202 $LFS hsm_clear --norelease $f || error "could not remove flag"
1204 # Could not release a file if lost
1205 $LFS hsm_set --lost $f || error "could not add flag"
1206 $LFS hsm_release $f && error "release should not succeed"
1207 $LFS hsm_clear --lost $f || error "could not remove flag"
1209 # Could not release a file if dirty
1210 $LFS hsm_set --dirty $f || error "could not add flag"
1211 $LFS hsm_release $f && error "release should not succeed"
1212 $LFS hsm_clear --dirty $f || error "could not remove flag"
1214 run_test 20 "Release is not permitted"
1217 # test needs a running copytool
1221 local f=$DIR/$tdir/test_release
1223 # Create a file and check its states
1224 local fid=$(make_small $f)
1225 check_hsm_flags $f "0x00000000"
1227 $LFS hsm_archive $f || error "could not archive file"
1228 wait_request_state $fid ARCHIVE SUCCEED
1230 [ $(stat -c "%b" $f) -ne "0" ] || error "wrong block number"
1231 local sz=$(stat -c "%s" $f)
1232 [ $sz -ne "0" ] || error "file size should not be zero"
1234 # Release and check states
1235 $LFS hsm_release $f || error "could not release file"
1236 check_hsm_flags $f "0x0000000d"
1238 [ $(stat -c "%b" $f) -eq "0" ] || error "wrong block number"
1239 [ $(stat -c "%s" $f) -eq $sz ] || error "wrong file size"
1241 # Check we can release an file without stripe info
1245 check_hsm_flags $f "0x00000000"
1246 $LFS hsm_archive $f || error "could not archive file"
1247 wait_request_state $fid ARCHIVE SUCCEED
1249 # Release and check states
1250 $LFS hsm_release $f || error "could not release file"
1251 check_hsm_flags $f "0x0000000d"
1253 # Release again a file that is already released is OK
1254 $LFS hsm_release $f || fail "second release should succeed"
1255 check_hsm_flags $f "0x0000000d"
1259 run_test 21 "Simple release tests"
1262 # test needs a running copytool
1267 local f=$DIR/$tdir/test_release
1268 local swap=$DIR/$tdir/test_swap
1270 # Create a file and check its states
1271 local fid=$(make_small $f)
1272 check_hsm_flags $f "0x00000000"
1274 $LFS hsm_archive $f || error "could not archive file"
1275 wait_request_state $fid ARCHIVE SUCCEED
1277 # Release and check states
1278 $LFS hsm_release $f || error "could not release file"
1279 check_hsm_flags $f "0x0000000d"
1282 $LFS swap_layouts $swap $f && error "swap_layouts should failed"
1287 run_test 22 "Could not swap a release file"
1290 # test needs a running copytool
1295 local f=$DIR/$tdir/test_mtime
1297 # Create a file and check its states
1298 local fid=$(make_small $f)
1299 check_hsm_flags $f "0x00000000"
1301 $LFS hsm_archive $f || error "could not archive file"
1302 wait_request_state $fid ARCHIVE SUCCEED
1304 # Set modification time in the past
1305 touch -m -a -d @978261179 $f
1307 # Release and check states
1308 $LFS hsm_release $f || error "could not release file"
1309 check_hsm_flags $f "0x0000000d"
1311 local MTIME=$(stat -c "%Y" $f)
1312 local ATIME=$(stat -c "%X" $f)
1313 [ $MTIME -eq "978261179" ] || fail "bad mtime: $MTIME"
1314 [ $ATIME -eq "978261179" ] || fail "bad atime: $ATIME"
1318 run_test 23 "Release does not change a/mtime (utime)"
1321 # test needs a running copytool
1326 local f=$DIR/$tdir/test_mtime
1328 # Create a file and check its states
1329 local fid=$(make_small $f)
1330 check_hsm_flags $f "0x00000000"
1332 # make mtime is different
1335 local MTIME=$(stat -c "%Y" $f)
1336 local ATIME=$(stat -c "%X" $f)
1338 $LFS hsm_archive $f || error "could not archive file"
1339 wait_request_state $fid ARCHIVE SUCCEED
1341 # Release and check states
1342 $LFS hsm_release $f || error "could not release file"
1343 check_hsm_flags $f "0x0000000d"
1345 [ "$(stat -c "%Y" $f)" -eq "$MTIME" ] ||
1346 error "mtime should be $MTIME"
1348 [ "$(stat -c "%X" $f)" -eq "$ATIME" ] ||
1349 error "atime should be $ATIME"
1353 run_test 24 "Release does not change a/mtime (i/o)"
1356 # test needs a running copytool
1359 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1360 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
1361 local f=$DIR/$tdir/$tfile
1363 import_file $tdir/$tfile $f
1365 $LFS hsm_set --lost $f
1370 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1374 run_test 25a "Restore lost file (HS_LOST flag) from import"\
1375 " (Operation not permitted)"
1378 # test needs a running copytool
1383 local f=$DIR/$tdir/$tfile
1384 local fid=$(copy_file /etc/passwd $f)
1386 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1387 wait_request_state $fid ARCHIVE SUCCEED
1390 $LFS hsm_set --lost $f
1394 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1398 run_test 25b "Restore lost file (HS_LOST flag) after release"\
1399 " (Operation not permitted)"
1402 # test needs a running copytool
1406 local f=$DIR/$tdir/$tfile
1407 local fid=$(make_large_for_progress $f)
1408 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1409 wait_request_state $fid ARCHIVE SUCCEED
1412 wait_request_state $fid REMOVE SUCCEED
1414 check_hsm_flags $f "0x00000000"
1418 run_test 26 "Remove the archive of a valid file"
1421 # test needs a running copytool
1425 make_archive $tdir/$tfile
1426 local f=$DIR/$tdir/$tfile
1427 import_file $tdir/$tfile $f
1428 local fid=$(path2fid $f)
1432 [[ $? != 0 ]] || error "Remove of a released file should fail"
1436 run_test 27a "Remove the archive of an imported file (Operation not permitted)"
1439 # test needs a running copytool
1443 local f=$DIR/$tdir/$tfile
1444 local fid=$(make_large_for_progress $f)
1445 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1446 wait_request_state $fid ARCHIVE SUCCEED
1451 [[ $? != 0 ]] || error "Remove of a released file should fail"
1455 run_test 27b "Remove the archive of a relased file (Operation not permitted)"
1458 # test needs a running copytool
1462 local f=$DIR/$tdir/$tfile
1463 local fid=$(make_large_for_progress $f)
1464 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1465 wait_request_state $fid ARCHIVE SUCCEED
1474 wait_request_state $fid REMOVE SUCCEED
1478 run_test 28 "Concurrent archive/file remove"
1481 # restore at exec cannot work on agent node (because of Linux kernel
1482 # protection of executables)
1483 need2clients || return 0
1485 # test needs a running copytool
1488 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1489 cp -p /bin/true $HSM_ARCHIVE/$tdir/$tfile
1490 local f=$DIR/$tdir/true
1491 import_file $tdir/$tfile $f
1493 local fid=$(path2fid $f)
1495 # set no retry action mode
1501 # remove no try action mode
1505 [[ $st == 0 ]] || error "Failed to exec a released file"
1509 run_test 30a "Restore at exec (import case)"
1512 # restore at exec cannot work on agent node (because of Linux kernel
1513 # protection of executables)
1514 need2clients || return 0
1516 # test needs a running copytool
1520 local f=$DIR/$tdir/true
1521 local fid=$(copy_file /bin/true $f)
1523 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1524 wait_request_state $fid ARCHIVE SUCCEED
1527 # set no retry action mode
1533 # remove no try action mode
1537 [[ $st == 0 ]] || error "Failed to exec a released file"
1541 run_test 30b "Restore at exec (release case)"
1543 restore_and_check_size() {
1546 local s=$(stat -c "%s" $f)
1548 local st=$(get_hsm_flags $f)
1552 while [[ "$st" != "0x00000009" && $cpt -le 10 ]]
1554 n=$(stat -c "%s" $f)
1555 # we echo in both cases to show stat is not
1559 echo "size seen is $n != $s"
1562 echo "size seen is right: $n == $s"
1564 st=$(get_hsm_flags $f)
1568 if [[ $cpt -lt 10 ]]
1570 echo " restore is too long"
1574 wait_request_state $fid RESTORE SUCCEED
1579 # test needs a running copytool
1584 make_archive $tdir/$tfile
1585 local f=$DIR/$tdir/$tfile
1586 import_file $tdir/$tfile $f
1587 local fid=$($LFS path2fid $f)
1588 HSM_ARCHIVE_PURGE=false copytool_setup
1590 restore_and_check_size $f $fid
1593 [[ $err -eq 0 ]] || error "File size changed during restore"
1597 run_test 31a "Import a large file and check size during restore"
1601 # test needs a running copytool
1606 local f=$DIR/$tdir/$tfile
1607 local fid=$(make_large_for_progress $f)
1608 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1609 wait_request_state $fid ARCHIVE SUCCEED
1612 restore_and_check_size $f $fid
1615 [[ $err -eq 0 ]] || error "File size changed during restore"
1619 run_test 31b "Restore a large unaligned file and check size during restore"
1622 # test needs a running copytool
1627 local f=$DIR/$tdir/$tfile
1628 local fid=$(make_large_for_progress_aligned $f)
1629 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1630 wait_request_state $fid ARCHIVE SUCCEED
1633 restore_and_check_size $f $fid
1636 [[ $err -eq 0 ]] || error "File size changed during restore"
1640 run_test 31c "Restore a large aligned file and check size during restore"
1643 # test needs a running copytool
1648 local f=$DIR/$tdir/$tfile
1649 local fid=$(make_large_for_progress $f)
1650 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1651 wait_request_state $fid ARCHIVE SUCCEED
1654 md5sum $f >/dev/null &
1656 wait_request_state $fid RESTORE STARTED
1661 # Check restore trigger process was killed
1662 local killed=$(ps -o pid,comm hp $pid >/dev/null)
1666 wait_request_state $fid RESTORE CANCELED
1667 wait_request_state $fid CANCEL SUCCEED
1670 error "Cannot kill process waiting for restore ($killed)"
1674 run_test 33 "Kill a restore waiting process"
1677 # test needs a running copytool
1682 local f=$DIR/$tdir/$tfile
1683 local fid=$(make_large_for_progress $f)
1684 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1685 wait_request_state $fid ARCHIVE SUCCEED
1688 md5sum $f >/dev/null &
1690 wait_request_state $fid RESTORE STARTED
1692 rm $f || error "rm $f failed"
1693 # rm must not block during restore
1694 wait_request_state $fid RESTORE STARTED
1696 wait_request_state $fid RESTORE SUCCEED
1697 # check md5sum pgm finished
1698 local there=$(ps -o pid,comm hp $pid >/dev/null)
1699 [[ -z $there ]] || error "Restore initiator does not exit"
1701 local rc=$(wait $pid)
1702 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
1706 run_test 34 "Remove file during restore"
1709 # test needs a running copytool
1714 local f=$DIR/$tdir/$tfile
1715 local f1=$DIR/$tdir/$tfile-1
1716 local fid=$(make_large_for_progress $f)
1717 local fid1=$(copy_file /etc/passwd $f1)
1718 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1719 wait_request_state $fid ARCHIVE SUCCEED
1722 md5sum $f >/dev/null &
1724 wait_request_state $fid RESTORE STARTED
1726 mv $f1 $f || error "mv $f1 $f failed"
1727 # mv must not block during restore
1728 wait_request_state $fid RESTORE STARTED
1730 wait_request_state $fid RESTORE SUCCEED
1731 # check md5sum pgm finished
1732 local there=$(ps -o pid,comm hp $pid >/dev/null)
1733 [[ -z $there ]] || error "Restore initiator does not exit"
1735 local rc=$(wait $pid)
1736 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
1739 [[ $fid2 == $fid1 ]] || error "Wrong fid after mv $fid2 != $fid1"
1743 run_test 35 "Overwrite file during restore"
1746 # test needs a running copytool
1751 local f=$DIR/$tdir/$tfile
1752 local fid=$(make_large_for_progress $f)
1753 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1754 wait_request_state $fid ARCHIVE SUCCEED
1757 md5sum $f >/dev/null &
1759 wait_request_state $fid RESTORE STARTED
1762 # rm must not block during restore
1763 wait_request_state $fid RESTORE STARTED
1765 wait_request_state $fid RESTORE SUCCEED
1766 # check md5sum pgm finished
1767 local there=$(ps -o pid,comm hp $pid >/dev/null)
1769 error "Restore initiator does not exit"
1771 local rc=$(wait $pid)
1773 error "Restore initiator failed with $rc"
1777 run_test 36 "Move file during restore"
1784 for n in $(seq 1 $count); do
1785 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $prefix.$n
1787 echo "$count archive requests submitted"
1791 local stream_count=4
1792 local file_count=100
1794 local f=$DIR/$tdir/$tfile
1799 for i in $(seq 1 $file_count); do
1800 for p in $(seq 1 $stream_count); do
1801 fid=$(copy_file /etc/hosts $f.$p.$i)
1805 # to be sure wait_all_done will not be mislead by previous tests
1807 wait_for_grace_delay
1809 # start archive streams in background (archive files in parallel)
1810 for p in $(seq 1 $stream_count); do
1811 multi_archive $f.$p $file_count &
1814 echo -n "Wait for all requests being enqueued..."
1820 run_test 40 "Parallel archive requests"
1823 # test needs a running copytool
1827 local f=$DIR/$tdir/$tfile
1828 local fid=$(copy_file /etc/motd $f 1)
1830 $LFS hsm_archive $f || error "could not archive file"
1831 wait_request_state $fid ARCHIVE SUCCEED
1832 check_hsm_flags $f "0x00000009"
1834 multiop_bg_pause $f O_c || error "multiop failed"
1838 client_up || client_up || true
1840 kill -USR1 $MULTIPID
1841 wait $MULTIPID || error "multiop close failed"
1843 check_hsm_flags $f "0x0000000b"
1847 run_test 52 "Opened for write file on an evicted client should be set dirty"
1850 # test needs a running copytool
1854 local f=$DIR/$tdir/$tfile
1855 local fid=$(copy_file /etc/motd $f 1)
1857 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
1858 error "could not archive file"
1859 wait_request_state $fid ARCHIVE SUCCEED
1860 check_hsm_flags $f "0x00000009"
1862 multiop_bg_pause $f o_c || error "multiop failed"
1866 client_up || client_up || true
1868 kill -USR1 $MULTIPID
1869 wait $MULTIPID || error "multiop close failed"
1871 check_hsm_flags $f "0x00000009"
1875 run_test 53 "Opened for read file on an evicted client should not be set dirty"
1878 # test needs a running copytool
1882 local f=$DIR/$tdir/$tfile
1883 local fid=$(make_small $f)
1885 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
1886 error "could not archive file"
1887 wait_request_state $fid ARCHIVE STARTED
1889 check_hsm_flags $f "0x00000001"
1891 # Avoid coordinator resending this request as soon it has failed.
1896 wait_request_state $fid ARCHIVE FAILED
1898 check_hsm_flags $f "0x00000003"
1903 run_test 54 "Write during an archive cancels it"
1906 # test needs a running copytool
1910 local f=$DIR/$tdir/$tfile
1911 local fid=$(make_small $f)
1913 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
1914 error "could not archive file"
1915 wait_request_state $fid ARCHIVE STARTED
1917 check_hsm_flags $f "0x00000001"
1919 # Avoid coordinator resending this request as soon it has failed.
1922 $TRUNCATE $f 1024 || error "truncate failed"
1924 wait_request_state $fid ARCHIVE FAILED
1926 check_hsm_flags $f "0x00000003"
1931 run_test 55 "Truncate during an archive cancels it"
1934 # test needs a running copytool
1938 local f=$DIR/$tdir/$tfile
1939 local fid=$(make_large_for_progress $f)
1941 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
1942 error "could not archive file"
1943 wait_request_state $fid ARCHIVE STARTED
1945 check_hsm_flags $f "0x00000001"
1947 # Change metadata and sync to be sure we are not changing only
1952 wait_request_state $fid ARCHIVE SUCCEED
1954 check_hsm_flags $f "0x00000009"
1958 run_test 56 "Setattr during an archive is ok"
1961 # Need one client for I/O, one for request
1962 need2clients || return 0
1964 # test needs a running copytool
1968 local f=$DIR/$tdir/test_archive_remote
1969 # Create a file on a remote node
1970 do_node $CLIENT2 "dd if=/dev/urandom of=$f bs=1M "\
1971 "count=2 conv=fsync"
1974 do_node $CLIENT2 "$LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f" ||
1975 error "hsm_archive failed"
1976 local fid=$(path2fid $f)
1977 wait_request_state $fid ARCHIVE SUCCEED
1979 # Release and implicit restore it
1980 do_node $CLIENT2 "$LFS hsm_release $f" ||
1981 error "hsm_release failed"
1982 do_node $CLIENT2 "md5sum $f" ||
1983 error "hsm_restore failed"
1985 wait_request_state $fid RESTORE SUCCEED
1989 run_test 57 "Archive a file with dirty cache on another node"
1992 # test needs a running copytool
1996 local f=$DIR/$tdir/$tfile
1997 local fid=$(make_small $f)
1999 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2000 error "could not archive file"
2001 wait_request_state $fid ARCHIVE SUCCEED
2003 $LFS hsm_release $f || error "could not release file"
2005 $TRUNCATE $f 0 || error "truncate failed"
2008 local sz=$(stat -c %s $f)
2009 [[ $sz == 0 ]] || error "size after truncate is $sz != 0"
2013 check_hsm_flags $f "0x0000000b"
2015 local state=$(get_request_state $fid RESTORE)
2016 [[ "$state" == "" ]] ||
2017 error "truncate 0 trigs a restore, state = $state"
2021 run_test 58 "Truncate 0 on a released file must not trigger restore"
2024 # test needs a running copytool
2028 local f=$DIR/$tdir/$tfile
2029 local fid=$(copy_file /etc/passwd $f)
2032 local sz=$(stat -c %s $ref)
2036 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2037 error "could not archive file"
2038 wait_request_state $fid ARCHIVE SUCCEED
2040 $LFS hsm_release $f || error "could not release file"
2042 $TRUNCATE $f $sz || error "truncate failed"
2045 local sz1=$(stat -c %s $f)
2046 [[ $sz1 == $sz ]] || error "size after truncate is $sz1 != $sz"
2050 check_hsm_flags $f "0x0000000b"
2052 local state=$(get_request_state $fid RESTORE)
2053 [[ "$state" == "SUCCEED" ]] ||
2054 error "truncate $sz does not trig a successfull restore,"\
2057 cmp $ref $f || error "file data wrong after truncate"
2061 run_test 59 "Truncate != 0 on a released file"
2066 local f=$DIR/$tdir/$tfile
2067 local FILELIST=/tmp/filelist.txt
2071 for i in $(seq 1 $file_count); do
2072 fid=$(copy_file /etc/hosts $f.$i)
2073 echo $f.$i >> $FILELIST
2076 # to be sure wait_all_done will not be mislead by previous tests
2078 wait_for_grace_delay
2079 $LFS hsm_archive --filelist $FILELIST ||
2080 error "cannot archive a file list"
2082 $LFS hsm_release --filelist $FILELIST ||
2083 error "cannot release a file list"
2084 $LFS hsm_restore --filelist $FILELIST ||
2085 error "cannot restore a file list"
2089 run_test 90 "Archive/restore a file list"
2091 double_verify_reset_hsm_param() {
2093 echo "Testing $HSM_PARAM.$p"
2094 local val=$(get_hsm_param $p)
2096 local val2=$(($val * 2))
2097 set_hsm_param $p $val2
2098 val=$(get_hsm_param $p)
2099 [[ $val == $val2 ]] ||
2100 error "$HSM_PARAM.$p: $val != $val2 should be (2 * $save)"
2101 echo "Set $p to 0 must failed"
2105 set_hsm_param $p $save
2109 error "we must not be able to set $HSM_PARAM.$p to 0"
2114 double_verify_reset_hsm_param loop_period
2115 double_verify_reset_hsm_param grace_delay
2116 double_verify_reset_hsm_param request_timeout
2117 double_verify_reset_hsm_param max_requests
2118 double_verify_reset_hsm_param archive_id
2120 run_test 100 "Set coordinator /proc tunables"
2127 run_test 102 "Verify coordinator control"
2130 # test needs a running copytool
2137 for i in $(seq 1 20); do
2138 fid=$(copy_file /etc/passwd $DIR/$tdir/$i)
2140 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/*
2144 echo "Current requests"
2145 local res=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2146 $HSM_PARAM.agent_actions |\
2147 grep -v CANCELED | grep -v SUCCEED | grep -v FAILED")
2149 [[ -z "$res" ]] || error "Some request have not been canceled"
2153 run_test 103 "Purge all requests"
2158 # test needs a running copytool
2162 local f=$DIR/$tdir/$tfile
2163 local fid=$(make_large_for_progress $f)
2164 # if cdt is on, it can serve too quickly the request
2166 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER --data $DATA $f
2167 local data1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2168 $HSM_PARAM.agent_actions |\
2169 grep $fid | cut -f16 -d=")
2172 [[ "$data1" == "$DATAHEX" ]] ||
2173 error "Data field in records is ($data1) and not ($DATAHEX)"
2177 run_test 104 "Copy tool data field"
2184 for i in $(seq -w 1 10); do
2185 cp /etc/passwd $DIR/$tdir/$i
2186 $LFS hsm_archive $DIR/$tdir/$i
2188 local reqcnt1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2189 $HSM_PARAM.agent_actions |\
2190 grep WAITING | wc -l")
2193 local reqcnt2=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2194 $HSM_PARAM.agent_actions |\
2195 grep WAITING | wc -l")
2198 [[ "$reqcnt1" == "$reqcnt2" ]] ||
2199 error "Requests count after shutdown $reqcnt2 != "\
2200 "before shutdown $reqcnt1"
2202 run_test 105 "Restart of coordinator"
2205 # test needs a running copytool
2208 local uuid=$(do_rpc_nodes $(facet_active_host $SINGLEAGT) \
2209 get_client_uuid | cut -d' ' -f2)
2210 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2213 [[ ! -z "$agent" ]] || error "My uuid $uuid not found in agent list"
2214 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2216 [[ -z "$agent" ]] ||
2217 error "My uuid $uuid still found in agent list,"\
2218 " after copytool shutdown"
2220 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2223 [[ ! -z "$agent" ]] ||
2224 error "My uuid $uuid not found in agent list after"\
2227 run_test 106 "Copytool register/unregister"
2230 # test needs a running copytool
2232 # create and archive file
2234 local f1=$DIR/$tdir/$tfile
2235 local fid=$(copy_file /etc/passwd $f1)
2236 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2237 wait_request_state $fid ARCHIVE SUCCEED
2238 # shutdown and restart MDS
2240 # check the copytool still gets messages from MDT
2241 local f2=$DIR/$tdir/2
2242 local fid=$(copy_file /etc/passwd $f2)
2243 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f2
2244 # main check of this sanity: this request MUST succeed
2245 wait_request_state $fid ARCHIVE SUCCEED
2248 run_test 107 "Copytool re-register after MDS restart"
2251 # test needs a running copytool
2254 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2255 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2256 local f=$DIR/$tdir/$tfile
2257 import_file $tdir/$tfile $f
2258 local fid=$(path2fid $f)
2260 cdt_set_no_blocking_restore
2265 wait_request_state $fid RESTORE SUCCEED
2266 cdt_clear_no_blocking_restore
2270 error "md5sum returns $st != 1, "\
2271 "should also perror ENODATA (No data available)"
2275 run_test 110a "Non blocking restore policy (import case)"
2278 # test needs a running copytool
2282 local f=$DIR/$tdir/$tfile
2283 local fid=$(copy_file /etc/passwd $f)
2284 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2285 wait_request_state $fid ARCHIVE SUCCEED
2288 cdt_set_no_blocking_restore
2293 wait_request_state $fid RESTORE SUCCEED
2294 cdt_clear_no_blocking_restore
2298 error "md5sum returns $st != 1, "\
2299 "should also perror ENODATA (No data available)"
2303 run_test 110b "Non blocking restore policy (release case)"
2306 # test needs a running copytool
2309 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2310 local f=$DIR/$tdir/$tfile
2311 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2312 import_file $tdir/$tfile $f
2313 local fid=$(path2fid $f)
2317 copytool_remove_backend $fid
2320 wait_request_state $fid RESTORE FAILED
2327 [[ $st == 0 ]] || error "Restore does not failed"
2331 run_test 111a "No retry policy (import case), restore will error"\
2332 " (No such file or directory)"
2335 # test needs a running copytool
2339 local f=$DIR/$tdir/$tfile
2340 local fid=$(copy_file /etc/passwd $f)
2342 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2343 wait_request_state $fid ARCHIVE SUCCEED
2346 copytool_remove_backend $fid
2349 wait_request_state $fid RESTORE FAILED
2356 [[ $st == 0 ]] || error "Restore does not failed"
2360 run_test 111b "No retry policy (release case), restore will error"\
2361 " (No such file or directory)"
2364 # test needs a running copytool
2368 local f=$DIR/$tdir/$tfile
2369 local fid=$(copy_file /etc/passwd $f)
2371 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2372 local l=$($LFS hsm_action $f)
2374 local res=$(echo $l | cut -f 2- -d" " | grep ARCHIVE)
2378 wait_request_state $fid ARCHIVE SUCCEED
2381 [[ ! -z "$res" ]] || error "action is $l which is not an ARCHIVE"
2385 run_test 112 "State of recorded request"
2388 # test needs a running copytool
2392 local f=$DIR/$tdir/$tfile
2393 local fid=$(make_large_for_cancel $f)
2394 # test with cdt on is made in test_221
2396 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2399 wait_request_state $fid ARCHIVE CANCELED
2400 wait_request_state $fid CANCEL SUCCEED
2404 run_test 200 "Register/Cancel archive"
2407 # test needs a running copytool
2411 local f=$DIR/$tdir/$tfile
2412 make_archive $tdir/$tfile
2413 import_file $tdir/$tfile $f
2414 local fid=$(path2fid $f)
2416 # test with cdt on is made in test_222
2421 wait_request_state $fid RESTORE CANCELED
2422 wait_request_state $fid CANCEL SUCCEED
2426 run_test 201 "Register/Cancel restore"
2429 # test needs a running copytool
2433 local f=$DIR/$tdir/$tfile
2434 local fid=$(make_large_for_progress $f)
2435 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2436 wait_request_state $fid ARCHIVE SUCCEED
2442 wait_request_state $fid REMOVE CANCELED
2446 run_test 202 "Register/Cancel remove"
2449 # test needs a running copytool
2454 local f=$DIR/$tdir/$tfile
2455 local fid=$(copy_file /etc/passwd $f)
2459 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2460 wait_request_state $fid ARCHIVE SUCCEED
2462 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2466 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2470 run_test 220 "Changelog for archive"
2473 # test needs a running copytool
2478 local f=$DIR/$tdir/$tfile
2479 local fid=$(make_large_for_cancel $f)
2483 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2484 wait_request_state $fid ARCHIVE STARTED
2486 wait_request_state $fid ARCHIVE CANCELED
2487 wait_request_state $fid CANCEL SUCCEED
2489 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2492 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2496 run_test 221 "Changelog for archive canceled"
2499 # test needs a running copytool
2502 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2503 local f=$DIR/$tdir/$tfile
2504 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2505 import_file $tdir/$tfile $f
2506 local fid=$(path2fid $f)
2511 wait_request_state $fid RESTORE SUCCEED
2513 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2516 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2520 run_test 222a "Changelog for explicit restore"
2523 # test needs a running copytool
2527 local f=$DIR/$tdir/$tfile
2528 local fid=$(copy_file /etc/passwd $f)
2531 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2532 wait_request_state $fid ARCHIVE SUCCEED
2537 wait_request_state $fid RESTORE SUCCEED
2539 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2542 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2546 run_test 222b "Changelog for implicit restore"
2549 # test needs a running copytool
2554 local f=$DIR/$tdir/$tfile
2555 make_archive $tdir/$tfile
2559 import_file $tdir/$tfile $f
2560 local fid=$(path2fid $f)
2563 wait_request_state $fid RESTORE STARTED
2565 wait_request_state $fid RESTORE CANCELED
2566 wait_request_state $fid CANCEL SUCCEED
2568 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2571 [[ $flags == $target ]] ||
2572 error "Changelog flag is $flags not $target"
2576 run_test 223a "Changelog for restore canceled (import case)"
2579 # test needs a running copytool
2584 local f=$DIR/$tdir/$tfile
2585 local fid=$(make_large_for_progress $f)
2588 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2589 wait_request_state $fid ARCHIVE SUCCEED
2592 wait_request_state $fid RESTORE STARTED
2594 wait_request_state $fid RESTORE CANCELED
2595 wait_request_state $fid CANCEL SUCCEED
2597 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2600 [[ $flags == $target ]] ||
2601 error "Changelog flag is $flags not $target"
2605 run_test 223b "Changelog for restore canceled (release case)"
2608 # test needs a running copytool
2613 local f=$DIR/$tdir/$tfile
2614 local fid=$(copy_file /etc/passwd $f)
2617 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2618 wait_request_state $fid ARCHIVE SUCCEED
2621 wait_request_state $fid REMOVE SUCCEED
2623 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2626 [[ $flags == $target ]] ||
2627 error "Changelog flag is $flags not $target"
2631 run_test 224 "Changelog for remove"
2634 # test needs a running copytool
2637 # test is not usable because remove request is too fast
2638 # so it is always finished before cancel can be done ...
2639 echo "Test disabled"
2644 local f=$DIR/$tdir/$tfile
2645 local fid=$(make_large_for_progress $f)
2648 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2649 wait_request_state $fid ARCHIVE SUCCEED
2651 # if cdt is on, it can serve too quickly the request
2656 wait_request_state $fid REMOVE CANCELED
2657 wait_request_state $fid CANCEL SUCCEED
2659 flags=$(changelog_get_flags $MDT0 RENME $fid2)
2660 local flags=$($LFS changelog $MDT0 | grep HSM | grep $fid | tail -1 |
2664 [[ $flags == $target ]] ||
2665 error "Changelog flag is $flags not $target"
2669 run_test 225 "Changelog for remove canceled"
2672 # test needs a running copytool
2677 local f1=$DIR/$tdir/$tfile-1
2678 local f2=$DIR/$tdir/$tfile-2
2679 local f3=$DIR/$tdir/$tfile-3
2680 local fid1=$(copy_file /etc/passwd $f1)
2681 local fid2=$(copy_file /etc/passwd $f2)
2682 copy_file /etc/passwd $f3
2685 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2686 wait_request_state $fid1 ARCHIVE SUCCEED
2688 $LFS hsm_archive $f2
2689 wait_request_state $fid2 ARCHIVE SUCCEED
2691 rm $f1 || error "rm $f1 failed"
2693 local flags=$(changelog_get_flags $MDT0 UNLNK $fid1)
2696 [[ $flags == $target ]] ||
2697 error "Changelog flag is $flags not $target"
2699 mv $f3 $f2 || error "mv $f3 $f2 failed"
2701 flags=$(changelog_get_flags $MDT0 RENME $fid2)
2704 [[ $flags == $target ]] ||
2705 error "Changelog flag is $flags not $target"
2709 run_test 226 "changelog for last rm/mv with exiting archive"
2711 check_flags_changes() {
2719 $LFS hsm_set --$hsm_flag $f ||
2720 error "Cannot set $hsm_flag on $f"
2721 local flags=($(changelog_get_flags $MDT0 HSM $fid))
2722 local seen=${#flags[*]}
2724 [[ $seen == $cnt ]] ||
2725 error "set $hsm_flag: Changelog events $seen != $cnt"
2726 [[ ${flags[$((cnt - 1))]} == $target ]] ||
2727 error "set $hsm_flag: Changelog flags are "\
2728 "${flags[$((cnt - 1))]} not $target"
2730 $LFS hsm_clear --$hsm_flag $f ||
2731 error "Cannot clear $hsm_flag on $f"
2732 flags=($(changelog_get_flags $MDT0 HSM $fid))
2735 [[ $cnt == $seen ]] ||
2736 error "clear $hsm_flag: Changelog events $seen != $cnt"
2738 [[ ${flags[$((cnt - 1))]} == $target ]] ||
2739 error "clear $hsm_flag: Changelog flag is "\
2740 "${flags[$((cnt - 1))]} not $target"
2744 # test needs a running copytool
2751 for i in norelease noarchive exists archived
2753 local f=$DIR/$tdir/$tfile-$i
2754 local fid=$(copy_file /etc/passwd $f)
2755 check_flags_changes $f $fid $i 0 1
2758 f=$DIR/$tdir/$tfile---lost
2759 fid=$(copy_file /etc/passwd $f)
2760 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2761 wait_request_state $fid ARCHIVE SUCCEED
2762 check_flags_changes $f $fid lost 3 1
2766 run_test 227 "changelog when explicit setting of HSM flags"
2769 # test needs a running copytool
2773 local maxrequest=$(get_hsm_param max_requests)
2774 local rqcnt=$(($maxrequest * 3))
2778 for i in $(seq -w 1 $rqcnt); do
2780 dd if=/dev/urandom of=$DIR/$tdir/$i bs=1M count=10 conv=fsync
2782 # we do it in 2 steps, so all requests arrive at the same time
2783 for i in $(seq -w 1 $rqcnt); do
2784 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$i
2789 while [[ $cnt != 0 || $wt != 0 ]]; do
2791 cnt=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2792 $HSM_PARAM.agent_actions |\
2793 grep STARTED | grep -v CANCEL | wc -l")
2794 [[ $cnt -le $maxrequest ]] ||
2795 error "$cnt > $maxrequest too many started requests"
2796 wt=$(do_facet $SINGLEMDS "$LCTL get_param\
2797 $HSM_PARAM.agent_actions |\
2798 grep WAITING | wc -l")
2799 echo "max=$maxrequest started=$cnt waiting=$wt"
2804 run_test 250 "Coordinator max request"
2807 # test needs a running copytool
2811 local f=$DIR/$tdir/$tfile
2812 local fid=$(make_large_for_cancel $f)
2815 # to have a short test
2816 local old_to=$(get_hsm_param request_timeout)
2817 set_hsm_param request_timeout 4
2818 # to be sure the cdt will wake up frequently so
2819 # it will be able to cancel the "old" request
2820 local old_loop=$(get_hsm_param loop_period)
2821 set_hsm_param loop_period 2
2824 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2825 wait_request_state $fid ARCHIVE STARTED
2827 wait_request_state $fid ARCHIVE CANCELED
2829 set_hsm_param request_timeout $old_to
2830 set_hsm_param loop_period $old_loop
2834 run_test 251 "Coordinator request timeout"
2837 # the only way to test ondisk conf is to restart MDS ...
2838 echo "Stop coordinator and remove coordinator state at mount"
2841 # clean on disk conf set by default
2842 cdt_clear_mount_state
2843 cdt_check_state stopped
2845 # check cdt still off after umount/remount
2847 cdt_check_state stopped
2849 echo "Set coordinator start at mount, and start coordinator"
2850 cdt_set_mount_state enabled
2853 cdt_check_state enabled
2855 # check cdt still on after umount/remount
2857 cdt_check_state enabled
2859 # we are back to original state (cdt started at mount)
2861 run_test 300 "On disk coordinator state kept between MDT umount/mount"
2866 check_and_cleanup_lustre