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"
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.
117 cdt_set_sanity_policy
120 search_and_kill_copytool() {
121 local agents=${1:-$(facet_active_host $SINGLEAGT)}
123 echo "Killing existing copytools on $agents"
124 do_nodesv $agents "killall -q $HSMTOOL_BASE" || true
128 local facet=${1:-$SINGLEAGT}
129 local lustre_mntpnt=${2:-$MOUNT}
131 local hsm_root=$(copytool_device $facet)
132 local agent=$(facet_active_host $facet)
134 if [[ -z "$arc_id" ]] &&
135 do_facet $facet "pkill -CONT -x $HSMTOOL_BASE"; then
136 echo "Wakeup copytool $facet on $agent"
140 if $HSM_ARCHIVE_PURGE; then
141 echo "Purging archive on $agent"
142 do_facet $facet "rm -rf $hsm_root/*"
145 echo "Starting copytool $facet on $agent"
146 do_facet $facet "mkdir -p $hsm_root" || error "mkdir '$hsm_root' failed"
147 # bandwidth is limited to 1MB/s so the copy time is known and
148 # independent of hardware
149 local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --hsm-root $hsm_root"
150 [[ -z "$arc_id" ]] || cmd+=" --archive $arc_id"
151 cmd+=" --bandwidth 1 $lustre_mntpnt"
153 # Redirect the standard output and error to a log file which
154 # can be uploaded to Maloo.
155 local prefix=$TESTLOG_PREFIX
156 [[ -z "$TESTNAME" ]] || prefix=$prefix.$TESTNAME
157 local copytool_log=$prefix.copytool${arc_id}_log.$agent.log
159 do_facet $facet "$cmd < /dev/null > $copytool_log 2>&1" ||
160 error "start copytool $facet on $agent failed"
166 local agents=${1:-$(facet_active_host $SINGLEAGT)}
168 do_nodesv $agents "pkill -INT -x $HSMTOOL_BASE" || return 0
170 echo "Copytool is stopped on $agents"
174 local agents=${1:-$(facet_active_host $SINGLEAGT)}
176 do_nodesv $agents "pkill -STOP -x $HSMTOOL_BASE" || return 0
177 echo "Copytool is suspended on $agents"
180 copytool_remove_backend() {
182 local be=$(find $HSM_ARCHIVE -name $fid)
183 echo "Remove from backend: $fid = $be"
188 do_facet $SINGLEAGT \
189 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
190 --import $1 $2 $MOUNT" ||
191 error "import of $1 to $2 failed"
195 local file=$HSM_ARCHIVE/$1
196 mkdir -p $(dirname $file)
197 dd if=/dev/urandom of=$file count=32 bs=1000000 ||
198 error "cannot create $file"
202 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0\
203 changelog_register -n)
204 do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog_mask="+hsm"
205 $LFS changelog_clear $MDT0 $CL_USER 0
208 changelog_cleanup() {
209 # $LFS changelog $MDT0
210 [[ -n "$CL_USER" ]] || return 0
212 $LFS changelog_clear $MDT0 $CL_USER 0
213 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
217 changelog_get_flags() {
222 $LFS changelog $mdt | awk "/$cltype/ && /t=\[$fid\]/ {print \$5}"
227 local val=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.$param)
234 do_facet $SINGLEMDS $LCTL set_param -n $HSM_PARAM.$param=$value
241 do_facet $SINGLEMDS $LCTL set_param $MDT_PARAM.hsm_control=$cmd
242 wait_result $SINGLEMDS "$LCTL get_param -n $MDT_PARAM.hsm_control"\
243 $target 10 || error "cdt state is not $target"
246 cdt_set_sanity_policy() {
247 if [[ "$CDT_POLICY_HAD_CHANGED" ]]
250 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+NRA
251 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-NBR
252 CDT_POLICY_HAD_CHANGED=
257 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+NRA
258 CDT_POLICY_HAD_CHANGED=true
261 cdt_clear_no_retry() {
262 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-NRA
263 CDT_POLICY_HAD_CHANGED=true
266 cdt_set_non_blocking_restore() {
267 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+NBR
268 CDT_POLICY_HAD_CHANGED=true
271 cdt_clear_non_blocking_restore() {
272 do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-NBR
273 CDT_POLICY_HAD_CHANGED=true
276 cdt_clear_mount_state() {
277 # /!\ conf_param and set_param syntax differ +> we cannot use
279 do_facet $SINGLEMDS $LCTL conf_param -d $FSNAME-MDT0000.mdt.hsm_control
282 cdt_set_mount_state() {
283 # /!\ conf_param and set_param syntax differ +> we cannot use
285 do_facet $SINGLEMDS $LCTL conf_param $FSNAME-MDT0000.mdt.hsm_control=$1
290 wait_result $SINGLEMDS\
291 "$LCTL get_param -n $MDT_PARAM.hsm_control" "$target" 20 ||
292 error "cdt state is not $target"
296 set_test_state disabled disabled
300 set_test_state enabled enabled
304 set_test_state shutdown stopped
308 set_test_state purge enabled
314 cdt_set_sanity_policy
319 if [[ $CLIENTCOUNT -lt $clnt_count ]]; then
320 skip "Need $clnt_count or more clients, have $CLIENTCOUNT"
327 $LFS path2fid $1 | tr -d '[]'
334 if [[ $u == "user" ]]
336 local st=$($RUNAS $LFS hsm_state $f)
338 local st=$($LFS hsm_state $f)
342 [[ $? == 0 ]] || error "$LFS hsm_state $f failed (run as $u)"
344 st=$(echo $st | cut -f 2 -d" " | tr -d "()," )
348 get_hsm_archive_id() {
350 local st=$($LFS hsm_state $f)
351 [[ $? == 0 ]] || error "$LFS hsm_state $f failed"
353 local ar=$(echo $st | grep "archive_id" | cut -f5 -d" " |
362 local st=$(get_hsm_flags $f)
363 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
366 check_hsm_flags_user() {
370 local st=$(get_hsm_flags $f user)
371 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
389 cp $1 $f || error "cannot copy $1 to $f"
390 path2fid $f || error "cannot get fid on $f"
394 local file2=${1/$DIR/$DIR2}
395 dd if=/dev/urandom of=$file2 count=2 bs=1M conv=fsync ||
396 error "cannot create $file2"
397 path2fid $1 || error "cannot get fid on $1"
400 cleanup_large_files() {
401 local ratio=$(df $MOUNT |awk '{print $5}' |sed 's/%//g' |grep -v Use)
402 [ $ratio -gt 50 ] && find $MOUNT -size +10M -exec rm -f {} \;
405 make_large_for_striping() {
406 local file2=${1/$DIR/$DIR2}
407 local sz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -1)
411 dd if=/dev/urandom of=$file2 count=5 bs=$sz conv=fsync ||
412 error "cannot create $file2"
413 path2fid $1 || error "cannot get fid on $1"
416 make_large_for_progress() {
417 local file2=${1/$DIR/$DIR2}
421 # big file is large enough, so copy time is > 30s
422 # so copytool make 1 progress
423 # size is not a multiple of 1M to avoid stripe
425 dd if=/dev/urandom of=$file2 count=39 bs=1000000 conv=fsync ||
426 error "cannot create $file2"
427 path2fid $1 || error "cannot get fid on $1"
430 make_large_for_progress_aligned() {
431 local file2=${1/$DIR/$DIR2}
435 # big file is large enough, so copy time is > 30s
436 # so copytool make 1 progress
437 # size is a multiple of 1M to have stripe
439 dd if=/dev/urandom of=$file2 count=33 bs=1M conv=fsync ||
440 error "cannot create $file2"
441 path2fid $1 || error "cannot get fid on $1"
444 make_large_for_cancel() {
445 local file2=${1/$DIR/$DIR2}
449 # Copy timeout is 100s. 105MB => 105s
450 dd if=/dev/urandom of=$file2 count=103 bs=1M conv=fsync ||
451 error "cannot create $file2"
452 path2fid $1 || error "cannot get fid on $1"
458 wait_update --verbose $(facet_active_host $facet) "$@"
461 wait_request_state() {
466 local cmd="$LCTL get_param -n $HSM_PARAM.agent_actions"
467 cmd+=" | awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
469 wait_result $SINGLEMDS "$cmd" $state 100 ||
470 error "request on $fid is not $state"
473 get_request_state() {
477 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.agent_actions |"\
478 "awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
481 get_request_count() {
485 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.agent_actions |"\
486 "awk -vn=0 '/'$fid'.*action='$request'/ {n++}; END {print n}'"
492 local cmd="$LCTL get_param -n $HSM_PARAM.agent_actions"
493 cmd+=" | egrep 'WAITING|STARTED'"
495 wait_result $SINGLEMDS "$cmd" "" $timeout ||
496 error "requests did not complete"
499 wait_for_grace_delay() {
500 local val=$(get_hsm_param grace_delay)
504 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
505 awk '{gsub(/_UUID/,""); print $1}' | head -1)
510 # cleanup from previous bad setup
511 search_and_kill_copytool
513 # for recovery tests, coordinator needs to be started at mount
515 # the lustre conf must be without hsm on (like for sanity.sh)
516 echo "Set HSM on and start"
517 cdt_set_mount_state enabled
518 cdt_check_state enabled
520 echo "Start copytool"
523 echo "Set sanity-hsm HSM policy"
524 cdt_set_sanity_policy
526 # finished requests are quickly removed from list
527 set_hsm_param grace_delay 10
533 local f=$DIR/$tdir/$tfile
537 check_hsm_flags_user $f "0x00000000"
539 $RUNAS $LFS hsm_set --norelease $f ||
540 error "user could not change hsm flags"
541 check_hsm_flags_user $f "0x00000010"
543 $RUNAS $LFS hsm_clear --norelease $f ||
544 error "user could not clear hsm flags"
545 check_hsm_flags_user $f "0x00000000"
547 # User could not change those flags...
548 $RUNAS $LFS hsm_set --exists $f &&
549 error "user should not set this flag"
550 check_hsm_flags_user $f "0x00000000"
553 $LFS hsm_set --exists $f ||
554 error "root could not change hsm flags"
555 check_hsm_flags_user $f "0x00000001"
557 $LFS hsm_clear --exists $f ||
558 error "root could not clear hsm state"
559 check_hsm_flags_user $f "0x00000000"
562 run_test 1 "lfs hsm flags root/non-root access"
566 local f=$DIR/$tdir/$tfile
568 # 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 || error "user could not change hsm flags"
573 check_hsm_flags $f "0x00000001"
575 # chmod do not put the file dirty
576 chmod 600 $f || error "could not chmod test file"
577 check_hsm_flags $f "0x00000001"
579 # chown do not put the file dirty
580 chown $RUNAS_ID $f || error "could not chown test file"
581 check_hsm_flags $f "0x00000001"
583 # truncate put the file dirty
584 $TRUNCATE $f 1 || error "could not truncate test file"
585 check_hsm_flags $f "0x00000003"
587 $LFS hsm_clear --dirty $f || error "could not clear hsm flags"
588 check_hsm_flags $f "0x00000001"
590 run_test 2 "Check file dirtyness when doing setattr"
596 # New files are not dirty
598 check_hsm_flags $f "0x00000000"
600 # For test, we simulate an archived file.
601 $LFS hsm_set --exists $f ||
602 error "user could not change hsm flags"
603 check_hsm_flags $f "0x00000001"
605 # Reading a file, does not set dirty
606 cat $f > /dev/null || error "could not read file"
607 check_hsm_flags $f "0x00000001"
609 # Open for write without modifying data, does not set dirty
610 openfile -f O_WRONLY $f || error "could not open test file"
611 check_hsm_flags $f "0x00000001"
613 # Append to a file sets it dirty
614 cp -p /etc/passwd $f.append || error "could not create file"
615 $LFS hsm_set --exists $f.append ||
616 error "user could not change hsm flags"
617 dd if=/etc/passwd of=$f.append bs=1 count=3\
618 conv=notrunc oflag=append status=noxfer ||
619 error "could not append to test file"
620 check_hsm_flags $f.append "0x00000003"
622 # Modify a file sets it dirty
623 cp -p /etc/passwd $f.modify || error "could not create file"
624 $LFS hsm_set --exists $f.modify ||
625 error "user could not change hsm flags"
626 dd if=/dev/zero of=$f.modify bs=1 count=3\
627 conv=notrunc status=noxfer ||
628 error "could not modify test file"
629 check_hsm_flags $f.modify "0x00000003"
631 # Open O_TRUNC sets dirty
632 cp -p /etc/passwd $f.trunc || error "could not create file"
633 $LFS hsm_set --exists $f.trunc ||
634 error "user could not change hsm flags"
635 cp /etc/group $f.trunc || error "could not override a file"
636 check_hsm_flags $f.trunc "0x00000003"
638 # Mmapped a file sets dirty
639 cp -p /etc/passwd $f.mmap || error "could not create file"
640 $LFS hsm_set --exists $f.mmap ||
641 error "user could not change hsm flags"
642 multiop $f.mmap OSMWUc || error "could not mmap a file"
643 check_hsm_flags $f.mmap "0x00000003"
645 run_test 3 "Check file dirtyness when opening for write"
649 local f=$DIR/$tdir/$tfile
650 local fid=$(make_small $f)
653 local st=$(get_request_state $fid CANCEL)
654 [[ -z "$st" ]] || error "hsm_cancel must not be registered (state=$st)"
656 run_test 4 "Useless cancel must not be registered"
659 # test needs a running copytool
663 local f=$DIR/$tdir/$tfile
664 local fid=$(copy_file /etc/passwd $f)
666 wait_request_state $fid ARCHIVE SUCCEED
668 check_hsm_flags $f "0x00000009"
672 run_test 8 "Test default archive number"
676 local f=$DIR/$tdir/$tfile
677 local fid=$(copy_file /etc/passwd $f)
678 # we do not use the default one to be sure
679 local new_an=$((HSM_ARCHIVE_NUMBER + 1))
681 copytool_setup $SINGLEAGT $MOUNT $new_an
682 $LFS hsm_archive --archive $new_an $f
683 wait_request_state $fid ARCHIVE SUCCEED
685 check_hsm_flags $f "0x00000009"
689 run_test 9 "Use of explict archive number, with dedicated copytool"
692 needclients 3 || return 0
698 copytool_cleanup $(comma_list $(agts_nodes))
700 # start all of the copytools
701 for n in $(seq $AGTCOUNT); do
705 trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
708 for n in $(seq $AGTCOUNT); do
709 file=$DIR/$tdir/$tfile.$n
710 fid=$(make_small $file)
712 $LFS hsm_archive $file || error "could not archive file $file"
713 wait_request_state $fid ARCHIVE SUCCEED
714 check_hsm_flags $file "0x00000009"
718 copytool_cleanup $(comma_list $(agts_nodes))
720 run_test 9a "Multiple remote agents"
723 # test needs a running copytool
726 mkdir -p $DIR/$tdir/d1
727 local f=$DIR/$tdir/$tfile
728 local fid=$(copy_file /etc/hosts $f)
729 $LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f ||
730 error "hsm_archive failed"
731 wait_request_state $fid ARCHIVE SUCCEED
733 local AFILE=$(ls $HSM_ARCHIVE/*/*/*/*/*/*/$fid) ||
734 error "fid $fid not in archive $HSM_ARCHIVE"
735 echo "Verifying content"
736 diff $f $AFILE || error "archived file differs"
737 echo "Verifying hsm state "
738 check_hsm_flags $f "0x00000009"
740 echo "Verifying archive number is $HSM_ARCHIVE_NUMBER"
741 local st=$(get_hsm_archive_id $f)
742 [[ $st == $HSM_ARCHIVE_NUMBER ]] ||
743 error "Wrong archive number, $st != $HSM_ARCHIVE_NUMBER"
748 run_test 10a "Archive a file"
751 # test needs a running copytool
754 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
755 local f=$DIR/$tdir/$tfile
756 local fid=$(copy_file /etc/hosts $f)
757 $LFS hsm_archive $f || error "archive request failed"
758 wait_request_state $fid ARCHIVE SUCCEED
760 $LFS hsm_archive $f || error "archive of non dirty file failed"
761 local cnt=$(get_request_count $fid ARCHIVE)
762 [[ "$cnt" == "1" ]] ||
763 error "archive of non dirty file must not make a request"
767 run_test 10b "Archive of non dirty file must work without doing request"
770 # test needs a running copytool
773 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
774 local f=$DIR/$tdir/$tfile
775 local fid=$(copy_file /etc/hosts $f)
776 $LFS hsm_set --noarchive $f
777 $LFS hsm_archive $f && error "archive a noarchive file must fail"
781 run_test 10c "Check forbidden archive"
784 # test needs a running copytool
788 local f=$DIR/$tdir/$tfile
789 local fid=$(copy_file /etc/hosts $f)
790 $LFS hsm_archive $f || error "cannot archive $f"
791 wait_request_state $fid ARCHIVE SUCCEED
793 local ar=$(get_hsm_archive_id $f)
794 local dflt=$(get_hsm_param archive_id)
795 [[ $ar == $dflt ]] ||
796 error "archived file is not on default archive: $ar != $dflt"
800 run_test 10d "Archive a file on the default archive id"
803 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
804 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
805 local f=$DIR/$tdir/$tfile
807 import_file $tdir/$tfile $f
808 echo -n "Verifying released state: "
809 check_hsm_flags $f "0x0000000d"
811 local LSZ=$(stat -c "%s" $f)
812 local ASZ=$(stat -c "%s" $HSM_ARCHIVE/$tdir/$tfile)
814 echo "Verifying imported size $LSZ=$ASZ"
815 [[ $LSZ -eq $ASZ ]] || error "Incorrect size $LSZ != $ASZ"
816 echo -n "Verifying released pattern: "
817 local PTRN=$($GETSTRIPE -L $f)
819 [[ $PTRN == 80000001 ]] || error "Is not released"
820 local fid=$(path2fid $f)
821 echo "Verifying new fid $fid in archive"
823 local AFILE=$(ls $HSM_ARCHIVE/*/*/*/*/*/*/$fid) ||
824 error "fid $fid not in archive $HSM_ARCHIVE"
826 run_test 11 "Import a file"
829 # test needs a running copytool
832 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
833 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
834 local f=$DIR/$tdir/$tfile
835 import_file $tdir/$tfile $f
836 local f=$DIR2/$tdir/$tfile
837 echo "Verifying released state: "
838 check_hsm_flags $f "0x0000000d"
840 local fid=$(path2fid $f)
842 wait_request_state $fid RESTORE SUCCEED
844 echo "Verifying file state: "
845 check_hsm_flags $f "0x00000009"
847 diff -q $HSM_ARCHIVE/$tdir/$tfile $f
849 [[ $? -eq 0 ]] || error "Restored file differs"
853 run_test 12a "Restore an imported file explicitly"
856 # test needs a running copytool
859 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
860 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
861 local f=$DIR/$tdir/$tfile
862 import_file $tdir/$tfile $f
863 echo "Verifying released state: "
864 check_hsm_flags $f "0x0000000d"
866 cat $f > /dev/null || error "File read failed"
868 echo "Verifying file state after restore: "
869 check_hsm_flags $f "0x00000009"
871 diff -q $HSM_ARCHIVE/$tdir/$tfile $f
873 [[ $? -eq 0 ]] || error "Restored file differs"
877 run_test 12b "Restore an imported file implicitly"
880 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
882 # test needs a running copytool
886 local f=$DIR/$tdir/$tfile
887 $LFS setstripe -c 2 $f
888 local fid=$(make_large_for_striping $f)
889 local FILE_CRC=$(md5sum $f)
891 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
892 wait_request_state $fid ARCHIVE SUCCEED
893 $LFS hsm_release $f || error "release $f failed"
895 echo "$FILE_CRC" | md5sum -c
897 [[ $? -eq 0 ]] || error "Restored file differs"
901 run_test 12c "Restore a file with stripe of 2"
904 # test needs a running copytool
907 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
908 local f=$DIR/$tdir/$tfile
909 local fid=$(copy_file /etc/hosts $f)
910 $LFS hsm_restore $f || error "restore of non archived file failed"
911 local cnt=$(get_request_count $fid RESTORE)
912 [[ "$cnt" == "0" ]] ||
913 error "restore non archived must not make a request"
914 $LFS hsm_archive $f ||
915 error "archive request failed"
916 wait_request_state $fid ARCHIVE SUCCEED
917 $LFS hsm_restore $f ||
918 error "restore of non released file failed"
919 local cnt=$(get_request_count $fid RESTORE)
920 [[ "$cnt" == "0" ]] ||
921 error "restore a non dirty file must not make a request"
925 run_test 12d "Restore of a non archived, non released file must work"\
926 " without doing request"
929 # test needs a running copytool
932 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
933 local f=$DIR/$tdir/$tfile
934 local fid=$(copy_file /etc/hosts $f)
935 $LFS hsm_archive $f || error "archive request failed"
936 wait_request_state $fid ARCHIVE SUCCEED
943 $LFS hsm_restore $f && error "restore a dirty file must fail"
947 run_test 12e "Check forbidden restore"
950 # test needs a running copytool
954 local f=$DIR/$tdir/$tfile
955 local fid=$(copy_file /etc/hosts $f)
957 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
958 wait_request_state $fid ARCHIVE SUCCEED
959 $LFS hsm_release $f || error "release of $f failed"
961 wait_request_state $fid RESTORE SUCCEED
963 echo -n "Verifying file state: "
964 check_hsm_flags $f "0x00000009"
966 diff -q /etc/hosts $f
968 [[ $? -eq 0 ]] || error "Restored file differs"
972 run_test 12f "Restore a released file explicitly"
975 # test needs a running copytool
979 local f=$DIR/$tdir/$tfile
980 local fid=$(copy_file /etc/hosts $f)
982 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
983 wait_request_state $fid ARCHIVE SUCCEED
984 $LFS hsm_release $f || error "release of $f failed"
986 diff -q /etc/hosts $f
989 # we check we had a restore done
990 wait_request_state $fid RESTORE SUCCEED
992 [[ $st -eq 0 ]] || error "Restored file differs"
996 run_test 12g "Restore a released file implicitly"
999 needclients 2 || return 0
1001 # test needs a running copytool
1005 local f=$DIR/$tdir/$tfile
1006 local fid=$(copy_file /etc/hosts $f)
1008 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1009 wait_request_state $fid ARCHIVE SUCCEED
1010 $LFS hsm_release $f || error "release of $f failed"
1012 do_node $CLIENT2 diff -q /etc/hosts $f
1015 # we check we had a restore done
1016 wait_request_state $fid RESTORE SUCCEED
1018 [[ $st -eq 0 ]] || error "Restored file differs"
1022 run_test 12h "Restore a released file implicitly from a second node"
1025 # test needs a running copytool
1029 local f=$DIR/$tdir/$tfile
1030 local fid=$(copy_file /etc/passwd $f)
1031 $LFS hsm_archive $f || error "archive of $f failed"
1032 wait_request_state $fid ARCHIVE SUCCEED
1034 $LFS hsm_release $f || error "release of $f failed"
1038 [[ $? -eq 0 ]] || error "Restored file differs"
1042 run_test 12m "Archive/release/implicit restore"
1045 # test needs a running copytool
1048 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1049 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
1050 local f=$DIR/$tdir/$tfile
1051 import_file $tdir/$tfile $f
1053 cmp /etc/hosts $f || error "Restored file differs"
1055 $LFS hsm_release $f || error "release of $f failed"
1059 run_test 12n "Import/implicit restore/release"
1062 # test needs a running copytool
1065 local ARC_SUBDIR="import.orig"
1069 # populate directory to be imported
1070 for d in $(seq 1 10); do
1071 local CURR_DIR="$HSM_ARCHIVE/$ARC_SUBDIR/dir.$d"
1072 mkdir -p "$CURR_DIR"
1073 for f in $(seq 1 10); do
1074 CURR_FILE="$CURR_DIR/$tfile.$f"
1075 # write file-specific data
1076 echo "d=$d, f=$f, dir=$CURR_DIR, file=$CURR_FILE"\
1081 import_file "$ARC_SUBDIR" $DIR/$tdir
1082 # diff lustre content and origin (triggers file restoration)
1083 # there must be 10x10 identical files, and no difference
1084 local cnt_ok=$(diff -rs $HSM_ARCHIVE/$ARC_SUBDIR \
1085 $DIR/$tdir/$ARC_SUBDIR |
1086 grep identical | wc -l)
1087 local cnt_diff=$(diff -r $HSM_ARCHIVE/$ARC_SUBDIR \
1088 $DIR/$tdir/$ARC_SUBDIR |
1091 [ $cnt_diff -eq 0 ] ||
1092 error "$cnt_diff imported files differ from read data"
1093 [ $cnt_ok -eq 100 ] ||
1094 error "not enough identical files ($cnt_ok != 100)"
1098 run_test 13 "Recursively import and restore a directory"
1101 # test needs a running copytool
1106 local f=$DIR/$tdir/$tfile
1107 local fid=$(make_small $f)
1108 local sum=$(md5sum $f | awk '{print $1}')
1109 $LFS hsm_archive $f || error "could not archive file"
1110 wait_request_state $fid ARCHIVE SUCCEED
1114 # create released file (simulate llapi_hsm_import call)
1116 local fid2=$(path2fid $f)
1117 $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
1118 $LFS hsm_release $f || error "could not release file"
1120 # rebind the archive to the newly created file
1121 echo "rebind $fid to $fid2"
1123 do_facet $SINGLEAGT \
1124 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1125 --rebind $fid $fid2 $DIR" || error "could not rebind file"
1127 # restore file and compare md5sum
1128 local sum2=$(md5sum $f | awk '{print $1}')
1130 [[ $sum == $sum2 ]] || error "md5sum mismatch after restore"
1134 run_test 14 "Rebind archived file to a new fid"
1137 # test needs a running copytool
1142 local f=$DIR/$tdir/$tfile
1144 local tmpfile=$SHARED_DIRECTORY/tmp.$$
1148 for i in $(seq 1 $count); do
1149 fids[$i]=$(make_small $f.$i)
1150 sums[$i]=$(md5sum $f.$i | awk '{print $1}')
1151 $LFS hsm_archive $f.$i || error "could not archive file"
1153 wait_all_done $(($count*60))
1157 for i in $(seq 1 $count); do
1160 local fid2=$(path2fid $f.$i)
1161 # add the rebind operation to the list
1162 echo ${fids[$i]} $fid2 >> $tmpfile
1164 # set it released (simulate llapi_hsm_import call)
1165 $LFS hsm_set --archived --exists $f.$i ||
1166 error "could not force hsm flags"
1167 $LFS hsm_release $f.$i || error "could not release file"
1169 nl=$(wc -l < $tmpfile)
1170 [[ $nl == $count ]] || error "$nl files in list, $count expected"
1172 echo "rebind list of files"
1173 do_facet $SINGLEAGT \
1174 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1175 --rebind $tmpfile $DIR" || error "could not rebind file list"
1177 # restore files and compare md5sum
1178 for i in $(seq 1 $count); do
1179 local sum2=$(md5sum $f.$i | awk '{print $1}')
1180 [[ $sum2 == ${sums[$i]} ]] ||
1181 error "md5sum mismatch after restore ($sum2 != ${sums[$i]})"
1187 run_test 15 "Rebind a list of files"
1190 # test needs a running copytool
1194 # create a known size file so we can verify transfer speed
1197 dd if=/dev/zero of=$ref bs=1M count=20
1200 local f=$DIR/$tdir/$tfile
1201 local fid=$(copy_file $ref $f)
1203 local start=$(date +%s)
1205 wait_request_state $fid ARCHIVE SUCCEED
1206 local end=$(date +%s)
1207 local duration=$((end - start))
1209 [[ $duration -ge $goal ]] ||
1210 error "Transfer is too fast $duration < $goal"
1214 run_test 16 "Test CT bandwith control option"
1219 local f=$DIR/$tdir/$tfile
1220 touch $f || error "touch $f failed"
1222 # Could not release a non-archived file
1223 $LFS hsm_release $f && error "release should not succeed"
1225 # For following tests, we must test them with HS_ARCHIVED set
1226 $LFS hsm_set --exists --archived $f || error "could not add flag"
1228 # Could not release a file if no-release is set
1229 $LFS hsm_set --norelease $f || error "could not add flag"
1230 $LFS hsm_release $f && error "release should not succeed"
1231 $LFS hsm_clear --norelease $f || error "could not remove flag"
1233 # Could not release a file if lost
1234 $LFS hsm_set --lost $f || error "could not add flag"
1235 $LFS hsm_release $f && error "release should not succeed"
1236 $LFS hsm_clear --lost $f || error "could not remove flag"
1238 # Could not release a file if dirty
1239 $LFS hsm_set --dirty $f || error "could not add flag"
1240 $LFS hsm_release $f && error "release should not succeed"
1241 $LFS hsm_clear --dirty $f || error "could not remove flag"
1243 run_test 20 "Release is not permitted"
1246 # test needs a running copytool
1250 local f=$DIR/$tdir/test_release
1252 # Create a file and check its states
1253 local fid=$(make_small $f)
1254 check_hsm_flags $f "0x00000000"
1256 $LFS hsm_archive $f || error "could not archive file"
1257 wait_request_state $fid ARCHIVE SUCCEED
1259 [ $(stat -c "%b" $f) -ne "1" ] || error "wrong block number"
1260 local sz=$(stat -c "%s" $f)
1261 [ $sz -ne "0" ] || error "file size should not be zero"
1263 # Release and check states
1264 $LFS hsm_release $f || error "could not release file"
1265 check_hsm_flags $f "0x0000000d"
1267 [ $(stat -c "%b" $f) -eq "1" ] || error "wrong block number"
1268 [ $(stat -c "%s" $f) -eq $sz ] || error "wrong file size"
1270 # Check we can release an file without stripe info
1274 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"
1282 # Release again a file that is already released is OK
1283 $LFS hsm_release $f || fail "second release should succeed"
1284 check_hsm_flags $f "0x0000000d"
1288 run_test 21 "Simple release tests"
1291 # test needs a running copytool
1296 local f=$DIR/$tdir/test_release
1297 local swap=$DIR/$tdir/test_swap
1299 # Create a file and check its states
1300 local fid=$(make_small $f)
1301 check_hsm_flags $f "0x00000000"
1303 $LFS hsm_archive $f || error "could not archive file"
1304 wait_request_state $fid ARCHIVE SUCCEED
1306 # Release and check states
1307 $LFS hsm_release $f || error "could not release file"
1308 check_hsm_flags $f "0x0000000d"
1311 $LFS swap_layouts $swap $f && error "swap_layouts should failed"
1316 run_test 22 "Could not swap a release file"
1319 # test needs a running copytool
1324 local f=$DIR/$tdir/test_mtime
1326 # Create a file and check its states
1327 local fid=$(make_small $f)
1328 check_hsm_flags $f "0x00000000"
1330 $LFS hsm_archive $f || error "could not archive file"
1331 wait_request_state $fid ARCHIVE SUCCEED
1333 # Set modification time in the past
1334 touch -m -a -d @978261179 $f
1336 # Release and check states
1337 $LFS hsm_release $f || error "could not release file"
1338 check_hsm_flags $f "0x0000000d"
1340 local MTIME=$(stat -c "%Y" $f)
1341 local ATIME=$(stat -c "%X" $f)
1342 [ $MTIME -eq "978261179" ] || fail "bad mtime: $MTIME"
1343 [ $ATIME -eq "978261179" ] || fail "bad atime: $ATIME"
1347 run_test 23 "Release does not change a/mtime (utime)"
1350 local file=$DIR/$tdir/$tfile
1359 # test needs a running copytool
1364 fid=$(make_small $file)
1366 # Create a file and check its states
1367 check_hsm_flags $file "0x00000000"
1369 # Ensure atime is less than mtime and ctime.
1373 atime0=$(stat -c "%X" $file)
1374 mtime0=$(stat -c "%Y" $file)
1375 ctime0=$(stat -c "%Z" $file)
1377 [ $atime0 -lt $mtime0 ] ||
1378 error "atime $atime0 is not less than mtime $mtime0"
1380 [ $atime0 -lt $ctime0 ] ||
1381 error "atime $atime0 is not less than ctime $ctime0"
1383 # Archive should not change any timestamps.
1384 $LFS hsm_archive $file || error "cannot archive '$file'"
1385 wait_request_state $fid ARCHIVE SUCCEED
1387 atime1=$(stat -c "%X" $file)
1388 mtime1=$(stat -c "%Y" $file)
1389 ctime1=$(stat -c "%Z" $file)
1391 [ $atime0 -eq $atime1 ] ||
1392 error "archive changed atime from $atime0 to $atime1"
1394 [ $mtime0 -eq $mtime1 ] ||
1395 error "archive changed mtime from $mtime0 to $mtime1"
1397 [ $ctime0 -eq $ctime1 ] ||
1398 error "archive changed ctime from $ctime0 to $ctime1"
1400 # Release should not change any timestamps.
1401 $LFS hsm_release $file || error "cannot release '$file'"
1402 check_hsm_flags $file "0x0000000d"
1404 atime1=$(stat -c "%X" $file)
1405 mtime1=$(stat -c "%Y" $file)
1406 ctime1=$(stat -c "%Z" $file)
1408 [ $atime0 -eq $atime1 ] ||
1409 error "release changed atime from $atime0 to $atime1"
1411 [ $mtime0 -eq $mtime1 ] ||
1412 error "release changed mtime from $mtime0 to $mtime1"
1414 [ $ctime0 -eq $ctime1 ] ||
1415 error "release changed ctime from $ctime0 to $ctime1"
1417 # Restore should not change atime or mtime and should not
1419 $LFS hsm_restore $file
1420 wait_request_state $fid RESTORE SUCCEED
1422 atime1=$(stat -c "%X" $file)
1423 mtime1=$(stat -c "%Y" $file)
1424 ctime1=$(stat -c "%Z" $file)
1426 [ $atime0 -eq $atime1 ] ||
1427 error "restore changed atime from $atime0 to $atime1"
1429 [ $mtime0 -eq $mtime1 ] ||
1430 error "restore changed mtime from $mtime0 to $mtime1"
1432 [ $ctime0 -le $ctime1 ] ||
1433 error "restore changed ctime from $ctime0 to $ctime1"
1437 # Once more, after unmount and mount.
1438 umount_client $MOUNT || error "cannot unmount '$MOUNT'"
1439 mount_client $MOUNT || error "cannot mount '$MOUNT'"
1441 atime1=$(stat -c "%X" $file)
1442 mtime1=$(stat -c "%Y" $file)
1443 ctime1=$(stat -c "%Z" $file)
1445 [ $atime0 -eq $atime1 ] ||
1446 error "remount changed atime from $atime0 to $atime1"
1448 [ $mtime0 -eq $mtime1 ] ||
1449 error "remount changed mtime from $mtime0 to $mtime1"
1451 [ $ctime0 -le $ctime1 ] ||
1452 error "remount changed ctime from $ctime0 to $ctime1"
1454 run_test 24a "Archive, release, and restore does not change a/mtime (i/o)"
1457 local file=$DIR/$tdir/$tfile
1463 # Test needs a running copytool.
1467 # Check that root can do HSM actions on a ordinary user's file.
1469 fid=$(make_small $file)
1470 sum0=$(md5sum $file)
1472 chown $RUNAS_ID:$RUNAS_GID $file ||
1473 error "cannot chown '$file' to '$RUNAS_ID'"
1475 chmod ugo-w $DIR/$tdir ||
1476 error "cannot chmod '$DIR/$tdir'"
1478 $LFS hsm_archive $file
1479 wait_request_state $fid ARCHIVE SUCCEED
1481 $LFS hsm_release $file ||
1482 check_hsm_flags $file "0x0000000d"
1484 $LFS hsm_restore $file
1485 wait_request_state $fid RESTORE SUCCEED
1487 # Check that ordinary user can get HSM state.
1488 $RUNAS $LFS hsm_state $file ||
1489 error "user '$RUNAS_ID' cannot get HSM state of '$file'"
1491 $LFS hsm_release $file ||
1492 check_hsm_flags $file "0x0000000d"
1494 # Check that ordinary user can accessed released file.
1495 sum1=$($RUNAS md5sum $file) ||
1496 error "user '$RUNAS_ID' cannot read '$file'"
1498 [ "$sum0" == "$sum1" ] ||
1499 error "md5sum mismatch for '$file'"
1503 run_test 24b "root can archive, release, and restore user files"
1506 # test needs a running copytool
1509 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1510 cp /etc/hosts $HSM_ARCHIVE/$tdir/$tfile
1511 local f=$DIR/$tdir/$tfile
1513 import_file $tdir/$tfile $f
1515 $LFS hsm_set --lost $f
1520 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1524 run_test 25a "Restore lost file (HS_LOST flag) from import"\
1525 " (Operation not permitted)"
1528 # test needs a running copytool
1533 local f=$DIR/$tdir/$tfile
1534 local fid=$(copy_file /etc/passwd $f)
1536 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1537 wait_request_state $fid ARCHIVE SUCCEED
1540 $LFS hsm_set --lost $f
1544 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1548 run_test 25b "Restore lost file (HS_LOST flag) after release"\
1549 " (Operation not permitted)"
1552 # test needs a running copytool
1556 local f=$DIR/$tdir/$tfile
1557 local fid=$(make_large_for_progress $f)
1558 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1559 wait_request_state $fid ARCHIVE SUCCEED
1562 wait_request_state $fid REMOVE SUCCEED
1564 check_hsm_flags $f "0x00000000"
1568 run_test 26 "Remove the archive of a valid file"
1571 # test needs a running copytool
1575 make_archive $tdir/$tfile
1576 local f=$DIR/$tdir/$tfile
1577 import_file $tdir/$tfile $f
1578 local fid=$(path2fid $f)
1582 [[ $? != 0 ]] || error "Remove of a released file should fail"
1586 run_test 27a "Remove the archive of an imported file (Operation not permitted)"
1589 # test needs a running copytool
1593 local f=$DIR/$tdir/$tfile
1594 local fid=$(make_large_for_progress $f)
1595 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1596 wait_request_state $fid ARCHIVE SUCCEED
1601 [[ $? != 0 ]] || error "Remove of a released file should fail"
1605 run_test 27b "Remove the archive of a relased file (Operation not permitted)"
1608 # test needs a running copytool
1612 local f=$DIR/$tdir/$tfile
1613 local fid=$(make_large_for_progress $f)
1614 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1615 wait_request_state $fid ARCHIVE SUCCEED
1624 wait_request_state $fid REMOVE SUCCEED
1628 run_test 28 "Concurrent archive/file remove"
1631 # restore at exec cannot work on agent node (because of Linux kernel
1632 # protection of executables)
1633 needclients 2 || return 0
1635 # test needs a running copytool
1638 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1639 cp -p /bin/true $HSM_ARCHIVE/$tdir/$tfile
1640 local f=$DIR/$tdir/true
1641 import_file $tdir/$tfile $f
1643 local fid=$(path2fid $f)
1645 # set no retry action mode
1651 # remove no try action mode
1655 [[ $st == 0 ]] || error "Failed to exec a released file"
1659 run_test 30a "Restore at exec (import case)"
1662 # restore at exec cannot work on agent node (because of Linux kernel
1663 # protection of executables)
1664 needclients 2 || return 0
1666 # test needs a running copytool
1670 local f=$DIR/$tdir/true
1671 local fid=$(copy_file /bin/true $f)
1673 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1674 wait_request_state $fid ARCHIVE SUCCEED
1677 # set no retry action mode
1683 # remove no try action mode
1687 [[ $st == 0 ]] || error "Failed to exec a released file"
1691 run_test 30b "Restore at exec (release case)"
1693 restore_and_check_size() {
1696 local s=$(stat -c "%s" $f)
1698 local st=$(get_hsm_flags $f)
1702 while [[ "$st" != "0x00000009" && $cpt -le 10 ]]
1704 n=$(stat -c "%s" $f)
1705 # we echo in both cases to show stat is not
1709 echo "size seen is $n != $s"
1712 echo "size seen is right: $n == $s"
1714 st=$(get_hsm_flags $f)
1718 if [[ $cpt -lt 10 ]]
1720 echo " restore is too long"
1724 wait_request_state $fid RESTORE SUCCEED
1729 # test needs a running copytool
1734 make_archive $tdir/$tfile
1735 local f=$DIR/$tdir/$tfile
1736 import_file $tdir/$tfile $f
1737 local fid=$($LFS path2fid $f)
1738 HSM_ARCHIVE_PURGE=false copytool_setup
1740 restore_and_check_size $f $fid
1743 [[ $err -eq 0 ]] || error "File size changed during restore"
1747 run_test 31a "Import a large file and check size during restore"
1751 # test needs a running copytool
1756 local f=$DIR/$tdir/$tfile
1757 local fid=$(make_large_for_progress $f)
1758 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1759 wait_request_state $fid ARCHIVE SUCCEED
1762 restore_and_check_size $f $fid
1765 [[ $err -eq 0 ]] || error "File size changed during restore"
1769 run_test 31b "Restore a large unaligned file and check size during restore"
1772 # test needs a running copytool
1777 local f=$DIR/$tdir/$tfile
1778 local fid=$(make_large_for_progress_aligned $f)
1779 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1780 wait_request_state $fid ARCHIVE SUCCEED
1783 restore_and_check_size $f $fid
1786 [[ $err -eq 0 ]] || error "File size changed during restore"
1790 run_test 31c "Restore a large aligned file and check size during restore"
1793 # test needs a running copytool
1798 local f=$DIR/$tdir/$tfile
1799 local fid=$(make_large_for_progress $f)
1800 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1801 wait_request_state $fid ARCHIVE SUCCEED
1804 md5sum $f >/dev/null &
1806 wait_request_state $fid RESTORE STARTED
1811 # Check restore trigger process was killed
1812 local killed=$(ps -o pid,comm hp $pid >/dev/null)
1816 wait_request_state $fid RESTORE CANCELED
1817 wait_request_state $fid CANCEL SUCCEED
1820 error "Cannot kill process waiting for restore ($killed)"
1824 run_test 33 "Kill a restore waiting process"
1827 # test needs a running copytool
1832 local f=$DIR/$tdir/$tfile
1833 local fid=$(make_large_for_progress $f)
1834 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1835 wait_request_state $fid ARCHIVE SUCCEED
1838 md5sum $f >/dev/null &
1840 wait_request_state $fid RESTORE STARTED
1842 rm $f || error "rm $f failed"
1843 # rm must not block during restore
1844 wait_request_state $fid RESTORE STARTED
1846 wait_request_state $fid RESTORE SUCCEED
1847 # check md5sum pgm finished
1848 local there=$(ps -o pid,comm hp $pid >/dev/null)
1849 [[ -z $there ]] || error "Restore initiator does not exit"
1851 local rc=$(wait $pid)
1852 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
1856 run_test 34 "Remove file during restore"
1859 # test needs a running copytool
1864 local f=$DIR/$tdir/$tfile
1865 local f1=$DIR/$tdir/$tfile-1
1866 local fid=$(make_large_for_progress $f)
1867 local fid1=$(copy_file /etc/passwd $f1)
1868 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1869 wait_request_state $fid ARCHIVE SUCCEED
1872 md5sum $f >/dev/null &
1874 wait_request_state $fid RESTORE STARTED
1876 mv $f1 $f || error "mv $f1 $f failed"
1877 # mv must not block during restore
1878 wait_request_state $fid RESTORE STARTED
1880 wait_request_state $fid RESTORE SUCCEED
1881 # check md5sum pgm finished
1882 local there=$(ps -o pid,comm hp $pid >/dev/null)
1883 [[ -z $there ]] || error "Restore initiator does not exit"
1885 local rc=$(wait $pid)
1886 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
1889 [[ $fid2 == $fid1 ]] || error "Wrong fid after mv $fid2 != $fid1"
1893 run_test 35 "Overwrite file during restore"
1896 # test needs a running copytool
1901 local f=$DIR/$tdir/$tfile
1902 local fid=$(make_large_for_progress $f)
1903 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1904 wait_request_state $fid ARCHIVE SUCCEED
1907 md5sum $f >/dev/null &
1909 wait_request_state $fid RESTORE STARTED
1912 # rm must not block during restore
1913 wait_request_state $fid RESTORE STARTED
1915 wait_request_state $fid RESTORE SUCCEED
1916 # check md5sum pgm finished
1917 local there=$(ps -o pid,comm hp $pid >/dev/null)
1919 error "Restore initiator does not exit"
1921 local rc=$(wait $pid)
1923 error "Restore initiator failed with $rc"
1927 run_test 36 "Move file during restore"
1934 for n in $(seq 1 $count); do
1935 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $prefix.$n
1937 echo "$count archive requests submitted"
1941 local stream_count=4
1942 local file_count=100
1944 local f=$DIR/$tdir/$tfile
1949 for i in $(seq 1 $file_count); do
1950 for p in $(seq 1 $stream_count); do
1951 fid=$(copy_file /etc/hosts $f.$p.$i)
1955 # to be sure wait_all_done will not be mislead by previous tests
1957 wait_for_grace_delay
1959 # start archive streams in background (archive files in parallel)
1960 for p in $(seq 1 $stream_count); do
1961 multi_archive $f.$p $file_count &
1964 echo -n "Wait for all requests being enqueued..."
1970 run_test 40 "Parallel archive requests"
1973 # test needs a running copytool
1977 local f=$DIR/$tdir/$tfile
1978 local fid=$(copy_file /etc/motd $f 1)
1980 $LFS hsm_archive $f || 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 "0x0000000b"
1997 run_test 52 "Opened for write file on an evicted client should be set dirty"
2000 # test needs a running copytool
2004 local f=$DIR/$tdir/$tfile
2005 local fid=$(copy_file /etc/motd $f 1)
2007 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2008 error "could not archive file"
2009 wait_request_state $fid ARCHIVE SUCCEED
2010 check_hsm_flags $f "0x00000009"
2012 multiop_bg_pause $f o_c || error "multiop failed"
2016 client_up || client_up || true
2018 kill -USR1 $MULTIPID
2019 wait $MULTIPID || error "multiop close failed"
2021 check_hsm_flags $f "0x00000009"
2025 run_test 53 "Opened for read file on an evicted client should not be set dirty"
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.
2046 wait_request_state $fid ARCHIVE FAILED
2048 check_hsm_flags $f "0x00000003"
2053 run_test 54 "Write during an archive cancels it"
2056 # test needs a running copytool
2060 local f=$DIR/$tdir/$tfile
2061 local fid=$(make_small $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 # Avoid coordinator resending this request as soon it has failed.
2072 $TRUNCATE $f 1024 || error "truncate failed"
2074 wait_request_state $fid ARCHIVE FAILED
2076 check_hsm_flags $f "0x00000003"
2081 run_test 55 "Truncate during an archive cancels it"
2084 # test needs a running copytool
2088 local f=$DIR/$tdir/$tfile
2089 local fid=$(make_large_for_progress $f)
2091 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2092 error "could not archive file"
2093 wait_request_state $fid ARCHIVE STARTED
2095 check_hsm_flags $f "0x00000001"
2097 # Change metadata and sync to be sure we are not changing only
2102 wait_request_state $fid ARCHIVE SUCCEED
2104 check_hsm_flags $f "0x00000009"
2108 run_test 56 "Setattr during an archive is ok"
2111 # Need one client for I/O, one for request
2112 needclients 2 || return 0
2114 # test needs a running copytool
2118 local f=$DIR/$tdir/test_archive_remote
2119 # Create a file on a remote node
2120 do_node $CLIENT2 "dd if=/dev/urandom of=$f bs=1M "\
2121 "count=2 conv=fsync"
2124 do_node $CLIENT2 "$LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f" ||
2125 error "hsm_archive failed"
2126 local fid=$(path2fid $f)
2127 wait_request_state $fid ARCHIVE SUCCEED
2129 # Release and implicit restore it
2130 do_node $CLIENT2 "$LFS hsm_release $f" ||
2131 error "hsm_release failed"
2132 do_node $CLIENT2 "md5sum $f" ||
2133 error "hsm_restore failed"
2135 wait_request_state $fid RESTORE SUCCEED
2139 run_test 57 "Archive a file with dirty cache on another node"
2141 truncate_released_file() {
2145 local sz=$(stat -c %s $src_file)
2146 local f=$DIR/$tdir/$tfile
2147 local fid=$(copy_file $1 $f)
2151 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2152 error "could not archive file"
2153 wait_request_state $fid ARCHIVE SUCCEED
2155 $LFS hsm_release $f || error "could not release file"
2157 $TRUNCATE $f $trunc_to || error "truncate failed"
2160 local sz1=$(stat -c %s $f)
2161 [[ $sz1 == $trunc_to ]] ||
2162 error "size after trunc: $sz1 expect $trunc_to, original $sz"
2165 check_hsm_flags $f "0x0000000b"
2167 local state=$(get_request_state $fid RESTORE)
2168 [[ "$state" == "SUCCEED" ]] ||
2169 error "truncate $sz does not trig restore, state = $state"
2171 $TRUNCATE $ref $trunc_to
2172 cmp $ref $f || error "file data wrong after truncate"
2178 # test needs a running copytool
2183 local sz=$(stat -c %s /etc/passwd)
2185 echo "truncate up from $sz to $((sz*2))"
2186 truncate_released_file /etc/passwd $((sz*2))
2188 echo "truncate down from $sz to $((sz/2))"
2189 truncate_released_file /etc/passwd $((sz/2))
2191 echo "truncate to 0"
2192 truncate_released_file /etc/passwd 0
2196 run_test 58 "Truncate a released file will trigger restore"
2201 local f=$DIR/$tdir/$tfile
2202 local FILELIST=/tmp/filelist.txt
2206 for i in $(seq 1 $file_count); do
2207 fid=$(copy_file /etc/hosts $f.$i)
2208 echo $f.$i >> $FILELIST
2211 # to be sure wait_all_done will not be mislead by previous tests
2213 wait_for_grace_delay
2214 $LFS hsm_archive --filelist $FILELIST ||
2215 error "cannot archive a file list"
2217 $LFS hsm_release --filelist $FILELIST ||
2218 error "cannot release a file list"
2219 $LFS hsm_restore --filelist $FILELIST ||
2220 error "cannot restore a file list"
2224 run_test 90 "Archive/restore a file list"
2226 double_verify_reset_hsm_param() {
2228 echo "Testing $HSM_PARAM.$p"
2229 local val=$(get_hsm_param $p)
2231 local val2=$(($val * 2))
2232 set_hsm_param $p $val2
2233 val=$(get_hsm_param $p)
2234 [[ $val == $val2 ]] ||
2235 error "$HSM_PARAM.$p: $val != $val2 should be (2 * $save)"
2236 echo "Set $p to 0 must failed"
2240 set_hsm_param $p $save
2244 error "we must not be able to set $HSM_PARAM.$p to 0"
2249 double_verify_reset_hsm_param loop_period
2250 double_verify_reset_hsm_param grace_delay
2251 double_verify_reset_hsm_param request_timeout
2252 double_verify_reset_hsm_param max_requests
2253 double_verify_reset_hsm_param archive_id
2255 run_test 100 "Set coordinator /proc tunables"
2262 run_test 102 "Verify coordinator control"
2265 # test needs a running copytool
2272 for i in $(seq 1 20); do
2273 fid=$(copy_file /etc/passwd $DIR/$tdir/$i)
2275 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/*
2279 echo "Current requests"
2280 local res=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2281 $HSM_PARAM.agent_actions |\
2282 grep -v CANCELED | grep -v SUCCEED | grep -v FAILED")
2284 [[ -z "$res" ]] || error "Some request have not been canceled"
2288 run_test 103 "Purge all requests"
2293 # test needs a running copytool
2297 local f=$DIR/$tdir/$tfile
2298 local fid=$(make_large_for_progress $f)
2299 # if cdt is on, it can serve too quickly the request
2301 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER --data $DATA $f
2302 local data1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2303 $HSM_PARAM.agent_actions |\
2304 grep $fid | cut -f16 -d=")
2307 [[ "$data1" == "$DATAHEX" ]] ||
2308 error "Data field in records is ($data1) and not ($DATAHEX)"
2312 run_test 104 "Copy tool data field"
2319 for i in $(seq -w 1 10); do
2320 cp /etc/passwd $DIR/$tdir/$i
2321 $LFS hsm_archive $DIR/$tdir/$i
2323 local reqcnt1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2324 $HSM_PARAM.agent_actions |\
2325 grep WAITING | wc -l")
2328 local reqcnt2=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2329 $HSM_PARAM.agent_actions |\
2330 grep WAITING | wc -l")
2333 [[ "$reqcnt1" == "$reqcnt2" ]] ||
2334 error "Requests count after shutdown $reqcnt2 != "\
2335 "before shutdown $reqcnt1"
2337 run_test 105 "Restart of coordinator"
2340 # test needs a running copytool
2343 local uuid=$(do_rpc_nodes $(facet_active_host $SINGLEAGT) \
2344 get_client_uuid | cut -d' ' -f2)
2345 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2348 [[ ! -z "$agent" ]] || error "My uuid $uuid not found in agent list"
2349 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2351 [[ -z "$agent" ]] ||
2352 error "My uuid $uuid still found in agent list,"\
2353 " after copytool shutdown"
2355 local agent=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.agents |
2358 [[ ! -z "$agent" ]] ||
2359 error "My uuid $uuid not found in agent list after"\
2362 run_test 106 "Copytool register/unregister"
2365 # test needs a running copytool
2367 # create and archive file
2369 local f1=$DIR/$tdir/$tfile
2370 local fid=$(copy_file /etc/passwd $f1)
2371 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2372 wait_request_state $fid ARCHIVE SUCCEED
2373 # shutdown and restart MDS
2375 # check the copytool still gets messages from MDT
2376 local f2=$DIR/$tdir/2
2377 local fid=$(copy_file /etc/passwd $f2)
2378 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f2
2379 # main check of this sanity: this request MUST succeed
2380 wait_request_state $fid ARCHIVE SUCCEED
2383 run_test 107 "Copytool re-register after MDS restart"
2385 policy_set_and_test()
2389 do_facet $SINGLEMDS $LCTL set_param "$HSM_PARAM.policy=\\\"$change\\\""
2390 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2391 [[ "$policy" == "$target" ]] ||
2392 error "Wrong policy after '$change': '$policy' != '$target'"
2396 # to force default policy setting if error
2397 CDT_POLICY_HAD_CHANGED=true
2399 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2400 local default="NonBlockingRestore [NoRetryAction]"
2401 [[ "$policy" == "$default" ]] ||
2402 error "default policy has changed,"\
2403 " '$policy' != '$default' update the test"
2404 policy_set_and_test "+NBR" "[NonBlockingRestore] [NoRetryAction]"
2405 policy_set_and_test "+NRA" "[NonBlockingRestore] [NoRetryAction]"
2406 policy_set_and_test "-NBR" "NonBlockingRestore [NoRetryAction]"
2407 policy_set_and_test "-NRA" "NonBlockingRestore NoRetryAction"
2408 policy_set_and_test "NRA NBR" "[NonBlockingRestore] [NoRetryAction]"
2409 # useless bacause we know but safer for futur changes to use real value
2410 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2411 echo "Next set_param must failed"
2412 policy_set_and_test "wrong" "$policy"
2415 echo "Back to default policy"
2416 cdt_set_sanity_policy
2418 run_test 109 "Policy display/change"
2421 # test needs a running copytool
2424 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2425 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2426 local f=$DIR/$tdir/$tfile
2427 import_file $tdir/$tfile $f
2428 local fid=$(path2fid $f)
2430 cdt_set_non_blocking_restore
2435 wait_request_state $fid RESTORE SUCCEED
2436 cdt_clear_non_blocking_restore
2440 error "md5sum returns $st != 1, "\
2441 "should also perror ENODATA (No data available)"
2445 run_test 110a "Non blocking restore policy (import case)"
2448 # test needs a running copytool
2452 local f=$DIR/$tdir/$tfile
2453 local fid=$(copy_file /etc/passwd $f)
2454 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2455 wait_request_state $fid ARCHIVE SUCCEED
2458 cdt_set_non_blocking_restore
2463 wait_request_state $fid RESTORE SUCCEED
2464 cdt_clear_non_blocking_restore
2468 error "md5sum returns $st != 1, "\
2469 "should also perror ENODATA (No data available)"
2473 run_test 110b "Non blocking restore policy (release case)"
2476 # test needs a running copytool
2479 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2480 local f=$DIR/$tdir/$tfile
2481 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2482 import_file $tdir/$tfile $f
2483 local fid=$(path2fid $f)
2487 copytool_remove_backend $fid
2490 wait_request_state $fid RESTORE FAILED
2497 [[ $st == 0 ]] || error "Restore does not failed"
2501 run_test 111a "No retry policy (import case), restore will error"\
2502 " (No such file or directory)"
2505 # test needs a running copytool
2509 local f=$DIR/$tdir/$tfile
2510 local fid=$(copy_file /etc/passwd $f)
2512 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2513 wait_request_state $fid ARCHIVE SUCCEED
2516 copytool_remove_backend $fid
2519 wait_request_state $fid RESTORE FAILED
2526 [[ $st == 0 ]] || error "Restore does not failed"
2530 run_test 111b "No retry policy (release case), restore will error"\
2531 " (No such file or directory)"
2534 # test needs a running copytool
2538 local f=$DIR/$tdir/$tfile
2539 local fid=$(copy_file /etc/passwd $f)
2541 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2542 local l=$($LFS hsm_action $f)
2544 local res=$(echo $l | cut -f 2- -d" " | grep ARCHIVE)
2548 wait_request_state $fid ARCHIVE SUCCEED
2551 [[ ! -z "$res" ]] || error "action is $l which is not an ARCHIVE"
2555 run_test 112 "State of recorded request"
2558 # test needs a running copytool
2562 local f=$DIR/$tdir/$tfile
2563 local fid=$(make_large_for_cancel $f)
2564 # test with cdt on is made in test_221
2566 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2569 wait_request_state $fid ARCHIVE CANCELED
2570 wait_request_state $fid CANCEL SUCCEED
2574 run_test 200 "Register/Cancel archive"
2577 # test needs a running copytool
2581 local f=$DIR/$tdir/$tfile
2582 make_archive $tdir/$tfile
2583 import_file $tdir/$tfile $f
2584 local fid=$(path2fid $f)
2586 # test with cdt on is made in test_222
2591 wait_request_state $fid RESTORE CANCELED
2592 wait_request_state $fid CANCEL SUCCEED
2596 run_test 201 "Register/Cancel restore"
2599 # test needs a running copytool
2603 local f=$DIR/$tdir/$tfile
2604 local fid=$(make_large_for_progress $f)
2605 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2606 wait_request_state $fid ARCHIVE SUCCEED
2612 wait_request_state $fid REMOVE CANCELED
2616 run_test 202 "Register/Cancel remove"
2619 # test needs a running copytool
2624 local f=$DIR/$tdir/$tfile
2625 local fid=$(copy_file /etc/passwd $f)
2629 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2630 wait_request_state $fid ARCHIVE SUCCEED
2632 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2636 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2640 run_test 220 "Changelog for archive"
2643 # test needs a running copytool
2648 local f=$DIR/$tdir/$tfile
2649 local fid=$(make_large_for_cancel $f)
2653 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2654 wait_request_state $fid ARCHIVE STARTED
2656 wait_request_state $fid ARCHIVE CANCELED
2657 wait_request_state $fid CANCEL SUCCEED
2659 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2662 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2666 run_test 221 "Changelog for archive canceled"
2669 # test needs a running copytool
2672 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
2673 local f=$DIR/$tdir/$tfile
2674 cp /etc/passwd $HSM_ARCHIVE/$tdir/$tfile
2675 import_file $tdir/$tfile $f
2676 local fid=$(path2fid $f)
2681 wait_request_state $fid RESTORE SUCCEED
2683 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2686 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2690 run_test 222a "Changelog for explicit restore"
2693 # test needs a running copytool
2697 local f=$DIR/$tdir/$tfile
2698 local fid=$(copy_file /etc/passwd $f)
2701 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2702 wait_request_state $fid ARCHIVE SUCCEED
2707 wait_request_state $fid RESTORE SUCCEED
2709 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2712 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
2716 run_test 222b "Changelog for implicit restore"
2719 # test needs a running copytool
2724 local f=$DIR/$tdir/$tfile
2725 make_archive $tdir/$tfile
2729 import_file $tdir/$tfile $f
2730 local fid=$(path2fid $f)
2733 wait_request_state $fid RESTORE STARTED
2735 wait_request_state $fid RESTORE CANCELED
2736 wait_request_state $fid CANCEL SUCCEED
2738 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2741 [[ $flags == $target ]] ||
2742 error "Changelog flag is $flags not $target"
2746 run_test 223a "Changelog for restore canceled (import case)"
2749 # test needs a running copytool
2754 local f=$DIR/$tdir/$tfile
2755 local fid=$(make_large_for_progress $f)
2758 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2759 wait_request_state $fid ARCHIVE SUCCEED
2762 wait_request_state $fid RESTORE STARTED
2764 wait_request_state $fid RESTORE CANCELED
2765 wait_request_state $fid CANCEL SUCCEED
2767 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2770 [[ $flags == $target ]] ||
2771 error "Changelog flag is $flags not $target"
2775 run_test 223b "Changelog for restore canceled (release case)"
2778 # test needs a running copytool
2783 local f=$DIR/$tdir/$tfile
2784 local fid=$(copy_file /etc/passwd $f)
2787 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2788 wait_request_state $fid ARCHIVE SUCCEED
2791 wait_request_state $fid REMOVE SUCCEED
2793 local flags=$(changelog_get_flags $MDT0 HSM $fid | tail -1)
2796 [[ $flags == $target ]] ||
2797 error "Changelog flag is $flags not $target"
2801 run_test 224 "Changelog for remove"
2804 # test needs a running copytool
2807 # test is not usable because remove request is too fast
2808 # so it is always finished before cancel can be done ...
2809 echo "Test disabled"
2814 local f=$DIR/$tdir/$tfile
2815 local fid=$(make_large_for_progress $f)
2818 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2819 wait_request_state $fid ARCHIVE SUCCEED
2821 # if cdt is on, it can serve too quickly the request
2826 wait_request_state $fid REMOVE CANCELED
2827 wait_request_state $fid CANCEL SUCCEED
2829 flags=$(changelog_get_flags $MDT0 RENME $fid2)
2830 local flags=$($LFS changelog $MDT0 | grep HSM | grep $fid | tail -1 |
2834 [[ $flags == $target ]] ||
2835 error "Changelog flag is $flags not $target"
2839 run_test 225 "Changelog for remove canceled"
2842 # test needs a running copytool
2847 local f1=$DIR/$tdir/$tfile-1
2848 local f2=$DIR/$tdir/$tfile-2
2849 local f3=$DIR/$tdir/$tfile-3
2850 local fid1=$(copy_file /etc/passwd $f1)
2851 local fid2=$(copy_file /etc/passwd $f2)
2852 copy_file /etc/passwd $f3
2855 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2856 wait_request_state $fid1 ARCHIVE SUCCEED
2858 $LFS hsm_archive $f2
2859 wait_request_state $fid2 ARCHIVE SUCCEED
2861 rm $f1 || error "rm $f1 failed"
2863 local flags=$(changelog_get_flags $MDT0 UNLNK $fid1)
2866 [[ $flags == $target ]] ||
2867 error "Changelog flag is $flags not $target"
2869 mv $f3 $f2 || error "mv $f3 $f2 failed"
2871 flags=$(changelog_get_flags $MDT0 RENME $fid2)
2874 [[ $flags == $target ]] ||
2875 error "Changelog flag is $flags not $target"
2879 run_test 226 "changelog for last rm/mv with exiting archive"
2881 check_flags_changes() {
2889 $LFS hsm_set --$hsm_flag $f ||
2890 error "Cannot set $hsm_flag on $f"
2891 local flags=($(changelog_get_flags $MDT0 HSM $fid))
2892 local seen=${#flags[*]}
2894 [[ $seen == $cnt ]] ||
2895 error "set $hsm_flag: Changelog events $seen != $cnt"
2896 [[ ${flags[$((cnt - 1))]} == $target ]] ||
2897 error "set $hsm_flag: Changelog flags are "\
2898 "${flags[$((cnt - 1))]} not $target"
2900 $LFS hsm_clear --$hsm_flag $f ||
2901 error "Cannot clear $hsm_flag on $f"
2902 flags=($(changelog_get_flags $MDT0 HSM $fid))
2905 [[ $cnt == $seen ]] ||
2906 error "clear $hsm_flag: Changelog events $seen != $cnt"
2908 [[ ${flags[$((cnt - 1))]} == $target ]] ||
2909 error "clear $hsm_flag: Changelog flag is "\
2910 "${flags[$((cnt - 1))]} not $target"
2914 # test needs a running copytool
2921 for i in norelease noarchive exists archived
2923 local f=$DIR/$tdir/$tfile-$i
2924 local fid=$(copy_file /etc/passwd $f)
2925 check_flags_changes $f $fid $i 0 1
2928 f=$DIR/$tdir/$tfile---lost
2929 fid=$(copy_file /etc/passwd $f)
2930 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2931 wait_request_state $fid ARCHIVE SUCCEED
2932 check_flags_changes $f $fid lost 3 1
2936 run_test 227 "changelog when explicit setting of HSM flags"
2939 # test needs a running copytool
2943 local maxrequest=$(get_hsm_param max_requests)
2944 local rqcnt=$(($maxrequest * 3))
2948 for i in $(seq -w 1 $rqcnt); do
2950 dd if=/dev/urandom of=$DIR/$tdir/$i bs=1M count=10 conv=fsync
2952 # we do it in 2 steps, so all requests arrive at the same time
2953 for i in $(seq -w 1 $rqcnt); do
2954 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$i
2959 while [[ $cnt != 0 || $wt != 0 ]]; do
2961 cnt=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2962 $HSM_PARAM.agent_actions |\
2963 grep STARTED | grep -v CANCEL | wc -l")
2964 [[ $cnt -le $maxrequest ]] ||
2965 error "$cnt > $maxrequest too many started requests"
2966 wt=$(do_facet $SINGLEMDS "$LCTL get_param\
2967 $HSM_PARAM.agent_actions |\
2968 grep WAITING | wc -l")
2969 echo "max=$maxrequest started=$cnt waiting=$wt"
2974 run_test 250 "Coordinator max request"
2977 # test needs a running copytool
2981 local f=$DIR/$tdir/$tfile
2982 local fid=$(make_large_for_cancel $f)
2985 # to have a short test
2986 local old_to=$(get_hsm_param request_timeout)
2987 set_hsm_param request_timeout 4
2988 # to be sure the cdt will wake up frequently so
2989 # it will be able to cancel the "old" request
2990 local old_loop=$(get_hsm_param loop_period)
2991 set_hsm_param loop_period 2
2994 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2995 wait_request_state $fid ARCHIVE STARTED
2997 wait_request_state $fid ARCHIVE CANCELED
2999 set_hsm_param request_timeout $old_to
3000 set_hsm_param loop_period $old_loop
3004 run_test 251 "Coordinator request timeout"
3007 # the only way to test ondisk conf is to restart MDS ...
3008 echo "Stop coordinator and remove coordinator state at mount"
3011 # clean on disk conf set by default
3012 cdt_clear_mount_state
3013 cdt_check_state stopped
3015 # check cdt still off after umount/remount
3017 cdt_check_state stopped
3019 echo "Set coordinator start at mount, and start coordinator"
3020 cdt_set_mount_state enabled
3023 cdt_check_state enabled
3025 # check cdt still on after umount/remount
3027 cdt_check_state enabled
3029 # we are back to original state (cdt started at mount)
3031 run_test 300 "On disk coordinator state kept between MDT umount/mount"
3036 check_and_cleanup_lustre