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: 3815
15 ALWAYS_EXCEPT="$SANITY_HSM_EXCEPT 34 35 36"
16 # bug number for skipped test:4178 4176
17 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 200 221 223b 31a"
18 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
20 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
22 . $LUSTRE/tests/test-framework.sh
24 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
27 MULTIOP=${MULTIOP:-multiop}
28 OPENFILE=${OPENFILE:-openfile}
29 MCREATE=${MCREATE:-mcreate}
30 MOUNT_2=${MOUNT_2:-"yes"}
33 # script only handles up to 10 MDTs (because of MDT_PREFIX)
34 [ $MDSCOUNT -gt 9 ] &&
35 error "script cannot handle more than 9 MDTs, please fix" && exit
37 check_and_setup_lustre
39 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ]]; then
40 skip_env "Need MDS version at least 2.4.53" && exit
43 # $RUNAS_ID may get set incorrectly somewhere else
44 if [[ $UID -eq 0 && $RUNAS_ID -eq 0 ]]; then
45 skip_env "\$RUNAS_ID set to 0, but \$UID is also 0!" && exit
47 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
52 # In order to test multiple remote HSM agents, a new facet type named "AGT" and
53 # the following associated variables are added:
55 # AGTCOUNT: number of agents
56 # AGTDEV{N}: target HSM mount point (root path of the backend)
57 # agt{N}_HOST: hostname of the agent agt{N}
58 # SINGLEAGT: facet of the single agent
60 # The number of agents is initialized as the number of remote client nodes.
61 # By default, only single copytool is started on a remote client/agent. If there
62 # was no remote client, then the copytool will be started on the local client.
68 export AGTCOUNT=${AGTCOUNT:-$((CLIENTCOUNT - 1))}
69 [[ $AGTCOUNT -gt 0 ]] || AGTCOUNT=1
71 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-$TMP}
72 if [[ $CLIENTCOUNT -gt 1 ]] &&
73 ! check_shared_dir $SHARED_DIRECTORY $CLIENTS; then
74 skip_env "SHARED_DIRECTORY should be accessible"\
79 for n in $(seq $AGTCOUNT); do
80 eval export AGTDEV$n=\$\{AGTDEV$n:-"$SHARED_DIRECTORY/arc$n"\}
81 agent=CLIENT$((n + 1))
82 if [[ -z "${!agent}" ]]; then
83 [[ $CLIENTCOUNT -eq 1 ]] && agent=CLIENT1 ||
86 eval export agt${n}_HOST=\$\{agt${n}_HOST:-${!agent}\}
89 export SINGLEAGT=${SINGLEAGT:-agt1}
91 export HSMTOOL=${HSMTOOL:-"lhsmtool_posix"}
92 export HSMTOOL_VERBOSE=${HSMTOOL_VERBOSE:-""}
93 export HSMTOOL_UPDATE_INTERVAL=${HSMTOOL_UPDATE_INTERVAL:=""}
94 export HSMTOOL_BASE=$(basename "$HSMTOOL" | cut -f1 -d" ")
95 HSM_ARCHIVE=$(copytool_device $SINGLEAGT)
98 # The test only support up to 10 MDTs
99 MDT_PREFIX="mdt.$FSNAME-MDT000"
100 HSM_PARAM="${MDT_PREFIX}0.hsm"
102 # archive is purged at copytool setup
103 HSM_ARCHIVE_PURGE=true
106 # Get the backend root path for the given agent facet.
109 local dev=AGTDEV$(facet_number $facet)
114 # Stop copytool and unregister an existing changelog user.
118 cdt_set_sanity_policy
123 # get MDT device for each mdc
124 for mdtno in $(seq 1 $MDSCOUNT); do
125 local idx=$(($mdtno - 1))
126 MDT[$idx]=$($LCTL get_param -n \
127 mdc.$FSNAME-MDT000${idx}-mdc-*.mds_server_uuid |
128 awk '{gsub(/_UUID/,""); print $1}' | head -1)
133 local agents=${1:-$(facet_active_host $SINGLEAGT)}
134 do_nodesv $agents "pgrep -x $HSMTOOL_BASE"
137 search_and_kill_copytool() {
138 local agents=${1:-$(facet_active_host $SINGLEAGT)}
140 echo "Killing existing copytools on $agents"
141 do_nodesv $agents "killall -q $HSMTOOL_BASE" || true
145 local facet=${1:-$SINGLEAGT}
146 local lustre_mntpnt=${2:-$MOUNT}
148 local hsm_root=${4:-$(copytool_device $facet)}
149 local agent=$(facet_active_host $facet)
151 if [[ -z "$arc_id" ]] &&
152 do_facet $facet "pkill -CONT -x $HSMTOOL_BASE"; then
153 echo "Wakeup copytool $facet on $agent"
157 if $HSM_ARCHIVE_PURGE; then
158 echo "Purging archive on $agent"
159 do_facet $facet "rm -rf $hsm_root/*"
162 echo "Starting copytool $facet on $agent"
163 do_facet $facet "mkdir -p $hsm_root" || error "mkdir '$hsm_root' failed"
164 # bandwidth is limited to 1MB/s so the copy time is known and
165 # independent of hardware
166 local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --hsm-root $hsm_root"
167 [[ -z "$arc_id" ]] || cmd+=" --archive $arc_id"
168 [[ -z "$HSMTOOL_UPDATE_INTERVAL" ]] ||
169 cmd+=" --update-interval $HSMTOOL_UPDATE_INTERVAL"
170 cmd+=" --bandwidth 1 $lustre_mntpnt"
172 # Redirect the standard output and error to a log file which
173 # can be uploaded to Maloo.
174 local prefix=$TESTLOG_PREFIX
175 [[ -z "$TESTNAME" ]] || prefix=$prefix.$TESTNAME
176 local copytool_log=$prefix.copytool${arc_id}_log.$agent.log
178 do_facet $facet "$cmd < /dev/null > $copytool_log 2>&1" ||
179 error "start copytool $facet on $agent failed"
185 local agents=${1:-$(facet_active_host $SINGLEAGT)}
191 do_nodesv $agents "pkill -INT -x $HSMTOOL_BASE" || return 0
193 echo "Copytool is stopped on $agents"
195 # clean all CDTs orphans requests from previous tests
196 # that would otherwise need to timeout to clear.
197 for mdtno in $(seq 1 $MDSCOUNT); do
199 mdt_hsmctrl="mdt.$FSNAME-MDT000${idx}.hsm_control"
200 oldstate=$(do_facet mds${mdtno} "$LCTL get_param -n " \
202 # skip already stop[ed,ing] CDTs
203 echo $oldstate | grep stop && continue
205 do_facet mds${mdtno} "$LCTL set_param $mdt_hsmctrl=shutdown"
206 wait_result mds${mdtno} "$LCTL get_param -n $mdt_hsmctrl" \
208 error "mds${mdtno} cdt state is not stopped"
209 do_facet mds${mdtno} "$LCTL set_param $mdt_hsmctrl=$oldstate"
210 wait_result mds${mdtno} "$LCTL get_param -n $mdt_hsmctrl" \
212 error "mds${mdtno} cdt state is not $oldstate"
217 local agents=${1:-$(facet_active_host $SINGLEAGT)}
219 do_nodesv $agents "pkill -STOP -x $HSMTOOL_BASE" || return 0
220 echo "Copytool is suspended on $agents"
223 copytool_remove_backend() {
225 local be=$(do_facet $SINGLEAGT find $HSM_ARCHIVE -name $fid)
226 echo "Remove from backend: $fid = $be"
227 do_facet $SINGLEAGT rm -f $be
231 do_facet $SINGLEAGT \
232 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
233 --import $1 $2 $MOUNT" ||
234 error "import of $1 to $2 failed"
238 local file=$HSM_ARCHIVE/$1
239 do_facet $SINGLEAGT mkdir -p $(dirname $file)
240 do_facet $SINGLEAGT dd if=/dev/urandom of=$file count=32 bs=1000000 ||
241 error "cannot create $file"
245 local file=$HSM_ARCHIVE/$2
246 do_facet $SINGLEAGT mkdir -p $(dirname $file)
247 do_facet $SINGLEAGT cp -p $1 $file || error "cannot copy $1 to $file"
256 if [[ "$value" != "" ]]; then
259 for mdtno in $(seq 1 $MDSCOUNT); do
260 local idx=$(($mdtno - 1))
261 local facet=mds${mdtno}
262 # if $arg include -P option, run 1 set_param per MDT on the MGS
263 # else, run set_param on each MDT
264 [[ $arg = *"-P"* ]] && facet=mgs
265 do_facet $facet $LCTL set_param $arg mdt.${MDT[$idx]}.$key$value
266 [[ $? != 0 ]] && rc=1
276 for mdtno in $(seq 1 $MDSCOUNT); do
277 local idx=$(($mdtno - 1))
278 wait_result mds${mdtno} \
279 "$LCTL get_param -n $MDT_PREFIX${idx}.$key" "$target" \
281 error "$key state is not '$target' on mds${mdtno}"
288 for mdtno in $(seq 1 $MDSCOUNT); do
289 local idx=$(($mdtno - 1))
290 local cl_user=$(do_facet mds${mdtno} $LCTL \
291 --device ${MDT[$idx]} \
292 changelog_register -n)
294 do_facet mds${mdtno} lctl set_param \
295 mdd.${MDT[$idx]}.changelog_mask="+hsm"
296 $LFS changelog_clear ${MDT[$idx]} $cl_user 0
300 changelog_cleanup() {
302 for mdtno in $(seq 1 $MDSCOUNT); do
303 local idx=$(($mdtno - 1))
304 [[ -z ${CL_USERS[$idx]} ]] && continue
305 $LFS changelog_clear ${MDT[$idx]} ${CL_USERS[$idx]} 0
306 do_facet mds${mdtno} lctl --device ${MDT[$idx]} \
307 changelog_deregister ${CL_USERS[$idx]}
312 changelog_get_flags() {
317 $LFS changelog $mdt | awk "/$cltype/ && /t=\[$fid\]/ {print \$5}"
322 local val=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.$param)
330 mdts_set_param "$opt -n" "hsm.$param" "$value"
337 mdts_set_param "" hsm_control "$cmd"
338 mdts_check_param hsm_control "$target" 10
341 cdt_set_sanity_policy() {
342 if [[ "$CDT_POLICY_HAD_CHANGED" ]]
345 mdts_set_param "" hsm.policy "+NRA"
346 mdts_set_param "" hsm.policy "-NBR"
347 CDT_POLICY_HAD_CHANGED=
352 mdts_set_param "" hsm.policy "+NRA"
353 CDT_POLICY_HAD_CHANGED=true
356 cdt_clear_no_retry() {
357 mdts_set_param "" hsm.policy "-NRA"
358 CDT_POLICY_HAD_CHANGED=true
361 cdt_set_non_blocking_restore() {
362 mdts_set_param "" hsm.policy "+NBR"
363 CDT_POLICY_HAD_CHANGED=true
366 cdt_clear_non_blocking_restore() {
367 mdts_set_param "" hsm.policy "-NBR"
368 CDT_POLICY_HAD_CHANGED=true
371 cdt_clear_mount_state() {
372 mdts_set_param "-P -d" hsm_control ""
375 cdt_set_mount_state() {
376 mdts_set_param "-P" hsm_control "$1"
380 mdts_check_param hsm_control "$1" 20
384 set_test_state disabled disabled
388 set_test_state enabled enabled
392 set_test_state shutdown stopped
396 set_test_state purge enabled
402 cdt_set_sanity_policy
406 local client_count=$1
407 if [[ $CLIENTCOUNT -lt $client_count ]]; then
408 skip "Need $client_count or more clients, have $CLIENTCOUNT"
415 $LFS path2fid $1 | tr -d '[]'
422 if [[ $u == "user" ]]; then
423 local st=$($RUNAS $LFS hsm_state $f)
425 local st=$($LFS hsm_state $f)
429 [[ $? == 0 ]] || error "$LFS hsm_state $f failed (run as $u)"
431 st=$(echo $st | cut -f 2 -d" " | tr -d "()," )
435 get_hsm_archive_id() {
437 local st=$($LFS hsm_state $f)
438 [[ $? == 0 ]] || error "$LFS hsm_state $f failed"
440 local ar=$(echo $st | grep "archive_id" | cut -f5 -d" " |
449 local st=$(get_hsm_flags $f)
450 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
453 check_hsm_flags_user() {
457 local st=$(get_hsm_flags $f user)
458 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
470 if [[ "$3" != 1 ]]; then
474 cp $1 $f || error "cannot copy $1 to $f"
475 path2fid $f || error "cannot get fid on $f"
479 local file2=${1/$DIR/$DIR2}
480 dd if=/dev/urandom of=$file2 count=2 bs=1M conv=fsync ||
481 error "cannot create $file2"
482 path2fid $1 || error "cannot get fid on $1"
486 dd if=/dev/urandom of=$1 count=1 bs=1M conv=sync ||
487 error "cannot create $1"
488 path2fid $1 || error "cannot get fid on $1"
491 cleanup_large_files() {
492 local ratio=$(df -P $MOUNT | tail -1 | awk '{print $5}' |
494 [ $ratio -gt 50 ] && find $MOUNT -size +10M -exec rm -f {} \;
497 make_large_for_striping() {
498 local file2=${1/$DIR/$DIR2}
499 local sz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -1)
503 dd if=/dev/urandom of=$file2 count=5 bs=$sz conv=fsync ||
504 error "cannot create $file2"
505 path2fid $1 || error "cannot get fid on $1"
508 make_large_for_progress() {
509 local file2=${1/$DIR/$DIR2}
513 # big file is large enough, so copy time is > 30s
514 # so copytool make 1 progress
515 # size is not a multiple of 1M to avoid stripe
517 dd if=/dev/urandom of=$file2 count=39 bs=1000000 conv=fsync ||
518 error "cannot create $file2"
519 path2fid $1 || error "cannot get fid on $1"
522 make_large_for_progress_aligned() {
523 local file2=${1/$DIR/$DIR2}
527 # big file is large enough, so copy time is > 30s
528 # so copytool make 1 progress
529 # size is a multiple of 1M to have stripe
531 dd if=/dev/urandom of=$file2 count=33 bs=1M conv=fsync ||
532 error "cannot create $file2"
533 path2fid $1 || error "cannot get fid on $1"
536 make_large_for_cancel() {
537 local file2=${1/$DIR/$DIR2}
541 # Copy timeout is 100s. 105MB => 105s
542 dd if=/dev/urandom of=$file2 count=103 bs=1M conv=fsync ||
543 error "cannot create $file2"
544 path2fid $1 || error "cannot get fid on $1"
550 wait_update --verbose $(facet_active_host $facet) "$@"
553 wait_request_state() {
557 # 4th arg (mdt index) is optional
559 local mds=mds$(($mdtidx + 1))
561 local cmd="$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.actions"
562 cmd+=" | awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
564 wait_result $mds "$cmd" $state 100 ||
565 error "request on $fid is not $state on $mds"
568 wait_request_progress() {
572 # 4th arg (mdt index) is optional
574 local mds=mds$((mdtidx + 1))
576 local cmd="$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.active_requests"
577 cmd+=" | awk '/'$fid'.*action='$request'/ {print \\\$12}' | cut -f2 -d="
579 wait_result $mds "$cmd" $progress 100 ||
580 error "request on $fid has not made progress $progress on $mds"
583 get_request_state() {
587 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.actions |"\
588 "awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
591 get_request_count() {
595 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.actions |"\
596 "awk -vn=0 '/'$fid'.*action='$request'/ {n++}; END {print n}'"
602 local cmd="$LCTL get_param -n $HSM_PARAM.actions"
603 cmd+=" | egrep 'WAITING|STARTED'"
605 wait_result $SINGLEMDS "$cmd" "" $timeout ||
606 error "requests did not complete"
609 wait_for_grace_delay() {
610 local val=$(get_hsm_param grace_delay)
614 # populate MDT device array
620 # cleanup from previous bad setup
621 search_and_kill_copytool
623 # for recovery tests, coordinator needs to be started at mount
625 # the lustre conf must be without hsm on (like for sanity.sh)
626 echo "Set HSM on and start"
627 cdt_set_mount_state enabled
628 cdt_check_state enabled
630 echo "Start copytool"
633 echo "Set sanity-hsm HSM policy"
634 cdt_set_sanity_policy
636 # finished requests are quickly removed from list
637 set_hsm_param grace_delay 10
643 local f=$DIR/$tdir/$tfile
647 check_hsm_flags_user $f "0x00000000"
649 $RUNAS $LFS hsm_set --norelease $f ||
650 error "user could not change hsm flags"
651 check_hsm_flags_user $f "0x00000010"
653 $RUNAS $LFS hsm_clear --norelease $f ||
654 error "user could not clear hsm flags"
655 check_hsm_flags_user $f "0x00000000"
657 # User could not change those flags...
658 $RUNAS $LFS hsm_set --exists $f &&
659 error "user should not set this flag"
660 check_hsm_flags_user $f "0x00000000"
663 $LFS hsm_set --exists $f ||
664 error "root could not change hsm flags"
665 check_hsm_flags_user $f "0x00000001"
667 $LFS hsm_clear --exists $f ||
668 error "root could not clear hsm state"
669 check_hsm_flags_user $f "0x00000000"
672 run_test 1 "lfs hsm flags root/non-root access"
676 local f=$DIR/$tdir/$tfile
678 # New files are not dirty
679 check_hsm_flags $f "0x00000000"
681 # For test, we simulate an archived file.
682 $LFS hsm_set --exists $f || error "user could not change hsm flags"
683 check_hsm_flags $f "0x00000001"
685 # chmod do not put the file dirty
686 chmod 600 $f || error "could not chmod test file"
687 check_hsm_flags $f "0x00000001"
689 # chown do not put the file dirty
690 chown $RUNAS_ID $f || error "could not chown test file"
691 check_hsm_flags $f "0x00000001"
693 # truncate put the file dirty
694 $TRUNCATE $f 1 || error "could not truncate test file"
695 check_hsm_flags $f "0x00000003"
697 $LFS hsm_clear --dirty $f || error "could not clear hsm flags"
698 check_hsm_flags $f "0x00000001"
700 run_test 2 "Check file dirtyness when doing setattr"
706 # New files are not dirty
708 check_hsm_flags $f "0x00000000"
710 # For test, we simulate an archived file.
711 $LFS hsm_set --exists $f ||
712 error "user could not change hsm flags"
713 check_hsm_flags $f "0x00000001"
715 # Reading a file, does not set dirty
716 cat $f > /dev/null || error "could not read file"
717 check_hsm_flags $f "0x00000001"
719 # Open for write without modifying data, does not set dirty
720 openfile -f O_WRONLY $f || error "could not open test file"
721 check_hsm_flags $f "0x00000001"
723 # Append to a file sets it dirty
724 cp -p /etc/passwd $f.append || error "could not create file"
725 $LFS hsm_set --exists $f.append ||
726 error "user could not change hsm flags"
727 dd if=/etc/passwd of=$f.append bs=1 count=3\
728 conv=notrunc oflag=append status=noxfer ||
729 error "could not append to test file"
730 check_hsm_flags $f.append "0x00000003"
732 # Modify a file sets it dirty
733 cp -p /etc/passwd $f.modify || error "could not create file"
734 $LFS hsm_set --exists $f.modify ||
735 error "user could not change hsm flags"
736 dd if=/dev/zero of=$f.modify bs=1 count=3\
737 conv=notrunc status=noxfer ||
738 error "could not modify test file"
739 check_hsm_flags $f.modify "0x00000003"
741 # Open O_TRUNC sets dirty
742 cp -p /etc/passwd $f.trunc || error "could not create file"
743 $LFS hsm_set --exists $f.trunc ||
744 error "user could not change hsm flags"
745 cp /etc/group $f.trunc || error "could not override a file"
746 check_hsm_flags $f.trunc "0x00000003"
748 # Mmapped a file sets dirty
749 cp -p /etc/passwd $f.mmap || error "could not create file"
750 $LFS hsm_set --exists $f.mmap ||
751 error "user could not change hsm flags"
752 multiop $f.mmap OSMWUc || error "could not mmap a file"
753 check_hsm_flags $f.mmap "0x00000003"
755 run_test 3 "Check file dirtyness when opening for write"
759 local f=$DIR/$tdir/$tfile
760 local fid=$(make_small $f)
763 local st=$(get_request_state $fid CANCEL)
764 [[ -z "$st" ]] || error "hsm_cancel must not be registered (state=$st)"
766 run_test 4 "Useless cancel must not be registered"
769 # test needs a running copytool
773 local f=$DIR/$tdir/$tfile
774 local fid=$(copy_file /etc/passwd $f)
776 wait_request_state $fid ARCHIVE SUCCEED
778 check_hsm_flags $f "0x00000009"
782 run_test 8 "Test default archive number"
786 local f=$DIR/$tdir/$tfile
787 local fid=$(copy_file /etc/passwd $f)
788 # we do not use the default one to be sure
789 local new_an=$((HSM_ARCHIVE_NUMBER + 1))
791 copytool_setup $SINGLEAGT $MOUNT $new_an
792 $LFS hsm_archive --archive $new_an $f
793 wait_request_state $fid ARCHIVE SUCCEED
795 check_hsm_flags $f "0x00000009"
799 run_test 9 "Use of explict archive number, with dedicated copytool"
802 needclients 3 || return 0
808 copytool_cleanup $(comma_list $(agts_nodes))
810 # start all of the copytools
811 for n in $(seq $AGTCOUNT); do
815 trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
818 for n in $(seq $AGTCOUNT); do
819 file=$DIR/$tdir/$tfile.$n
820 fid=$(make_small $file)
822 $LFS hsm_archive $file || error "could not archive file $file"
823 wait_request_state $fid ARCHIVE SUCCEED
824 check_hsm_flags $file "0x00000009"
828 copytool_cleanup $(comma_list $(agts_nodes))
830 run_test 9a "Multiple remote agents"
833 # test needs a running copytool
836 mkdir -p $DIR/$tdir/d1
837 local f=$DIR/$tdir/$tfile
838 local fid=$(copy_file /etc/hosts $f)
839 $LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f ||
840 error "hsm_archive failed"
841 wait_request_state $fid ARCHIVE SUCCEED
843 local AFILE=$(do_facet $SINGLEAGT ls $HSM_ARCHIVE'/*/*/*/*/*/*/'$fid) ||
844 error "fid $fid not in archive $HSM_ARCHIVE"
845 echo "Verifying content"
846 do_facet $SINGLEAGT diff $f $AFILE || error "archived file differs"
847 echo "Verifying hsm state "
848 check_hsm_flags $f "0x00000009"
850 echo "Verifying archive number is $HSM_ARCHIVE_NUMBER"
851 local st=$(get_hsm_archive_id $f)
852 [[ $st == $HSM_ARCHIVE_NUMBER ]] ||
853 error "Wrong archive number, $st != $HSM_ARCHIVE_NUMBER"
858 run_test 10a "Archive a file"
861 # test needs a running copytool
865 local f=$DIR/$tdir/$tfile
866 local fid=$(copy_file /etc/hosts $f)
867 $LFS hsm_archive $f || error "archive request failed"
868 wait_request_state $fid ARCHIVE SUCCEED
870 $LFS hsm_archive $f || error "archive of non dirty file failed"
871 local cnt=$(get_request_count $fid ARCHIVE)
872 [[ "$cnt" == "1" ]] ||
873 error "archive of non dirty file must not make a request"
877 run_test 10b "Archive of non dirty file must work without doing request"
880 # test needs a running copytool
884 local f=$DIR/$tdir/$tfile
885 local fid=$(copy_file /etc/hosts $f)
886 $LFS hsm_set --noarchive $f
887 $LFS hsm_archive $f && error "archive a noarchive file must fail"
891 run_test 10c "Check forbidden archive"
894 # test needs a running copytool
898 local f=$DIR/$tdir/$tfile
899 local fid=$(copy_file /etc/hosts $f)
900 $LFS hsm_archive $f || error "cannot archive $f"
901 wait_request_state $fid ARCHIVE SUCCEED
903 local ar=$(get_hsm_archive_id $f)
904 local dflt=$(get_hsm_param default_archive_id)
905 [[ $ar == $dflt ]] ||
906 error "archived file is not on default archive: $ar != $dflt"
910 run_test 10d "Archive a file on the default archive id"
914 copy2archive /etc/hosts $tdir/$tfile
915 local f=$DIR/$tdir/$tfile
917 import_file $tdir/$tfile $f
918 echo -n "Verifying released state: "
919 check_hsm_flags $f "0x0000000d"
921 local LSZ=$(stat -c "%s" $f)
922 local ASZ=$(do_facet $SINGLEAGT stat -c "%s" $HSM_ARCHIVE/$tdir/$tfile)
924 echo "Verifying imported size $LSZ=$ASZ"
925 [[ $LSZ -eq $ASZ ]] || error "Incorrect size $LSZ != $ASZ"
926 echo -n "Verifying released pattern: "
927 local PTRN=$($GETSTRIPE -L $f)
929 [[ $PTRN == 80000001 ]] || error "Is not released"
930 local fid=$(path2fid $f)
931 echo "Verifying new fid $fid in archive"
933 local AFILE=$(do_facet $SINGLEAGT ls $HSM_ARCHIVE'/*/*/*/*/*/*/'$fid) ||
934 error "fid $fid not in archive $HSM_ARCHIVE"
936 run_test 11 "Import a file"
939 # test needs a running copytool
943 copy2archive /etc/hosts $tdir/$tfile
945 local f=$DIR/$tdir/$tfile
946 import_file $tdir/$tfile $f
947 local f=$DIR2/$tdir/$tfile
948 echo "Verifying released state: "
949 check_hsm_flags $f "0x0000000d"
951 local fid=$(path2fid $f)
953 wait_request_state $fid RESTORE SUCCEED
955 echo "Verifying file state: "
956 check_hsm_flags $f "0x00000009"
958 do_facet $SINGLEAGT diff -q $HSM_ARCHIVE/$tdir/$tfile $f
960 [[ $? -eq 0 ]] || error "Restored file differs"
964 run_test 12a "Restore an imported file explicitly"
967 # test needs a running copytool
971 copy2archive /etc/hosts $tdir/$tfile
973 local f=$DIR/$tdir/$tfile
974 import_file $tdir/$tfile $f
975 echo "Verifying released state: "
976 check_hsm_flags $f "0x0000000d"
978 cat $f > /dev/null || error "File read failed"
980 echo "Verifying file state after restore: "
981 check_hsm_flags $f "0x00000009"
983 do_facet $SINGLEAGT diff -q $HSM_ARCHIVE/$tdir/$tfile $f
985 [[ $? -eq 0 ]] || error "Restored file differs"
989 run_test 12b "Restore an imported file implicitly"
992 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
994 # test needs a running copytool
998 local f=$DIR/$tdir/$tfile
999 $LFS setstripe -c 2 $f
1000 local fid=$(make_large_for_striping $f)
1001 local FILE_CRC=$(md5sum $f)
1003 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1004 wait_request_state $fid ARCHIVE SUCCEED
1005 $LFS hsm_release $f || error "release $f failed"
1007 echo "$FILE_CRC" | md5sum -c
1009 [[ $? -eq 0 ]] || error "Restored file differs"
1013 run_test 12c "Restore a file with stripe of 2"
1016 # test needs a running copytool
1021 local f=$DIR/$tdir/$tfile
1022 local fid=$(copy_file /etc/hosts $f)
1023 $LFS hsm_restore $f || error "restore of non archived file failed"
1024 local cnt=$(get_request_count $fid RESTORE)
1025 [[ "$cnt" == "0" ]] ||
1026 error "restore non archived must not make a request"
1027 $LFS hsm_archive $f ||
1028 error "archive request failed"
1029 wait_request_state $fid ARCHIVE SUCCEED
1030 $LFS hsm_restore $f ||
1031 error "restore of non released file failed"
1032 local cnt=$(get_request_count $fid RESTORE)
1033 [[ "$cnt" == "0" ]] ||
1034 error "restore a non dirty file must not make a request"
1038 run_test 12d "Restore of a non archived, non released file must work"\
1039 " without doing request"
1042 # test needs a running copytool
1045 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1046 local f=$DIR/$tdir/$tfile
1047 local fid=$(copy_file /etc/hosts $f)
1048 $LFS hsm_archive $f || error "archive request failed"
1049 wait_request_state $fid ARCHIVE SUCCEED
1052 cat /etc/hosts >> $f
1056 $LFS hsm_restore $f && error "restore a dirty file must fail"
1060 run_test 12e "Check forbidden restore"
1063 # test needs a running copytool
1067 local f=$DIR/$tdir/$tfile
1068 local fid=$(copy_file /etc/hosts $f)
1070 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1071 wait_request_state $fid ARCHIVE SUCCEED
1072 $LFS hsm_release $f || error "release of $f failed"
1074 wait_request_state $fid RESTORE SUCCEED
1076 echo -n "Verifying file state: "
1077 check_hsm_flags $f "0x00000009"
1079 diff -q /etc/hosts $f
1081 [[ $? -eq 0 ]] || error "Restored file differs"
1085 run_test 12f "Restore a released file explicitly"
1088 # test needs a running copytool
1092 local f=$DIR/$tdir/$tfile
1093 local fid=$(copy_file /etc/hosts $f)
1095 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1096 wait_request_state $fid ARCHIVE SUCCEED
1097 $LFS hsm_release $f || error "release of $f failed"
1099 diff -q /etc/hosts $f
1102 # we check we had a restore done
1103 wait_request_state $fid RESTORE SUCCEED
1105 [[ $st -eq 0 ]] || error "Restored file differs"
1109 run_test 12g "Restore a released file implicitly"
1112 needclients 2 || return 0
1114 # test needs a running copytool
1118 local f=$DIR/$tdir/$tfile
1119 local fid=$(copy_file /etc/hosts $f)
1121 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1122 wait_request_state $fid ARCHIVE SUCCEED
1123 $LFS hsm_release $f || error "release of $f failed"
1125 do_node $CLIENT2 diff -q /etc/hosts $f
1128 # we check we had a restore done
1129 wait_request_state $fid RESTORE SUCCEED
1131 [[ $st -eq 0 ]] || error "Restored file differs"
1135 run_test 12h "Restore a released file implicitly from a second node"
1138 # test needs a running copytool
1142 local f=$DIR/$tdir/$tfile
1143 local fid=$(copy_file /etc/passwd $f)
1144 $LFS hsm_archive $f || error "archive of $f failed"
1145 wait_request_state $fid ARCHIVE SUCCEED
1147 $LFS hsm_release $f || error "release of $f failed"
1151 [[ $? -eq 0 ]] || error "Restored file differs"
1155 run_test 12m "Archive/release/implicit restore"
1158 # test needs a running copytool
1162 copy2archive /etc/hosts $tdir/$tfile
1164 local f=$DIR/$tdir/$tfile
1165 import_file $tdir/$tfile $f
1167 do_facet $SINGLEAGT cmp /etc/hosts $f ||
1168 error "Restored file differs"
1170 $LFS hsm_release $f || error "release of $f failed"
1174 run_test 12n "Import/implicit restore/release"
1177 # test needs a running copytool
1181 local f=$DIR/$tdir/$tfile
1182 local fid=$(copy_file /etc/hosts $f)
1184 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1185 wait_request_state $fid ARCHIVE SUCCEED
1186 $LFS hsm_release $f || error "release of $f failed"
1188 #define OBD_FAIL_MDS_HSM_SWAP_LAYOUTS 0x152
1189 do_facet $SINGLEMDS lctl set_param fail_loc=0x152
1191 # set no retry action mode
1194 diff -q /etc/hosts $f
1197 # we check we had a restore failure
1198 wait_request_state $fid RESTORE FAILED
1200 [[ $st -eq 0 ]] && error "Restore must fail"
1202 # remove no retry action mode
1205 # check file is still released
1206 check_hsm_flags $f "0x0000000d"
1208 # retry w/o failure injection
1209 do_facet $SINGLEMDS lctl set_param fail_loc=0
1211 # to be sure previous RESTORE result is gone
1213 wait_for_grace_delay
1215 diff -q /etc/hosts $f
1218 # we check we had a restore done
1219 wait_request_state $fid RESTORE SUCCEED
1221 [[ $st -eq 0 ]] || error "Restored file differs"
1225 run_test 12o "Layout-swap failure during Restore leaves file released"
1228 # test needs a running copytool
1231 local ARC_SUBDIR="import.orig"
1235 # populate directory to be imported
1236 for d in $(seq 1 10); do
1237 local CURR_DIR="$HSM_ARCHIVE/$ARC_SUBDIR/dir.$d"
1238 do_facet $SINGLEAGT mkdir -p "$CURR_DIR"
1239 for f in $(seq 1 10); do
1240 CURR_FILE="$CURR_DIR/$tfile.$f"
1241 # write file-specific data
1242 do_facet $SINGLEAGT \
1243 "echo d=$d, f=$f, dir=$CURR_DIR, "\
1244 "file=$CURR_FILE > $CURR_FILE"
1248 import_file "$ARC_SUBDIR" $DIR/$tdir
1249 # diff lustre content and origin (triggers file restoration)
1250 # there must be 10x10 identical files, and no difference
1251 local cnt_ok=$(do_facet $SINGLEAGT diff -rs $HSM_ARCHIVE/$ARC_SUBDIR \
1252 $DIR/$tdir/$ARC_SUBDIR | grep identical | wc -l)
1253 local cnt_diff=$(do_facet $SINGLEAGT diff -r $HSM_ARCHIVE/$ARC_SUBDIR \
1254 $DIR/$tdir/$ARC_SUBDIR | wc -l)
1256 [ $cnt_diff -eq 0 ] ||
1257 error "$cnt_diff imported files differ from read data"
1258 [ $cnt_ok -eq 100 ] ||
1259 error "not enough identical files ($cnt_ok != 100)"
1263 run_test 13 "Recursively import and restore a directory"
1266 # test needs a running copytool
1271 local f=$DIR/$tdir/$tfile
1272 local fid=$(make_small $f)
1273 local sum=$(md5sum $f | awk '{print $1}')
1274 $LFS hsm_archive $f || error "could not archive file"
1275 wait_request_state $fid ARCHIVE SUCCEED
1279 # create released file (simulate llapi_hsm_import call)
1281 local fid2=$(path2fid $f)
1282 $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
1283 $LFS hsm_release $f || error "could not release file"
1285 # rebind the archive to the newly created file
1286 echo "rebind $fid to $fid2"
1288 do_facet $SINGLEAGT \
1289 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1290 --rebind $fid $fid2 $DIR" || error "could not rebind file"
1292 # restore file and compare md5sum
1293 local sum2=$(md5sum $f | awk '{print $1}')
1295 [[ $sum == $sum2 ]] || error "md5sum mismatch after restore"
1299 run_test 14 "Rebind archived file to a new fid"
1302 # test needs a running copytool
1307 local f=$DIR/$tdir/$tfile
1309 local tmpfile=$SHARED_DIRECTORY/tmp.$$
1313 for i in $(seq 1 $count); do
1314 fids[$i]=$(make_small $f.$i)
1315 sums[$i]=$(md5sum $f.$i | awk '{print $1}')
1316 $LFS hsm_archive $f.$i || error "could not archive file"
1318 wait_all_done $(($count*60))
1322 for i in $(seq 1 $count); do
1325 local fid2=$(path2fid $f.$i)
1326 # add the rebind operation to the list
1327 echo ${fids[$i]} $fid2 >> $tmpfile
1329 # set it released (simulate llapi_hsm_import call)
1330 $LFS hsm_set --archived --exists $f.$i ||
1331 error "could not force hsm flags"
1332 $LFS hsm_release $f.$i || error "could not release file"
1334 nl=$(wc -l < $tmpfile)
1335 [[ $nl == $count ]] || error "$nl files in list, $count expected"
1337 echo "rebind list of files"
1338 do_facet $SINGLEAGT \
1339 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1340 --rebind $tmpfile $DIR" || error "could not rebind file list"
1342 # restore files and compare md5sum
1343 for i in $(seq 1 $count); do
1344 local sum2=$(md5sum $f.$i | awk '{print $1}')
1345 [[ $sum2 == ${sums[$i]} ]] ||
1346 error "md5sum mismatch after restore ($sum2 != ${sums[$i]})"
1352 run_test 15 "Rebind a list of files"
1355 # test needs a running copytool
1359 # create a known size file so we can verify transfer speed
1362 dd if=/dev/zero of=$ref bs=1M count=20
1365 local f=$DIR/$tdir/$tfile
1366 local fid=$(copy_file $ref $f)
1368 local start=$(date +%s)
1370 wait_request_state $fid ARCHIVE SUCCEED
1371 local end=$(date +%s)
1372 local duration=$((end - start))
1374 [[ $duration -ge $goal ]] ||
1375 error "Transfer is too fast $duration < $goal"
1379 run_test 16 "Test CT bandwith control option"
1384 local f=$DIR/$tdir/$tfile
1385 touch $f || error "touch $f failed"
1387 # Could not release a non-archived file
1388 $LFS hsm_release $f && error "release should not succeed"
1390 # For following tests, we must test them with HS_ARCHIVED set
1391 $LFS hsm_set --exists --archived $f || error "could not add flag"
1393 # Could not release a file if no-release is set
1394 $LFS hsm_set --norelease $f || error "could not add flag"
1395 $LFS hsm_release $f && error "release should not succeed"
1396 $LFS hsm_clear --norelease $f || error "could not remove flag"
1398 # Could not release a file if lost
1399 $LFS hsm_set --lost $f || error "could not add flag"
1400 $LFS hsm_release $f && error "release should not succeed"
1401 $LFS hsm_clear --lost $f || error "could not remove flag"
1403 # Could not release a file if dirty
1404 $LFS hsm_set --dirty $f || error "could not add flag"
1405 $LFS hsm_release $f && error "release should not succeed"
1406 $LFS hsm_clear --dirty $f || error "could not remove flag"
1408 run_test 20 "Release is not permitted"
1411 # test needs a running copytool
1415 local f=$DIR/$tdir/test_release
1417 # Create a file and check its states
1418 local fid=$(make_small $f)
1419 check_hsm_flags $f "0x00000000"
1421 # LU-4388/LU-4389 - ZFS does not report full number of blocks
1422 # used until file is flushed to disk
1423 if [ $(facet_fstype ost1) == "zfs" ]; then
1424 # this causes an OST_SYNC rpc to be sent
1425 dd if=/dev/zero of=$f bs=512 count=1 oflag=sync conv=notrunc,fsync
1426 # clear locks to reread file data
1427 cancel_lru_locks osc
1430 local orig_size=$(stat -c "%s" $f)
1431 local orig_blocks=$(stat -c "%b" $f)
1433 start_full_debug_logging
1435 $LFS hsm_archive $f || error "could not archive file"
1436 wait_request_state $fid ARCHIVE SUCCEED
1438 local blocks=$(stat -c "%b" $f)
1439 [ $blocks -eq $orig_blocks ] ||
1440 error "$f: wrong block number after archive: " \
1441 "$blocks != $orig_blocks"
1442 local size=$(stat -c "%s" $f)
1443 [ $size -eq $orig_size ] ||
1444 error "$f: wrong size after archive: $size != $orig_size"
1446 # Release and check states
1447 $LFS hsm_release $f || error "could not release file"
1448 check_hsm_flags $f "0x0000000d"
1450 blocks=$(stat -c "%b" $f)
1451 [ $blocks -gt 5 ] &&
1452 error "$f: too many blocks after release: $blocks > 5"
1453 size=$(stat -c "%s" $f)
1454 [ $size -ne $orig_size ] &&
1455 error "$f: wrong size after release: $size != $orig_size"
1457 # Check we can release an file without stripe info
1461 check_hsm_flags $f "0x00000000"
1462 $LFS hsm_archive $f || error "could not archive file"
1463 wait_request_state $fid ARCHIVE SUCCEED
1465 # Release and check states
1466 $LFS hsm_release $f || error "could not release file"
1467 check_hsm_flags $f "0x0000000d"
1469 # Release again a file that is already released is OK
1470 $LFS hsm_release $f || fail "second release should succeed"
1471 check_hsm_flags $f "0x0000000d"
1473 stop_full_debug_logging
1477 run_test 21 "Simple release tests"
1480 # test needs a running copytool
1485 local f=$DIR/$tdir/test_release
1486 local swap=$DIR/$tdir/test_swap
1488 # Create a file and check its states
1489 local fid=$(make_small $f)
1490 check_hsm_flags $f "0x00000000"
1492 $LFS hsm_archive $f || error "could not archive file"
1493 wait_request_state $fid ARCHIVE SUCCEED
1495 # Release and check states
1496 $LFS hsm_release $f || error "could not release file"
1497 check_hsm_flags $f "0x0000000d"
1500 $LFS swap_layouts $swap $f && error "swap_layouts should failed"
1505 run_test 22 "Could not swap a release file"
1508 # test needs a running copytool
1513 local f=$DIR/$tdir/test_mtime
1515 # Create a file and check its states
1516 local fid=$(make_small $f)
1517 check_hsm_flags $f "0x00000000"
1519 $LFS hsm_archive $f || error "could not archive file"
1520 wait_request_state $fid ARCHIVE SUCCEED
1522 # Set modification time in the past
1523 touch -m -a -d @978261179 $f
1525 # Release and check states
1526 $LFS hsm_release $f || error "could not release file"
1527 check_hsm_flags $f "0x0000000d"
1529 local MTIME=$(stat -c "%Y" $f)
1530 local ATIME=$(stat -c "%X" $f)
1531 [ $MTIME -eq "978261179" ] || fail "bad mtime: $MTIME"
1532 [ $ATIME -eq "978261179" ] || fail "bad atime: $ATIME"
1536 run_test 23 "Release does not change a/mtime (utime)"
1539 local file=$DIR/$tdir/$tfile
1548 # test needs a running copytool
1553 fid=$(make_small $file)
1555 # Create a file and check its states
1556 check_hsm_flags $file "0x00000000"
1558 # Ensure atime is less than mtime and ctime.
1562 atime0=$(stat -c "%X" $file)
1563 mtime0=$(stat -c "%Y" $file)
1564 ctime0=$(stat -c "%Z" $file)
1566 [ $atime0 -lt $mtime0 ] ||
1567 error "atime $atime0 is not less than mtime $mtime0"
1569 [ $atime0 -lt $ctime0 ] ||
1570 error "atime $atime0 is not less than ctime $ctime0"
1572 # Archive should not change any timestamps.
1573 $LFS hsm_archive $file || error "cannot archive '$file'"
1574 wait_request_state $fid ARCHIVE SUCCEED
1576 atime1=$(stat -c "%X" $file)
1577 mtime1=$(stat -c "%Y" $file)
1578 ctime1=$(stat -c "%Z" $file)
1580 [ $atime0 -eq $atime1 ] ||
1581 error "archive changed atime from $atime0 to $atime1"
1583 [ $mtime0 -eq $mtime1 ] ||
1584 error "archive changed mtime from $mtime0 to $mtime1"
1586 [ $ctime0 -eq $ctime1 ] ||
1587 error "archive changed ctime from $ctime0 to $ctime1"
1589 # Release should not change any timestamps.
1590 $LFS hsm_release $file || error "cannot release '$file'"
1591 check_hsm_flags $file "0x0000000d"
1593 atime1=$(stat -c "%X" $file)
1594 mtime1=$(stat -c "%Y" $file)
1595 ctime1=$(stat -c "%Z" $file)
1597 [ $atime0 -eq $atime1 ] ||
1598 error "release changed atime from $atime0 to $atime1"
1600 [ $mtime0 -eq $mtime1 ] ||
1601 error "release changed mtime from $mtime0 to $mtime1"
1603 [ $ctime0 -eq $ctime1 ] ||
1604 error "release changed ctime from $ctime0 to $ctime1"
1606 # Restore should not change atime or mtime and should not
1608 $LFS hsm_restore $file
1609 wait_request_state $fid RESTORE SUCCEED
1611 atime1=$(stat -c "%X" $file)
1612 mtime1=$(stat -c "%Y" $file)
1613 ctime1=$(stat -c "%Z" $file)
1615 [ $atime0 -eq $atime1 ] ||
1616 error "restore changed atime from $atime0 to $atime1"
1618 [ $mtime0 -eq $mtime1 ] ||
1619 error "restore changed mtime from $mtime0 to $mtime1"
1621 [ $ctime0 -le $ctime1 ] ||
1622 error "restore changed ctime from $ctime0 to $ctime1"
1626 # Once more, after unmount and mount.
1627 umount_client $MOUNT || error "cannot unmount '$MOUNT'"
1628 mount_client $MOUNT || error "cannot mount '$MOUNT'"
1630 atime1=$(stat -c "%X" $file)
1631 mtime1=$(stat -c "%Y" $file)
1632 ctime1=$(stat -c "%Z" $file)
1634 [ $atime0 -eq $atime1 ] ||
1635 error "remount changed atime from $atime0 to $atime1"
1637 [ $mtime0 -eq $mtime1 ] ||
1638 error "remount changed mtime from $mtime0 to $mtime1"
1640 [ $ctime0 -le $ctime1 ] ||
1641 error "remount changed ctime from $ctime0 to $ctime1"
1643 run_test 24a "Archive, release, and restore does not change a/mtime (i/o)"
1646 local file=$DIR/$tdir/$tfile
1652 # Test needs a running copytool.
1656 # Check that root can do HSM actions on a ordinary user's file.
1658 fid=$(make_small $file)
1659 sum0=$(md5sum $file)
1661 chown $RUNAS_ID:$RUNAS_GID $file ||
1662 error "cannot chown '$file' to '$RUNAS_ID'"
1664 chmod ugo-w $DIR/$tdir ||
1665 error "cannot chmod '$DIR/$tdir'"
1667 $LFS hsm_archive $file
1668 wait_request_state $fid ARCHIVE SUCCEED
1670 $LFS hsm_release $file
1671 check_hsm_flags $file "0x0000000d"
1673 $LFS hsm_restore $file
1674 wait_request_state $fid RESTORE SUCCEED
1676 # Check that ordinary user can get HSM state.
1677 $RUNAS $LFS hsm_state $file ||
1678 error "user '$RUNAS_ID' cannot get HSM state of '$file'"
1680 $LFS hsm_release $file
1681 check_hsm_flags $file "0x0000000d"
1683 # Check that ordinary user can accessed released file.
1684 sum1=$($RUNAS md5sum $file) ||
1685 error "user '$RUNAS_ID' cannot read '$file'"
1687 [ "$sum0" == "$sum1" ] ||
1688 error "md5sum mismatch for '$file'"
1692 run_test 24b "root can archive, release, and restore user files"
1694 cleanup_test_24c() {
1696 set_hsm_param user_request_mask RESTORE
1697 set_hsm_param group_request_mask RESTORE
1698 set_hsm_param other_request_mask RESTORE
1702 local file=$DIR/$tdir/$tfile
1703 local action=archive
1708 # test needs a running copytool
1713 # Save the default masks and check that cleanup_24c will
1714 # restore the request masks correctly.
1715 user_save=$(get_hsm_param user_request_mask)
1716 group_save=$(get_hsm_param group_request_mask)
1717 other_save=$(get_hsm_param other_request_mask)
1719 [ "$user_save" == RESTORE ] ||
1720 error "user_request_mask is '$user_save' expected 'RESTORE'"
1721 [ "$group_save" == RESTORE ] ||
1722 error "group_request_mask is '$group_save' expected 'RESTORE'"
1723 [ "$other_save" == RESTORE ] ||
1724 error "other_request_mask is '$other_save' expected 'RESTORE'"
1726 trap cleanup_test_24c EXIT
1731 chown $RUNAS_ID:nobody $file ||
1732 error "cannot chown '$file' to '$RUNAS_ID:nobody'"
1734 set_hsm_param user_request_mask ""
1735 $RUNAS $LFS hsm_$action $file &&
1736 error "$action by user should fail"
1738 set_hsm_param user_request_mask $action
1739 $RUNAS $LFS hsm_$action $file ||
1740 error "$action by user should succeed"
1745 chown nobody:$RUNAS_GID $file ||
1746 error "cannot chown '$file' to 'nobody:$RUNAS_GID'"
1748 set_hsm_param group_request_mask ""
1749 $RUNAS $LFS hsm_$action $file &&
1750 error "$action by group should fail"
1752 set_hsm_param group_request_mask $action
1753 $RUNAS $LFS hsm_$action $file ||
1754 error "$action by group should succeed"
1759 chown nobody:nobody $file ||
1760 error "cannot chown '$file' to 'nobody:nobody'"
1762 set_hsm_param other_request_mask ""
1763 $RUNAS $LFS hsm_$action $file &&
1764 error "$action by other should fail"
1766 set_hsm_param other_request_mask $action
1767 $RUNAS $LFS hsm_$action $file ||
1768 error "$action by other should succeed"
1773 run_test 24c "check that user,group,other request masks work"
1775 cleanup_test_24d() {
1777 mount -o remount,rw $MOUNT2
1781 local file1=$DIR/$tdir/$tfile
1782 local file2=$DIR2/$tdir/$tfile
1790 fid1=$(make_small $file1)
1792 trap cleanup_test_24d EXIT
1794 mount -o remount,ro $MOUNT2
1796 fid2=$(path2fid $file2)
1797 [ "$fid1" == "$fid2" ] ||
1798 error "FID mismatch '$fid1' != '$fid2'"
1800 $LFS hsm_archive $file2 &&
1801 error "archive should fail on read-only mount"
1802 check_hsm_flags $file1 "0x00000000"
1804 $LFS hsm_archive $file1
1805 wait_request_state $fid1 ARCHIVE SUCCEED
1807 $LFS hsm_release $file1
1808 $LFS hsm_restore $file2
1809 wait_request_state $fid1 RESTORE SUCCEED
1811 $LFS hsm_release $file1 || error "cannot release '$file1'"
1812 dd if=$file2 of=/dev/null bs=1M || "cannot read '$file2'"
1814 $LFS hsm_release $file2 &&
1815 error "release should fail on read-only mount"
1820 run_test 24d "check that read-only mounts are respected"
1823 # test needs a running copytool
1827 copy2archive /etc/hosts $tdir/$tfile
1829 local f=$DIR/$tdir/$tfile
1831 import_file $tdir/$tfile $f
1833 $LFS hsm_set --lost $f
1838 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1842 run_test 25a "Restore lost file (HS_LOST flag) from import"\
1843 " (Operation not permitted)"
1846 # test needs a running copytool
1851 local f=$DIR/$tdir/$tfile
1852 local fid=$(copy_file /etc/passwd $f)
1854 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1855 wait_request_state $fid ARCHIVE SUCCEED
1858 $LFS hsm_set --lost $f
1862 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1866 run_test 25b "Restore lost file (HS_LOST flag) after release"\
1867 " (Operation not permitted)"
1870 # test needs a running copytool
1874 local f=$DIR/$tdir/$tfile
1875 local fid=$(make_large_for_progress $f)
1876 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1877 wait_request_state $fid ARCHIVE SUCCEED
1880 wait_request_state $fid REMOVE SUCCEED
1882 check_hsm_flags $f "0x00000000"
1886 run_test 26 "Remove the archive of a valid file"
1889 # test needs a running copytool
1893 make_archive $tdir/$tfile
1894 local f=$DIR/$tdir/$tfile
1895 import_file $tdir/$tfile $f
1896 local fid=$(path2fid $f)
1900 [[ $? != 0 ]] || error "Remove of a released file should fail"
1904 run_test 27a "Remove the archive of an imported file (Operation not permitted)"
1907 # test needs a running copytool
1911 local f=$DIR/$tdir/$tfile
1912 local fid=$(make_large_for_progress $f)
1913 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1914 wait_request_state $fid ARCHIVE SUCCEED
1919 [[ $? != 0 ]] || error "Remove of a released file should fail"
1923 run_test 27b "Remove the archive of a relased file (Operation not permitted)"
1926 # test needs a running copytool
1930 local f=$DIR/$tdir/$tfile
1931 local fid=$(make_large_for_progress $f)
1932 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1933 wait_request_state $fid ARCHIVE SUCCEED
1942 wait_request_state $fid REMOVE SUCCEED
1946 run_test 28 "Concurrent archive/file remove"
1949 # restore at exec cannot work on agent node (because of Linux kernel
1950 # protection of executables)
1951 needclients 2 || return 0
1953 # test needs a running copytool
1957 copy2archive /bin/true $tdir/$tfile
1959 local f=$DIR/$tdir/true
1960 import_file $tdir/$tfile $f
1962 local fid=$(path2fid $f)
1964 # set no retry action mode
1970 # remove no try action mode
1974 [[ $st == 0 ]] || error "Failed to exec a released file"
1978 run_test 30a "Restore at exec (import case)"
1981 # restore at exec cannot work on agent node (because of Linux kernel
1982 # protection of executables)
1983 needclients 2 || return 0
1985 # test needs a running copytool
1989 local f=$DIR/$tdir/true
1990 local fid=$(copy_file /bin/true $f)
1992 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1993 wait_request_state $fid ARCHIVE SUCCEED
1996 # set no retry action mode
2002 # remove no try action mode
2006 [[ $st == 0 ]] || error "Failed to exec a released file"
2010 run_test 30b "Restore at exec (release case)"
2013 needclients 2 || return 0
2015 # test needs a running copytool
2019 local f=$DIR/$tdir/SLEEP
2020 local fid=$(copy_file /bin/sleep $f)
2022 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2023 wait_request_state $fid ARCHIVE SUCCEED
2025 check_hsm_flags $f "0x0000000d"
2026 # set no retry action mode
2028 do_node $CLIENT2 "$f 10" &
2032 [[ $? == 0 ]] && error "Update during exec of released file must fail"
2034 [[ $? == 0 ]] || error "Execution failed during run"
2036 [[ $? == 0 ]] || error "Binary overwritten during exec"
2039 # remove no try action mode
2041 check_hsm_flags $f "0x00000009"
2045 run_test 30c "Update during exec of released file must fail"
2047 restore_and_check_size() {
2050 local s=$(stat -c "%s" $f)
2052 local st=$(get_hsm_flags $f)
2056 while [[ "$st" != "0x00000009" && $cpt -le 10 ]]
2058 n=$(stat -c "%s" $f)
2059 # we echo in both cases to show stat is not
2061 if [[ $n != $s ]]; then
2062 echo "size seen is $n != $s"
2065 echo "size seen is right: $n == $s"
2067 st=$(get_hsm_flags $f)
2071 if [[ $cpt -lt 10 ]]; then
2074 echo " restore is too long"
2075 wait_request_state $fid RESTORE SUCCEED
2081 # test needs a running copytool
2086 make_archive $tdir/$tfile
2087 local f=$DIR/$tdir/$tfile
2088 import_file $tdir/$tfile $f
2089 local fid=$($LFS path2fid $f)
2090 HSM_ARCHIVE_PURGE=false copytool_setup
2092 restore_and_check_size $f $fid
2095 [[ $err -eq 0 ]] || error "File size changed during restore"
2099 run_test 31a "Import a large file and check size during restore"
2103 # test needs a running copytool
2108 local f=$DIR/$tdir/$tfile
2109 local fid=$(make_large_for_progress $f)
2110 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2111 wait_request_state $fid ARCHIVE SUCCEED
2114 restore_and_check_size $f $fid
2117 [[ $err -eq 0 ]] || error "File size changed during restore"
2121 run_test 31b "Restore a large unaligned file and check size during restore"
2124 # test needs a running copytool
2129 local f=$DIR/$tdir/$tfile
2130 local fid=$(make_large_for_progress_aligned $f)
2131 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2132 wait_request_state $fid ARCHIVE SUCCEED
2135 restore_and_check_size $f $fid
2138 [[ $err -eq 0 ]] || error "File size changed during restore"
2142 run_test 31c "Restore a large aligned file and check size during restore"
2145 # test needs a running copytool
2150 local f=$DIR/$tdir/$tfile
2151 local fid=$(make_large_for_progress $f)
2152 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2153 wait_request_state $fid ARCHIVE SUCCEED
2156 md5sum $f >/dev/null &
2158 wait_request_state $fid RESTORE STARTED
2163 # Check restore trigger process was killed
2164 local killed=$(ps -o pid,comm hp $pid >/dev/null)
2168 wait_request_state $fid RESTORE CANCELED
2169 wait_request_state $fid CANCEL SUCCEED
2172 error "Cannot kill process waiting for restore ($killed)"
2176 run_test 33 "Kill a restore waiting process"
2179 # test needs a running copytool
2184 local f=$DIR/$tdir/$tfile
2185 local fid=$(make_large_for_progress $f)
2186 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2187 wait_request_state $fid ARCHIVE SUCCEED
2190 md5sum $f >/dev/null &
2192 wait_request_state $fid RESTORE STARTED
2194 rm $f || error "rm $f failed"
2195 # rm must not block during restore
2196 wait_request_state $fid RESTORE STARTED
2198 wait_request_state $fid RESTORE SUCCEED
2199 # check md5sum pgm finished
2200 local there=$(ps -o pid,comm hp $pid >/dev/null)
2201 [[ -z $there ]] || error "Restore initiator does not exit"
2203 local rc=$(wait $pid)
2204 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2208 run_test 34 "Remove file during restore"
2211 # test needs a running copytool
2216 local f=$DIR/$tdir/$tfile
2217 local f1=$DIR/$tdir/$tfile-1
2218 local fid=$(make_large_for_progress $f)
2219 local fid1=$(copy_file /etc/passwd $f1)
2220 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2221 wait_request_state $fid ARCHIVE SUCCEED
2224 md5sum $f >/dev/null &
2226 wait_request_state $fid RESTORE STARTED
2228 mv $f1 $f || error "mv $f1 $f failed"
2229 # mv must not block during restore
2230 wait_request_state $fid RESTORE STARTED
2232 wait_request_state $fid RESTORE SUCCEED
2233 # check md5sum pgm finished
2234 local there=$(ps -o pid,comm hp $pid >/dev/null)
2235 [[ -z $there ]] || error "Restore initiator does not exit"
2237 local rc=$(wait $pid)
2238 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2241 [[ $fid2 == $fid1 ]] || error "Wrong fid after mv $fid2 != $fid1"
2245 run_test 35 "Overwrite file during restore"
2248 # test needs a running copytool
2253 local f=$DIR/$tdir/$tfile
2254 local fid=$(make_large_for_progress $f)
2255 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2256 wait_request_state $fid ARCHIVE SUCCEED
2259 md5sum $f >/dev/null &
2261 wait_request_state $fid RESTORE STARTED
2264 # rm must not block during restore
2265 wait_request_state $fid RESTORE STARTED
2267 wait_request_state $fid RESTORE SUCCEED
2268 # check md5sum pgm finished
2269 local there=$(ps -o pid,comm hp $pid >/dev/null)
2271 error "Restore initiator does not exit"
2273 local rc=$(wait $pid)
2275 error "Restore initiator failed with $rc"
2279 run_test 36 "Move file during restore"
2286 for n in $(seq 1 $count); do
2287 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $prefix.$n
2289 echo "$count archive requests submitted"
2293 local stream_count=4
2294 local file_count=100
2296 local f=$DIR/$tdir/$tfile
2301 for i in $(seq 1 $file_count); do
2302 for p in $(seq 1 $stream_count); do
2303 fid=$(copy_file /etc/hosts $f.$p.$i)
2306 # force copytool to use a local/temp archive dir to ensure best
2307 # performance vs remote/NFS mounts used in auto-tests
2308 if df --local $HSM_ARCHIVE >/dev/null 2>&1 ; then
2311 copytool_setup $SINGLEAGT $MOUNT $HSM_ARCHIVE_NUMBER $TMP/$tdir
2313 # to be sure wait_all_done will not be mislead by previous tests
2315 wait_for_grace_delay
2317 # start archive streams in background (archive files in parallel)
2318 for p in $(seq 1 $stream_count); do
2319 multi_archive $f.$p $file_count &
2322 echo -n "Wait for all requests being enqueued..."
2328 run_test 40 "Parallel archive requests"
2331 # test needs a running copytool
2335 local f=$DIR/$tdir/$tfile
2336 local fid=$(copy_file /etc/motd $f 1)
2338 $LFS hsm_archive $f || error "could not archive file"
2339 wait_request_state $fid ARCHIVE SUCCEED
2340 check_hsm_flags $f "0x00000009"
2342 multiop_bg_pause $f O_c || error "multiop failed"
2346 client_up || client_up || true
2348 kill -USR1 $MULTIPID
2349 wait $MULTIPID || error "multiop close failed"
2351 check_hsm_flags $f "0x0000000b"
2355 run_test 52 "Opened for write file on an evicted client should be set dirty"
2358 # test needs a running copytool
2362 local f=$DIR/$tdir/$tfile
2363 local fid=$(copy_file /etc/motd $f 1)
2365 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2366 error "could not archive file"
2367 wait_request_state $fid ARCHIVE SUCCEED
2368 check_hsm_flags $f "0x00000009"
2370 multiop_bg_pause $f o_c || error "multiop failed"
2374 client_up || client_up || true
2376 kill -USR1 $MULTIPID
2377 wait $MULTIPID || error "multiop close failed"
2379 check_hsm_flags $f "0x00000009"
2383 run_test 53 "Opened for read file on an evicted client should not be set dirty"
2386 # test needs a running copytool
2390 local f=$DIR/$tdir/$tfile
2391 local fid=$(make_small $f)
2393 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2394 error "could not archive file"
2395 wait_request_state $fid ARCHIVE STARTED
2397 check_hsm_flags $f "0x00000001"
2399 # Avoid coordinator resending this request as soon it has failed.
2404 wait_request_state $fid ARCHIVE FAILED
2406 check_hsm_flags $f "0x00000003"
2411 run_test 54 "Write during an archive cancels it"
2414 # test needs a running copytool
2418 local f=$DIR/$tdir/$tfile
2419 local fid=$(make_small $f)
2421 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2422 error "could not archive file"
2423 wait_request_state $fid ARCHIVE STARTED
2425 check_hsm_flags $f "0x00000001"
2427 # Avoid coordinator resending this request as soon it has failed.
2430 $TRUNCATE $f 1024 || error "truncate failed"
2432 wait_request_state $fid ARCHIVE FAILED
2434 check_hsm_flags $f "0x00000003"
2439 run_test 55 "Truncate during an archive cancels it"
2442 # test needs a running copytool
2446 local f=$DIR/$tdir/$tfile
2447 local fid=$(make_large_for_progress $f)
2449 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2450 error "could not archive file"
2451 wait_request_state $fid ARCHIVE STARTED
2453 check_hsm_flags $f "0x00000001"
2455 # Change metadata and sync to be sure we are not changing only
2460 wait_request_state $fid ARCHIVE SUCCEED
2462 check_hsm_flags $f "0x00000009"
2466 run_test 56 "Setattr during an archive is ok"
2469 # Need one client for I/O, one for request
2470 needclients 2 || return 0
2472 # test needs a running copytool
2476 local f=$DIR/$tdir/test_archive_remote
2477 # Create a file on a remote node
2478 do_node $CLIENT2 "dd if=/dev/urandom of=$f bs=1M "\
2479 "count=2 conv=fsync"
2482 do_node $CLIENT2 "$LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f" ||
2483 error "hsm_archive failed"
2484 local fid=$(path2fid $f)
2485 wait_request_state $fid ARCHIVE SUCCEED
2487 # Release and implicit restore it
2488 do_node $CLIENT2 "$LFS hsm_release $f" ||
2489 error "hsm_release failed"
2490 do_node $CLIENT2 "md5sum $f" ||
2491 error "hsm_restore failed"
2493 wait_request_state $fid RESTORE SUCCEED
2497 run_test 57 "Archive a file with dirty cache on another node"
2499 truncate_released_file() {
2503 local sz=$(stat -c %s $src_file)
2504 local f=$DIR/$tdir/$tfile
2505 local fid=$(copy_file $1 $f)
2509 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2510 error "could not archive file"
2511 wait_request_state $fid ARCHIVE SUCCEED
2513 $LFS hsm_release $f || error "could not release file"
2515 $TRUNCATE $f $trunc_to || error "truncate failed"
2518 local sz1=$(stat -c %s $f)
2519 [[ $sz1 == $trunc_to ]] ||
2520 error "size after trunc: $sz1 expect $trunc_to, original $sz"
2523 check_hsm_flags $f "0x0000000b"
2525 local state=$(get_request_state $fid RESTORE)
2526 [[ "$state" == "SUCCEED" ]] ||
2527 error "truncate $sz does not trig restore, state = $state"
2529 $TRUNCATE $ref $trunc_to
2530 cmp $ref $f || error "file data wrong after truncate"
2536 # test needs a running copytool
2541 local sz=$(stat -c %s /etc/passwd)
2543 echo "truncate up from $sz to $((sz*2))"
2544 truncate_released_file /etc/passwd $((sz*2))
2546 echo "truncate down from $sz to $((sz/2))"
2547 truncate_released_file /etc/passwd $((sz/2))
2549 echo "truncate to 0"
2550 truncate_released_file /etc/passwd 0
2554 run_test 58 "Truncate a released file will trigger restore"
2558 local progress_timeout=$((interval * 2))
2560 # test needs a new running copytool
2562 HSMTOOL_UPDATE_INTERVAL=$interval copytool_setup
2565 local f=$DIR/$tdir/$tfile
2566 local fid=$(make_large_for_progress $f)
2568 local start_at=$(date +%s)
2569 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2570 error "could not archive file"
2571 wait_request_progress $fid ARCHIVE 5242880
2572 local finish_at=$(date +%s)
2573 local elapsed=$((finish_at - start_at))
2575 if [ $elapsed -gt $progress_timeout ]; then
2576 error "Expected progress update within $progress_timeout seconds"
2577 elif [ $elapsed -lt $interval ]; then
2578 error "Expected progress update after at least $interval seconds"
2584 run_test 60 "Changing progress update interval from default"
2589 local f=$DIR/$tdir/$tfile
2590 local FILELIST=/tmp/filelist.txt
2594 for i in $(seq 1 $file_count); do
2595 fid=$(copy_file /etc/hosts $f.$i)
2596 echo $f.$i >> $FILELIST
2599 # to be sure wait_all_done will not be mislead by previous tests
2601 wait_for_grace_delay
2602 $LFS hsm_archive --filelist $FILELIST ||
2603 error "cannot archive a file list"
2605 $LFS hsm_release --filelist $FILELIST ||
2606 error "cannot release a file list"
2607 $LFS hsm_restore --filelist $FILELIST ||
2608 error "cannot restore a file list"
2612 run_test 90 "Archive/restore a file list"
2614 double_verify_reset_hsm_param() {
2616 echo "Testing $HSM_PARAM.$p"
2617 local val=$(get_hsm_param $p)
2619 local val2=$(($val * 2))
2620 set_hsm_param $p $val2
2621 val=$(get_hsm_param $p)
2622 [[ $val == $val2 ]] ||
2623 error "$HSM_PARAM.$p: $val != $val2 should be (2 * $save)"
2624 echo "Set $p to 0 must failed"
2628 set_hsm_param $p $save
2630 if [[ $rc == 0 ]]; then
2631 error "we must not be able to set $HSM_PARAM.$p to 0"
2636 double_verify_reset_hsm_param loop_period
2637 double_verify_reset_hsm_param grace_delay
2638 double_verify_reset_hsm_param active_request_timeout
2639 double_verify_reset_hsm_param max_requests
2640 double_verify_reset_hsm_param default_archive_id
2642 run_test 100 "Set coordinator /proc tunables"
2649 run_test 102 "Verify coordinator control"
2652 # test needs a running copytool
2659 for i in $(seq 1 20); do
2660 fid=$(copy_file /etc/passwd $DIR/$tdir/$i)
2662 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/*
2666 echo "Current requests"
2667 local res=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2668 $HSM_PARAM.actions |\
2669 grep -v CANCELED | grep -v SUCCEED | grep -v FAILED")
2671 [[ -z "$res" ]] || error "Some request have not been canceled"
2675 run_test 103 "Purge all requests"
2680 # test needs a running copytool
2684 local f=$DIR/$tdir/$tfile
2685 local fid=$(make_large_for_progress $f)
2686 # if cdt is on, it can serve too quickly the request
2688 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER --data $DATA $f
2689 local data1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2690 $HSM_PARAM.actions |\
2691 grep $fid | cut -f16 -d=")
2694 [[ "$data1" == "$DATAHEX" ]] ||
2695 error "Data field in records is ($data1) and not ($DATAHEX)"
2699 run_test 104 "Copy tool data field"
2706 for i in $(seq -w 1 10); do
2707 cp /etc/passwd $DIR/$tdir/$i
2708 $LFS hsm_archive $DIR/$tdir/$i
2710 local reqcnt1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2711 $HSM_PARAM.actions |\
2712 grep WAITING | wc -l")
2715 local reqcnt2=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2716 $HSM_PARAM.actions |\
2717 grep WAITING | wc -l")
2720 [[ "$reqcnt1" == "$reqcnt2" ]] ||
2721 error "Requests count after shutdown $reqcnt2 != "\
2722 "before shutdown $reqcnt1"
2724 run_test 105 "Restart of coordinator"
2726 get_agent_by_uuid_mdt() {
2729 local mds=mds$(($mdtidx + 1))
2730 do_facet $mds "$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.agents |\
2734 check_agent_registered_by_mdt() {
2737 local mds=mds$(($mdtidx + 1))
2738 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
2739 if [[ ! -z "$agent" ]]; then
2740 echo "found agent $agent on $mds"
2742 error "uuid $uuid not found in agent list on $mds"
2746 check_agent_unregistered_by_mdt() {
2749 local mds=mds$(($mdtidx + 1))
2750 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
2751 if [[ -z "$agent" ]]; then
2752 echo "uuid not found in agent list on $mds"
2754 error "uuid found in agent list on $mds: $agent"
2758 check_agent_registered() {
2761 for mdsno in $(seq 1 $MDSCOUNT); do
2762 check_agent_registered_by_mdt $uuid $((mdsno - 1))
2766 check_agent_unregistered() {
2769 for mdsno in $(seq 1 $MDSCOUNT); do
2770 check_agent_unregistered_by_mdt $uuid $((mdsno - 1))
2775 local uuid=$(do_rpc_nodes $(facet_active_host $SINGLEAGT) \
2776 get_client_uuid $MOUNT | cut -d' ' -f2)
2779 check_agent_registered $uuid
2781 search_copytools || error "No copytool found"
2784 check_agent_unregistered $uuid
2787 check_agent_registered $uuid
2791 run_test 106 "Copytool register/unregister"
2794 # test needs a running copytool
2796 # create and archive file
2798 local f1=$DIR/$tdir/$tfile
2799 local fid=$(copy_file /etc/passwd $f1)
2800 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2801 wait_request_state $fid ARCHIVE SUCCEED
2802 # shutdown and restart MDS
2804 # check the copytool still gets messages from MDT
2805 local f2=$DIR/$tdir/2
2806 local fid=$(copy_file /etc/passwd $f2)
2807 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f2
2808 # main check of this sanity: this request MUST succeed
2809 wait_request_state $fid ARCHIVE SUCCEED
2812 run_test 107 "Copytool re-register after MDS restart"
2814 policy_set_and_test()
2818 do_facet $SINGLEMDS $LCTL set_param "$HSM_PARAM.policy=\\\"$change\\\""
2819 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2820 [[ "$policy" == "$target" ]] ||
2821 error "Wrong policy after '$change': '$policy' != '$target'"
2825 # to force default policy setting if error
2826 CDT_POLICY_HAD_CHANGED=true
2828 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2829 local default="NonBlockingRestore [NoRetryAction]"
2830 [[ "$policy" == "$default" ]] ||
2831 error "default policy has changed,"\
2832 " '$policy' != '$default' update the test"
2833 policy_set_and_test "+NBR" "[NonBlockingRestore] [NoRetryAction]"
2834 policy_set_and_test "+NRA" "[NonBlockingRestore] [NoRetryAction]"
2835 policy_set_and_test "-NBR" "NonBlockingRestore [NoRetryAction]"
2836 policy_set_and_test "-NRA" "NonBlockingRestore NoRetryAction"
2837 policy_set_and_test "NRA NBR" "[NonBlockingRestore] [NoRetryAction]"
2838 # useless bacause we know but safer for futur changes to use real value
2839 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2840 echo "Next set_param must failed"
2841 policy_set_and_test "wrong" "$policy"
2844 echo "Back to default policy"
2845 cdt_set_sanity_policy
2847 run_test 109 "Policy display/change"
2850 # test needs a running copytool
2855 copy2archive /etc/passwd $tdir/$tfile
2857 local f=$DIR/$tdir/$tfile
2858 import_file $tdir/$tfile $f
2859 local fid=$(path2fid $f)
2861 cdt_set_non_blocking_restore
2866 wait_request_state $fid RESTORE SUCCEED
2867 cdt_clear_non_blocking_restore
2871 error "md5sum returns $st != 1, "\
2872 "should also perror ENODATA (No data available)"
2876 run_test 110a "Non blocking restore policy (import case)"
2879 # test needs a running copytool
2883 local f=$DIR/$tdir/$tfile
2884 local fid=$(copy_file /etc/passwd $f)
2885 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2886 wait_request_state $fid ARCHIVE SUCCEED
2889 cdt_set_non_blocking_restore
2894 wait_request_state $fid RESTORE SUCCEED
2895 cdt_clear_non_blocking_restore
2899 error "md5sum returns $st != 1, "\
2900 "should also perror ENODATA (No data available)"
2904 run_test 110b "Non blocking restore policy (release case)"
2907 # test needs a running copytool
2911 copy2archive /etc/passwd $tdir/$tfile
2913 local f=$DIR/$tdir/$tfile
2915 import_file $tdir/$tfile $f
2916 local fid=$(path2fid $f)
2920 copytool_remove_backend $fid
2923 wait_request_state $fid RESTORE FAILED
2930 [[ $st == 0 ]] || error "Restore does not failed"
2934 run_test 111a "No retry policy (import case), restore will error"\
2935 " (No such file or directory)"
2938 # test needs a running copytool
2942 local f=$DIR/$tdir/$tfile
2943 local fid=$(copy_file /etc/passwd $f)
2945 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2946 wait_request_state $fid ARCHIVE SUCCEED
2949 copytool_remove_backend $fid
2952 wait_request_state $fid RESTORE FAILED
2959 [[ $st == 0 ]] || error "Restore does not failed"
2963 run_test 111b "No retry policy (release case), restore will error"\
2964 " (No such file or directory)"
2967 # test needs a running copytool
2971 local f=$DIR/$tdir/$tfile
2972 local fid=$(copy_file /etc/passwd $f)
2974 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2975 local l=$($LFS hsm_action $f)
2977 local res=$(echo $l | cut -f 2- -d" " | grep ARCHIVE)
2981 wait_request_state $fid ARCHIVE SUCCEED
2984 [[ ! -z "$res" ]] || error "action is $l which is not an ARCHIVE"
2988 run_test 112 "State of recorded request"
2991 # test needs a running copytool
2995 local f=$DIR/$tdir/$tfile
2996 local fid=$(make_large_for_cancel $f)
2997 # test with cdt on is made in test_221
2999 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3002 wait_request_state $fid ARCHIVE CANCELED
3003 wait_request_state $fid CANCEL SUCCEED
3007 run_test 200 "Register/Cancel archive"
3010 # test needs a running copytool
3014 local f=$DIR/$tdir/$tfile
3015 make_archive $tdir/$tfile
3016 import_file $tdir/$tfile $f
3017 local fid=$(path2fid $f)
3019 # test with cdt on is made in test_222
3024 wait_request_state $fid RESTORE CANCELED
3025 wait_request_state $fid CANCEL SUCCEED
3029 run_test 201 "Register/Cancel restore"
3032 # test needs a running copytool
3036 local f=$DIR/$tdir/$tfile
3037 local fid=$(make_large_for_progress $f)
3038 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3039 wait_request_state $fid ARCHIVE SUCCEED
3045 wait_request_state $fid REMOVE CANCELED
3049 run_test 202 "Register/Cancel remove"
3052 # test needs a running copytool
3057 local f=$DIR/$tdir/$tfile
3058 local fid=$(copy_file /etc/passwd $f)
3062 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3063 wait_request_state $fid ARCHIVE SUCCEED
3065 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3069 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3073 run_test 220 "Changelog for archive"
3076 # test needs a running copytool
3081 local f=$DIR/$tdir/$tfile
3082 local fid=$(make_large_for_cancel $f)
3086 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3087 wait_request_state $fid ARCHIVE STARTED
3089 wait_request_state $fid ARCHIVE CANCELED
3090 wait_request_state $fid CANCEL SUCCEED
3092 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3095 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3099 run_test 221 "Changelog for archive canceled"
3102 # test needs a running copytool
3106 copy2archive /etc/passwd $tdir/$tfile
3108 local f=$DIR/$tdir/$tfile
3109 import_file $tdir/$tfile $f
3110 local fid=$(path2fid $f)
3115 wait_request_state $fid RESTORE SUCCEED
3117 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3120 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3124 run_test 222a "Changelog for explicit restore"
3127 # test needs a running copytool
3131 local f=$DIR/$tdir/$tfile
3132 local fid=$(copy_file /etc/passwd $f)
3135 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3136 wait_request_state $fid ARCHIVE SUCCEED
3141 wait_request_state $fid RESTORE SUCCEED
3143 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3146 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3150 run_test 222b "Changelog for implicit restore"
3153 # test needs a running copytool
3158 local f=$DIR/$tdir/$tfile
3159 make_archive $tdir/$tfile
3163 import_file $tdir/$tfile $f
3164 local fid=$(path2fid $f)
3167 wait_request_state $fid RESTORE STARTED
3169 wait_request_state $fid RESTORE CANCELED
3170 wait_request_state $fid CANCEL SUCCEED
3172 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3175 [[ $flags == $target ]] ||
3176 error "Changelog flag is $flags not $target"
3180 run_test 223a "Changelog for restore canceled (import case)"
3183 # test needs a running copytool
3188 local f=$DIR/$tdir/$tfile
3189 local fid=$(make_large_for_progress $f)
3192 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3193 wait_request_state $fid ARCHIVE SUCCEED
3196 wait_request_state $fid RESTORE STARTED
3198 wait_request_state $fid RESTORE CANCELED
3199 wait_request_state $fid CANCEL SUCCEED
3201 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3204 [[ $flags == $target ]] ||
3205 error "Changelog flag is $flags not $target"
3209 run_test 223b "Changelog for restore canceled (release case)"
3212 # test needs a running copytool
3217 local f=$DIR/$tdir/$tfile
3218 local fid=$(copy_file /etc/passwd $f)
3221 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3222 wait_request_state $fid ARCHIVE SUCCEED
3225 wait_request_state $fid REMOVE SUCCEED
3227 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -n 1)
3230 [[ $flags == $target ]] ||
3231 error "Changelog flag is $flags not $target"
3235 run_test 224 "Changelog for remove"
3238 # test needs a running copytool
3241 # test is not usable because remove request is too fast
3242 # so it is always finished before cancel can be done ...
3243 echo "Test disabled"
3248 local f=$DIR/$tdir/$tfile
3249 local fid=$(make_large_for_progress $f)
3252 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3253 wait_request_state $fid ARCHIVE SUCCEED
3255 # if cdt is on, it can serve too quickly the request
3260 wait_request_state $fid REMOVE CANCELED
3261 wait_request_state $fid CANCEL SUCCEED
3263 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3264 local flags=$($LFS changelog ${MDT[0]} | grep HSM | grep $fid |
3265 tail -n 1 | awk '{print $5}')
3268 [[ $flags == $target ]] ||
3269 error "Changelog flag is $flags not $target"
3273 run_test 225 "Changelog for remove canceled"
3276 # test needs a running copytool
3281 local f1=$DIR/$tdir/$tfile-1
3282 local f2=$DIR/$tdir/$tfile-2
3283 local f3=$DIR/$tdir/$tfile-3
3284 local fid1=$(copy_file /etc/passwd $f1)
3285 local fid2=$(copy_file /etc/passwd $f2)
3286 copy_file /etc/passwd $f3
3289 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
3290 wait_request_state $fid1 ARCHIVE SUCCEED
3292 $LFS hsm_archive $f2
3293 wait_request_state $fid2 ARCHIVE SUCCEED
3295 rm $f1 || error "rm $f1 failed"
3297 local flags=$(changelog_get_flags ${MDT[0]} UNLNK $fid1)
3300 [[ $flags == $target ]] ||
3301 error "Changelog flag is $flags not $target"
3303 mv $f3 $f2 || error "mv $f3 $f2 failed"
3305 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3308 [[ $flags == $target ]] ||
3309 error "Changelog flag is $flags not $target"
3313 run_test 226 "changelog for last rm/mv with exiting archive"
3315 check_flags_changes() {
3323 $LFS hsm_set --$hsm_flag $f ||
3324 error "Cannot set $hsm_flag on $f"
3325 local flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3326 local seen=${#flags[*]}
3328 [[ $seen == $cnt ]] ||
3329 error "set $hsm_flag: Changelog events $seen != $cnt"
3330 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3331 error "set $hsm_flag: Changelog flags are "\
3332 "${flags[$((cnt - 1))]} not $target"
3334 $LFS hsm_clear --$hsm_flag $f ||
3335 error "Cannot clear $hsm_flag on $f"
3336 flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3339 [[ $cnt == $seen ]] ||
3340 error "clear $hsm_flag: Changelog events $seen != $cnt"
3342 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3343 error "clear $hsm_flag: Changelog flag is "\
3344 "${flags[$((cnt - 1))]} not $target"
3348 # test needs a running copytool
3355 for i in norelease noarchive exists archived
3357 local f=$DIR/$tdir/$tfile-$i
3358 local fid=$(copy_file /etc/passwd $f)
3359 check_flags_changes $f $fid $i 0 1
3362 f=$DIR/$tdir/$tfile---lost
3363 fid=$(copy_file /etc/passwd $f)
3364 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3365 wait_request_state $fid ARCHIVE SUCCEED
3366 check_flags_changes $f $fid lost 3 1
3370 run_test 227 "changelog when explicit setting of HSM flags"
3373 # test needs a running copytool
3376 local fid=$(make_small_sync $DIR/$tfile)
3377 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tfile
3378 wait_request_state $fid ARCHIVE SUCCEED
3380 $LFS hsm_release $DIR/$tfile
3381 check_hsm_flags $DIR/$tfile "0x0000000d"
3383 filefrag $DIR/$tfile | grep " 1 extent found" ||
3384 error "filefrag on released file must return only one extent"
3386 # only newer versions of cp detect sparse files by stat/FIEMAP
3388 cp --sparse=auto $DIR/$tfile $DIR/$tfile.2 ||
3389 error "copying $DIR/$tfile"
3390 cmp $DIR/$tfile $DIR/$tfile.2 || error "comparing copied $DIR/$tfile"
3392 $LFS hsm_release $DIR/$tfile
3393 check_hsm_flags $DIR/$tfile "0x0000000d"
3395 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
3397 tar cf - --sparse $DIR/$tfile | tar xvf - -C $DIR/$tdir ||
3399 cmp $DIR/$tfile $DIR/$tdir/$DIR/$tfile ||
3400 error "comparing untarred $DIR/$tfile"
3402 rm -f $DIR/$tfile $DIR/$tfile.2 ||
3403 error "rm $DIR/$tfile or $DIR/$tfile.2 failed"
3406 run_test 228 "On released file, return extend to FIEMAP. For [cp,tar] --sparse"
3409 # test needs a running copytool
3413 local maxrequest=$(get_hsm_param max_requests)
3414 local rqcnt=$(($maxrequest * 3))
3418 for i in $(seq -w 1 $rqcnt); do
3420 dd if=/dev/urandom of=$DIR/$tdir/$i bs=1M count=10 conv=fsync
3422 # we do it in 2 steps, so all requests arrive at the same time
3423 for i in $(seq -w 1 $rqcnt); do
3424 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$i
3429 while [[ $cnt != 0 || $wt != 0 ]]; do
3431 cnt=$(do_facet $SINGLEMDS "$LCTL get_param -n\
3432 $HSM_PARAM.actions |\
3433 grep STARTED | grep -v CANCEL | wc -l")
3434 [[ $cnt -le $maxrequest ]] ||
3435 error "$cnt > $maxrequest too many started requests"
3436 wt=$(do_facet $SINGLEMDS "$LCTL get_param\
3437 $HSM_PARAM.actions |\
3438 grep WAITING | wc -l")
3439 echo "max=$maxrequest started=$cnt waiting=$wt"
3444 run_test 250 "Coordinator max request"
3447 # test needs a running copytool
3451 local f=$DIR/$tdir/$tfile
3452 local fid=$(make_large_for_cancel $f)
3455 # to have a short test
3456 local old_to=$(get_hsm_param active_request_timeout)
3457 set_hsm_param active_request_timeout 4
3458 # to be sure the cdt will wake up frequently so
3459 # it will be able to cancel the "old" request
3460 local old_loop=$(get_hsm_param loop_period)
3461 set_hsm_param loop_period 2
3464 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3465 wait_request_state $fid ARCHIVE STARTED
3467 wait_request_state $fid ARCHIVE CANCELED
3469 set_hsm_param active_request_timeout $old_to
3470 set_hsm_param loop_period $old_loop
3474 run_test 251 "Coordinator request timeout"
3477 # the only way to test ondisk conf is to restart MDS ...
3478 echo "Stop coordinator and remove coordinator state at mount"
3481 # clean on disk conf set by default
3482 cdt_clear_mount_state
3483 cdt_check_state stopped
3485 # check cdt still off after umount/remount
3487 cdt_check_state stopped
3489 echo "Set coordinator start at mount, and start coordinator"
3490 cdt_set_mount_state enabled
3493 cdt_check_state enabled
3495 # check cdt still on after umount/remount
3497 cdt_check_state enabled
3499 # we are back to original state (cdt started at mount)
3501 run_test 300 "On disk coordinator state kept between MDT umount/mount"
3504 local ai=$(get_hsm_param default_archive_id)
3505 local new=$((ai + 1))
3507 set_hsm_param default_archive_id $new -P
3509 local res=$(get_hsm_param default_archive_id)
3512 set_hsm_param default_archive_id "" "-P -d"
3514 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
3516 run_test 301 "HSM tunnable are persistent"
3519 local ai=$(get_hsm_param default_archive_id)
3520 local new=$((ai + 1))
3525 set_hsm_param default_archive_id $new -P
3528 for mdtno in $(seq 1 $MDSCOUNT); do
3533 cdt_check_state enabled
3535 local res=$(get_hsm_param default_archive_id)
3538 set_hsm_param default_archive_id "" "-P -d"
3540 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
3542 run_test 302 "HSM tunnable are persistent when CDT is off"
3545 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3551 local dir_mdt0=$DIR/$tdir/mdt0
3552 local dir_mdt1=$DIR/$tdir/mdt1
3554 # create 1 dir per MDT
3555 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3556 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
3558 # create 1 file in each MDT
3559 local fid1=$(make_small $dir_mdt0/$tfile)
3560 local fid2=$(make_small $dir_mdt1/$tfile)
3562 # check that hsm request on mdt0 is sent to the right MDS
3563 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
3564 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3565 echo "archive successful on mdt0"
3567 # check that hsm request on mdt1 is sent to the right MDS
3568 $LFS hsm_archive $dir_mdt1/$tfile || error "lfs hsm_archive"
3569 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
3570 echo "archive successful on mdt1"
3573 # clean test files and directories
3574 rm -rf $dir_mdt0 $dir_mdt1
3576 run_test 400 "Single request is sent to the right MDT"
3579 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3585 local dir_mdt0=$DIR/$tdir/mdt0
3586 local dir_mdt1=$DIR/$tdir/mdt1
3588 # create 1 dir per MDT
3589 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3590 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
3592 # create 1 file in each MDT
3593 local fid1=$(make_small $dir_mdt0/$tfile)
3594 local fid2=$(make_small $dir_mdt1/$tfile)
3596 # check that compound requests are shunt to the rights MDTs
3597 $LFS hsm_archive $dir_mdt0/$tfile $dir_mdt1/$tfile ||
3598 error "lfs hsm_archive"
3599 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3600 echo "archive successful on mdt0"
3601 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
3602 echo "archive successful on mdt1"
3605 # clean test files and directories
3606 rm -rf $dir_mdt0 $dir_mdt1
3608 run_test 401 "Compound requests split and sent to their respective MDTs"
3610 mdc_change_state() # facet, MDT_pattern, activate|deactivate
3615 local node=$(facet_active_host $facet)
3617 for mdc in $(do_facet $facet "$LCTL dl | grep -E ${pattern}-mdc" |
3618 awk '{print $4}'); do
3619 echo "$3 $mdc on $node"
3620 do_facet $facet "$LCTL --device $mdc $state" || return 1
3625 # make sure there is no running copytool
3628 # deactivate all mdc on agent1
3629 mdc_change_state $SINGLEAGT "MDT000." "deactivate"
3631 copytool_setup $SINGLEAGT
3633 check_agent_unregistered "uuid" # match any agent
3635 # no expected running copytool
3636 search_copytools $agent && error "Copytool start should have failed"
3639 mdc_change_state $SINGLEAGT "MDT000." "activate"
3641 run_test 402 "Copytool start fails if all MDTs are inactive"
3644 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3646 # make sure there is no running copytool
3649 local agent=$(facet_active_host $SINGLEAGT)
3650 local uuid=$(do_rpc_nodes $agent get_client_uuid | cut -d' ' -f2)
3652 # deactivate all mdc for MDT0001
3653 mdc_change_state $SINGLEAGT "MDT0001" "deactivate"
3656 # check the agent is registered on MDT0000, and not on MDT0001
3657 check_agent_registered_by_mdt $uuid 0
3658 check_agent_unregistered_by_mdt $uuid 1
3660 # check running copytool process
3661 search_copytools $agent || error "No running copytools on $agent"
3663 # reactivate all mdc for MDT0001
3664 mdc_change_state $SINGLEAGT "MDT0001" "activate"
3666 # make sure the copytool is now registered to all MDTs
3667 check_agent_registered $uuid
3671 run_test 403 "Copytool starts with inactive MDT and register on reconnect"
3674 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3678 # create files on both MDT0000 and MDT0001
3681 local dir_mdt0=$DIR/$tdir/mdt0
3682 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3684 # create 1 file on mdt0
3685 local fid1=$(make_small $dir_mdt0/$tfile)
3687 # deactivate all mdc for MDT0001
3688 mdc_change_state $SINGLEAGT "MDT0001" "deactivate"
3690 # send an HSM request for files in MDT0000
3691 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
3693 # check for completion of files in MDT0000
3694 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3695 echo "archive successful on mdt0"
3697 # reactivate all mdc for MDT0001
3698 mdc_change_state $SINGLEAGT "MDT0001" "activate"
3701 # clean test files and directories
3704 run_test 404 "Inactive MDT does not block requests for active MDTs"
3709 check_and_cleanup_lustre