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 diff -q /etc/hosts $f
1214 # we check we had a restore done
1215 wait_request_state $fid RESTORE SUCCEED
1217 [[ $st -eq 0 ]] || error "Restored file differs"
1221 run_test 12o "Layout-swap failure during Restore leaves file released"
1224 # test needs a running copytool
1227 local ARC_SUBDIR="import.orig"
1231 # populate directory to be imported
1232 for d in $(seq 1 10); do
1233 local CURR_DIR="$HSM_ARCHIVE/$ARC_SUBDIR/dir.$d"
1234 do_facet $SINGLEAGT mkdir -p "$CURR_DIR"
1235 for f in $(seq 1 10); do
1236 CURR_FILE="$CURR_DIR/$tfile.$f"
1237 # write file-specific data
1238 do_facet $SINGLEAGT \
1239 "echo d=$d, f=$f, dir=$CURR_DIR, "\
1240 "file=$CURR_FILE > $CURR_FILE"
1244 import_file "$ARC_SUBDIR" $DIR/$tdir
1245 # diff lustre content and origin (triggers file restoration)
1246 # there must be 10x10 identical files, and no difference
1247 local cnt_ok=$(do_facet $SINGLEAGT diff -rs $HSM_ARCHIVE/$ARC_SUBDIR \
1248 $DIR/$tdir/$ARC_SUBDIR | grep identical | wc -l)
1249 local cnt_diff=$(do_facet $SINGLEAGT diff -r $HSM_ARCHIVE/$ARC_SUBDIR \
1250 $DIR/$tdir/$ARC_SUBDIR | wc -l)
1252 [ $cnt_diff -eq 0 ] ||
1253 error "$cnt_diff imported files differ from read data"
1254 [ $cnt_ok -eq 100 ] ||
1255 error "not enough identical files ($cnt_ok != 100)"
1259 run_test 13 "Recursively import and restore a directory"
1262 # test needs a running copytool
1267 local f=$DIR/$tdir/$tfile
1268 local fid=$(make_small $f)
1269 local sum=$(md5sum $f | awk '{print $1}')
1270 $LFS hsm_archive $f || error "could not archive file"
1271 wait_request_state $fid ARCHIVE SUCCEED
1275 # create released file (simulate llapi_hsm_import call)
1277 local fid2=$(path2fid $f)
1278 $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
1279 $LFS hsm_release $f || error "could not release file"
1281 # rebind the archive to the newly created file
1282 echo "rebind $fid to $fid2"
1284 do_facet $SINGLEAGT \
1285 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1286 --rebind $fid $fid2 $DIR" || error "could not rebind file"
1288 # restore file and compare md5sum
1289 local sum2=$(md5sum $f | awk '{print $1}')
1291 [[ $sum == $sum2 ]] || error "md5sum mismatch after restore"
1295 run_test 14 "Rebind archived file to a new fid"
1298 # test needs a running copytool
1303 local f=$DIR/$tdir/$tfile
1305 local tmpfile=$SHARED_DIRECTORY/tmp.$$
1309 for i in $(seq 1 $count); do
1310 fids[$i]=$(make_small $f.$i)
1311 sums[$i]=$(md5sum $f.$i | awk '{print $1}')
1312 $LFS hsm_archive $f.$i || error "could not archive file"
1314 wait_all_done $(($count*60))
1318 for i in $(seq 1 $count); do
1321 local fid2=$(path2fid $f.$i)
1322 # add the rebind operation to the list
1323 echo ${fids[$i]} $fid2 >> $tmpfile
1325 # set it released (simulate llapi_hsm_import call)
1326 $LFS hsm_set --archived --exists $f.$i ||
1327 error "could not force hsm flags"
1328 $LFS hsm_release $f.$i || error "could not release file"
1330 nl=$(wc -l < $tmpfile)
1331 [[ $nl == $count ]] || error "$nl files in list, $count expected"
1333 echo "rebind list of files"
1334 do_facet $SINGLEAGT \
1335 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1336 --rebind $tmpfile $DIR" || error "could not rebind file list"
1338 # restore files and compare md5sum
1339 for i in $(seq 1 $count); do
1340 local sum2=$(md5sum $f.$i | awk '{print $1}')
1341 [[ $sum2 == ${sums[$i]} ]] ||
1342 error "md5sum mismatch after restore ($sum2 != ${sums[$i]})"
1348 run_test 15 "Rebind a list of files"
1351 # test needs a running copytool
1355 # create a known size file so we can verify transfer speed
1358 dd if=/dev/zero of=$ref bs=1M count=20
1361 local f=$DIR/$tdir/$tfile
1362 local fid=$(copy_file $ref $f)
1364 local start=$(date +%s)
1366 wait_request_state $fid ARCHIVE SUCCEED
1367 local end=$(date +%s)
1368 local duration=$((end - start))
1370 [[ $duration -ge $goal ]] ||
1371 error "Transfer is too fast $duration < $goal"
1375 run_test 16 "Test CT bandwith control option"
1380 local f=$DIR/$tdir/$tfile
1381 touch $f || error "touch $f failed"
1383 # Could not release a non-archived file
1384 $LFS hsm_release $f && error "release should not succeed"
1386 # For following tests, we must test them with HS_ARCHIVED set
1387 $LFS hsm_set --exists --archived $f || error "could not add flag"
1389 # Could not release a file if no-release is set
1390 $LFS hsm_set --norelease $f || error "could not add flag"
1391 $LFS hsm_release $f && error "release should not succeed"
1392 $LFS hsm_clear --norelease $f || error "could not remove flag"
1394 # Could not release a file if lost
1395 $LFS hsm_set --lost $f || error "could not add flag"
1396 $LFS hsm_release $f && error "release should not succeed"
1397 $LFS hsm_clear --lost $f || error "could not remove flag"
1399 # Could not release a file if dirty
1400 $LFS hsm_set --dirty $f || error "could not add flag"
1401 $LFS hsm_release $f && error "release should not succeed"
1402 $LFS hsm_clear --dirty $f || error "could not remove flag"
1404 run_test 20 "Release is not permitted"
1407 # test needs a running copytool
1411 local f=$DIR/$tdir/test_release
1413 # Create a file and check its states
1414 local fid=$(make_small $f)
1415 check_hsm_flags $f "0x00000000"
1417 # LU-4388/LU-4389 - ZFS does not report full number of blocks
1418 # used until file is flushed to disk
1419 if [ $(facet_fstype ost1) == "zfs" ]; then
1420 # this causes an OST_SYNC rpc to be sent
1421 dd if=/dev/zero of=$f bs=512 count=1 oflag=sync conv=notrunc,fsync
1422 # clear locks to reread file data
1423 cancel_lru_locks osc
1426 local orig_size=$(stat -c "%s" $f)
1427 local orig_blocks=$(stat -c "%b" $f)
1429 start_full_debug_logging
1431 $LFS hsm_archive $f || error "could not archive file"
1432 wait_request_state $fid ARCHIVE SUCCEED
1434 local blocks=$(stat -c "%b" $f)
1435 [ $blocks -eq $orig_blocks ] ||
1436 error "$f: wrong block number after archive: " \
1437 "$blocks != $orig_blocks"
1438 local size=$(stat -c "%s" $f)
1439 [ $size -eq $orig_size ] ||
1440 error "$f: wrong size after archive: $size != $orig_size"
1442 # Release and check states
1443 $LFS hsm_release $f || error "could not release file"
1444 check_hsm_flags $f "0x0000000d"
1446 blocks=$(stat -c "%b" $f)
1447 [ $blocks -gt 5 ] &&
1448 error "$f: too many blocks after release: $blocks > 5"
1449 size=$(stat -c "%s" $f)
1450 [ $size -ne $orig_size ] &&
1451 error "$f: wrong size after release: $size != $orig_size"
1453 # Check we can release an file without stripe info
1457 check_hsm_flags $f "0x00000000"
1458 $LFS hsm_archive $f || error "could not archive file"
1459 wait_request_state $fid ARCHIVE SUCCEED
1461 # Release and check states
1462 $LFS hsm_release $f || error "could not release file"
1463 check_hsm_flags $f "0x0000000d"
1465 # Release again a file that is already released is OK
1466 $LFS hsm_release $f || fail "second release should succeed"
1467 check_hsm_flags $f "0x0000000d"
1469 stop_full_debug_logging
1473 run_test 21 "Simple release tests"
1476 # test needs a running copytool
1481 local f=$DIR/$tdir/test_release
1482 local swap=$DIR/$tdir/test_swap
1484 # Create a file and check its states
1485 local fid=$(make_small $f)
1486 check_hsm_flags $f "0x00000000"
1488 $LFS hsm_archive $f || error "could not archive file"
1489 wait_request_state $fid ARCHIVE SUCCEED
1491 # Release and check states
1492 $LFS hsm_release $f || error "could not release file"
1493 check_hsm_flags $f "0x0000000d"
1496 $LFS swap_layouts $swap $f && error "swap_layouts should failed"
1501 run_test 22 "Could not swap a release file"
1504 # test needs a running copytool
1509 local f=$DIR/$tdir/test_mtime
1511 # Create a file and check its states
1512 local fid=$(make_small $f)
1513 check_hsm_flags $f "0x00000000"
1515 $LFS hsm_archive $f || error "could not archive file"
1516 wait_request_state $fid ARCHIVE SUCCEED
1518 # Set modification time in the past
1519 touch -m -a -d @978261179 $f
1521 # Release and check states
1522 $LFS hsm_release $f || error "could not release file"
1523 check_hsm_flags $f "0x0000000d"
1525 local MTIME=$(stat -c "%Y" $f)
1526 local ATIME=$(stat -c "%X" $f)
1527 [ $MTIME -eq "978261179" ] || fail "bad mtime: $MTIME"
1528 [ $ATIME -eq "978261179" ] || fail "bad atime: $ATIME"
1532 run_test 23 "Release does not change a/mtime (utime)"
1535 local file=$DIR/$tdir/$tfile
1544 # test needs a running copytool
1549 fid=$(make_small $file)
1551 # Create a file and check its states
1552 check_hsm_flags $file "0x00000000"
1554 # Ensure atime is less than mtime and ctime.
1558 atime0=$(stat -c "%X" $file)
1559 mtime0=$(stat -c "%Y" $file)
1560 ctime0=$(stat -c "%Z" $file)
1562 [ $atime0 -lt $mtime0 ] ||
1563 error "atime $atime0 is not less than mtime $mtime0"
1565 [ $atime0 -lt $ctime0 ] ||
1566 error "atime $atime0 is not less than ctime $ctime0"
1568 # Archive should not change any timestamps.
1569 $LFS hsm_archive $file || error "cannot archive '$file'"
1570 wait_request_state $fid ARCHIVE SUCCEED
1572 atime1=$(stat -c "%X" $file)
1573 mtime1=$(stat -c "%Y" $file)
1574 ctime1=$(stat -c "%Z" $file)
1576 [ $atime0 -eq $atime1 ] ||
1577 error "archive changed atime from $atime0 to $atime1"
1579 [ $mtime0 -eq $mtime1 ] ||
1580 error "archive changed mtime from $mtime0 to $mtime1"
1582 [ $ctime0 -eq $ctime1 ] ||
1583 error "archive changed ctime from $ctime0 to $ctime1"
1585 # Release should not change any timestamps.
1586 $LFS hsm_release $file || error "cannot release '$file'"
1587 check_hsm_flags $file "0x0000000d"
1589 atime1=$(stat -c "%X" $file)
1590 mtime1=$(stat -c "%Y" $file)
1591 ctime1=$(stat -c "%Z" $file)
1593 [ $atime0 -eq $atime1 ] ||
1594 error "release changed atime from $atime0 to $atime1"
1596 [ $mtime0 -eq $mtime1 ] ||
1597 error "release changed mtime from $mtime0 to $mtime1"
1599 [ $ctime0 -eq $ctime1 ] ||
1600 error "release changed ctime from $ctime0 to $ctime1"
1602 # Restore should not change atime or mtime and should not
1604 $LFS hsm_restore $file
1605 wait_request_state $fid RESTORE SUCCEED
1607 atime1=$(stat -c "%X" $file)
1608 mtime1=$(stat -c "%Y" $file)
1609 ctime1=$(stat -c "%Z" $file)
1611 [ $atime0 -eq $atime1 ] ||
1612 error "restore changed atime from $atime0 to $atime1"
1614 [ $mtime0 -eq $mtime1 ] ||
1615 error "restore changed mtime from $mtime0 to $mtime1"
1617 [ $ctime0 -le $ctime1 ] ||
1618 error "restore changed ctime from $ctime0 to $ctime1"
1622 # Once more, after unmount and mount.
1623 umount_client $MOUNT || error "cannot unmount '$MOUNT'"
1624 mount_client $MOUNT || error "cannot mount '$MOUNT'"
1626 atime1=$(stat -c "%X" $file)
1627 mtime1=$(stat -c "%Y" $file)
1628 ctime1=$(stat -c "%Z" $file)
1630 [ $atime0 -eq $atime1 ] ||
1631 error "remount changed atime from $atime0 to $atime1"
1633 [ $mtime0 -eq $mtime1 ] ||
1634 error "remount changed mtime from $mtime0 to $mtime1"
1636 [ $ctime0 -le $ctime1 ] ||
1637 error "remount changed ctime from $ctime0 to $ctime1"
1639 run_test 24a "Archive, release, and restore does not change a/mtime (i/o)"
1642 local file=$DIR/$tdir/$tfile
1648 # Test needs a running copytool.
1652 # Check that root can do HSM actions on a ordinary user's file.
1654 fid=$(make_small $file)
1655 sum0=$(md5sum $file)
1657 chown $RUNAS_ID:$RUNAS_GID $file ||
1658 error "cannot chown '$file' to '$RUNAS_ID'"
1660 chmod ugo-w $DIR/$tdir ||
1661 error "cannot chmod '$DIR/$tdir'"
1663 $LFS hsm_archive $file
1664 wait_request_state $fid ARCHIVE SUCCEED
1666 $LFS hsm_release $file
1667 check_hsm_flags $file "0x0000000d"
1669 $LFS hsm_restore $file
1670 wait_request_state $fid RESTORE SUCCEED
1672 # Check that ordinary user can get HSM state.
1673 $RUNAS $LFS hsm_state $file ||
1674 error "user '$RUNAS_ID' cannot get HSM state of '$file'"
1676 $LFS hsm_release $file
1677 check_hsm_flags $file "0x0000000d"
1679 # Check that ordinary user can accessed released file.
1680 sum1=$($RUNAS md5sum $file) ||
1681 error "user '$RUNAS_ID' cannot read '$file'"
1683 [ "$sum0" == "$sum1" ] ||
1684 error "md5sum mismatch for '$file'"
1688 run_test 24b "root can archive, release, and restore user files"
1690 cleanup_test_24c() {
1692 set_hsm_param user_request_mask RESTORE
1693 set_hsm_param group_request_mask RESTORE
1694 set_hsm_param other_request_mask RESTORE
1698 local file=$DIR/$tdir/$tfile
1699 local action=archive
1704 # test needs a running copytool
1709 # Save the default masks and check that cleanup_24c will
1710 # restore the request masks correctly.
1711 user_save=$(get_hsm_param user_request_mask)
1712 group_save=$(get_hsm_param group_request_mask)
1713 other_save=$(get_hsm_param other_request_mask)
1715 [ "$user_save" == RESTORE ] ||
1716 error "user_request_mask is '$user_save' expected 'RESTORE'"
1717 [ "$group_save" == RESTORE ] ||
1718 error "group_request_mask is '$group_save' expected 'RESTORE'"
1719 [ "$other_save" == RESTORE ] ||
1720 error "other_request_mask is '$other_save' expected 'RESTORE'"
1722 trap cleanup_test_24c EXIT
1727 chown $RUNAS_ID:nobody $file ||
1728 error "cannot chown '$file' to '$RUNAS_ID:nobody'"
1730 set_hsm_param user_request_mask ""
1731 $RUNAS $LFS hsm_$action $file &&
1732 error "$action by user should fail"
1734 set_hsm_param user_request_mask $action
1735 $RUNAS $LFS hsm_$action $file ||
1736 error "$action by user should succeed"
1741 chown nobody:$RUNAS_GID $file ||
1742 error "cannot chown '$file' to 'nobody:$RUNAS_GID'"
1744 set_hsm_param group_request_mask ""
1745 $RUNAS $LFS hsm_$action $file &&
1746 error "$action by group should fail"
1748 set_hsm_param group_request_mask $action
1749 $RUNAS $LFS hsm_$action $file ||
1750 error "$action by group should succeed"
1755 chown nobody:nobody $file ||
1756 error "cannot chown '$file' to 'nobody:nobody'"
1758 set_hsm_param other_request_mask ""
1759 $RUNAS $LFS hsm_$action $file &&
1760 error "$action by other should fail"
1762 set_hsm_param other_request_mask $action
1763 $RUNAS $LFS hsm_$action $file ||
1764 error "$action by other should succeed"
1769 run_test 24c "check that user,group,other request masks work"
1771 cleanup_test_24d() {
1773 mount -o remount,rw $MOUNT2
1777 local file1=$DIR/$tdir/$tfile
1778 local file2=$DIR2/$tdir/$tfile
1786 fid1=$(make_small $file1)
1788 trap cleanup_test_24d EXIT
1790 mount -o remount,ro $MOUNT2
1792 fid2=$(path2fid $file2)
1793 [ "$fid1" == "$fid2" ] ||
1794 error "FID mismatch '$fid1' != '$fid2'"
1796 $LFS hsm_archive $file2 &&
1797 error "archive should fail on read-only mount"
1798 check_hsm_flags $file1 "0x00000000"
1800 $LFS hsm_archive $file1
1801 wait_request_state $fid1 ARCHIVE SUCCEED
1803 $LFS hsm_release $file1
1804 $LFS hsm_restore $file2
1805 wait_request_state $fid1 RESTORE SUCCEED
1807 $LFS hsm_release $file1 || error "cannot release '$file1'"
1808 dd if=$file2 of=/dev/null bs=1M || "cannot read '$file2'"
1810 $LFS hsm_release $file2 &&
1811 error "release should fail on read-only mount"
1816 run_test 24d "check that read-only mounts are respected"
1819 # test needs a running copytool
1823 copy2archive /etc/hosts $tdir/$tfile
1825 local f=$DIR/$tdir/$tfile
1827 import_file $tdir/$tfile $f
1829 $LFS hsm_set --lost $f
1834 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1838 run_test 25a "Restore lost file (HS_LOST flag) from import"\
1839 " (Operation not permitted)"
1842 # test needs a running copytool
1847 local f=$DIR/$tdir/$tfile
1848 local fid=$(copy_file /etc/passwd $f)
1850 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1851 wait_request_state $fid ARCHIVE SUCCEED
1854 $LFS hsm_set --lost $f
1858 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1862 run_test 25b "Restore lost file (HS_LOST flag) after release"\
1863 " (Operation not permitted)"
1866 # test needs a running copytool
1870 local f=$DIR/$tdir/$tfile
1871 local fid=$(make_large_for_progress $f)
1872 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1873 wait_request_state $fid ARCHIVE SUCCEED
1876 wait_request_state $fid REMOVE SUCCEED
1878 check_hsm_flags $f "0x00000000"
1882 run_test 26 "Remove the archive of a valid file"
1885 # test needs a running copytool
1889 make_archive $tdir/$tfile
1890 local f=$DIR/$tdir/$tfile
1891 import_file $tdir/$tfile $f
1892 local fid=$(path2fid $f)
1896 [[ $? != 0 ]] || error "Remove of a released file should fail"
1900 run_test 27a "Remove the archive of an imported file (Operation not permitted)"
1903 # test needs a running copytool
1907 local f=$DIR/$tdir/$tfile
1908 local fid=$(make_large_for_progress $f)
1909 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1910 wait_request_state $fid ARCHIVE SUCCEED
1915 [[ $? != 0 ]] || error "Remove of a released file should fail"
1919 run_test 27b "Remove the archive of a relased file (Operation not permitted)"
1922 # test needs a running copytool
1926 local f=$DIR/$tdir/$tfile
1927 local fid=$(make_large_for_progress $f)
1928 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1929 wait_request_state $fid ARCHIVE SUCCEED
1938 wait_request_state $fid REMOVE SUCCEED
1942 run_test 28 "Concurrent archive/file remove"
1945 # restore at exec cannot work on agent node (because of Linux kernel
1946 # protection of executables)
1947 needclients 2 || return 0
1949 # test needs a running copytool
1953 copy2archive /bin/true $tdir/$tfile
1955 local f=$DIR/$tdir/true
1956 import_file $tdir/$tfile $f
1958 local fid=$(path2fid $f)
1960 # set no retry action mode
1966 # remove no try action mode
1970 [[ $st == 0 ]] || error "Failed to exec a released file"
1974 run_test 30a "Restore at exec (import case)"
1977 # restore at exec cannot work on agent node (because of Linux kernel
1978 # protection of executables)
1979 needclients 2 || return 0
1981 # test needs a running copytool
1985 local f=$DIR/$tdir/true
1986 local fid=$(copy_file /bin/true $f)
1988 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1989 wait_request_state $fid ARCHIVE SUCCEED
1992 # set no retry action mode
1998 # remove no try action mode
2002 [[ $st == 0 ]] || error "Failed to exec a released file"
2006 run_test 30b "Restore at exec (release case)"
2009 needclients 2 || return 0
2011 # test needs a running copytool
2015 local f=$DIR/$tdir/SLEEP
2016 local fid=$(copy_file /bin/sleep $f)
2018 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2019 wait_request_state $fid ARCHIVE SUCCEED
2021 check_hsm_flags $f "0x0000000d"
2022 # set no retry action mode
2024 do_node $CLIENT2 "$f 10" &
2028 [[ $? == 0 ]] && error "Update during exec of released file must fail"
2030 [[ $? == 0 ]] || error "Execution failed during run"
2032 [[ $? == 0 ]] || error "Binary overwritten during exec"
2035 # remove no try action mode
2037 check_hsm_flags $f "0x00000009"
2041 run_test 30c "Update during exec of released file must fail"
2043 restore_and_check_size() {
2046 local s=$(stat -c "%s" $f)
2048 local st=$(get_hsm_flags $f)
2052 while [[ "$st" != "0x00000009" && $cpt -le 10 ]]
2054 n=$(stat -c "%s" $f)
2055 # we echo in both cases to show stat is not
2057 if [[ $n != $s ]]; then
2058 echo "size seen is $n != $s"
2061 echo "size seen is right: $n == $s"
2063 st=$(get_hsm_flags $f)
2067 if [[ $cpt -lt 10 ]]; then
2070 echo " restore is too long"
2071 wait_request_state $fid RESTORE SUCCEED
2077 # test needs a running copytool
2082 make_archive $tdir/$tfile
2083 local f=$DIR/$tdir/$tfile
2084 import_file $tdir/$tfile $f
2085 local fid=$($LFS path2fid $f)
2086 HSM_ARCHIVE_PURGE=false copytool_setup
2088 restore_and_check_size $f $fid
2091 [[ $err -eq 0 ]] || error "File size changed during restore"
2095 run_test 31a "Import a large file and check size during restore"
2099 # test needs a running copytool
2104 local f=$DIR/$tdir/$tfile
2105 local fid=$(make_large_for_progress $f)
2106 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2107 wait_request_state $fid ARCHIVE SUCCEED
2110 restore_and_check_size $f $fid
2113 [[ $err -eq 0 ]] || error "File size changed during restore"
2117 run_test 31b "Restore a large unaligned file and check size during restore"
2120 # test needs a running copytool
2125 local f=$DIR/$tdir/$tfile
2126 local fid=$(make_large_for_progress_aligned $f)
2127 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2128 wait_request_state $fid ARCHIVE SUCCEED
2131 restore_and_check_size $f $fid
2134 [[ $err -eq 0 ]] || error "File size changed during restore"
2138 run_test 31c "Restore a large aligned file and check size during restore"
2141 # test needs a running copytool
2146 local f=$DIR/$tdir/$tfile
2147 local fid=$(make_large_for_progress $f)
2148 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2149 wait_request_state $fid ARCHIVE SUCCEED
2152 md5sum $f >/dev/null &
2154 wait_request_state $fid RESTORE STARTED
2159 # Check restore trigger process was killed
2160 local killed=$(ps -o pid,comm hp $pid >/dev/null)
2164 wait_request_state $fid RESTORE CANCELED
2165 wait_request_state $fid CANCEL SUCCEED
2168 error "Cannot kill process waiting for restore ($killed)"
2172 run_test 33 "Kill a restore waiting process"
2175 # test needs a running copytool
2180 local f=$DIR/$tdir/$tfile
2181 local fid=$(make_large_for_progress $f)
2182 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2183 wait_request_state $fid ARCHIVE SUCCEED
2186 md5sum $f >/dev/null &
2188 wait_request_state $fid RESTORE STARTED
2190 rm $f || error "rm $f failed"
2191 # rm must not block during restore
2192 wait_request_state $fid RESTORE STARTED
2194 wait_request_state $fid RESTORE SUCCEED
2195 # check md5sum pgm finished
2196 local there=$(ps -o pid,comm hp $pid >/dev/null)
2197 [[ -z $there ]] || error "Restore initiator does not exit"
2199 local rc=$(wait $pid)
2200 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2204 run_test 34 "Remove file during restore"
2207 # test needs a running copytool
2212 local f=$DIR/$tdir/$tfile
2213 local f1=$DIR/$tdir/$tfile-1
2214 local fid=$(make_large_for_progress $f)
2215 local fid1=$(copy_file /etc/passwd $f1)
2216 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2217 wait_request_state $fid ARCHIVE SUCCEED
2220 md5sum $f >/dev/null &
2222 wait_request_state $fid RESTORE STARTED
2224 mv $f1 $f || error "mv $f1 $f failed"
2225 # mv must not block during restore
2226 wait_request_state $fid RESTORE STARTED
2228 wait_request_state $fid RESTORE SUCCEED
2229 # check md5sum pgm finished
2230 local there=$(ps -o pid,comm hp $pid >/dev/null)
2231 [[ -z $there ]] || error "Restore initiator does not exit"
2233 local rc=$(wait $pid)
2234 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2237 [[ $fid2 == $fid1 ]] || error "Wrong fid after mv $fid2 != $fid1"
2241 run_test 35 "Overwrite file during restore"
2244 # test needs a running copytool
2249 local f=$DIR/$tdir/$tfile
2250 local fid=$(make_large_for_progress $f)
2251 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2252 wait_request_state $fid ARCHIVE SUCCEED
2255 md5sum $f >/dev/null &
2257 wait_request_state $fid RESTORE STARTED
2260 # rm must not block during restore
2261 wait_request_state $fid RESTORE STARTED
2263 wait_request_state $fid RESTORE SUCCEED
2264 # check md5sum pgm finished
2265 local there=$(ps -o pid,comm hp $pid >/dev/null)
2267 error "Restore initiator does not exit"
2269 local rc=$(wait $pid)
2271 error "Restore initiator failed with $rc"
2275 run_test 36 "Move file during restore"
2282 for n in $(seq 1 $count); do
2283 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $prefix.$n
2285 echo "$count archive requests submitted"
2289 local stream_count=4
2290 local file_count=100
2292 local f=$DIR/$tdir/$tfile
2297 for i in $(seq 1 $file_count); do
2298 for p in $(seq 1 $stream_count); do
2299 fid=$(copy_file /etc/hosts $f.$p.$i)
2302 # force copytool to use a local/temp archive dir to ensure best
2303 # performance vs remote/NFS mounts used in auto-tests
2304 if df --local $HSM_ARCHIVE >/dev/null 2>&1 ; then
2307 copytool_setup $SINGLEAGT $MOUNT $HSM_ARCHIVE_NUMBER $TMP/$tdir
2309 # to be sure wait_all_done will not be mislead by previous tests
2311 wait_for_grace_delay
2313 # start archive streams in background (archive files in parallel)
2314 for p in $(seq 1 $stream_count); do
2315 multi_archive $f.$p $file_count &
2318 echo -n "Wait for all requests being enqueued..."
2324 run_test 40 "Parallel archive requests"
2327 # test needs a running copytool
2331 local f=$DIR/$tdir/$tfile
2332 local fid=$(copy_file /etc/motd $f 1)
2334 $LFS hsm_archive $f || error "could not archive file"
2335 wait_request_state $fid ARCHIVE SUCCEED
2336 check_hsm_flags $f "0x00000009"
2338 multiop_bg_pause $f O_c || error "multiop failed"
2342 client_up || client_up || true
2344 kill -USR1 $MULTIPID
2345 wait $MULTIPID || error "multiop close failed"
2347 check_hsm_flags $f "0x0000000b"
2351 run_test 52 "Opened for write file on an evicted client should be set dirty"
2354 # test needs a running copytool
2358 local f=$DIR/$tdir/$tfile
2359 local fid=$(copy_file /etc/motd $f 1)
2361 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2362 error "could not archive file"
2363 wait_request_state $fid ARCHIVE SUCCEED
2364 check_hsm_flags $f "0x00000009"
2366 multiop_bg_pause $f o_c || error "multiop failed"
2370 client_up || client_up || true
2372 kill -USR1 $MULTIPID
2373 wait $MULTIPID || error "multiop close failed"
2375 check_hsm_flags $f "0x00000009"
2379 run_test 53 "Opened for read file on an evicted client should not be set dirty"
2382 # test needs a running copytool
2386 local f=$DIR/$tdir/$tfile
2387 local fid=$(make_small $f)
2389 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2390 error "could not archive file"
2391 wait_request_state $fid ARCHIVE STARTED
2393 check_hsm_flags $f "0x00000001"
2395 # Avoid coordinator resending this request as soon it has failed.
2400 wait_request_state $fid ARCHIVE FAILED
2402 check_hsm_flags $f "0x00000003"
2407 run_test 54 "Write during an archive cancels it"
2410 # test needs a running copytool
2414 local f=$DIR/$tdir/$tfile
2415 local fid=$(make_small $f)
2417 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2418 error "could not archive file"
2419 wait_request_state $fid ARCHIVE STARTED
2421 check_hsm_flags $f "0x00000001"
2423 # Avoid coordinator resending this request as soon it has failed.
2426 $TRUNCATE $f 1024 || error "truncate failed"
2428 wait_request_state $fid ARCHIVE FAILED
2430 check_hsm_flags $f "0x00000003"
2435 run_test 55 "Truncate during an archive cancels it"
2438 # test needs a running copytool
2442 local f=$DIR/$tdir/$tfile
2443 local fid=$(make_large_for_progress $f)
2445 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2446 error "could not archive file"
2447 wait_request_state $fid ARCHIVE STARTED
2449 check_hsm_flags $f "0x00000001"
2451 # Change metadata and sync to be sure we are not changing only
2456 wait_request_state $fid ARCHIVE SUCCEED
2458 check_hsm_flags $f "0x00000009"
2462 run_test 56 "Setattr during an archive is ok"
2465 # Need one client for I/O, one for request
2466 needclients 2 || return 0
2468 # test needs a running copytool
2472 local f=$DIR/$tdir/test_archive_remote
2473 # Create a file on a remote node
2474 do_node $CLIENT2 "dd if=/dev/urandom of=$f bs=1M "\
2475 "count=2 conv=fsync"
2478 do_node $CLIENT2 "$LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f" ||
2479 error "hsm_archive failed"
2480 local fid=$(path2fid $f)
2481 wait_request_state $fid ARCHIVE SUCCEED
2483 # Release and implicit restore it
2484 do_node $CLIENT2 "$LFS hsm_release $f" ||
2485 error "hsm_release failed"
2486 do_node $CLIENT2 "md5sum $f" ||
2487 error "hsm_restore failed"
2489 wait_request_state $fid RESTORE SUCCEED
2493 run_test 57 "Archive a file with dirty cache on another node"
2495 truncate_released_file() {
2499 local sz=$(stat -c %s $src_file)
2500 local f=$DIR/$tdir/$tfile
2501 local fid=$(copy_file $1 $f)
2505 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2506 error "could not archive file"
2507 wait_request_state $fid ARCHIVE SUCCEED
2509 $LFS hsm_release $f || error "could not release file"
2511 $TRUNCATE $f $trunc_to || error "truncate failed"
2514 local sz1=$(stat -c %s $f)
2515 [[ $sz1 == $trunc_to ]] ||
2516 error "size after trunc: $sz1 expect $trunc_to, original $sz"
2519 check_hsm_flags $f "0x0000000b"
2521 local state=$(get_request_state $fid RESTORE)
2522 [[ "$state" == "SUCCEED" ]] ||
2523 error "truncate $sz does not trig restore, state = $state"
2525 $TRUNCATE $ref $trunc_to
2526 cmp $ref $f || error "file data wrong after truncate"
2532 # test needs a running copytool
2537 local sz=$(stat -c %s /etc/passwd)
2539 echo "truncate up from $sz to $((sz*2))"
2540 truncate_released_file /etc/passwd $((sz*2))
2542 echo "truncate down from $sz to $((sz/2))"
2543 truncate_released_file /etc/passwd $((sz/2))
2545 echo "truncate to 0"
2546 truncate_released_file /etc/passwd 0
2550 run_test 58 "Truncate a released file will trigger restore"
2554 local progress_timeout=$((interval * 2))
2556 # test needs a new running copytool
2558 HSMTOOL_UPDATE_INTERVAL=$interval copytool_setup
2561 local f=$DIR/$tdir/$tfile
2562 local fid=$(make_large_for_progress $f)
2564 local start_at=$(date +%s)
2565 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2566 error "could not archive file"
2567 wait_request_progress $fid ARCHIVE 5242880
2568 local finish_at=$(date +%s)
2569 local elapsed=$((finish_at - start_at))
2571 if [ $elapsed -gt $progress_timeout ]; then
2572 error "Expected progress update within $progress_timeout seconds"
2573 elif [ $elapsed -lt $interval ]; then
2574 error "Expected progress update after at least $interval seconds"
2580 run_test 60 "Changing progress update interval from default"
2585 local f=$DIR/$tdir/$tfile
2586 local FILELIST=/tmp/filelist.txt
2590 for i in $(seq 1 $file_count); do
2591 fid=$(copy_file /etc/hosts $f.$i)
2592 echo $f.$i >> $FILELIST
2595 # to be sure wait_all_done will not be mislead by previous tests
2597 wait_for_grace_delay
2598 $LFS hsm_archive --filelist $FILELIST ||
2599 error "cannot archive a file list"
2601 $LFS hsm_release --filelist $FILELIST ||
2602 error "cannot release a file list"
2603 $LFS hsm_restore --filelist $FILELIST ||
2604 error "cannot restore a file list"
2608 run_test 90 "Archive/restore a file list"
2610 double_verify_reset_hsm_param() {
2612 echo "Testing $HSM_PARAM.$p"
2613 local val=$(get_hsm_param $p)
2615 local val2=$(($val * 2))
2616 set_hsm_param $p $val2
2617 val=$(get_hsm_param $p)
2618 [[ $val == $val2 ]] ||
2619 error "$HSM_PARAM.$p: $val != $val2 should be (2 * $save)"
2620 echo "Set $p to 0 must failed"
2624 set_hsm_param $p $save
2626 if [[ $rc == 0 ]]; then
2627 error "we must not be able to set $HSM_PARAM.$p to 0"
2632 double_verify_reset_hsm_param loop_period
2633 double_verify_reset_hsm_param grace_delay
2634 double_verify_reset_hsm_param active_request_timeout
2635 double_verify_reset_hsm_param max_requests
2636 double_verify_reset_hsm_param default_archive_id
2638 run_test 100 "Set coordinator /proc tunables"
2645 run_test 102 "Verify coordinator control"
2648 # test needs a running copytool
2655 for i in $(seq 1 20); do
2656 fid=$(copy_file /etc/passwd $DIR/$tdir/$i)
2658 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/*
2662 echo "Current requests"
2663 local res=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2664 $HSM_PARAM.actions |\
2665 grep -v CANCELED | grep -v SUCCEED | grep -v FAILED")
2667 [[ -z "$res" ]] || error "Some request have not been canceled"
2671 run_test 103 "Purge all requests"
2676 # test needs a running copytool
2680 local f=$DIR/$tdir/$tfile
2681 local fid=$(make_large_for_progress $f)
2682 # if cdt is on, it can serve too quickly the request
2684 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER --data $DATA $f
2685 local data1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2686 $HSM_PARAM.actions |\
2687 grep $fid | cut -f16 -d=")
2690 [[ "$data1" == "$DATAHEX" ]] ||
2691 error "Data field in records is ($data1) and not ($DATAHEX)"
2695 run_test 104 "Copy tool data field"
2702 for i in $(seq -w 1 10); do
2703 cp /etc/passwd $DIR/$tdir/$i
2704 $LFS hsm_archive $DIR/$tdir/$i
2706 local reqcnt1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2707 $HSM_PARAM.actions |\
2708 grep WAITING | wc -l")
2711 local reqcnt2=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2712 $HSM_PARAM.actions |\
2713 grep WAITING | wc -l")
2716 [[ "$reqcnt1" == "$reqcnt2" ]] ||
2717 error "Requests count after shutdown $reqcnt2 != "\
2718 "before shutdown $reqcnt1"
2720 run_test 105 "Restart of coordinator"
2722 get_agent_by_uuid_mdt() {
2725 local mds=mds$(($mdtidx + 1))
2726 do_facet $mds "$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.agents |\
2730 check_agent_registered_by_mdt() {
2733 local mds=mds$(($mdtidx + 1))
2734 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
2735 if [[ ! -z "$agent" ]]; then
2736 echo "found agent $agent on $mds"
2738 error "uuid $uuid not found in agent list on $mds"
2742 check_agent_unregistered_by_mdt() {
2745 local mds=mds$(($mdtidx + 1))
2746 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
2747 if [[ -z "$agent" ]]; then
2748 echo "uuid not found in agent list on $mds"
2750 error "uuid found in agent list on $mds: $agent"
2754 check_agent_registered() {
2757 for mdsno in $(seq 1 $MDSCOUNT); do
2758 check_agent_registered_by_mdt $uuid $((mdsno - 1))
2762 check_agent_unregistered() {
2765 for mdsno in $(seq 1 $MDSCOUNT); do
2766 check_agent_unregistered_by_mdt $uuid $((mdsno - 1))
2771 local uuid=$(do_rpc_nodes $(facet_active_host $SINGLEAGT) \
2772 get_client_uuid $MOUNT | cut -d' ' -f2)
2775 check_agent_registered $uuid
2777 search_copytools || error "No copytool found"
2780 check_agent_unregistered $uuid
2783 check_agent_registered $uuid
2787 run_test 106 "Copytool register/unregister"
2790 # test needs a running copytool
2792 # create and archive file
2794 local f1=$DIR/$tdir/$tfile
2795 local fid=$(copy_file /etc/passwd $f1)
2796 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2797 wait_request_state $fid ARCHIVE SUCCEED
2798 # shutdown and restart MDS
2800 # check the copytool still gets messages from MDT
2801 local f2=$DIR/$tdir/2
2802 local fid=$(copy_file /etc/passwd $f2)
2803 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f2
2804 # main check of this sanity: this request MUST succeed
2805 wait_request_state $fid ARCHIVE SUCCEED
2808 run_test 107 "Copytool re-register after MDS restart"
2810 policy_set_and_test()
2814 do_facet $SINGLEMDS $LCTL set_param "$HSM_PARAM.policy=\\\"$change\\\""
2815 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2816 [[ "$policy" == "$target" ]] ||
2817 error "Wrong policy after '$change': '$policy' != '$target'"
2821 # to force default policy setting if error
2822 CDT_POLICY_HAD_CHANGED=true
2824 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2825 local default="NonBlockingRestore [NoRetryAction]"
2826 [[ "$policy" == "$default" ]] ||
2827 error "default policy has changed,"\
2828 " '$policy' != '$default' update the test"
2829 policy_set_and_test "+NBR" "[NonBlockingRestore] [NoRetryAction]"
2830 policy_set_and_test "+NRA" "[NonBlockingRestore] [NoRetryAction]"
2831 policy_set_and_test "-NBR" "NonBlockingRestore [NoRetryAction]"
2832 policy_set_and_test "-NRA" "NonBlockingRestore NoRetryAction"
2833 policy_set_and_test "NRA NBR" "[NonBlockingRestore] [NoRetryAction]"
2834 # useless bacause we know but safer for futur changes to use real value
2835 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2836 echo "Next set_param must failed"
2837 policy_set_and_test "wrong" "$policy"
2840 echo "Back to default policy"
2841 cdt_set_sanity_policy
2843 run_test 109 "Policy display/change"
2846 # test needs a running copytool
2851 copy2archive /etc/passwd $tdir/$tfile
2853 local f=$DIR/$tdir/$tfile
2854 import_file $tdir/$tfile $f
2855 local fid=$(path2fid $f)
2857 cdt_set_non_blocking_restore
2862 wait_request_state $fid RESTORE SUCCEED
2863 cdt_clear_non_blocking_restore
2867 error "md5sum returns $st != 1, "\
2868 "should also perror ENODATA (No data available)"
2872 run_test 110a "Non blocking restore policy (import case)"
2875 # test needs a running copytool
2879 local f=$DIR/$tdir/$tfile
2880 local fid=$(copy_file /etc/passwd $f)
2881 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2882 wait_request_state $fid ARCHIVE SUCCEED
2885 cdt_set_non_blocking_restore
2890 wait_request_state $fid RESTORE SUCCEED
2891 cdt_clear_non_blocking_restore
2895 error "md5sum returns $st != 1, "\
2896 "should also perror ENODATA (No data available)"
2900 run_test 110b "Non blocking restore policy (release case)"
2903 # test needs a running copytool
2907 copy2archive /etc/passwd $tdir/$tfile
2909 local f=$DIR/$tdir/$tfile
2911 import_file $tdir/$tfile $f
2912 local fid=$(path2fid $f)
2916 copytool_remove_backend $fid
2919 wait_request_state $fid RESTORE FAILED
2926 [[ $st == 0 ]] || error "Restore does not failed"
2930 run_test 111a "No retry policy (import case), restore will error"\
2931 " (No such file or directory)"
2934 # test needs a running copytool
2938 local f=$DIR/$tdir/$tfile
2939 local fid=$(copy_file /etc/passwd $f)
2941 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2942 wait_request_state $fid ARCHIVE SUCCEED
2945 copytool_remove_backend $fid
2948 wait_request_state $fid RESTORE FAILED
2955 [[ $st == 0 ]] || error "Restore does not failed"
2959 run_test 111b "No retry policy (release case), restore will error"\
2960 " (No such file or directory)"
2963 # test needs a running copytool
2967 local f=$DIR/$tdir/$tfile
2968 local fid=$(copy_file /etc/passwd $f)
2970 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2971 local l=$($LFS hsm_action $f)
2973 local res=$(echo $l | cut -f 2- -d" " | grep ARCHIVE)
2977 wait_request_state $fid ARCHIVE SUCCEED
2980 [[ ! -z "$res" ]] || error "action is $l which is not an ARCHIVE"
2984 run_test 112 "State of recorded request"
2987 # test needs a running copytool
2991 local f=$DIR/$tdir/$tfile
2992 local fid=$(make_large_for_cancel $f)
2993 # test with cdt on is made in test_221
2995 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2998 wait_request_state $fid ARCHIVE CANCELED
2999 wait_request_state $fid CANCEL SUCCEED
3003 run_test 200 "Register/Cancel archive"
3006 # test needs a running copytool
3010 local f=$DIR/$tdir/$tfile
3011 make_archive $tdir/$tfile
3012 import_file $tdir/$tfile $f
3013 local fid=$(path2fid $f)
3015 # test with cdt on is made in test_222
3020 wait_request_state $fid RESTORE CANCELED
3021 wait_request_state $fid CANCEL SUCCEED
3025 run_test 201 "Register/Cancel restore"
3028 # test needs a running copytool
3032 local f=$DIR/$tdir/$tfile
3033 local fid=$(make_large_for_progress $f)
3034 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3035 wait_request_state $fid ARCHIVE SUCCEED
3041 wait_request_state $fid REMOVE CANCELED
3045 run_test 202 "Register/Cancel remove"
3048 # test needs a running copytool
3053 local f=$DIR/$tdir/$tfile
3054 local fid=$(copy_file /etc/passwd $f)
3058 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3059 wait_request_state $fid ARCHIVE SUCCEED
3061 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3065 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3069 run_test 220 "Changelog for archive"
3072 # test needs a running copytool
3077 local f=$DIR/$tdir/$tfile
3078 local fid=$(make_large_for_cancel $f)
3082 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3083 wait_request_state $fid ARCHIVE STARTED
3085 wait_request_state $fid ARCHIVE CANCELED
3086 wait_request_state $fid CANCEL SUCCEED
3088 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3091 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3095 run_test 221 "Changelog for archive canceled"
3098 # test needs a running copytool
3102 copy2archive /etc/passwd $tdir/$tfile
3104 local f=$DIR/$tdir/$tfile
3105 import_file $tdir/$tfile $f
3106 local fid=$(path2fid $f)
3111 wait_request_state $fid RESTORE SUCCEED
3113 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3116 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3120 run_test 222a "Changelog for explicit restore"
3123 # test needs a running copytool
3127 local f=$DIR/$tdir/$tfile
3128 local fid=$(copy_file /etc/passwd $f)
3131 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3132 wait_request_state $fid ARCHIVE SUCCEED
3137 wait_request_state $fid RESTORE SUCCEED
3139 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3142 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3146 run_test 222b "Changelog for implicit restore"
3149 # test needs a running copytool
3154 local f=$DIR/$tdir/$tfile
3155 make_archive $tdir/$tfile
3159 import_file $tdir/$tfile $f
3160 local fid=$(path2fid $f)
3163 wait_request_state $fid RESTORE STARTED
3165 wait_request_state $fid RESTORE CANCELED
3166 wait_request_state $fid CANCEL SUCCEED
3168 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3171 [[ $flags == $target ]] ||
3172 error "Changelog flag is $flags not $target"
3176 run_test 223a "Changelog for restore canceled (import case)"
3179 # test needs a running copytool
3184 local f=$DIR/$tdir/$tfile
3185 local fid=$(make_large_for_progress $f)
3188 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3189 wait_request_state $fid ARCHIVE SUCCEED
3192 wait_request_state $fid RESTORE STARTED
3194 wait_request_state $fid RESTORE CANCELED
3195 wait_request_state $fid CANCEL SUCCEED
3197 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3200 [[ $flags == $target ]] ||
3201 error "Changelog flag is $flags not $target"
3205 run_test 223b "Changelog for restore canceled (release case)"
3208 # test needs a running copytool
3213 local f=$DIR/$tdir/$tfile
3214 local fid=$(copy_file /etc/passwd $f)
3217 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3218 wait_request_state $fid ARCHIVE SUCCEED
3221 wait_request_state $fid REMOVE SUCCEED
3223 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -n 1)
3226 [[ $flags == $target ]] ||
3227 error "Changelog flag is $flags not $target"
3231 run_test 224 "Changelog for remove"
3234 # test needs a running copytool
3237 # test is not usable because remove request is too fast
3238 # so it is always finished before cancel can be done ...
3239 echo "Test disabled"
3244 local f=$DIR/$tdir/$tfile
3245 local fid=$(make_large_for_progress $f)
3248 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3249 wait_request_state $fid ARCHIVE SUCCEED
3251 # if cdt is on, it can serve too quickly the request
3256 wait_request_state $fid REMOVE CANCELED
3257 wait_request_state $fid CANCEL SUCCEED
3259 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3260 local flags=$($LFS changelog ${MDT[0]} | grep HSM | grep $fid |
3261 tail -n 1 | awk '{print $5}')
3264 [[ $flags == $target ]] ||
3265 error "Changelog flag is $flags not $target"
3269 run_test 225 "Changelog for remove canceled"
3272 # test needs a running copytool
3277 local f1=$DIR/$tdir/$tfile-1
3278 local f2=$DIR/$tdir/$tfile-2
3279 local f3=$DIR/$tdir/$tfile-3
3280 local fid1=$(copy_file /etc/passwd $f1)
3281 local fid2=$(copy_file /etc/passwd $f2)
3282 copy_file /etc/passwd $f3
3285 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
3286 wait_request_state $fid1 ARCHIVE SUCCEED
3288 $LFS hsm_archive $f2
3289 wait_request_state $fid2 ARCHIVE SUCCEED
3291 rm $f1 || error "rm $f1 failed"
3293 local flags=$(changelog_get_flags ${MDT[0]} UNLNK $fid1)
3296 [[ $flags == $target ]] ||
3297 error "Changelog flag is $flags not $target"
3299 mv $f3 $f2 || error "mv $f3 $f2 failed"
3301 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3304 [[ $flags == $target ]] ||
3305 error "Changelog flag is $flags not $target"
3309 run_test 226 "changelog for last rm/mv with exiting archive"
3311 check_flags_changes() {
3319 $LFS hsm_set --$hsm_flag $f ||
3320 error "Cannot set $hsm_flag on $f"
3321 local flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3322 local seen=${#flags[*]}
3324 [[ $seen == $cnt ]] ||
3325 error "set $hsm_flag: Changelog events $seen != $cnt"
3326 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3327 error "set $hsm_flag: Changelog flags are "\
3328 "${flags[$((cnt - 1))]} not $target"
3330 $LFS hsm_clear --$hsm_flag $f ||
3331 error "Cannot clear $hsm_flag on $f"
3332 flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3335 [[ $cnt == $seen ]] ||
3336 error "clear $hsm_flag: Changelog events $seen != $cnt"
3338 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3339 error "clear $hsm_flag: Changelog flag is "\
3340 "${flags[$((cnt - 1))]} not $target"
3344 # test needs a running copytool
3351 for i in norelease noarchive exists archived
3353 local f=$DIR/$tdir/$tfile-$i
3354 local fid=$(copy_file /etc/passwd $f)
3355 check_flags_changes $f $fid $i 0 1
3358 f=$DIR/$tdir/$tfile---lost
3359 fid=$(copy_file /etc/passwd $f)
3360 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3361 wait_request_state $fid ARCHIVE SUCCEED
3362 check_flags_changes $f $fid lost 3 1
3366 run_test 227 "changelog when explicit setting of HSM flags"
3369 # test needs a running copytool
3372 local fid=$(make_small_sync $DIR/$tfile)
3373 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tfile
3374 wait_request_state $fid ARCHIVE SUCCEED
3376 $LFS hsm_release $DIR/$tfile
3377 check_hsm_flags $DIR/$tfile "0x0000000d"
3379 filefrag $DIR/$tfile | grep " 1 extent found" ||
3380 error "filefrag on released file must return only one extent"
3382 # only newer versions of cp detect sparse files by stat/FIEMAP
3384 cp --sparse=auto $DIR/$tfile $DIR/$tfile.2 ||
3385 error "copying $DIR/$tfile"
3386 cmp $DIR/$tfile $DIR/$tfile.2 || error "comparing copied $DIR/$tfile"
3388 $LFS hsm_release $DIR/$tfile
3389 check_hsm_flags $DIR/$tfile "0x0000000d"
3391 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
3393 tar cf - --sparse $DIR/$tfile | tar xvf - -C $DIR/$tdir ||
3395 cmp $DIR/$tfile $DIR/$tdir/$DIR/$tfile ||
3396 error "comparing untarred $DIR/$tfile"
3398 rm -f $DIR/$tfile $DIR/$tfile.2 ||
3399 error "rm $DIR/$tfile or $DIR/$tfile.2 failed"
3402 run_test 228 "On released file, return extend to FIEMAP. For [cp,tar] --sparse"
3405 # test needs a running copytool
3409 local maxrequest=$(get_hsm_param max_requests)
3410 local rqcnt=$(($maxrequest * 3))
3414 for i in $(seq -w 1 $rqcnt); do
3416 dd if=/dev/urandom of=$DIR/$tdir/$i bs=1M count=10 conv=fsync
3418 # we do it in 2 steps, so all requests arrive at the same time
3419 for i in $(seq -w 1 $rqcnt); do
3420 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$i
3425 while [[ $cnt != 0 || $wt != 0 ]]; do
3427 cnt=$(do_facet $SINGLEMDS "$LCTL get_param -n\
3428 $HSM_PARAM.actions |\
3429 grep STARTED | grep -v CANCEL | wc -l")
3430 [[ $cnt -le $maxrequest ]] ||
3431 error "$cnt > $maxrequest too many started requests"
3432 wt=$(do_facet $SINGLEMDS "$LCTL get_param\
3433 $HSM_PARAM.actions |\
3434 grep WAITING | wc -l")
3435 echo "max=$maxrequest started=$cnt waiting=$wt"
3440 run_test 250 "Coordinator max request"
3443 # test needs a running copytool
3447 local f=$DIR/$tdir/$tfile
3448 local fid=$(make_large_for_cancel $f)
3451 # to have a short test
3452 local old_to=$(get_hsm_param active_request_timeout)
3453 set_hsm_param active_request_timeout 4
3454 # to be sure the cdt will wake up frequently so
3455 # it will be able to cancel the "old" request
3456 local old_loop=$(get_hsm_param loop_period)
3457 set_hsm_param loop_period 2
3460 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3461 wait_request_state $fid ARCHIVE STARTED
3463 wait_request_state $fid ARCHIVE CANCELED
3465 set_hsm_param active_request_timeout $old_to
3466 set_hsm_param loop_period $old_loop
3470 run_test 251 "Coordinator request timeout"
3473 # the only way to test ondisk conf is to restart MDS ...
3474 echo "Stop coordinator and remove coordinator state at mount"
3477 # clean on disk conf set by default
3478 cdt_clear_mount_state
3479 cdt_check_state stopped
3481 # check cdt still off after umount/remount
3483 cdt_check_state stopped
3485 echo "Set coordinator start at mount, and start coordinator"
3486 cdt_set_mount_state enabled
3489 cdt_check_state enabled
3491 # check cdt still on after umount/remount
3493 cdt_check_state enabled
3495 # we are back to original state (cdt started at mount)
3497 run_test 300 "On disk coordinator state kept between MDT umount/mount"
3500 local ai=$(get_hsm_param default_archive_id)
3501 local new=$((ai + 1))
3503 set_hsm_param default_archive_id $new -P
3505 local res=$(get_hsm_param default_archive_id)
3508 set_hsm_param default_archive_id "" "-P -d"
3510 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
3512 run_test 301 "HSM tunnable are persistent"
3515 local ai=$(get_hsm_param default_archive_id)
3516 local new=$((ai + 1))
3521 set_hsm_param default_archive_id $new -P
3524 for mdtno in $(seq 1 $MDSCOUNT); do
3529 cdt_check_state enabled
3531 local res=$(get_hsm_param default_archive_id)
3534 set_hsm_param default_archive_id "" "-P -d"
3536 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
3538 run_test 302 "HSM tunnable are persistent when CDT is off"
3541 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3547 local dir_mdt0=$DIR/$tdir/mdt0
3548 local dir_mdt1=$DIR/$tdir/mdt1
3550 # create 1 dir per MDT
3551 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3552 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
3554 # create 1 file in each MDT
3555 local fid1=$(make_small $dir_mdt0/$tfile)
3556 local fid2=$(make_small $dir_mdt1/$tfile)
3558 # check that hsm request on mdt0 is sent to the right MDS
3559 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
3560 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3561 echo "archive successful on mdt0"
3563 # check that hsm request on mdt1 is sent to the right MDS
3564 $LFS hsm_archive $dir_mdt1/$tfile || error "lfs hsm_archive"
3565 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
3566 echo "archive successful on mdt1"
3569 # clean test files and directories
3570 rm -rf $dir_mdt0 $dir_mdt1
3572 run_test 400 "Single request is sent to the right MDT"
3575 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3581 local dir_mdt0=$DIR/$tdir/mdt0
3582 local dir_mdt1=$DIR/$tdir/mdt1
3584 # create 1 dir per MDT
3585 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3586 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
3588 # create 1 file in each MDT
3589 local fid1=$(make_small $dir_mdt0/$tfile)
3590 local fid2=$(make_small $dir_mdt1/$tfile)
3592 # check that compound requests are shunt to the rights MDTs
3593 $LFS hsm_archive $dir_mdt0/$tfile $dir_mdt1/$tfile ||
3594 error "lfs hsm_archive"
3595 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3596 echo "archive successful on mdt0"
3597 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
3598 echo "archive successful on mdt1"
3601 # clean test files and directories
3602 rm -rf $dir_mdt0 $dir_mdt1
3604 run_test 401 "Compound requests split and sent to their respective MDTs"
3606 mdc_change_state() # facet, MDT_pattern, activate|deactivate
3611 local node=$(facet_active_host $facet)
3613 for mdc in $(do_facet $facet "$LCTL dl | grep -E ${pattern}-mdc" |
3614 awk '{print $4}'); do
3615 echo "$3 $mdc on $node"
3616 do_facet $facet "$LCTL --device $mdc $state" || return 1
3621 # make sure there is no running copytool
3624 # deactivate all mdc on agent1
3625 mdc_change_state $SINGLEAGT "MDT000." "deactivate"
3627 copytool_setup $SINGLEAGT
3629 check_agent_unregistered "uuid" # match any agent
3631 # no expected running copytool
3632 search_copytools $agent && error "Copytool start should have failed"
3635 mdc_change_state $SINGLEAGT "MDT000." "activate"
3637 run_test 402 "Copytool start fails if all MDTs are inactive"
3640 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3642 # make sure there is no running copytool
3645 local agent=$(facet_active_host $SINGLEAGT)
3646 local uuid=$(do_rpc_nodes $agent get_client_uuid | cut -d' ' -f2)
3648 # deactivate all mdc for MDT0001
3649 mdc_change_state $SINGLEAGT "MDT0001" "deactivate"
3652 # check the agent is registered on MDT0000, and not on MDT0001
3653 check_agent_registered_by_mdt $uuid 0
3654 check_agent_unregistered_by_mdt $uuid 1
3656 # check running copytool process
3657 search_copytools $agent || error "No running copytools on $agent"
3659 # reactivate all mdc for MDT0001
3660 mdc_change_state $SINGLEAGT "MDT0001" "activate"
3662 # make sure the copytool is now registered to all MDTs
3663 check_agent_registered $uuid
3667 run_test 403 "Copytool starts with inactive MDT and register on reconnect"
3670 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3674 # create files on both MDT0000 and MDT0001
3677 local dir_mdt0=$DIR/$tdir/mdt0
3678 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3680 # create 1 file on mdt0
3681 local fid1=$(make_small $dir_mdt0/$tfile)
3683 # deactivate all mdc for MDT0001
3684 mdc_change_state $SINGLEAGT "MDT0001" "deactivate"
3686 # send an HSM request for files in MDT0000
3687 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
3689 # check for completion of files in MDT0000
3690 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3691 echo "archive successful on mdt0"
3693 # reactivate all mdc for MDT0001
3694 mdc_change_state $SINGLEAGT "MDT0001" "activate"
3697 # clean test files and directories
3700 run_test 404 "Inactive MDT does not block requests for active MDTs"
3705 check_and_cleanup_lustre