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
18 ALWAYS_EXCEPT="$SANITY_HSM_EXCEPT 12a 12b 12n 13 30a 31a 34 35 36 58 59"
19 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110a 200 201 221 222a 223a 223b 225"
21 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/test-framework.sh
25 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
28 MULTIOP=${MULTIOP:-multiop}
29 OPENFILE=${OPENFILE:-openfile}
30 MCREATE=${MCREATE:-mcreate}
31 MOUNT_2=${MOUNT_2:-"yes"}
34 if [[ $MDSCOUNT -ge 2 ]]; then
35 skip_env "Only run with single MDT for now" && exit
38 check_and_setup_lustre
40 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ]]; then
41 skip_env "Need MDS version at least 2.4.53" && exit
44 # $RUNAS_ID may get set incorrectly somewhere else
45 if [[ $UID -eq 0 && $RUNAS_ID -eq 0 ]]; then
46 skip_env "\$RUNAS_ID set to 0, but \$UID is also 0!" && exit
48 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
53 # In order to test multiple remote HSM agents, a new facet type named "AGT" and
54 # the following associated variables are added:
56 # AGTCOUNT: number of agents
57 # AGTDEV{N}: target HSM mount point (root path of the backend)
58 # agt{N}_HOST: hostname of the agent agt{N}
59 # SINGLEAGT: facet of the single agent
61 # The number of agents is initialized as the number of remote client nodes.
62 # By default, only single copytool is started on a remote client/agent. If there
63 # was no remote client, then the copytool will be started on the local client.
69 export AGTCOUNT=${AGTCOUNT:-$((CLIENTCOUNT - 1))}
70 [[ $AGTCOUNT -gt 0 ]] || AGTCOUNT=1
72 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-$TMP}
73 if [[ $CLIENTCOUNT -gt 1 ]] &&
74 ! check_shared_dir $SHARED_DIRECTORY $CLIENTS; then
75 skip_env "SHARED_DIRECTORY should be accessible"\
80 for n in $(seq $AGTCOUNT); do
81 eval export AGTDEV$n=\$\{AGTDEV$n:-"$SHARED_DIRECTORY/arc$n"\}
82 agent=CLIENT$((n + 1))
83 if [[ -z "${!agent}" ]]; then
84 [[ $CLIENTCOUNT -eq 1 ]] && agent=CLIENT1 ||
87 eval export agt${n}_HOST=\$\{agt${n}_HOST:-${!agent}\}
90 export SINGLEAGT=${SINGLEAGT:-agt1}
92 export HSMTOOL=${HSMTOOL:-"lhsmtool_posix"}
93 export HSMTOOL_VERBOSE=${HSMTOOL_VERBOSE:-""}
94 export HSMTOOL_BASE=$(basename "$HSMTOOL" | cut -f1 -d" ")
95 HSM_ARCHIVE=$(copytool_device $SINGLEAGT)
98 MDT_PARAM="mdt.$FSNAME-MDT0000"
99 HSM_PARAM="$MDT_PARAM.hsm"
101 # archive is purged at copytool setup
102 HSM_ARCHIVE_PURGE=true
105 # Get the backend root path for the given agent facet.
108 local dev=AGTDEV$(facet_number $facet)
113 # Stop copytool and unregister an existing changelog user.
119 search_and_kill_copytool() {
120 local agents=${1:-$(facet_active_host $SINGLEAGT)}
122 echo "Killing existing copytools on $agents"
123 do_nodesv $agents "killall -q $HSMTOOL_BASE" || true
127 local facet=${1:-$SINGLEAGT}
128 local lustre_mntpnt=${2:-$MOUNT}
130 local hsm_root=$(copytool_device $facet)
131 local agent=$(facet_active_host $facet)
133 if [[ -z "$arc_id" ]] &&
134 do_facet $facet "pkill -CONT -x $HSMTOOL_BASE"; then
135 echo "Wakeup copytool $facet on $agent"
139 if $HSM_ARCHIVE_PURGE; then
140 echo "Purging archive on $agent"
141 do_facet $facet "rm -rf $hsm_root/*"
144 echo "Starting copytool $facet on $agent"
145 do_facet $facet "mkdir -p $hsm_root" || error "mkdir '$hsm_root' failed"
146 # bandwidth is limited to 1MB/s so the copy time is known and
147 # independent of hardware
148 local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --hsm-root $hsm_root"
149 [[ -z "$arc_id" ]] || cmd+=" --archive $arc_id"
150 cmd+=" --bandwidth 1 $lustre_mntpnt"
152 # Redirect the standard output and error to a log file which
153 # can be uploaded to Maloo.
154 local prefix=$TESTLOG_PREFIX
155 [[ -z "$TESTNAME" ]] || prefix=$prefix.$TESTNAME
156 local copytool_log=$prefix.copytool${arc_id}_log.$agent.log
158 do_facet $facet "$cmd < /dev/null > $copytool_log 2>&1" ||
159 error "start copytool $facet on $agent failed"
165 local agents=${1:-$(facet_active_host $SINGLEAGT)}
167 do_nodesv $agents "pkill -INT -x $HSMTOOL_BASE" || return 0
169 echo "Copytool is stopped on $agents"
173 local agents=${1:-$(facet_active_host $SINGLEAGT)}
175 do_nodesv $agents "pkill -STOP -x $HSMTOOL_BASE" || return 0
176 echo "Copytool is suspended on $agents"
179 copytool_remove_backend() {
181 local be=$(find $HSM_ARCHIVE -name $fid)
182 echo "Remove from backend: $fid = $be"
187 do_facet $SINGLEAGT \
188 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
189 --import $1 $2 $MOUNT" ||
190 error "import of $1 to $2 failed"
194 local file=$HSM_ARCHIVE/$1
195 mkdir -p $(dirname $file)
196 dd if=/dev/urandom of=$file count=32 bs=1000000 ||
197 error "cannot create $file"
201 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0\
202 changelog_register -n)
203 do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog_mask="+hsm"
204 $LFS changelog_clear $MDT0 $CL_USER 0
207 changelog_cleanup() {
208 # $LFS changelog $MDT0
209 [[ -n "$CL_USER" ]] || return 0
211 $LFS changelog_clear $MDT0 $CL_USER 0
212 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
216 changelog_get_flags() {
221 $LFS changelog $mdt | awk "/$cltype/ && /t=\[$fid\]/ {print \$5}"
226 local val=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.$param)
233 do_facet $SINGLEMDS $LCTL set_param -n $HSM_PARAM.$param=$value
240 do_facet $SINGLEMDS $LCTL set_param $MDT_PARAM.hsm_control=$cmd
241 wait_result $SINGLEMDS "$LCTL get_param -n $MDT_PARAM.hsm_control"\
242 $target 10 || error "cdt state is not $target"
245 cdt_set_sanity_policy() {
247 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nra
248 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nbr
249 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-gc
253 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+nra
256 cdt_clear_no_retry() {
257 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nra
260 cdt_set_no_blocking_restore() {
261 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+nbr
264 cdt_clear_no_blocking_restore() {
265 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nbr
268 cdt_clear_mount_state() {
269 # /!\ conf_param and set_param syntax differ +> we cannot use
271 do_facet $SINGLEMDS $LCTL conf_param -d $FSNAME-MDT0000.mdt.hsm_control
274 cdt_set_mount_state() {
275 # /!\ conf_param and set_param syntax differ +> we cannot use
277 do_facet $SINGLEMDS $LCTL conf_param $FSNAME-MDT0000.mdt.hsm_control=$1
282 wait_result $SINGLEMDS\
283 "$LCTL get_param -n $MDT_PARAM.hsm_control" "$target" 20 ||
284 error "cdt state is not $target"
288 set_test_state disabled disabled
292 set_test_state enabled enabled
296 set_test_state shutdown stopped
300 set_test_state purge enabled
306 cdt_set_sanity_policy
310 if [[ $CLIENTCOUNT -lt 2 ]]; then
311 skip "Need two or more clients, have $CLIENTCOUNT"
318 $LFS path2fid $1 | tr -d '[]'
325 if [[ $u == "user" ]]
327 local st=$($RUNAS $LFS hsm_state $f)
329 local st=$($LFS hsm_state $f)
333 [[ $? == 0 ]] || error "$LFS hsm_state $f failed (run as $u)"
335 st=$(echo $st | cut -f 2 -d" " | tr -d "()," )
339 get_hsm_archive_id() {
341 local st=$($LFS hsm_state $f)
342 [[ $? == 0 ]] || error "$LFS hsm_state $f failed"
344 local ar=$(echo $st | grep "archive_id" | cut -f5 -d" " |
353 local st=$(get_hsm_flags $f)
354 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
357 check_hsm_flags_user() {
361 local st=$(get_hsm_flags $f user)
362 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
380 cp $1 $f || error "cannot copy $1 to $f"
381 path2fid $f || error "cannot get fid on $f"
385 local file2=${1/$DIR/$DIR2}
386 dd if=/dev/urandom of=$file2 count=2 bs=1M conv=fsync ||
387 error "cannot create $file2"
388 path2fid $1 || error "cannot get fid on $1"
391 make_large_for_striping() {
392 local file2=${1/$DIR/$DIR2}
393 local sz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -1)
394 dd if=/dev/urandom of=$file2 count=5 bs=$sz conv=fsync ||
395 error "cannot create $file2"
396 path2fid $1 || error "cannot get fid on $1"
399 make_large_for_progress() {
400 local file2=${1/$DIR/$DIR2}
401 # big file is large enough, so copy time is > 30s
402 # so copytool make 1 progress
403 # size is not a multiple of 1M to avoid stripe
405 dd if=/dev/urandom of=$file2 count=39 bs=1000000 conv=fsync ||
406 error "cannot create $file2"
407 path2fid $1 || error "cannot get fid on $1"
410 make_large_for_progress_aligned() {
411 local file2=${1/$DIR/$DIR2}
412 # big file is large enough, so copy time is > 30s
413 # so copytool make 1 progress
414 # size is a multiple of 1M to have stripe
416 dd if=/dev/urandom of=$file2 count=33 bs=1M conv=fsync ||
417 error "cannot create $file2"
418 path2fid $1 || error "cannot get fid on $1"
421 make_large_for_cancel() {
422 local file2=${1/$DIR/$DIR2}
423 # Copy timeout is 100s. 105MB => 105s
424 dd if=/dev/urandom of=$file2 count=103 bs=1M conv=fsync ||
425 error "cannot create $file2"
426 path2fid $1 || error "cannot get fid on $1"
432 wait_update --verbose $(facet_active_host $facet) "$@"
435 wait_request_state() {
440 local cmd="$LCTL get_param -n $HSM_PARAM.agent_actions"
441 cmd+=" | awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
443 wait_result $SINGLEMDS "$cmd" $state 100 ||
444 error "request on $fid is not $state"
447 get_request_state() {
451 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.agent_actions |"\
452 "awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
455 get_request_count() {
459 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.agent_actions |"\
460 "awk -vn=0 '/'$fid'.*action='$request'/ {n++}; END {print n}'"
466 local cmd="$LCTL get_param -n $HSM_PARAM.agent_actions"
467 cmd+=" | egrep 'WAITING|STARTED'"
469 wait_result $SINGLEMDS "$cmd" "" $timeout ||
470 error "requests did not complete"
473 wait_for_grace_delay() {
474 local val=$(get_hsm_param grace_delay)
478 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
479 awk '{gsub(/_UUID/,""); print $1}' | head -1)
484 # cleanup from previous bad setup
485 search_and_kill_copytool
487 # for recovery tests, coordinator needs to be started at mount
489 # the lustre conf must be without hsm on (like for sanity.sh)
490 echo "Set HSM on and start"
491 cdt_set_mount_state enabled
492 cdt_check_state enabled
494 echo "Start copytool"
497 # finished requests are quickly removed from list
498 set_hsm_param grace_delay 10
504 local f=$DIR/$tdir/$tfile
508 check_hsm_flags_user $f "0x00000000"
510 $RUNAS $LFS hsm_set --norelease $f ||
511 error "user could not change hsm flags"
512 check_hsm_flags_user $f "0x00000010"
514 $RUNAS $LFS hsm_clear --norelease $f ||
515 error "user could not clear hsm flags"
516 check_hsm_flags_user $f "0x00000000"
518 # User could not change those flags...
519 $RUNAS $LFS hsm_set --exists $f &&
520 error "user should not set this flag"
521 check_hsm_flags_user $f "0x00000000"
524 $LFS hsm_set --exists $f ||
525 error "root could not change hsm flags"
526 check_hsm_flags_user $f "0x00000001"
528 $LFS hsm_clear --exists $f ||
529 error "root could not clear hsm state"
530 check_hsm_flags_user $f "0x00000000"
533 run_test 1 "lfs hsm flags root/non-root access"
537 local f=$DIR/$tdir/$tfile
539 # New files are not dirty
540 check_hsm_flags $f "0x00000000"
542 # For test, we simulate an archived file.
543 $LFS hsm_set --exists $f || error "user could not change hsm flags"
544 check_hsm_flags $f "0x00000001"
546 # chmod do not put the file dirty
547 chmod 600 $f || error "could not chmod test file"
548 check_hsm_flags $f "0x00000001"
550 # chown do not put the file dirty
551 chown $RUNAS_ID $f || error "could not chown test file"
552 check_hsm_flags $f "0x00000001"
554 # truncate put the file dirty
555 $TRUNCATE $f 1 || error "could not truncate test file"
556 check_hsm_flags $f "0x00000003"
558 $LFS hsm_clear --dirty $f || error "could not clear hsm flags"
559 check_hsm_flags $f "0x00000001"
561 run_test 2 "Check file dirtyness when doing setattr"
567 # New files are not dirty
569 check_hsm_flags $f "0x00000000"
571 # For test, we simulate an archived file.
572 $LFS hsm_set --exists $f ||
573 error "user could not change hsm flags"
574 check_hsm_flags $f "0x00000001"
576 # Reading a file, does not set dirty
577 cat $f > /dev/null || error "could not read file"
578 check_hsm_flags $f "0x00000001"
580 # Open for write without modifying data, does not set dirty
581 openfile -f O_WRONLY $f || error "could not open test file"
582 check_hsm_flags $f "0x00000001"
584 # Append to a file sets it dirty
585 cp -p /etc/passwd $f.append || error "could not create file"
586 $LFS hsm_set --exists $f.append ||
587 error "user could not change hsm flags"
588 dd if=/etc/passwd of=$f.append bs=1 count=3\
589 conv=notrunc oflag=append status=noxfer ||
590 error "could not append to test file"
591 check_hsm_flags $f.append "0x00000003"
593 # Modify a file sets it dirty
594 cp -p /etc/passwd $f.modify || error "could not create file"
595 $LFS hsm_set --exists $f.modify ||
596 error "user could not change hsm flags"
597 dd if=/dev/zero of=$f.modify bs=1 count=3\
598 conv=notrunc status=noxfer ||
599 error "could not modify test file"
600 check_hsm_flags $f.modify "0x00000003"
602 # Open O_TRUNC sets dirty
603 cp -p /etc/passwd $f.trunc || error "could not create file"
604 $LFS hsm_set --exists $f.trunc ||
605 error "user could not change hsm flags"
606 cp /etc/group $f.trunc || error "could not override a file"
607 check_hsm_flags $f.trunc "0x00000003"
609 # Mmapped a file sets dirty
610 cp -p /etc/passwd $f.mmap || error "could not create file"
611 $LFS hsm_set --exists $f.mmap ||
612 error "user could not change hsm flags"
613 multiop $f.mmap OSMWUc || error "could not mmap a file"
614 check_hsm_flags $f.mmap "0x00000003"
616 run_test 3 "Check file dirtyness when opening for write"
620 local f=$DIR/$tdir/$tfile
621 local fid=$(make_small $f)
624 local st=$(get_request_state $fid CANCEL)
625 [[ -z "$st" ]] || error "hsm_cancel must not be registered (state=$st)"
627 run_test 4 "Useless cancel must not be registered"
630 # test needs a running copytool
634 local f=$DIR/$tdir/$tfile
635 local fid=$(copy_file /etc/passwd $f)
637 wait_request_state $fid ARCHIVE SUCCEED
639 check_hsm_flags $f "0x00000009"
643 run_test 8 "Test default archive number"
647 local f=$DIR/$tdir/$tfile
648 local fid=$(copy_file /etc/passwd $f)
649 # we do not use the default one to be sure
650 local new_an=$((HSM_ARCHIVE_NUMBER + 1))
652 copytool_setup $SINGLEAGT $MOUNT $new_an
653 $LFS hsm_archive --archive $new_an $f
654 wait_request_state $fid ARCHIVE SUCCEED
656 check_hsm_flags $f "0x00000009"
660 run_test 9 "Use of explict archive number, with dedicated copytool"
663 [[ $CLIENTCOUNT -ge 3 ]] ||
664 { skip "Need three or more clients"; return 0; }
670 copytool_cleanup $(comma_list $(agts_nodes))
672 # start all of the copytools
673 for n in $(seq $AGTCOUNT); do
677 trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
680 for n in $(seq $AGTCOUNT); do
681 file=$DIR/$tdir/$tfile.$n
682 fid=$(make_small $file)
684 $LFS hsm_archive $file || error "could not archive file $file"
685 wait_request_state $fid ARCHIVE SUCCEED
686 check_hsm_flags $file "0x00000001"
690 copytool_cleanup $(comma_list $(agts_nodes))
692 run_test 9a "Multiple remote agents"
695 # test needs a running copytool
698 mkdir -p $DIR/$tdir/d1
699 local f=$DIR/$tdir/$tfile
700 local fid=$(copy_file /etc/hosts $f)
701 $LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f ||
702 error "hsm_archive failed"
703 wait_request_state $fid ARCHIVE SUCCEED
705 local AFILE=$(ls $HSM_ARCHIVE/*/*/*/*/*/*/$fid) ||
706 error "fid $fid not in archive $HSM_ARCHIVE"
707 echo "Verifying content"
708 diff $f $AFILE || error "archived file differs"
709 echo "Verifying hsm state "
710 check_hsm_flags $f "0x00000009"
712 echo "Verifying archive number is $HSM_ARCHIVE_NUMBER"
713 local st=$(get_hsm_archive_id $f)
714 [[ $st == $HSM_ARCHIVE_NUMBER ]] ||
715 error "Wrong archive number, $st != $HSM_ARCHIVE_NUMBER"
720 run_test 10a "Archive a file"
723 # test needs a running copytool
726 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
727 local f=$DIR/$tdir/$tfile
728 local fid=$(copy_file /etc/hosts $f)
729 $LFS hsm_archive $f || error "archive request failed"
730 wait_request_state $fid ARCHIVE SUCCEED
732 $LFS hsm_archive $f || error "archive of non dirty file failed"
733 local cnt=$(get_request_count $fid ARCHIVE)
734 [[ "$cnt" == "1" ]] ||
735 error "archive of non dirty file must not make a request"
739 run_test 10b "Archive of non dirty file must work without doing request"
742 # test needs a running copytool
745 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
746 local f=$DIR/$tdir/$tfile
747 local fid=$(copy_file /etc/hosts $f)
748 $LFS hsm_set --noarchive $f
749 $LFS hsm_archive $f && error "archive a noarchive file must fail"
753 run_test 10c "Check forbidden archive"
756 # test needs a running copytool
760 local f=$DIR/$tdir/$tfile
761 local fid=$(copy_file /etc/hosts $f)
762 $LFS hsm_archive $f || error "cannot archive $f"
763 wait_request_state $fid ARCHIVE SUCCEED
765 local ar=$(get_hsm_archive_id $f)
766 local dflt=$(get_hsm_param archive_id)
767 [[ $ar == $dflt ]] ||
768 error "archived file is not on default archive: $ar != $dflt"
772 run_test 10d "Archive a file on the default archive id"
775 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
776 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
777 local f=$DIR/$tdir/$tfile
779 import_file $tdir/$tfile $f
780 echo -n "Verifying released state: "
781 check_hsm_flags $f "0x0000000d"
783 local LSZ=$(stat -c "%s" $f)
784 local ASZ=$(stat -c "%s" $HSM_ARCHIVE/$tdir/$tfile)
786 echo "Verifying imported size $LSZ=$ASZ"
787 [[ $LSZ -eq $ASZ ]] || error "Incorrect size $LSZ != $ASZ"
788 echo -n "Verifying released pattern: "
789 local PTRN=$($GETSTRIPE -L $f)
791 [[ $PTRN == 80000001 ]] || error "Is not released"
792 local fid=$(path2fid $f)
793 echo "Verifying new fid $fid in archive"
795 local AFILE=$(ls $HSM_ARCHIVE/*/*/*/*/*/*/$fid) ||
796 error "fid $fid not in archive $HSM_ARCHIVE"
798 run_test 11 "Import a file"
801 # test needs a running copytool
804 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
805 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
806 local f=$DIR/$tdir/$tfile
807 import_file $tdir/$tfile $f
808 local f=$DIR2/$tdir/$tfile
809 echo "Verifying released state: "
810 check_hsm_flags $f "0x0000000d"
812 local fid=$(path2fid $f)
814 wait_request_state $fid RESTORE SUCCEED
816 echo "Verifying file state: "
817 check_hsm_flags $f "0x00000009"
819 diff -q $HSM_ARCHIVE/$tdir/$tfile $f
821 [[ $? -eq 0 ]] || error "Restored file differs"
825 run_test 12a "Restore an imported file explicitly"
828 # test needs a running copytool
831 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
832 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
833 local f=$DIR/$tdir/$tfile
834 import_file $tdir/$tfile $f
835 echo "Verifying released state: "
836 check_hsm_flags $f "0x0000000d"
838 cat $f > /dev/null || error "File read failed"
840 echo "Verifying file state after restore: "
841 check_hsm_flags $f "0x00000009"
843 diff -q $HSM_ARCHIVE/$tdir/$tfile $f
845 [[ $? -eq 0 ]] || error "Restored file differs"
849 run_test 12b "Restore an imported file implicitly"
852 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
854 # test needs a running copytool
858 local f=$DIR/$tdir/$tfile
859 $LFS setstripe -c 2 $f
860 local fid=$(make_large_for_striping $f)
861 local FILE_CRC=$(md5sum $f)
863 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
864 wait_request_state $fid ARCHIVE SUCCEED
865 $LFS hsm_release $f || error "release $f failed"
867 echo "$FILE_CRC" | md5sum -c
869 [[ $? -eq 0 ]] || error "Restored file differs"
873 run_test 12c "Restore a file with stripe of 2"
876 # test needs a running copytool
879 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
880 local f=$DIR/$tdir/$tfile
881 local fid=$(copy_file /etc/hosts $f)
882 $LFS hsm_restore $f || error "restore of non archived file failed"
883 local cnt=$(get_request_count $fid RESTORE)
884 [[ "$cnt" == "0" ]] ||
885 error "restore non archived must not make a request"
886 $LFS hsm_archive $f ||
887 error "archive request failed"
888 wait_request_state $fid ARCHIVE SUCCEED
889 $LFS hsm_restore $f ||
890 error "restore of non released file failed"
891 local cnt=$(get_request_count $fid RESTORE)
892 [[ "$cnt" == "0" ]] ||
893 error "restore a non dirty file must not make a request"
897 run_test 12d "Restore of a non archived, non released file must work"\
898 " without doing request"
901 # test needs a running copytool
904 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
905 local f=$DIR/$tdir/$tfile
906 local fid=$(copy_file /etc/hosts $f)
907 $LFS hsm_archive $f || error "archive request failed"
908 wait_request_state $fid ARCHIVE SUCCEED
915 $LFS hsm_restore $f && error "restore a dirty file must fail"
919 run_test 12e "Check forbidden restore"
922 # test needs a running copytool
926 local f=$DIR/$tdir/$tfile
927 local fid=$(copy_file /etc/hosts $f)
929 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
930 wait_request_state $fid ARCHIVE SUCCEED
931 $LFS hsm_release $f || error "release of $f failed"
933 wait_request_state $fid RESTORE SUCCEED
935 echo -n "Verifying file state: "
936 check_hsm_flags $f "0x00000009"
938 diff -q /etc/hosts $f
940 [[ $? -eq 0 ]] || error "Restored file differs"
944 run_test 12f "Restore a released file explicitly"
947 # test needs a running copytool
951 local f=$DIR/$tdir/$tfile
952 local fid=$(copy_file /etc/hosts $f)
954 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
955 wait_request_state $fid ARCHIVE SUCCEED
956 $LFS hsm_release $f || error "release of $f failed"
958 diff -q /etc/hosts $f
961 # we check we had a restore done
962 wait_request_state $fid RESTORE SUCCEED
964 [[ $st -eq 0 ]] || error "Restored file differs"
968 run_test 12g "Restore a released file implicitly"
971 need2clients || return 0
973 # test needs a running copytool
977 local f=$DIR/$tdir/$tfile
978 local fid=$(copy_file /etc/hosts $f)
980 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
981 wait_request_state $fid ARCHIVE SUCCEED
982 $LFS hsm_release $f || error "release of $f failed"
984 do_node $CLIENT2 diff -q /etc/hosts $f
987 # we check we had a restore done
988 wait_request_state $fid RESTORE SUCCEED
990 [[ $st -eq 0 ]] || error "Restored file differs"
994 run_test 12h "Restore a released file implicitly from a second node"
997 # test needs a running copytool
1001 local f=$DIR/$tdir/$tfile
1002 local fid=$(copy_file /etc/passwd $f)
1003 $LFS hsm_archive $f || error "archive of $f failed"
1004 wait_request_state $fid ARCHIVE SUCCEED
1006 $LFS hsm_release $f || error "release of $f failed"
1010 [[ $? -eq 0 ]] || error "Restored file differs"
1014 run_test 12m "Archive/release/implicit restore"
1017 # test needs a running copytool
1020 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1021 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
1022 local f=$DIR/$tdir/$tfile
1023 import_file $tdir/$tfile $f
1025 cmp /etc/hosts $f || error "Restored file differs"
1027 $LFS hsm_release $f || error "release of $f failed"
1031 run_test 12n "Import/implicit restore/release"
1034 # test needs a running copytool
1037 local ARC_SUBDIR="import.orig"
1041 # populate directory to be imported
1042 for d in $(seq 1 10); do
1043 local CURR_DIR="$HSM_ARCHIVE/$ARC_SUBDIR/dir.$d"
1044 mkdir -p "$CURR_DIR"
1045 for f in $(seq 1 10); do
1046 CURR_FILE="$CURR_DIR/$tfile.$f"
1047 # write file-specific data
1048 echo "d=$d, f=$f, dir=$CURR_DIR, file=$CURR_FILE"\
1053 import_file "$ARC_SUBDIR" $DIR/$tdir
1054 # diff lustre content and origin (triggers file restoration)
1055 # there must be 10x10 identical files, and no difference
1056 local cnt_ok=$(diff -rs $HSM_ARCHIVE/$ARC_SUBDIR \
1057 $DIR/$tdir/$ARC_SUBDIR |
1058 grep identical | wc -l)
1059 local cnt_diff=$(diff -r $HSM_ARCHIVE/$ARC_SUBDIR \
1060 $DIR/$tdir/$ARC_SUBDIR |
1063 [ $cnt_diff -eq 0 ] ||
1064 error "$cnt_diff imported files differ from read data"
1065 [ $cnt_ok -eq 100 ] ||
1066 error "not enough identical files ($cnt_ok != 100)"
1070 run_test 13 "Recursively import and restore a directory"
1073 # test needs a running copytool
1078 local f=$DIR/$tdir/$tfile
1079 local fid=$(make_small $f)
1080 local sum=$(md5sum $f | awk '{print $1}')
1081 $LFS hsm_archive $f || error "could not archive file"
1082 wait_request_state $fid ARCHIVE SUCCEED
1086 # create released file (simulate llapi_hsm_import call)
1088 local fid2=$(path2fid $f)
1089 $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
1090 $LFS hsm_release $f || error "could not release file"
1092 # rebind the archive to the newly created file
1093 echo "rebind $fid to $fid2"
1095 do_facet $SINGLEAGT \
1096 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1097 --rebind $fid $fid2 $DIR" || error "could not rebind file"
1099 # restore file and compare md5sum
1100 local sum2=$(md5sum $f | awk '{print $1}')
1102 [[ $sum == $sum2 ]] || error "md5sum mismatch after restore"
1106 run_test 14 "Rebind archived file to a new fid"
1109 # test needs a running copytool
1114 local f=$DIR/$tdir/$tfile
1116 local tmpfile=$SHARED_DIRECTORY/tmp.$$
1120 for i in $(seq 1 $count); do
1121 fids[$i]=$(make_small $f.$i)
1122 sums[$i]=$(md5sum $f.$i | awk '{print $1}')
1123 $LFS hsm_archive $f.$i || error "could not archive file"
1125 wait_all_done $(($count*60))
1129 for i in $(seq 1 $count); do
1132 local fid2=$(path2fid $f.$i)
1133 # add the rebind operation to the list
1134 echo ${fids[$i]} $fid2 >> $tmpfile
1136 # set it released (simulate llapi_hsm_import call)
1137 $LFS hsm_set --archived --exists $f.$i ||
1138 error "could not force hsm flags"
1139 $LFS hsm_release $f.$i || error "could not release file"
1141 nl=$(wc -l < $tmpfile)
1142 [[ $nl == $count ]] || error "$nl files in list, $count expected"
1144 echo "rebind list of files"
1145 do_facet $SINGLEAGT \
1146 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1147 --rebind $tmpfile $DIR" || error "could not rebind file list"
1149 # restore files and compare md5sum
1150 for i in $(seq 1 $count); do
1151 local sum2=$(md5sum $f.$i | awk '{print $1}')
1152 [[ $sum2 == ${sums[$i]} ]] ||
1153 error "md5sum mismatch after restore ($sum2 != ${sums[$i]})"
1159 run_test 15 "Rebind a list of files"
1162 # test needs a running copytool
1166 # create a known size file so we can verify transfer speed
1169 dd if=/dev/zero of=$ref bs=1M count=20
1172 local f=$DIR/$tdir/$tfile
1173 local fid=$(copy_file $ref $f)
1175 local start=$(date +%s)
1177 wait_request_state $fid ARCHIVE SUCCEED
1178 local end=$(date +%s)
1179 local duration=$((end - start))
1181 [[ $duration -ge $goal ]] ||
1182 error "Transfer is too fast $duration < $goal"
1186 run_test 16 "Test CT bandwith control option"
1191 local f=$DIR/$tdir/$tfile
1192 touch $f || error "touch $f failed"
1194 # Could not release a non-archived file
1195 $LFS hsm_release $f && error "release should not succeed"
1197 # For following tests, we must test them with HS_ARCHIVED set
1198 $LFS hsm_set --exists --archived $f || error "could not add flag"
1200 # Could not release a file if no-release is set
1201 $LFS hsm_set --norelease $f || error "could not add flag"
1202 $LFS hsm_release $f && error "release should not succeed"
1203 $LFS hsm_clear --norelease $f || error "could not remove flag"
1205 # Could not release a file if lost
1206 $LFS hsm_set --lost $f || error "could not add flag"
1207 $LFS hsm_release $f && error "release should not succeed"
1208 $LFS hsm_clear --lost $f || error "could not remove flag"
1210 # Could not release a file if dirty
1211 $LFS hsm_set --dirty $f || error "could not add flag"
1212 $LFS hsm_release $f && error "release should not succeed"
1213 $LFS hsm_clear --dirty $f || error "could not remove flag"
1215 run_test 20 "Release is not permitted"
1218 # test needs a running copytool
1222 local f=$DIR/$tdir/test_release
1224 # Create a file and check its states
1225 local fid=$(make_small $f)
1226 check_hsm_flags $f "0x00000000"
1228 $LFS hsm_archive $f || error "could not archive file"
1229 wait_request_state $fid ARCHIVE SUCCEED
1231 [ $(stat -c "%b" $f) -ne "0" ] || error "wrong block number"
1232 local sz=$(stat -c "%s" $f)
1233 [ $sz -ne "0" ] || error "file size should not be zero"
1235 # Release and check states
1236 $LFS hsm_release $f || error "could not release file"
1237 check_hsm_flags $f "0x0000000d"
1239 [ $(stat -c "%b" $f) -eq "0" ] || error "wrong block number"
1240 [ $(stat -c "%s" $f) -eq $sz ] || error "wrong file size"
1242 # Check we can release an file without stripe info
1246 check_hsm_flags $f "0x00000000"
1247 $LFS hsm_archive $f || error "could not archive file"
1248 wait_request_state $fid ARCHIVE SUCCEED
1250 # Release and check states
1251 $LFS hsm_release $f || error "could not release file"
1252 check_hsm_flags $f "0x0000000d"
1254 # Release again a file that is already released is OK
1255 $LFS hsm_release $f || fail "second release should succeed"
1256 check_hsm_flags $f "0x0000000d"
1260 run_test 21 "Simple release tests"
1263 # test needs a running copytool
1268 local f=$DIR/$tdir/test_release
1269 local swap=$DIR/$tdir/test_swap
1271 # Create a file and check its states
1272 local fid=$(make_small $f)
1273 check_hsm_flags $f "0x00000000"
1275 $LFS hsm_archive $f || error "could not archive file"
1276 wait_request_state $fid ARCHIVE SUCCEED
1278 # Release and check states
1279 $LFS hsm_release $f || error "could not release file"
1280 check_hsm_flags $f "0x0000000d"
1283 $LFS swap_layouts $swap $f && error "swap_layouts should failed"
1288 run_test 22 "Could not swap a release file"
1291 # test needs a running copytool
1296 local f=$DIR/$tdir/test_mtime
1298 # Create a file and check its states
1299 local fid=$(make_small $f)
1300 check_hsm_flags $f "0x00000000"
1302 $LFS hsm_archive $f || error "could not archive file"
1303 wait_request_state $fid ARCHIVE SUCCEED
1305 # Set modification time in the past
1306 touch -m -a -d @978261179 $f
1308 # Release and check states
1309 $LFS hsm_release $f || error "could not release file"
1310 check_hsm_flags $f "0x0000000d"
1312 local MTIME=$(stat -c "%Y" $f)
1313 local ATIME=$(stat -c "%X" $f)
1314 [ $MTIME -eq "978261179" ] || fail "bad mtime: $MTIME"
1315 [ $ATIME -eq "978261179" ] || fail "bad atime: $ATIME"
1319 run_test 23 "Release does not change a/mtime (utime)"
1322 local file=$DIR/$tdir/$tfile
1331 # test needs a running copytool
1336 fid=$(make_small $file)
1338 # Create a file and check its states
1339 check_hsm_flags $file "0x00000000"
1341 # Ensure atime is less than mtime and ctime.
1345 atime0=$(stat -c "%X" $file)
1346 mtime0=$(stat -c "%Y" $file)
1347 ctime0=$(stat -c "%Z" $file)
1349 [ $atime0 -lt $mtime0 ] ||
1350 error "atime $atime0 is not less than mtime $mtime0"
1352 [ $atime0 -lt $ctime0 ] ||
1353 error "atime $atime0 is not less than ctime $ctime0"
1355 # Archive should not change any timestamps.
1356 $LFS hsm_archive $file || error "cannot archive '$file'"
1357 wait_request_state $fid ARCHIVE SUCCEED
1359 atime1=$(stat -c "%X" $file)
1360 mtime1=$(stat -c "%Y" $file)
1361 ctime1=$(stat -c "%Z" $file)
1363 [ $atime0 -eq $atime1 ] ||
1364 error "archive changed atime from $atime0 to $atime1"
1366 [ $mtime0 -eq $mtime1 ] ||
1367 error "archive changed mtime from $mtime0 to $mtime1"
1369 [ $ctime0 -eq $ctime1 ] ||
1370 error "archive changed ctime from $ctime0 to $ctime1"
1372 # Release should not change any timestamps.
1373 $LFS hsm_release $file || error "cannot release '$file'"
1374 check_hsm_flags $file "0x0000000d"
1376 atime1=$(stat -c "%X" $file)
1377 mtime1=$(stat -c "%Y" $file)
1378 ctime1=$(stat -c "%Z" $file)
1380 [ $atime0 -eq $atime1 ] ||
1381 error "release changed atime from $atime0 to $atime1"
1383 [ $mtime0 -eq $mtime1 ] ||
1384 error "release changed mtime from $mtime0 to $mtime1"
1386 [ $ctime0 -eq $ctime1 ] ||
1387 error "release changed ctime from $ctime0 to $ctime1"
1389 # Restore should not change atime or mtime and should not
1391 $LFS hsm_restore $file
1392 wait_request_state $fid RESTORE SUCCEED
1394 atime1=$(stat -c "%X" $file)
1395 mtime1=$(stat -c "%Y" $file)
1396 ctime1=$(stat -c "%Z" $file)
1398 [ $atime0 -eq $atime1 ] ||
1399 error "restore changed atime from $atime0 to $atime1"
1401 [ $mtime0 -eq $mtime1 ] ||
1402 error "restore changed mtime from $mtime0 to $mtime1"
1404 [ $ctime0 -le $ctime1 ] ||
1405 error "restore changed ctime from $ctime0 to $ctime1"
1409 # Once more, after unmount and mount.
1410 umount_client $MOUNT || error "cannot unmount '$MOUNT'"
1411 mount_client $MOUNT || error "cannot mount '$MOUNT'"
1413 atime1=$(stat -c "%X" $file)
1414 mtime1=$(stat -c "%Y" $file)
1415 ctime1=$(stat -c "%Z" $file)
1417 [ $atime0 -eq $atime1 ] ||
1418 error "remount changed atime from $atime0 to $atime1"
1420 [ $mtime0 -eq $mtime1 ] ||
1421 error "remount changed mtime from $mtime0 to $mtime1"
1423 [ $ctime0 -le $ctime1 ] ||
1424 error "remount changed ctime from $ctime0 to $ctime1"
1426 run_test 24a "Archive, release, and restore does not change a/mtime (i/o)"
1429 local file=$DIR/$tdir/$tfile
1435 # Test needs a running copytool.
1439 # Check that root can do HSM actions on a ordinary user's file.
1441 fid=$(make_small $file)
1442 sum0=$(md5sum $file)
1444 chown $RUNAS_ID:$RUNAS_GID $file ||
1445 error "cannot chown '$file' to '$RUNAS_ID'"
1447 chmod ugo-w $DIR/$tdir ||
1448 error "cannot chmod '$DIR/$tdir'"
1450 $LFS hsm_archive $file
1451 wait_request_state $fid ARCHIVE SUCCEED
1453 $LFS hsm_release $file ||
1454 check_hsm_flags $file "0x0000000d"
1456 $LFS hsm_restore $file
1457 wait_request_state $fid RESTORE SUCCEED
1459 # Check that ordinary user can get HSM state.
1460 $RUNAS $LFS hsm_state $file ||
1461 error "user '$RUNAS_ID' cannot get HSM state of '$file'"
1463 $LFS hsm_release $file ||
1464 check_hsm_flags $file "0x0000000d"
1466 # Check that ordinary user can accessed released file.
1467 sum1=$($RUNAS md5sum $file) ||
1468 error "user '$RUNAS_ID' cannot read '$file'"
1470 [ "$sum0" == "$sum1" ] ||
1471 error "md5sum mismatch for '$file'"
1475 run_test 24b "root can archive, release, and restore user files"
1478 # test needs a running copytool
1481 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1482 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
1483 local f=$DIR/$tdir/$tfile
1485 import_file $tdir/$tfile $f
1487 $LFS hsm_set --lost $f
1492 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1496 run_test 25a "Restore lost file (HS_LOST flag) from import"\
1497 " (Operation not permitted)"
1500 # test needs a running copytool
1505 local f=$DIR/$tdir/$tfile
1506 local fid=$(copy_file /etc/passwd $f)
1508 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1509 wait_request_state $fid ARCHIVE SUCCEED
1512 $LFS hsm_set --lost $f
1516 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1520 run_test 25b "Restore lost file (HS_LOST flag) after release"\
1521 " (Operation not permitted)"
1524 # test needs a running copytool
1528 local f=$DIR/$tdir/$tfile
1529 local fid=$(make_large_for_progress $f)
1530 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1531 wait_request_state $fid ARCHIVE SUCCEED
1534 wait_request_state $fid REMOVE SUCCEED
1536 check_hsm_flags $f "0x00000000"
1540 run_test 26 "Remove the archive of a valid file"
1543 # test needs a running copytool
1547 make_archive $tdir/$tfile
1548 local f=$DIR/$tdir/$tfile
1549 import_file $tdir/$tfile $f
1550 local fid=$(path2fid $f)
1554 [[ $? != 0 ]] || error "Remove of a released file should fail"
1558 run_test 27a "Remove the archive of an imported file (Operation not permitted)"
1561 # test needs a running copytool
1565 local f=$DIR/$tdir/$tfile
1566 local fid=$(make_large_for_progress $f)
1567 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1568 wait_request_state $fid ARCHIVE SUCCEED
1573 [[ $? != 0 ]] || error "Remove of a released file should fail"
1577 run_test 27b "Remove the archive of a relased file (Operation not permitted)"
1580 # test needs a running copytool
1584 local f=$DIR/$tdir/$tfile
1585 local fid=$(make_large_for_progress $f)
1586 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1587 wait_request_state $fid ARCHIVE SUCCEED
1596 wait_request_state $fid REMOVE SUCCEED
1600 run_test 28 "Concurrent archive/file remove"
1603 # restore at exec cannot work on agent node (because of Linux kernel
1604 # protection of executables)
1605 need2clients || return 0
1607 # test needs a running copytool
1610 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1611 cp -p /bin/true $HSM_ARCHIVE/$tdir/$tfile
1612 local f=$DIR/$tdir/true
1613 import_file $tdir/$tfile $f
1615 local fid=$(path2fid $f)
1617 # set no retry action mode
1623 # remove no try action mode
1627 [[ $st == 0 ]] || error "Failed to exec a released file"
1631 run_test 30a "Restore at exec (import case)"
1634 # restore at exec cannot work on agent node (because of Linux kernel
1635 # protection of executables)
1636 need2clients || return 0
1638 # test needs a running copytool
1642 local f=$DIR/$tdir/true
1643 local fid=$(copy_file /bin/true $f)
1645 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1646 wait_request_state $fid ARCHIVE SUCCEED
1649 # set no retry action mode
1655 # remove no try action mode
1659 [[ $st == 0 ]] || error "Failed to exec a released file"
1663 run_test 30b "Restore at exec (release case)"
1665 restore_and_check_size() {
1668 local s=$(stat -c "%s" $f)
1670 local st=$(get_hsm_flags $f)
1674 while [[ "$st" != "0x00000009" && $cpt -le 10 ]]
1676 n=$(stat -c "%s" $f)
1677 # we echo in both cases to show stat is not
1681 echo "size seen is $n != $s"
1684 echo "size seen is right: $n == $s"
1686 st=$(get_hsm_flags $f)
1690 if [[ $cpt -lt 10 ]]
1692 echo " restore is too long"
1696 wait_request_state $fid RESTORE SUCCEED
1701 # test needs a running copytool
1706 make_archive $tdir/$tfile
1707 local f=$DIR/$tdir/$tfile
1708 import_file $tdir/$tfile $f
1709 local fid=$($LFS path2fid $f)
1710 HSM_ARCHIVE_PURGE=false copytool_setup
1712 restore_and_check_size $f $fid
1715 [[ $err -eq 0 ]] || error "File size changed during restore"
1719 run_test 31a "Import a large file and check size during restore"
1723 # test needs a running copytool
1728 local f=$DIR/$tdir/$tfile
1729 local fid=$(make_large_for_progress $f)
1730 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1731 wait_request_state $fid ARCHIVE SUCCEED
1734 restore_and_check_size $f $fid
1737 [[ $err -eq 0 ]] || error "File size changed during restore"
1741 run_test 31b "Restore a large unaligned file and check size during restore"
1744 # test needs a running copytool
1749 local f=$DIR/$tdir/$tfile
1750 local fid=$(make_large_for_progress_aligned $f)
1751 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1752 wait_request_state $fid ARCHIVE SUCCEED
1755 restore_and_check_size $f $fid
1758 [[ $err -eq 0 ]] || error "File size changed during restore"
1762 run_test 31c "Restore a large aligned file and check size during restore"
1765 # test needs a running copytool
1770 local f=$DIR/$tdir/$tfile
1771 local fid=$(make_large_for_progress $f)
1772 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1773 wait_request_state $fid ARCHIVE SUCCEED
1776 md5sum $f >/dev/null &
1778 wait_request_state $fid RESTORE STARTED
1783 # Check restore trigger process was killed
1784 local killed=$(ps -o pid,comm hp $pid >/dev/null)
1788 wait_request_state $fid RESTORE CANCELED
1789 wait_request_state $fid CANCEL SUCCEED
1792 error "Cannot kill process waiting for restore ($killed)"
1796 run_test 33 "Kill a restore waiting process"
1799 # test needs a running copytool
1804 local f=$DIR/$tdir/$tfile
1805 local fid=$(make_large_for_progress $f)
1806 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1807 wait_request_state $fid ARCHIVE SUCCEED
1810 md5sum $f >/dev/null &
1812 wait_request_state $fid RESTORE STARTED
1814 rm $f || error "rm $f failed"
1815 # rm must not block during restore
1816 wait_request_state $fid RESTORE STARTED
1818 wait_request_state $fid RESTORE SUCCEED
1819 # check md5sum pgm finished
1820 local there=$(ps -o pid,comm hp $pid >/dev/null)
1821 [[ -z $there ]] || error "Restore initiator does not exit"
1823 local rc=$(wait $pid)
1824 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
1828 run_test 34 "Remove file during restore"
1831 # test needs a running copytool
1836 local f=$DIR/$tdir/$tfile
1837 local f1=$DIR/$tdir/$tfile-1
1838 local fid=$(make_large_for_progress $f)
1839 local fid1=$(copy_file /etc/passwd $f1)
1840 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1841 wait_request_state $fid ARCHIVE SUCCEED
1844 md5sum $f >/dev/null &
1846 wait_request_state $fid RESTORE STARTED
1848 mv $f1 $f || error "mv $f1 $f failed"
1849 # mv must not block during restore
1850 wait_request_state $fid RESTORE STARTED
1852 wait_request_state $fid RESTORE SUCCEED
1853 # check md5sum pgm finished
1854 local there=$(ps -o pid,comm hp $pid >/dev/null)
1855 [[ -z $there ]] || error "Restore initiator does not exit"
1857 local rc=$(wait $pid)
1858 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
1861 [[ $fid2 == $fid1 ]] || error "Wrong fid after mv $fid2 != $fid1"
1865 run_test 35 "Overwrite file during restore"
1868 # test needs a running copytool
1873 local f=$DIR/$tdir/$tfile
1874 local fid=$(make_large_for_progress $f)
1875 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1876 wait_request_state $fid ARCHIVE SUCCEED
1879 md5sum $f >/dev/null &
1881 wait_request_state $fid RESTORE STARTED
1884 # rm must not block during restore
1885 wait_request_state $fid RESTORE STARTED
1887 wait_request_state $fid RESTORE SUCCEED
1888 # check md5sum pgm finished
1889 local there=$(ps -o pid,comm hp $pid >/dev/null)
1891 error "Restore initiator does not exit"
1893 local rc=$(wait $pid)
1895 error "Restore initiator failed with $rc"
1899 run_test 36 "Move file during restore"
1906 for n in $(seq 1 $count); do
1907 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $prefix.$n
1909 echo "$count archive requests submitted"
1913 local stream_count=4
1914 local file_count=100
1916 local f=$DIR/$tdir/$tfile
1921 for i in $(seq 1 $file_count); do
1922 for p in $(seq 1 $stream_count); do
1923 fid=$(copy_file /etc/hosts $f.$p.$i)
1927 # to be sure wait_all_done will not be mislead by previous tests
1929 wait_for_grace_delay
1931 # start archive streams in background (archive files in parallel)
1932 for p in $(seq 1 $stream_count); do
1933 multi_archive $f.$p $file_count &
1936 echo -n "Wait for all requests being enqueued..."
1942 run_test 40 "Parallel archive requests"
1945 # test needs a running copytool
1949 local f=$DIR/$tdir/$tfile
1950 local fid=$(copy_file /etc/motd $f 1)
1952 $LFS hsm_archive $f || error "could not archive file"
1953 wait_request_state $fid ARCHIVE SUCCEED
1954 check_hsm_flags $f "0x00000009"
1956 multiop_bg_pause $f O_c || error "multiop failed"
1960 client_up || client_up || true
1962 kill -USR1 $MULTIPID
1963 wait $MULTIPID || error "multiop close failed"
1965 check_hsm_flags $f "0x0000000b"
1969 run_test 52 "Opened for write file on an evicted client should be set dirty"
1972 # test needs a running copytool
1976 local f=$DIR/$tdir/$tfile
1977 local fid=$(copy_file /etc/motd $f 1)
1979 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
1980 error "could not archive file"
1981 wait_request_state $fid ARCHIVE SUCCEED
1982 check_hsm_flags $f "0x00000009"
1984 multiop_bg_pause $f o_c || error "multiop failed"
1988 client_up || client_up || true
1990 kill -USR1 $MULTIPID
1991 wait $MULTIPID || error "multiop close failed"
1993 check_hsm_flags $f "0x00000009"
1997 run_test 53 "Opened for read file on an evicted client should not be set dirty"
2000 # test needs a running copytool
2004 local f=$DIR/$tdir/$tfile
2005 local fid=$(make_small $f)
2007 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2008 error "could not archive file"
2009 wait_request_state $fid ARCHIVE STARTED
2011 check_hsm_flags $f "0x00000001"
2013 # Avoid coordinator resending this request as soon it has failed.
2018 wait_request_state $fid ARCHIVE FAILED
2020 check_hsm_flags $f "0x00000003"
2025 run_test 54 "Write during an archive cancels it"
2028 # test needs a running copytool
2032 local f=$DIR/$tdir/$tfile
2033 local fid=$(make_small $f)
2035 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2036 error "could not archive file"
2037 wait_request_state $fid ARCHIVE STARTED
2039 check_hsm_flags $f "0x00000001"
2041 # Avoid coordinator resending this request as soon it has failed.
2044 $TRUNCATE $f 1024 || error "truncate failed"
2046 wait_request_state $fid ARCHIVE FAILED
2048 check_hsm_flags $f "0x00000003"
2053 run_test 55 "Truncate during an archive cancels it"
2056 # test needs a running copytool
2060 local f=$DIR/$tdir/$tfile
2061 local fid=$(make_large_for_progress $f)
2063 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2064 error "could not archive file"
2065 wait_request_state $fid ARCHIVE STARTED
2067 check_hsm_flags $f "0x00000001"
2069 # Change metadata and sync to be sure we are not changing only
2074 wait_request_state $fid ARCHIVE SUCCEED
2076 check_hsm_flags $f "0x00000009"
2080 run_test 56 "Setattr during an archive is ok"
2083 # Need one client for I/O, one for request
2084 need2clients || return 0
2086 # test needs a running copytool
2090 local f=$DIR/$tdir/test_archive_remote
2091 # Create a file on a remote node
2092 do_node $CLIENT2 "dd if=/dev/urandom of=$f bs=1M "\
2093 "count=2 conv=fsync"
2096 do_node $CLIENT2 "$LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f" ||
2097 error "hsm_archive failed"
2098 local fid=$(path2fid $f)
2099 wait_request_state $fid ARCHIVE SUCCEED
2101 # Release and implicit restore it
2102 do_node $CLIENT2 "$LFS hsm_release $f" ||
2103 error "hsm_release failed"
2104 do_node $CLIENT2 "md5sum $f" ||
2105 error "hsm_restore failed"
2107 wait_request_state $fid RESTORE SUCCEED
2111 run_test 57 "Archive a file with dirty cache on another node"
2114 # test needs a running copytool
2118 local f=$DIR/$tdir/$tfile
2119 local fid=$(make_small $f)
2121 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2122 error "could not archive file"
2123 wait_request_state $fid ARCHIVE SUCCEED
2125 $LFS hsm_release $f || error "could not release file"
2127 $TRUNCATE $f 0 || error "truncate failed"
2130 local sz=$(stat -c %s $f)
2131 [[ $sz == 0 ]] || error "size after truncate is $sz != 0"
2135 check_hsm_flags $f "0x0000000b"
2137 local state=$(get_request_state $fid RESTORE)
2138 [[ "$state" == "" ]] ||
2139 error "truncate 0 trigs a restore, state = $state"
2143 run_test 58 "Truncate 0 on a released file must not trigger restore"
2146 # test needs a running copytool
2150 local f=$DIR/$tdir/$tfile
2151 local fid=$(copy_file /etc/passwd $f)
2154 local sz=$(stat -c %s $ref)
2158 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2159 error "could not archive file"
2160 wait_request_state $fid ARCHIVE SUCCEED
2162 $LFS hsm_release $f || error "could not release file"
2164 $TRUNCATE $f $sz || error "truncate failed"
2167 local sz1=$(stat -c %s $f)
2168 [[ $sz1 == $sz ]] || error "size after truncate is $sz1 != $sz"
2172 check_hsm_flags $f "0x0000000b"
2174 local state=$(get_request_state $fid RESTORE)
2175 [[ "$state" == "SUCCEED" ]] ||
2176 error "truncate $sz does not trig a successfull restore,"\
2179 cmp $ref $f || error "file data wrong after truncate"
2183 run_test 59 "Truncate != 0 on a released file"
2188 local f=$DIR/$tdir/$tfile
2189 local FILELIST=/tmp/filelist.txt
2193 for i in $(seq 1 $file_count); do
2194 fid=$(copy_file /etc/hosts $f.$i)
2195 echo $f.$i >> $FILELIST
2198 # to be sure wait_all_done will not be mislead by previous tests
2200 wait_for_grace_delay
2201 $LFS hsm_archive --filelist $FILELIST ||
2202 error "cannot archive a file list"
2204 $LFS hsm_release --filelist $FILELIST ||
2205 error "cannot release a file list"
2206 $LFS hsm_restore --filelist $FILELIST ||
2207 error "cannot restore a file list"
2211 run_test 90 "Archive/restore a file list"
2213 double_verify_reset_hsm_param() {
2215 echo "Testing $HSM_PARAM.$p"
2216 local val=$(get_hsm_param $p)
2218 local val2=$(($val * 2))
2219 set_hsm_param $p $val2
2220 val=$(get_hsm_param $p)
2221 [[ $val == $val2 ]] ||
2222 error "$HSM_PARAM.$p: $val != $val2 should be (2 * $save)"
2223 echo "Set $p to 0 must failed"
2227 set_hsm_param $p $save
2231 error "we must not be able to set $HSM_PARAM.$p to 0"
2236 double_verify_reset_hsm_param loop_period
2237 double_verify_reset_hsm_param grace_delay
2238 double_verify_reset_hsm_param request_timeout
2239 double_verify_reset_hsm_param max_requests
2240 double_verify_reset_hsm_param archive_id
2242 run_test 100 "Set coordinator /proc tunables"
2249 run_test 102 "Verify coordinator control"
2252 # test needs a running copytool
2259 for i in $(seq 1 20); do
2260 fid=$(copy_file /etc/passwd $DIR/$tdir/$i)
2262 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/*
2266 echo "Current requests"
2267 local res=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2268 $HSM_PARAM.agent_actions |\
2269 grep -v CANCELED | grep -v SUCCEED | grep -v FAILED")
2271 [[ -z "$res" ]] || error "Some request have not been canceled"
2275 run_test 103 "Purge all requests"
2280 # test needs a running copytool
2284 local f=$DIR/$tdir/$tfile
2285 local fid=$(make_large_for_progress $f)
2286 # if cdt is on, it can serve too quickly the request
2288 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER --data $DATA $f
2289 local data1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2290 $HSM_PARAM.agent_actions |\
2291 grep $fid | cut -f16 -d=")
2294 [[ "$data1" == "$DATAHEX" ]] ||
2295 error "Data field in records is ($data1) and not ($DATAHEX)"
2299 run_test 104 "Copy tool data field"
2306 for i in $(seq -w 1 10); do
2307 cp /etc/passwd $DIR/$tdir/$i
2308 $LFS hsm_archive $DIR/$tdir/$i
2310 local reqcnt1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2311 $HSM_PARAM.agent_actions |\
2312 grep WAITING | wc -l")
2315 local reqcnt2=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2316 $HSM_PARAM.agent_actions |\
2317 grep WAITING | wc -l")
2320 [[ "$reqcnt1" == "$reqcnt2" ]] ||
2321 error "Requests count after shutdown $reqcnt2 != "\
2322 "before shutdown $reqcnt1"
2324 run_test 105 "Restart of coordinator"
2327 # test needs a running copytool
2330 local uuid=$(do_rpc_nodes $(facet_active_host $SINGLEAGT) \
2331 get_client_uuid | cut -d' ' -f2)
2332 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2335 [[ ! -z "$agent" ]] || error "My uuid $uuid not found in agent list"
2336 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2338 [[ -z "$agent" ]] ||
2339 error "My uuid $uuid still found in agent list,"\
2340 " after copytool shutdown"
2342 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2345 [[ ! -z "$agent" ]] ||
2346 error "My uuid $uuid not found in agent list after"\
2349 run_test 106 "Copytool register/unregister"
2352 # test needs a running copytool
2354 # create and archive file
2356 local f1=$DIR/$tdir/$tfile
2357 local fid=$(copy_file /etc/passwd $f1)
2358 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2359 wait_request_state $fid ARCHIVE SUCCEED
2360 # shutdown and restart MDS
2362 # check the copytool still gets messages from MDT
2363 local f2=$DIR/$tdir/2
2364 local fid=$(copy_file /etc/passwd $f2)
2365 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f2
2366 # main check of this sanity: this request MUST succeed
2367 wait_request_state $fid ARCHIVE SUCCEED
2370 run_test 107 "Copytool re-register after MDS restart"
2373 # test needs a running copytool
2376 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2377 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2378 local f=$DIR/$tdir/$tfile
2379 import_file $tdir/$tfile $f
2380 local fid=$(path2fid $f)
2382 cdt_set_no_blocking_restore
2387 wait_request_state $fid RESTORE SUCCEED
2388 cdt_clear_no_blocking_restore
2392 error "md5sum returns $st != 1, "\
2393 "should also perror ENODATA (No data available)"
2397 run_test 110a "Non blocking restore policy (import case)"
2400 # test needs a running copytool
2404 local f=$DIR/$tdir/$tfile
2405 local fid=$(copy_file /etc/passwd $f)
2406 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2407 wait_request_state $fid ARCHIVE SUCCEED
2410 cdt_set_no_blocking_restore
2415 wait_request_state $fid RESTORE SUCCEED
2416 cdt_clear_no_blocking_restore
2420 error "md5sum returns $st != 1, "\
2421 "should also perror ENODATA (No data available)"
2425 run_test 110b "Non blocking restore policy (release case)"
2428 # test needs a running copytool
2431 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2432 local f=$DIR/$tdir/$tfile
2433 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2434 import_file $tdir/$tfile $f
2435 local fid=$(path2fid $f)
2439 copytool_remove_backend $fid
2442 wait_request_state $fid RESTORE FAILED
2449 [[ $st == 0 ]] || error "Restore does not failed"
2453 run_test 111a "No retry policy (import case), restore will error"\
2454 " (No such file or directory)"
2457 # test needs a running copytool
2461 local f=$DIR/$tdir/$tfile
2462 local fid=$(copy_file /etc/passwd $f)
2464 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2465 wait_request_state $fid ARCHIVE SUCCEED
2468 copytool_remove_backend $fid
2471 wait_request_state $fid RESTORE FAILED
2478 [[ $st == 0 ]] || error "Restore does not failed"
2482 run_test 111b "No retry policy (release case), restore will error"\
2483 " (No such file or directory)"
2486 # test needs a running copytool
2490 local f=$DIR/$tdir/$tfile
2491 local fid=$(copy_file /etc/passwd $f)
2493 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2494 local l=$($LFS hsm_action $f)
2496 local res=$(echo $l | cut -f 2- -d" " | grep ARCHIVE)
2500 wait_request_state $fid ARCHIVE SUCCEED
2503 [[ ! -z "$res" ]] || error "action is $l which is not an ARCHIVE"
2507 run_test 112 "State of recorded request"
2510 # test needs a running copytool
2514 local f=$DIR/$tdir/$tfile
2515 local fid=$(make_large_for_cancel $f)
2516 # test with cdt on is made in test_221
2518 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2521 wait_request_state $fid ARCHIVE CANCELED
2522 wait_request_state $fid CANCEL SUCCEED
2526 run_test 200 "Register/Cancel archive"
2529 # test needs a running copytool
2533 local f=$DIR/$tdir/$tfile
2534 make_archive $tdir/$tfile
2535 import_file $tdir/$tfile $f
2536 local fid=$(path2fid $f)
2538 # test with cdt on is made in test_222
2543 wait_request_state $fid RESTORE CANCELED
2544 wait_request_state $fid CANCEL SUCCEED
2548 run_test 201 "Register/Cancel restore"
2551 # test needs a running copytool
2555 local f=$DIR/$tdir/$tfile
2556 local fid=$(make_large_for_progress $f)
2557 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2558 wait_request_state $fid ARCHIVE SUCCEED
2564 wait_request_state $fid REMOVE CANCELED
2568 run_test 202 "Register/Cancel remove"
2571 # test needs a running copytool
2576 local f=$DIR/$tdir/$tfile
2577 local fid=$(copy_file /etc/passwd $f)
2581 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2582 wait_request_state $fid ARCHIVE SUCCEED
2584 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2588 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2592 run_test 220 "Changelog for archive"
2595 # test needs a running copytool
2600 local f=$DIR/$tdir/$tfile
2601 local fid=$(make_large_for_cancel $f)
2605 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2606 wait_request_state $fid ARCHIVE STARTED
2608 wait_request_state $fid ARCHIVE CANCELED
2609 wait_request_state $fid CANCEL SUCCEED
2611 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2614 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2618 run_test 221 "Changelog for archive canceled"
2621 # test needs a running copytool
2624 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2625 local f=$DIR/$tdir/$tfile
2626 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2627 import_file $tdir/$tfile $f
2628 local fid=$(path2fid $f)
2633 wait_request_state $fid RESTORE SUCCEED
2635 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2638 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2642 run_test 222a "Changelog for explicit restore"
2645 # test needs a running copytool
2649 local f=$DIR/$tdir/$tfile
2650 local fid=$(copy_file /etc/passwd $f)
2653 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2654 wait_request_state $fid ARCHIVE SUCCEED
2659 wait_request_state $fid RESTORE SUCCEED
2661 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2664 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2668 run_test 222b "Changelog for implicit restore"
2671 # test needs a running copytool
2676 local f=$DIR/$tdir/$tfile
2677 make_archive $tdir/$tfile
2681 import_file $tdir/$tfile $f
2682 local fid=$(path2fid $f)
2685 wait_request_state $fid RESTORE STARTED
2687 wait_request_state $fid RESTORE CANCELED
2688 wait_request_state $fid CANCEL SUCCEED
2690 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2693 [[ $flags == $target ]] ||
2694 error "Changelog flag is $flags not $target"
2698 run_test 223a "Changelog for restore canceled (import case)"
2701 # test needs a running copytool
2706 local f=$DIR/$tdir/$tfile
2707 local fid=$(make_large_for_progress $f)
2710 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2711 wait_request_state $fid ARCHIVE SUCCEED
2714 wait_request_state $fid RESTORE STARTED
2716 wait_request_state $fid RESTORE CANCELED
2717 wait_request_state $fid CANCEL SUCCEED
2719 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2722 [[ $flags == $target ]] ||
2723 error "Changelog flag is $flags not $target"
2727 run_test 223b "Changelog for restore canceled (release case)"
2730 # test needs a running copytool
2735 local f=$DIR/$tdir/$tfile
2736 local fid=$(copy_file /etc/passwd $f)
2739 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2740 wait_request_state $fid ARCHIVE SUCCEED
2743 wait_request_state $fid REMOVE SUCCEED
2745 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2748 [[ $flags == $target ]] ||
2749 error "Changelog flag is $flags not $target"
2753 run_test 224 "Changelog for remove"
2756 # test needs a running copytool
2759 # test is not usable because remove request is too fast
2760 # so it is always finished before cancel can be done ...
2761 echo "Test disabled"
2766 local f=$DIR/$tdir/$tfile
2767 local fid=$(make_large_for_progress $f)
2770 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2771 wait_request_state $fid ARCHIVE SUCCEED
2773 # if cdt is on, it can serve too quickly the request
2778 wait_request_state $fid REMOVE CANCELED
2779 wait_request_state $fid CANCEL SUCCEED
2781 flags=$(changelog_get_flags $MDT0 RENME $fid2)
2782 local flags=$($LFS changelog $MDT0 | grep HSM | grep $fid | tail -1 |
2786 [[ $flags == $target ]] ||
2787 error "Changelog flag is $flags not $target"
2791 run_test 225 "Changelog for remove canceled"
2794 # test needs a running copytool
2799 local f1=$DIR/$tdir/$tfile-1
2800 local f2=$DIR/$tdir/$tfile-2
2801 local f3=$DIR/$tdir/$tfile-3
2802 local fid1=$(copy_file /etc/passwd $f1)
2803 local fid2=$(copy_file /etc/passwd $f2)
2804 copy_file /etc/passwd $f3
2807 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2808 wait_request_state $fid1 ARCHIVE SUCCEED
2810 $LFS hsm_archive $f2
2811 wait_request_state $fid2 ARCHIVE SUCCEED
2813 rm $f1 || error "rm $f1 failed"
2815 local flags=$(changelog_get_flags $MDT0 UNLNK $fid1)
2818 [[ $flags == $target ]] ||
2819 error "Changelog flag is $flags not $target"
2821 mv $f3 $f2 || error "mv $f3 $f2 failed"
2823 flags=$(changelog_get_flags $MDT0 RENME $fid2)
2826 [[ $flags == $target ]] ||
2827 error "Changelog flag is $flags not $target"
2831 run_test 226 "changelog for last rm/mv with exiting archive"
2833 check_flags_changes() {
2841 $LFS hsm_set --$hsm_flag $f ||
2842 error "Cannot set $hsm_flag on $f"
2843 local flags=($(changelog_get_flags $MDT0 HSM $fid))
2844 local seen=${#flags[*]}
2846 [[ $seen == $cnt ]] ||
2847 error "set $hsm_flag: Changelog events $seen != $cnt"
2848 [[ ${flags[$((cnt - 1))]} == $target ]] ||
2849 error "set $hsm_flag: Changelog flags are "\
2850 "${flags[$((cnt - 1))]} not $target"
2852 $LFS hsm_clear --$hsm_flag $f ||
2853 error "Cannot clear $hsm_flag on $f"
2854 flags=($(changelog_get_flags $MDT0 HSM $fid))
2857 [[ $cnt == $seen ]] ||
2858 error "clear $hsm_flag: Changelog events $seen != $cnt"
2860 [[ ${flags[$((cnt - 1))]} == $target ]] ||
2861 error "clear $hsm_flag: Changelog flag is "\
2862 "${flags[$((cnt - 1))]} not $target"
2866 # test needs a running copytool
2873 for i in norelease noarchive exists archived
2875 local f=$DIR/$tdir/$tfile-$i
2876 local fid=$(copy_file /etc/passwd $f)
2877 check_flags_changes $f $fid $i 0 1
2880 f=$DIR/$tdir/$tfile---lost
2881 fid=$(copy_file /etc/passwd $f)
2882 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2883 wait_request_state $fid ARCHIVE SUCCEED
2884 check_flags_changes $f $fid lost 3 1
2888 run_test 227 "changelog when explicit setting of HSM flags"
2891 # test needs a running copytool
2895 local maxrequest=$(get_hsm_param max_requests)
2896 local rqcnt=$(($maxrequest * 3))
2900 for i in $(seq -w 1 $rqcnt); do
2902 dd if=/dev/urandom of=$DIR/$tdir/$i bs=1M count=10 conv=fsync
2904 # we do it in 2 steps, so all requests arrive at the same time
2905 for i in $(seq -w 1 $rqcnt); do
2906 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$i
2911 while [[ $cnt != 0 || $wt != 0 ]]; do
2913 cnt=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2914 $HSM_PARAM.agent_actions |\
2915 grep STARTED | grep -v CANCEL | wc -l")
2916 [[ $cnt -le $maxrequest ]] ||
2917 error "$cnt > $maxrequest too many started requests"
2918 wt=$(do_facet $SINGLEMDS "$LCTL get_param\
2919 $HSM_PARAM.agent_actions |\
2920 grep WAITING | wc -l")
2921 echo "max=$maxrequest started=$cnt waiting=$wt"
2926 run_test 250 "Coordinator max request"
2929 # test needs a running copytool
2933 local f=$DIR/$tdir/$tfile
2934 local fid=$(make_large_for_cancel $f)
2937 # to have a short test
2938 local old_to=$(get_hsm_param request_timeout)
2939 set_hsm_param request_timeout 4
2940 # to be sure the cdt will wake up frequently so
2941 # it will be able to cancel the "old" request
2942 local old_loop=$(get_hsm_param loop_period)
2943 set_hsm_param loop_period 2
2946 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2947 wait_request_state $fid ARCHIVE STARTED
2949 wait_request_state $fid ARCHIVE CANCELED
2951 set_hsm_param request_timeout $old_to
2952 set_hsm_param loop_period $old_loop
2956 run_test 251 "Coordinator request timeout"
2959 # the only way to test ondisk conf is to restart MDS ...
2960 echo "Stop coordinator and remove coordinator state at mount"
2963 # clean on disk conf set by default
2964 cdt_clear_mount_state
2965 cdt_check_state stopped
2967 # check cdt still off after umount/remount
2969 cdt_check_state stopped
2971 echo "Set coordinator start at mount, and start coordinator"
2972 cdt_set_mount_state enabled
2975 cdt_check_state enabled
2977 # check cdt still on after umount/remount
2979 cdt_check_state enabled
2981 # we are back to original state (cdt started at mount)
2983 run_test 300 "On disk coordinator state kept between MDT umount/mount"
2988 check_and_cleanup_lustre