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 get_request_state() {
572 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.actions |"\
573 "awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
576 get_request_count() {
580 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.actions |"\
581 "awk -vn=0 '/'$fid'.*action='$request'/ {n++}; END {print n}'"
587 local cmd="$LCTL get_param -n $HSM_PARAM.actions"
588 cmd+=" | egrep 'WAITING|STARTED'"
590 wait_result $SINGLEMDS "$cmd" "" $timeout ||
591 error "requests did not complete"
594 wait_for_grace_delay() {
595 local val=$(get_hsm_param grace_delay)
599 # populate MDT device array
605 # cleanup from previous bad setup
606 search_and_kill_copytool
608 # for recovery tests, coordinator needs to be started at mount
610 # the lustre conf must be without hsm on (like for sanity.sh)
611 echo "Set HSM on and start"
612 cdt_set_mount_state enabled
613 cdt_check_state enabled
615 echo "Start copytool"
618 echo "Set sanity-hsm HSM policy"
619 cdt_set_sanity_policy
621 # finished requests are quickly removed from list
622 set_hsm_param grace_delay 10
628 local f=$DIR/$tdir/$tfile
632 check_hsm_flags_user $f "0x00000000"
634 $RUNAS $LFS hsm_set --norelease $f ||
635 error "user could not change hsm flags"
636 check_hsm_flags_user $f "0x00000010"
638 $RUNAS $LFS hsm_clear --norelease $f ||
639 error "user could not clear hsm flags"
640 check_hsm_flags_user $f "0x00000000"
642 # User could not change those flags...
643 $RUNAS $LFS hsm_set --exists $f &&
644 error "user should not set this flag"
645 check_hsm_flags_user $f "0x00000000"
648 $LFS hsm_set --exists $f ||
649 error "root could not change hsm flags"
650 check_hsm_flags_user $f "0x00000001"
652 $LFS hsm_clear --exists $f ||
653 error "root could not clear hsm state"
654 check_hsm_flags_user $f "0x00000000"
657 run_test 1 "lfs hsm flags root/non-root access"
661 local f=$DIR/$tdir/$tfile
663 # New files are not dirty
664 check_hsm_flags $f "0x00000000"
666 # For test, we simulate an archived file.
667 $LFS hsm_set --exists $f || error "user could not change hsm flags"
668 check_hsm_flags $f "0x00000001"
670 # chmod do not put the file dirty
671 chmod 600 $f || error "could not chmod test file"
672 check_hsm_flags $f "0x00000001"
674 # chown do not put the file dirty
675 chown $RUNAS_ID $f || error "could not chown test file"
676 check_hsm_flags $f "0x00000001"
678 # truncate put the file dirty
679 $TRUNCATE $f 1 || error "could not truncate test file"
680 check_hsm_flags $f "0x00000003"
682 $LFS hsm_clear --dirty $f || error "could not clear hsm flags"
683 check_hsm_flags $f "0x00000001"
685 run_test 2 "Check file dirtyness when doing setattr"
691 # New files are not dirty
693 check_hsm_flags $f "0x00000000"
695 # For test, we simulate an archived file.
696 $LFS hsm_set --exists $f ||
697 error "user could not change hsm flags"
698 check_hsm_flags $f "0x00000001"
700 # Reading a file, does not set dirty
701 cat $f > /dev/null || error "could not read file"
702 check_hsm_flags $f "0x00000001"
704 # Open for write without modifying data, does not set dirty
705 openfile -f O_WRONLY $f || error "could not open test file"
706 check_hsm_flags $f "0x00000001"
708 # Append to a file sets it dirty
709 cp -p /etc/passwd $f.append || error "could not create file"
710 $LFS hsm_set --exists $f.append ||
711 error "user could not change hsm flags"
712 dd if=/etc/passwd of=$f.append bs=1 count=3\
713 conv=notrunc oflag=append status=noxfer ||
714 error "could not append to test file"
715 check_hsm_flags $f.append "0x00000003"
717 # Modify a file sets it dirty
718 cp -p /etc/passwd $f.modify || error "could not create file"
719 $LFS hsm_set --exists $f.modify ||
720 error "user could not change hsm flags"
721 dd if=/dev/zero of=$f.modify bs=1 count=3\
722 conv=notrunc status=noxfer ||
723 error "could not modify test file"
724 check_hsm_flags $f.modify "0x00000003"
726 # Open O_TRUNC sets dirty
727 cp -p /etc/passwd $f.trunc || error "could not create file"
728 $LFS hsm_set --exists $f.trunc ||
729 error "user could not change hsm flags"
730 cp /etc/group $f.trunc || error "could not override a file"
731 check_hsm_flags $f.trunc "0x00000003"
733 # Mmapped a file sets dirty
734 cp -p /etc/passwd $f.mmap || error "could not create file"
735 $LFS hsm_set --exists $f.mmap ||
736 error "user could not change hsm flags"
737 multiop $f.mmap OSMWUc || error "could not mmap a file"
738 check_hsm_flags $f.mmap "0x00000003"
740 run_test 3 "Check file dirtyness when opening for write"
744 local f=$DIR/$tdir/$tfile
745 local fid=$(make_small $f)
748 local st=$(get_request_state $fid CANCEL)
749 [[ -z "$st" ]] || error "hsm_cancel must not be registered (state=$st)"
751 run_test 4 "Useless cancel must not be registered"
754 # test needs a running copytool
758 local f=$DIR/$tdir/$tfile
759 local fid=$(copy_file /etc/passwd $f)
761 wait_request_state $fid ARCHIVE SUCCEED
763 check_hsm_flags $f "0x00000009"
767 run_test 8 "Test default archive number"
771 local f=$DIR/$tdir/$tfile
772 local fid=$(copy_file /etc/passwd $f)
773 # we do not use the default one to be sure
774 local new_an=$((HSM_ARCHIVE_NUMBER + 1))
776 copytool_setup $SINGLEAGT $MOUNT $new_an
777 $LFS hsm_archive --archive $new_an $f
778 wait_request_state $fid ARCHIVE SUCCEED
780 check_hsm_flags $f "0x00000009"
784 run_test 9 "Use of explict archive number, with dedicated copytool"
787 needclients 3 || return 0
793 copytool_cleanup $(comma_list $(agts_nodes))
795 # start all of the copytools
796 for n in $(seq $AGTCOUNT); do
800 trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
803 for n in $(seq $AGTCOUNT); do
804 file=$DIR/$tdir/$tfile.$n
805 fid=$(make_small $file)
807 $LFS hsm_archive $file || error "could not archive file $file"
808 wait_request_state $fid ARCHIVE SUCCEED
809 check_hsm_flags $file "0x00000009"
813 copytool_cleanup $(comma_list $(agts_nodes))
815 run_test 9a "Multiple remote agents"
818 # test needs a running copytool
821 mkdir -p $DIR/$tdir/d1
822 local f=$DIR/$tdir/$tfile
823 local fid=$(copy_file /etc/hosts $f)
824 $LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f ||
825 error "hsm_archive failed"
826 wait_request_state $fid ARCHIVE SUCCEED
828 local AFILE=$(do_facet $SINGLEAGT ls $HSM_ARCHIVE'/*/*/*/*/*/*/'$fid) ||
829 error "fid $fid not in archive $HSM_ARCHIVE"
830 echo "Verifying content"
831 do_facet $SINGLEAGT diff $f $AFILE || error "archived file differs"
832 echo "Verifying hsm state "
833 check_hsm_flags $f "0x00000009"
835 echo "Verifying archive number is $HSM_ARCHIVE_NUMBER"
836 local st=$(get_hsm_archive_id $f)
837 [[ $st == $HSM_ARCHIVE_NUMBER ]] ||
838 error "Wrong archive number, $st != $HSM_ARCHIVE_NUMBER"
843 run_test 10a "Archive a file"
846 # test needs a running copytool
850 local f=$DIR/$tdir/$tfile
851 local fid=$(copy_file /etc/hosts $f)
852 $LFS hsm_archive $f || error "archive request failed"
853 wait_request_state $fid ARCHIVE SUCCEED
855 $LFS hsm_archive $f || error "archive of non dirty file failed"
856 local cnt=$(get_request_count $fid ARCHIVE)
857 [[ "$cnt" == "1" ]] ||
858 error "archive of non dirty file must not make a request"
862 run_test 10b "Archive of non dirty file must work without doing request"
865 # test needs a running copytool
869 local f=$DIR/$tdir/$tfile
870 local fid=$(copy_file /etc/hosts $f)
871 $LFS hsm_set --noarchive $f
872 $LFS hsm_archive $f && error "archive a noarchive file must fail"
876 run_test 10c "Check forbidden archive"
879 # test needs a running copytool
883 local f=$DIR/$tdir/$tfile
884 local fid=$(copy_file /etc/hosts $f)
885 $LFS hsm_archive $f || error "cannot archive $f"
886 wait_request_state $fid ARCHIVE SUCCEED
888 local ar=$(get_hsm_archive_id $f)
889 local dflt=$(get_hsm_param default_archive_id)
890 [[ $ar == $dflt ]] ||
891 error "archived file is not on default archive: $ar != $dflt"
895 run_test 10d "Archive a file on the default archive id"
899 copy2archive /etc/hosts $tdir/$tfile
900 local f=$DIR/$tdir/$tfile
902 import_file $tdir/$tfile $f
903 echo -n "Verifying released state: "
904 check_hsm_flags $f "0x0000000d"
906 local LSZ=$(stat -c "%s" $f)
907 local ASZ=$(do_facet $SINGLEAGT stat -c "%s" $HSM_ARCHIVE/$tdir/$tfile)
909 echo "Verifying imported size $LSZ=$ASZ"
910 [[ $LSZ -eq $ASZ ]] || error "Incorrect size $LSZ != $ASZ"
911 echo -n "Verifying released pattern: "
912 local PTRN=$($GETSTRIPE -L $f)
914 [[ $PTRN == 80000001 ]] || error "Is not released"
915 local fid=$(path2fid $f)
916 echo "Verifying new fid $fid in archive"
918 local AFILE=$(do_facet $SINGLEAGT ls $HSM_ARCHIVE'/*/*/*/*/*/*/'$fid) ||
919 error "fid $fid not in archive $HSM_ARCHIVE"
921 run_test 11 "Import a file"
924 # test needs a running copytool
928 copy2archive /etc/hosts $tdir/$tfile
930 local f=$DIR/$tdir/$tfile
931 import_file $tdir/$tfile $f
932 local f=$DIR2/$tdir/$tfile
933 echo "Verifying released state: "
934 check_hsm_flags $f "0x0000000d"
936 local fid=$(path2fid $f)
938 wait_request_state $fid RESTORE SUCCEED
940 echo "Verifying file state: "
941 check_hsm_flags $f "0x00000009"
943 do_facet $SINGLEAGT diff -q $HSM_ARCHIVE/$tdir/$tfile $f
945 [[ $? -eq 0 ]] || error "Restored file differs"
949 run_test 12a "Restore an imported file explicitly"
952 # test needs a running copytool
956 copy2archive /etc/hosts $tdir/$tfile
958 local f=$DIR/$tdir/$tfile
959 import_file $tdir/$tfile $f
960 echo "Verifying released state: "
961 check_hsm_flags $f "0x0000000d"
963 cat $f > /dev/null || error "File read failed"
965 echo "Verifying file state after restore: "
966 check_hsm_flags $f "0x00000009"
968 do_facet $SINGLEAGT diff -q $HSM_ARCHIVE/$tdir/$tfile $f
970 [[ $? -eq 0 ]] || error "Restored file differs"
974 run_test 12b "Restore an imported file implicitly"
977 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
979 # test needs a running copytool
983 local f=$DIR/$tdir/$tfile
984 $LFS setstripe -c 2 $f
985 local fid=$(make_large_for_striping $f)
986 local FILE_CRC=$(md5sum $f)
988 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
989 wait_request_state $fid ARCHIVE SUCCEED
990 $LFS hsm_release $f || error "release $f failed"
992 echo "$FILE_CRC" | md5sum -c
994 [[ $? -eq 0 ]] || error "Restored file differs"
998 run_test 12c "Restore a file with stripe of 2"
1001 # test needs a running copytool
1006 local f=$DIR/$tdir/$tfile
1007 local fid=$(copy_file /etc/hosts $f)
1008 $LFS hsm_restore $f || error "restore of non archived file failed"
1009 local cnt=$(get_request_count $fid RESTORE)
1010 [[ "$cnt" == "0" ]] ||
1011 error "restore non archived must not make a request"
1012 $LFS hsm_archive $f ||
1013 error "archive request failed"
1014 wait_request_state $fid ARCHIVE SUCCEED
1015 $LFS hsm_restore $f ||
1016 error "restore of non released file failed"
1017 local cnt=$(get_request_count $fid RESTORE)
1018 [[ "$cnt" == "0" ]] ||
1019 error "restore a non dirty file must not make a request"
1023 run_test 12d "Restore of a non archived, non released file must work"\
1024 " without doing request"
1027 # test needs a running copytool
1030 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1031 local f=$DIR/$tdir/$tfile
1032 local fid=$(copy_file /etc/hosts $f)
1033 $LFS hsm_archive $f || error "archive request failed"
1034 wait_request_state $fid ARCHIVE SUCCEED
1037 cat /etc/hosts >> $f
1041 $LFS hsm_restore $f && error "restore a dirty file must fail"
1045 run_test 12e "Check forbidden restore"
1048 # test needs a running copytool
1052 local f=$DIR/$tdir/$tfile
1053 local fid=$(copy_file /etc/hosts $f)
1055 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1056 wait_request_state $fid ARCHIVE SUCCEED
1057 $LFS hsm_release $f || error "release of $f failed"
1059 wait_request_state $fid RESTORE SUCCEED
1061 echo -n "Verifying file state: "
1062 check_hsm_flags $f "0x00000009"
1064 diff -q /etc/hosts $f
1066 [[ $? -eq 0 ]] || error "Restored file differs"
1070 run_test 12f "Restore a released file explicitly"
1073 # test needs a running copytool
1077 local f=$DIR/$tdir/$tfile
1078 local fid=$(copy_file /etc/hosts $f)
1080 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1081 wait_request_state $fid ARCHIVE SUCCEED
1082 $LFS hsm_release $f || error "release of $f failed"
1084 diff -q /etc/hosts $f
1087 # we check we had a restore done
1088 wait_request_state $fid RESTORE SUCCEED
1090 [[ $st -eq 0 ]] || error "Restored file differs"
1094 run_test 12g "Restore a released file implicitly"
1097 needclients 2 || return 0
1099 # test needs a running copytool
1103 local f=$DIR/$tdir/$tfile
1104 local fid=$(copy_file /etc/hosts $f)
1106 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1107 wait_request_state $fid ARCHIVE SUCCEED
1108 $LFS hsm_release $f || error "release of $f failed"
1110 do_node $CLIENT2 diff -q /etc/hosts $f
1113 # we check we had a restore done
1114 wait_request_state $fid RESTORE SUCCEED
1116 [[ $st -eq 0 ]] || error "Restored file differs"
1120 run_test 12h "Restore a released file implicitly from a second node"
1123 # test needs a running copytool
1127 local f=$DIR/$tdir/$tfile
1128 local fid=$(copy_file /etc/passwd $f)
1129 $LFS hsm_archive $f || error "archive of $f failed"
1130 wait_request_state $fid ARCHIVE SUCCEED
1132 $LFS hsm_release $f || error "release of $f failed"
1136 [[ $? -eq 0 ]] || error "Restored file differs"
1140 run_test 12m "Archive/release/implicit restore"
1143 # test needs a running copytool
1147 copy2archive /etc/hosts $tdir/$tfile
1149 local f=$DIR/$tdir/$tfile
1150 import_file $tdir/$tfile $f
1152 do_facet $SINGLEAGT cmp /etc/hosts $f ||
1153 error "Restored file differs"
1155 $LFS hsm_release $f || error "release of $f failed"
1159 run_test 12n "Import/implicit restore/release"
1162 # test needs a running copytool
1166 local f=$DIR/$tdir/$tfile
1167 local fid=$(copy_file /etc/hosts $f)
1169 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1170 wait_request_state $fid ARCHIVE SUCCEED
1171 $LFS hsm_release $f || error "release of $f failed"
1173 #define OBD_FAIL_MDS_HSM_SWAP_LAYOUTS 0x152
1174 do_facet $SINGLEMDS lctl set_param fail_loc=0x152
1176 # set no retry action mode
1179 diff -q /etc/hosts $f
1182 # we check we had a restore failure
1183 wait_request_state $fid RESTORE FAILED
1185 [[ $st -eq 0 ]] && error "Restore must fail"
1187 # remove no retry action mode
1190 # check file is still released
1191 check_hsm_flags $f "0x0000000d"
1193 # retry w/o failure injection
1194 do_facet $SINGLEMDS lctl set_param fail_loc=0
1196 # to be sure previous RESTORE result is gone
1198 wait_for_grace_delay
1200 diff -q /etc/hosts $f
1203 # we check we had a restore done
1204 wait_request_state $fid RESTORE SUCCEED
1206 [[ $st -eq 0 ]] || error "Restored file differs"
1210 run_test 12o "Layout-swap failure during Restore leaves file released"
1213 # test needs a running copytool
1216 local ARC_SUBDIR="import.orig"
1220 # populate directory to be imported
1221 for d in $(seq 1 10); do
1222 local CURR_DIR="$HSM_ARCHIVE/$ARC_SUBDIR/dir.$d"
1223 do_facet $SINGLEAGT mkdir -p "$CURR_DIR"
1224 for f in $(seq 1 10); do
1225 CURR_FILE="$CURR_DIR/$tfile.$f"
1226 # write file-specific data
1227 do_facet $SINGLEAGT \
1228 "echo d=$d, f=$f, dir=$CURR_DIR, "\
1229 "file=$CURR_FILE > $CURR_FILE"
1233 import_file "$ARC_SUBDIR" $DIR/$tdir
1234 # diff lustre content and origin (triggers file restoration)
1235 # there must be 10x10 identical files, and no difference
1236 local cnt_ok=$(do_facet $SINGLEAGT diff -rs $HSM_ARCHIVE/$ARC_SUBDIR \
1237 $DIR/$tdir/$ARC_SUBDIR | grep identical | wc -l)
1238 local cnt_diff=$(do_facet $SINGLEAGT diff -r $HSM_ARCHIVE/$ARC_SUBDIR \
1239 $DIR/$tdir/$ARC_SUBDIR | wc -l)
1241 [ $cnt_diff -eq 0 ] ||
1242 error "$cnt_diff imported files differ from read data"
1243 [ $cnt_ok -eq 100 ] ||
1244 error "not enough identical files ($cnt_ok != 100)"
1248 run_test 13 "Recursively import and restore a directory"
1251 # test needs a running copytool
1256 local f=$DIR/$tdir/$tfile
1257 local fid=$(make_small $f)
1258 local sum=$(md5sum $f | awk '{print $1}')
1259 $LFS hsm_archive $f || error "could not archive file"
1260 wait_request_state $fid ARCHIVE SUCCEED
1264 # create released file (simulate llapi_hsm_import call)
1266 local fid2=$(path2fid $f)
1267 $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
1268 $LFS hsm_release $f || error "could not release file"
1270 # rebind the archive to the newly created file
1271 echo "rebind $fid to $fid2"
1273 do_facet $SINGLEAGT \
1274 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1275 --rebind $fid $fid2 $DIR" || error "could not rebind file"
1277 # restore file and compare md5sum
1278 local sum2=$(md5sum $f | awk '{print $1}')
1280 [[ $sum == $sum2 ]] || error "md5sum mismatch after restore"
1284 run_test 14 "Rebind archived file to a new fid"
1287 # test needs a running copytool
1292 local f=$DIR/$tdir/$tfile
1294 local tmpfile=$SHARED_DIRECTORY/tmp.$$
1298 for i in $(seq 1 $count); do
1299 fids[$i]=$(make_small $f.$i)
1300 sums[$i]=$(md5sum $f.$i | awk '{print $1}')
1301 $LFS hsm_archive $f.$i || error "could not archive file"
1303 wait_all_done $(($count*60))
1307 for i in $(seq 1 $count); do
1310 local fid2=$(path2fid $f.$i)
1311 # add the rebind operation to the list
1312 echo ${fids[$i]} $fid2 >> $tmpfile
1314 # set it released (simulate llapi_hsm_import call)
1315 $LFS hsm_set --archived --exists $f.$i ||
1316 error "could not force hsm flags"
1317 $LFS hsm_release $f.$i || error "could not release file"
1319 nl=$(wc -l < $tmpfile)
1320 [[ $nl == $count ]] || error "$nl files in list, $count expected"
1322 echo "rebind list of files"
1323 do_facet $SINGLEAGT \
1324 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1325 --rebind $tmpfile $DIR" || error "could not rebind file list"
1327 # restore files and compare md5sum
1328 for i in $(seq 1 $count); do
1329 local sum2=$(md5sum $f.$i | awk '{print $1}')
1330 [[ $sum2 == ${sums[$i]} ]] ||
1331 error "md5sum mismatch after restore ($sum2 != ${sums[$i]})"
1337 run_test 15 "Rebind a list of files"
1340 # test needs a running copytool
1344 # create a known size file so we can verify transfer speed
1347 dd if=/dev/zero of=$ref bs=1M count=20
1350 local f=$DIR/$tdir/$tfile
1351 local fid=$(copy_file $ref $f)
1353 local start=$(date +%s)
1355 wait_request_state $fid ARCHIVE SUCCEED
1356 local end=$(date +%s)
1357 local duration=$((end - start))
1359 [[ $duration -ge $goal ]] ||
1360 error "Transfer is too fast $duration < $goal"
1364 run_test 16 "Test CT bandwith control option"
1369 local f=$DIR/$tdir/$tfile
1370 touch $f || error "touch $f failed"
1372 # Could not release a non-archived file
1373 $LFS hsm_release $f && error "release should not succeed"
1375 # For following tests, we must test them with HS_ARCHIVED set
1376 $LFS hsm_set --exists --archived $f || error "could not add flag"
1378 # Could not release a file if no-release is set
1379 $LFS hsm_set --norelease $f || error "could not add flag"
1380 $LFS hsm_release $f && error "release should not succeed"
1381 $LFS hsm_clear --norelease $f || error "could not remove flag"
1383 # Could not release a file if lost
1384 $LFS hsm_set --lost $f || error "could not add flag"
1385 $LFS hsm_release $f && error "release should not succeed"
1386 $LFS hsm_clear --lost $f || error "could not remove flag"
1388 # Could not release a file if dirty
1389 $LFS hsm_set --dirty $f || error "could not add flag"
1390 $LFS hsm_release $f && error "release should not succeed"
1391 $LFS hsm_clear --dirty $f || error "could not remove flag"
1393 run_test 20 "Release is not permitted"
1396 # test needs a running copytool
1400 local f=$DIR/$tdir/test_release
1402 # Create a file and check its states
1403 local fid=$(make_small $f)
1404 check_hsm_flags $f "0x00000000"
1406 # LU-4388/LU-4389 - ZFS does not report full number of blocks
1407 # used until file is flushed to disk
1408 if [ $(facet_fstype ost1) == "zfs" ]; then
1409 # this causes an OST_SYNC rpc to be sent
1410 dd if=/dev/zero of=$f bs=512 count=1 oflag=sync conv=notrunc,fsync
1411 # clear locks to reread file data
1412 cancel_lru_locks osc
1415 local orig_size=$(stat -c "%s" $f)
1416 local orig_blocks=$(stat -c "%b" $f)
1418 start_full_debug_logging
1420 $LFS hsm_archive $f || error "could not archive file"
1421 wait_request_state $fid ARCHIVE SUCCEED
1423 local blocks=$(stat -c "%b" $f)
1424 [ $blocks -eq $orig_blocks ] ||
1425 error "$f: wrong block number after archive: " \
1426 "$blocks != $orig_blocks"
1427 local size=$(stat -c "%s" $f)
1428 [ $size -eq $orig_size ] ||
1429 error "$f: wrong size after archive: $size != $orig_size"
1431 # Release and check states
1432 $LFS hsm_release $f || error "could not release file"
1433 check_hsm_flags $f "0x0000000d"
1435 blocks=$(stat -c "%b" $f)
1436 [ $blocks -gt 5 ] &&
1437 error "$f: too many blocks after release: $blocks > 5"
1438 size=$(stat -c "%s" $f)
1439 [ $size -ne $orig_size ] &&
1440 error "$f: wrong size after release: $size != $orig_size"
1442 # Check we can release an file without stripe info
1446 check_hsm_flags $f "0x00000000"
1447 $LFS hsm_archive $f || error "could not archive file"
1448 wait_request_state $fid ARCHIVE SUCCEED
1450 # Release and check states
1451 $LFS hsm_release $f || error "could not release file"
1452 check_hsm_flags $f "0x0000000d"
1454 # Release again a file that is already released is OK
1455 $LFS hsm_release $f || fail "second release should succeed"
1456 check_hsm_flags $f "0x0000000d"
1458 stop_full_debug_logging
1462 run_test 21 "Simple release tests"
1465 # test needs a running copytool
1470 local f=$DIR/$tdir/test_release
1471 local swap=$DIR/$tdir/test_swap
1473 # Create a file and check its states
1474 local fid=$(make_small $f)
1475 check_hsm_flags $f "0x00000000"
1477 $LFS hsm_archive $f || error "could not archive file"
1478 wait_request_state $fid ARCHIVE SUCCEED
1480 # Release and check states
1481 $LFS hsm_release $f || error "could not release file"
1482 check_hsm_flags $f "0x0000000d"
1485 $LFS swap_layouts $swap $f && error "swap_layouts should failed"
1490 run_test 22 "Could not swap a release file"
1493 # test needs a running copytool
1498 local f=$DIR/$tdir/test_mtime
1500 # Create a file and check its states
1501 local fid=$(make_small $f)
1502 check_hsm_flags $f "0x00000000"
1504 $LFS hsm_archive $f || error "could not archive file"
1505 wait_request_state $fid ARCHIVE SUCCEED
1507 # Set modification time in the past
1508 touch -m -a -d @978261179 $f
1510 # Release and check states
1511 $LFS hsm_release $f || error "could not release file"
1512 check_hsm_flags $f "0x0000000d"
1514 local MTIME=$(stat -c "%Y" $f)
1515 local ATIME=$(stat -c "%X" $f)
1516 [ $MTIME -eq "978261179" ] || fail "bad mtime: $MTIME"
1517 [ $ATIME -eq "978261179" ] || fail "bad atime: $ATIME"
1521 run_test 23 "Release does not change a/mtime (utime)"
1524 local file=$DIR/$tdir/$tfile
1533 # test needs a running copytool
1538 fid=$(make_small $file)
1540 # Create a file and check its states
1541 check_hsm_flags $file "0x00000000"
1543 # Ensure atime is less than mtime and ctime.
1547 atime0=$(stat -c "%X" $file)
1548 mtime0=$(stat -c "%Y" $file)
1549 ctime0=$(stat -c "%Z" $file)
1551 [ $atime0 -lt $mtime0 ] ||
1552 error "atime $atime0 is not less than mtime $mtime0"
1554 [ $atime0 -lt $ctime0 ] ||
1555 error "atime $atime0 is not less than ctime $ctime0"
1557 # Archive should not change any timestamps.
1558 $LFS hsm_archive $file || error "cannot archive '$file'"
1559 wait_request_state $fid ARCHIVE SUCCEED
1561 atime1=$(stat -c "%X" $file)
1562 mtime1=$(stat -c "%Y" $file)
1563 ctime1=$(stat -c "%Z" $file)
1565 [ $atime0 -eq $atime1 ] ||
1566 error "archive changed atime from $atime0 to $atime1"
1568 [ $mtime0 -eq $mtime1 ] ||
1569 error "archive changed mtime from $mtime0 to $mtime1"
1571 [ $ctime0 -eq $ctime1 ] ||
1572 error "archive changed ctime from $ctime0 to $ctime1"
1574 # Release should not change any timestamps.
1575 $LFS hsm_release $file || error "cannot release '$file'"
1576 check_hsm_flags $file "0x0000000d"
1578 atime1=$(stat -c "%X" $file)
1579 mtime1=$(stat -c "%Y" $file)
1580 ctime1=$(stat -c "%Z" $file)
1582 [ $atime0 -eq $atime1 ] ||
1583 error "release changed atime from $atime0 to $atime1"
1585 [ $mtime0 -eq $mtime1 ] ||
1586 error "release changed mtime from $mtime0 to $mtime1"
1588 [ $ctime0 -eq $ctime1 ] ||
1589 error "release changed ctime from $ctime0 to $ctime1"
1591 # Restore should not change atime or mtime and should not
1593 $LFS hsm_restore $file
1594 wait_request_state $fid RESTORE SUCCEED
1596 atime1=$(stat -c "%X" $file)
1597 mtime1=$(stat -c "%Y" $file)
1598 ctime1=$(stat -c "%Z" $file)
1600 [ $atime0 -eq $atime1 ] ||
1601 error "restore changed atime from $atime0 to $atime1"
1603 [ $mtime0 -eq $mtime1 ] ||
1604 error "restore changed mtime from $mtime0 to $mtime1"
1606 [ $ctime0 -le $ctime1 ] ||
1607 error "restore changed ctime from $ctime0 to $ctime1"
1611 # Once more, after unmount and mount.
1612 umount_client $MOUNT || error "cannot unmount '$MOUNT'"
1613 mount_client $MOUNT || error "cannot mount '$MOUNT'"
1615 atime1=$(stat -c "%X" $file)
1616 mtime1=$(stat -c "%Y" $file)
1617 ctime1=$(stat -c "%Z" $file)
1619 [ $atime0 -eq $atime1 ] ||
1620 error "remount changed atime from $atime0 to $atime1"
1622 [ $mtime0 -eq $mtime1 ] ||
1623 error "remount changed mtime from $mtime0 to $mtime1"
1625 [ $ctime0 -le $ctime1 ] ||
1626 error "remount changed ctime from $ctime0 to $ctime1"
1628 run_test 24a "Archive, release, and restore does not change a/mtime (i/o)"
1631 local file=$DIR/$tdir/$tfile
1637 # Test needs a running copytool.
1641 # Check that root can do HSM actions on a ordinary user's file.
1643 fid=$(make_small $file)
1644 sum0=$(md5sum $file)
1646 chown $RUNAS_ID:$RUNAS_GID $file ||
1647 error "cannot chown '$file' to '$RUNAS_ID'"
1649 chmod ugo-w $DIR/$tdir ||
1650 error "cannot chmod '$DIR/$tdir'"
1652 $LFS hsm_archive $file
1653 wait_request_state $fid ARCHIVE SUCCEED
1655 $LFS hsm_release $file
1656 check_hsm_flags $file "0x0000000d"
1658 $LFS hsm_restore $file
1659 wait_request_state $fid RESTORE SUCCEED
1661 # Check that ordinary user can get HSM state.
1662 $RUNAS $LFS hsm_state $file ||
1663 error "user '$RUNAS_ID' cannot get HSM state of '$file'"
1665 $LFS hsm_release $file
1666 check_hsm_flags $file "0x0000000d"
1668 # Check that ordinary user can accessed released file.
1669 sum1=$($RUNAS md5sum $file) ||
1670 error "user '$RUNAS_ID' cannot read '$file'"
1672 [ "$sum0" == "$sum1" ] ||
1673 error "md5sum mismatch for '$file'"
1677 run_test 24b "root can archive, release, and restore user files"
1679 cleanup_test_24c() {
1681 set_hsm_param user_request_mask RESTORE
1682 set_hsm_param group_request_mask RESTORE
1683 set_hsm_param other_request_mask RESTORE
1687 local file=$DIR/$tdir/$tfile
1688 local action=archive
1693 # test needs a running copytool
1698 # Save the default masks and check that cleanup_24c will
1699 # restore the request masks correctly.
1700 user_save=$(get_hsm_param user_request_mask)
1701 group_save=$(get_hsm_param group_request_mask)
1702 other_save=$(get_hsm_param other_request_mask)
1704 [ "$user_save" == RESTORE ] ||
1705 error "user_request_mask is '$user_save' expected 'RESTORE'"
1706 [ "$group_save" == RESTORE ] ||
1707 error "group_request_mask is '$group_save' expected 'RESTORE'"
1708 [ "$other_save" == RESTORE ] ||
1709 error "other_request_mask is '$other_save' expected 'RESTORE'"
1711 trap cleanup_test_24c EXIT
1716 chown $RUNAS_ID:nobody $file ||
1717 error "cannot chown '$file' to '$RUNAS_ID:nobody'"
1719 set_hsm_param user_request_mask ""
1720 $RUNAS $LFS hsm_$action $file &&
1721 error "$action by user should fail"
1723 set_hsm_param user_request_mask $action
1724 $RUNAS $LFS hsm_$action $file ||
1725 error "$action by user should succeed"
1730 chown nobody:$RUNAS_GID $file ||
1731 error "cannot chown '$file' to 'nobody:$RUNAS_GID'"
1733 set_hsm_param group_request_mask ""
1734 $RUNAS $LFS hsm_$action $file &&
1735 error "$action by group should fail"
1737 set_hsm_param group_request_mask $action
1738 $RUNAS $LFS hsm_$action $file ||
1739 error "$action by group should succeed"
1744 chown nobody:nobody $file ||
1745 error "cannot chown '$file' to 'nobody:nobody'"
1747 set_hsm_param other_request_mask ""
1748 $RUNAS $LFS hsm_$action $file &&
1749 error "$action by other should fail"
1751 set_hsm_param other_request_mask $action
1752 $RUNAS $LFS hsm_$action $file ||
1753 error "$action by other should succeed"
1758 run_test 24c "check that user,group,other request masks work"
1760 cleanup_test_24d() {
1762 mount -o remount,rw $MOUNT2
1766 local file1=$DIR/$tdir/$tfile
1767 local file2=$DIR2/$tdir/$tfile
1775 fid1=$(make_small $file1)
1777 trap cleanup_test_24d EXIT
1779 mount -o remount,ro $MOUNT2
1781 fid2=$(path2fid $file2)
1782 [ "$fid1" == "$fid2" ] ||
1783 error "FID mismatch '$fid1' != '$fid2'"
1785 $LFS hsm_archive $file2 &&
1786 error "archive should fail on read-only mount"
1787 check_hsm_flags $file1 "0x00000000"
1789 $LFS hsm_archive $file1
1790 wait_request_state $fid1 ARCHIVE SUCCEED
1792 $LFS hsm_release $file1
1793 $LFS hsm_restore $file2
1794 wait_request_state $fid1 RESTORE SUCCEED
1796 $LFS hsm_release $file1 || error "cannot release '$file1'"
1797 dd if=$file2 of=/dev/null bs=1M || "cannot read '$file2'"
1799 $LFS hsm_release $file2 &&
1800 error "release should fail on read-only mount"
1805 run_test 24d "check that read-only mounts are respected"
1808 # test needs a running copytool
1812 copy2archive /etc/hosts $tdir/$tfile
1814 local f=$DIR/$tdir/$tfile
1816 import_file $tdir/$tfile $f
1818 $LFS hsm_set --lost $f
1823 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1827 run_test 25a "Restore lost file (HS_LOST flag) from import"\
1828 " (Operation not permitted)"
1831 # test needs a running copytool
1836 local f=$DIR/$tdir/$tfile
1837 local fid=$(copy_file /etc/passwd $f)
1839 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1840 wait_request_state $fid ARCHIVE SUCCEED
1843 $LFS hsm_set --lost $f
1847 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
1851 run_test 25b "Restore lost file (HS_LOST flag) after release"\
1852 " (Operation not permitted)"
1855 # test needs a running copytool
1859 local f=$DIR/$tdir/$tfile
1860 local fid=$(make_large_for_progress $f)
1861 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1862 wait_request_state $fid ARCHIVE SUCCEED
1865 wait_request_state $fid REMOVE SUCCEED
1867 check_hsm_flags $f "0x00000000"
1871 run_test 26 "Remove the archive of a valid file"
1874 # test needs a running copytool
1878 make_archive $tdir/$tfile
1879 local f=$DIR/$tdir/$tfile
1880 import_file $tdir/$tfile $f
1881 local fid=$(path2fid $f)
1885 [[ $? != 0 ]] || error "Remove of a released file should fail"
1889 run_test 27a "Remove the archive of an imported file (Operation not permitted)"
1892 # test needs a running copytool
1896 local f=$DIR/$tdir/$tfile
1897 local fid=$(make_large_for_progress $f)
1898 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1899 wait_request_state $fid ARCHIVE SUCCEED
1904 [[ $? != 0 ]] || error "Remove of a released file should fail"
1908 run_test 27b "Remove the archive of a relased file (Operation not permitted)"
1911 # test needs a running copytool
1915 local f=$DIR/$tdir/$tfile
1916 local fid=$(make_large_for_progress $f)
1917 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1918 wait_request_state $fid ARCHIVE SUCCEED
1927 wait_request_state $fid REMOVE SUCCEED
1931 run_test 28 "Concurrent archive/file remove"
1934 # restore at exec cannot work on agent node (because of Linux kernel
1935 # protection of executables)
1936 needclients 2 || return 0
1938 # test needs a running copytool
1942 copy2archive /bin/true $tdir/$tfile
1944 local f=$DIR/$tdir/true
1945 import_file $tdir/$tfile $f
1947 local fid=$(path2fid $f)
1949 # set no retry action mode
1955 # remove no try action mode
1959 [[ $st == 0 ]] || error "Failed to exec a released file"
1963 run_test 30a "Restore at exec (import case)"
1966 # restore at exec cannot work on agent node (because of Linux kernel
1967 # protection of executables)
1968 needclients 2 || return 0
1970 # test needs a running copytool
1974 local f=$DIR/$tdir/true
1975 local fid=$(copy_file /bin/true $f)
1977 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1978 wait_request_state $fid ARCHIVE SUCCEED
1981 # set no retry action mode
1987 # remove no try action mode
1991 [[ $st == 0 ]] || error "Failed to exec a released file"
1995 run_test 30b "Restore at exec (release case)"
1998 needclients 2 || return 0
2000 # test needs a running copytool
2004 local f=$DIR/$tdir/SLEEP
2005 local fid=$(copy_file /bin/sleep $f)
2007 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2008 wait_request_state $fid ARCHIVE SUCCEED
2010 check_hsm_flags $f "0x0000000d"
2011 # set no retry action mode
2013 do_node $CLIENT2 "$f 10" &
2017 [[ $? == 0 ]] && error "Update during exec of released file must fail"
2019 [[ $? == 0 ]] || error "Execution failed during run"
2021 [[ $? == 0 ]] || error "Binary overwritten during exec"
2024 # remove no try action mode
2026 check_hsm_flags $f "0x00000009"
2030 run_test 30c "Update during exec of released file must fail"
2032 restore_and_check_size() {
2035 local s=$(stat -c "%s" $f)
2037 local st=$(get_hsm_flags $f)
2041 while [[ "$st" != "0x00000009" && $cpt -le 10 ]]
2043 n=$(stat -c "%s" $f)
2044 # we echo in both cases to show stat is not
2046 if [[ $n != $s ]]; then
2047 echo "size seen is $n != $s"
2050 echo "size seen is right: $n == $s"
2052 st=$(get_hsm_flags $f)
2056 if [[ $cpt -lt 10 ]]; then
2059 echo " restore is too long"
2060 wait_request_state $fid RESTORE SUCCEED
2066 # test needs a running copytool
2071 make_archive $tdir/$tfile
2072 local f=$DIR/$tdir/$tfile
2073 import_file $tdir/$tfile $f
2074 local fid=$($LFS path2fid $f)
2075 HSM_ARCHIVE_PURGE=false copytool_setup
2077 restore_and_check_size $f $fid
2080 [[ $err -eq 0 ]] || error "File size changed during restore"
2084 run_test 31a "Import a large file and check size during restore"
2088 # test needs a running copytool
2093 local f=$DIR/$tdir/$tfile
2094 local fid=$(make_large_for_progress $f)
2095 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2096 wait_request_state $fid ARCHIVE SUCCEED
2099 restore_and_check_size $f $fid
2102 [[ $err -eq 0 ]] || error "File size changed during restore"
2106 run_test 31b "Restore a large unaligned file and check size during restore"
2109 # test needs a running copytool
2114 local f=$DIR/$tdir/$tfile
2115 local fid=$(make_large_for_progress_aligned $f)
2116 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2117 wait_request_state $fid ARCHIVE SUCCEED
2120 restore_and_check_size $f $fid
2123 [[ $err -eq 0 ]] || error "File size changed during restore"
2127 run_test 31c "Restore a large aligned file and check size during restore"
2130 # test needs a running copytool
2135 local f=$DIR/$tdir/$tfile
2136 local fid=$(make_large_for_progress $f)
2137 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2138 wait_request_state $fid ARCHIVE SUCCEED
2141 md5sum $f >/dev/null &
2143 wait_request_state $fid RESTORE STARTED
2148 # Check restore trigger process was killed
2149 local killed=$(ps -o pid,comm hp $pid >/dev/null)
2153 wait_request_state $fid RESTORE CANCELED
2154 wait_request_state $fid CANCEL SUCCEED
2157 error "Cannot kill process waiting for restore ($killed)"
2161 run_test 33 "Kill a restore waiting process"
2164 # test needs a running copytool
2169 local f=$DIR/$tdir/$tfile
2170 local fid=$(make_large_for_progress $f)
2171 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2172 wait_request_state $fid ARCHIVE SUCCEED
2175 md5sum $f >/dev/null &
2177 wait_request_state $fid RESTORE STARTED
2179 rm $f || error "rm $f failed"
2180 # rm must not block during restore
2181 wait_request_state $fid RESTORE STARTED
2183 wait_request_state $fid RESTORE SUCCEED
2184 # check md5sum pgm finished
2185 local there=$(ps -o pid,comm hp $pid >/dev/null)
2186 [[ -z $there ]] || error "Restore initiator does not exit"
2188 local rc=$(wait $pid)
2189 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2193 run_test 34 "Remove file during restore"
2196 # test needs a running copytool
2201 local f=$DIR/$tdir/$tfile
2202 local f1=$DIR/$tdir/$tfile-1
2203 local fid=$(make_large_for_progress $f)
2204 local fid1=$(copy_file /etc/passwd $f1)
2205 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2206 wait_request_state $fid ARCHIVE SUCCEED
2209 md5sum $f >/dev/null &
2211 wait_request_state $fid RESTORE STARTED
2213 mv $f1 $f || error "mv $f1 $f failed"
2214 # mv must not block during restore
2215 wait_request_state $fid RESTORE STARTED
2217 wait_request_state $fid RESTORE SUCCEED
2218 # check md5sum pgm finished
2219 local there=$(ps -o pid,comm hp $pid >/dev/null)
2220 [[ -z $there ]] || error "Restore initiator does not exit"
2222 local rc=$(wait $pid)
2223 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2226 [[ $fid2 == $fid1 ]] || error "Wrong fid after mv $fid2 != $fid1"
2230 run_test 35 "Overwrite file during restore"
2233 # test needs a running copytool
2238 local f=$DIR/$tdir/$tfile
2239 local fid=$(make_large_for_progress $f)
2240 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2241 wait_request_state $fid ARCHIVE SUCCEED
2244 md5sum $f >/dev/null &
2246 wait_request_state $fid RESTORE STARTED
2249 # rm must not block during restore
2250 wait_request_state $fid RESTORE STARTED
2252 wait_request_state $fid RESTORE SUCCEED
2253 # check md5sum pgm finished
2254 local there=$(ps -o pid,comm hp $pid >/dev/null)
2256 error "Restore initiator does not exit"
2258 local rc=$(wait $pid)
2260 error "Restore initiator failed with $rc"
2264 run_test 36 "Move file during restore"
2271 for n in $(seq 1 $count); do
2272 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $prefix.$n
2274 echo "$count archive requests submitted"
2278 local stream_count=4
2279 local file_count=100
2281 local f=$DIR/$tdir/$tfile
2286 for i in $(seq 1 $file_count); do
2287 for p in $(seq 1 $stream_count); do
2288 fid=$(copy_file /etc/hosts $f.$p.$i)
2291 # force copytool to use a local/temp archive dir to ensure best
2292 # performance vs remote/NFS mounts used in auto-tests
2293 if df --local $HSM_ARCHIVE >/dev/null 2>&1 ; then
2296 copytool_setup $SINGLEAGT $MOUNT $HSM_ARCHIVE_NUMBER $TMP/$tdir
2298 # to be sure wait_all_done will not be mislead by previous tests
2300 wait_for_grace_delay
2302 # start archive streams in background (archive files in parallel)
2303 for p in $(seq 1 $stream_count); do
2304 multi_archive $f.$p $file_count &
2307 echo -n "Wait for all requests being enqueued..."
2313 run_test 40 "Parallel archive requests"
2316 # test needs a running copytool
2320 local f=$DIR/$tdir/$tfile
2321 local fid=$(copy_file /etc/motd $f 1)
2323 $LFS hsm_archive $f || error "could not archive file"
2324 wait_request_state $fid ARCHIVE SUCCEED
2325 check_hsm_flags $f "0x00000009"
2327 multiop_bg_pause $f O_c || error "multiop failed"
2331 client_up || client_up || true
2333 kill -USR1 $MULTIPID
2334 wait $MULTIPID || error "multiop close failed"
2336 check_hsm_flags $f "0x0000000b"
2340 run_test 52 "Opened for write file on an evicted client should be set dirty"
2343 # test needs a running copytool
2347 local f=$DIR/$tdir/$tfile
2348 local fid=$(copy_file /etc/motd $f 1)
2350 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2351 error "could not archive file"
2352 wait_request_state $fid ARCHIVE SUCCEED
2353 check_hsm_flags $f "0x00000009"
2355 multiop_bg_pause $f o_c || error "multiop failed"
2359 client_up || client_up || true
2361 kill -USR1 $MULTIPID
2362 wait $MULTIPID || error "multiop close failed"
2364 check_hsm_flags $f "0x00000009"
2368 run_test 53 "Opened for read file on an evicted client should not be set dirty"
2371 # test needs a running copytool
2375 local f=$DIR/$tdir/$tfile
2376 local fid=$(make_small $f)
2378 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2379 error "could not archive file"
2380 wait_request_state $fid ARCHIVE STARTED
2382 check_hsm_flags $f "0x00000001"
2384 # Avoid coordinator resending this request as soon it has failed.
2389 wait_request_state $fid ARCHIVE FAILED
2391 check_hsm_flags $f "0x00000003"
2396 run_test 54 "Write during an archive cancels it"
2399 # test needs a running copytool
2403 local f=$DIR/$tdir/$tfile
2404 local fid=$(make_small $f)
2406 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2407 error "could not archive file"
2408 wait_request_state $fid ARCHIVE STARTED
2410 check_hsm_flags $f "0x00000001"
2412 # Avoid coordinator resending this request as soon it has failed.
2415 $TRUNCATE $f 1024 || error "truncate failed"
2417 wait_request_state $fid ARCHIVE FAILED
2419 check_hsm_flags $f "0x00000003"
2424 run_test 55 "Truncate during an archive cancels it"
2427 # test needs a running copytool
2431 local f=$DIR/$tdir/$tfile
2432 local fid=$(make_large_for_progress $f)
2434 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2435 error "could not archive file"
2436 wait_request_state $fid ARCHIVE STARTED
2438 check_hsm_flags $f "0x00000001"
2440 # Change metadata and sync to be sure we are not changing only
2445 wait_request_state $fid ARCHIVE SUCCEED
2447 check_hsm_flags $f "0x00000009"
2451 run_test 56 "Setattr during an archive is ok"
2454 # Need one client for I/O, one for request
2455 needclients 2 || return 0
2457 # test needs a running copytool
2461 local f=$DIR/$tdir/test_archive_remote
2462 # Create a file on a remote node
2463 do_node $CLIENT2 "dd if=/dev/urandom of=$f bs=1M "\
2464 "count=2 conv=fsync"
2467 do_node $CLIENT2 "$LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f" ||
2468 error "hsm_archive failed"
2469 local fid=$(path2fid $f)
2470 wait_request_state $fid ARCHIVE SUCCEED
2472 # Release and implicit restore it
2473 do_node $CLIENT2 "$LFS hsm_release $f" ||
2474 error "hsm_release failed"
2475 do_node $CLIENT2 "md5sum $f" ||
2476 error "hsm_restore failed"
2478 wait_request_state $fid RESTORE SUCCEED
2482 run_test 57 "Archive a file with dirty cache on another node"
2484 truncate_released_file() {
2488 local sz=$(stat -c %s $src_file)
2489 local f=$DIR/$tdir/$tfile
2490 local fid=$(copy_file $1 $f)
2494 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2495 error "could not archive file"
2496 wait_request_state $fid ARCHIVE SUCCEED
2498 $LFS hsm_release $f || error "could not release file"
2500 $TRUNCATE $f $trunc_to || error "truncate failed"
2503 local sz1=$(stat -c %s $f)
2504 [[ $sz1 == $trunc_to ]] ||
2505 error "size after trunc: $sz1 expect $trunc_to, original $sz"
2508 check_hsm_flags $f "0x0000000b"
2510 local state=$(get_request_state $fid RESTORE)
2511 [[ "$state" == "SUCCEED" ]] ||
2512 error "truncate $sz does not trig restore, state = $state"
2514 $TRUNCATE $ref $trunc_to
2515 cmp $ref $f || error "file data wrong after truncate"
2521 # test needs a running copytool
2526 local sz=$(stat -c %s /etc/passwd)
2528 echo "truncate up from $sz to $((sz*2))"
2529 truncate_released_file /etc/passwd $((sz*2))
2531 echo "truncate down from $sz to $((sz/2))"
2532 truncate_released_file /etc/passwd $((sz/2))
2534 echo "truncate to 0"
2535 truncate_released_file /etc/passwd 0
2539 run_test 58 "Truncate a released file will trigger restore"
2542 # This test validates the fix for LU-4512. Ensure that the -u
2543 # option changes the progress reporting interval from the default
2544 # (30 seconds) to the user-specified interval.
2546 local progress_timeout=$((interval * 2))
2548 # test needs a new running copytool
2550 HSMTOOL_UPDATE_INTERVAL=$interval copytool_setup
2553 local f=$DIR/$tdir/$tfile
2554 local fid=$(make_large_for_progress $f)
2556 local start_at=$(date +%s)
2557 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2558 error "could not archive file"
2561 local mdt=${MDT_PREFIX}${mdtidx}
2562 local mds=mds$((mdtidx + 1))
2564 local cmd="$LCTL get_param -n ${mdt}.hsm.active_requests"
2565 cmd+=" | awk '/'$fid'.*action=ARCHIVE/ {print \\\$12}' | cut -f2 -d="
2571 echo -n "Expecting a progress update within $progress_timeout seconds... "
2573 RESULT=$(do_node $(facet_active_host $mds) "$cmd")
2574 if [ $RESULT -gt 0 ]; then
2575 echo "$RESULT bytes copied in $WAIT seconds."
2577 elif [ $WAIT -ge $progress_timeout ]; then
2578 error "Timed out waiting for progress update!"
2581 WAIT=$((WAIT + sleep))
2585 local finish_at=$(date +%s)
2586 local elapsed=$((finish_at - start_at))
2588 # Ensure that the progress update occurred within the expected window.
2589 if [ $elapsed -gt $progress_timeout ]; then
2590 error "Expected progress update within $progress_timeout seconds"
2591 elif [ $elapsed -lt $interval ]; then
2592 error "Expected progress update after at least $interval seconds"
2598 run_test 60 "Changing progress update interval from default"
2603 local f=$DIR/$tdir/$tfile
2604 local FILELIST=/tmp/filelist.txt
2608 for i in $(seq 1 $file_count); do
2609 fid=$(copy_file /etc/hosts $f.$i)
2610 echo $f.$i >> $FILELIST
2613 # to be sure wait_all_done will not be mislead by previous tests
2615 wait_for_grace_delay
2616 $LFS hsm_archive --filelist $FILELIST ||
2617 error "cannot archive a file list"
2619 $LFS hsm_release --filelist $FILELIST ||
2620 error "cannot release a file list"
2621 $LFS hsm_restore --filelist $FILELIST ||
2622 error "cannot restore a file list"
2626 run_test 90 "Archive/restore a file list"
2628 double_verify_reset_hsm_param() {
2630 echo "Testing $HSM_PARAM.$p"
2631 local val=$(get_hsm_param $p)
2633 local val2=$(($val * 2))
2634 set_hsm_param $p $val2
2635 val=$(get_hsm_param $p)
2636 [[ $val == $val2 ]] ||
2637 error "$HSM_PARAM.$p: $val != $val2 should be (2 * $save)"
2638 echo "Set $p to 0 must failed"
2642 set_hsm_param $p $save
2644 if [[ $rc == 0 ]]; then
2645 error "we must not be able to set $HSM_PARAM.$p to 0"
2650 double_verify_reset_hsm_param loop_period
2651 double_verify_reset_hsm_param grace_delay
2652 double_verify_reset_hsm_param active_request_timeout
2653 double_verify_reset_hsm_param max_requests
2654 double_verify_reset_hsm_param default_archive_id
2656 run_test 100 "Set coordinator /proc tunables"
2663 run_test 102 "Verify coordinator control"
2666 # test needs a running copytool
2673 for i in $(seq 1 20); do
2674 fid=$(copy_file /etc/passwd $DIR/$tdir/$i)
2676 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/*
2680 echo "Current requests"
2681 local res=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2682 $HSM_PARAM.actions |\
2683 grep -v CANCELED | grep -v SUCCEED | grep -v FAILED")
2685 [[ -z "$res" ]] || error "Some request have not been canceled"
2689 run_test 103 "Purge all requests"
2694 # test needs a running copytool
2698 local f=$DIR/$tdir/$tfile
2699 local fid=$(make_large_for_progress $f)
2700 # if cdt is on, it can serve too quickly the request
2702 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER --data $DATA $f
2703 local data1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2704 $HSM_PARAM.actions |\
2705 grep $fid | cut -f16 -d=")
2708 [[ "$data1" == "$DATAHEX" ]] ||
2709 error "Data field in records is ($data1) and not ($DATAHEX)"
2713 run_test 104 "Copy tool data field"
2720 for i in $(seq -w 1 10); do
2721 cp /etc/passwd $DIR/$tdir/$i
2722 $LFS hsm_archive $DIR/$tdir/$i
2724 local reqcnt1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2725 $HSM_PARAM.actions |\
2726 grep WAITING | wc -l")
2729 local reqcnt2=$(do_facet $SINGLEMDS "$LCTL get_param -n\
2730 $HSM_PARAM.actions |\
2731 grep WAITING | wc -l")
2734 [[ "$reqcnt1" == "$reqcnt2" ]] ||
2735 error "Requests count after shutdown $reqcnt2 != "\
2736 "before shutdown $reqcnt1"
2738 run_test 105 "Restart of coordinator"
2740 get_agent_by_uuid_mdt() {
2743 local mds=mds$(($mdtidx + 1))
2744 do_facet $mds "$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.agents |\
2748 check_agent_registered_by_mdt() {
2751 local mds=mds$(($mdtidx + 1))
2752 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
2753 if [[ ! -z "$agent" ]]; then
2754 echo "found agent $agent on $mds"
2756 error "uuid $uuid not found in agent list on $mds"
2760 check_agent_unregistered_by_mdt() {
2763 local mds=mds$(($mdtidx + 1))
2764 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
2765 if [[ -z "$agent" ]]; then
2766 echo "uuid not found in agent list on $mds"
2768 error "uuid found in agent list on $mds: $agent"
2772 check_agent_registered() {
2775 for mdsno in $(seq 1 $MDSCOUNT); do
2776 check_agent_registered_by_mdt $uuid $((mdsno - 1))
2780 check_agent_unregistered() {
2783 for mdsno in $(seq 1 $MDSCOUNT); do
2784 check_agent_unregistered_by_mdt $uuid $((mdsno - 1))
2789 local uuid=$(do_rpc_nodes $(facet_active_host $SINGLEAGT) \
2790 get_client_uuid $MOUNT | cut -d' ' -f2)
2793 check_agent_registered $uuid
2795 search_copytools || error "No copytool found"
2798 check_agent_unregistered $uuid
2801 check_agent_registered $uuid
2805 run_test 106 "Copytool register/unregister"
2808 # test needs a running copytool
2810 # create and archive file
2812 local f1=$DIR/$tdir/$tfile
2813 local fid=$(copy_file /etc/passwd $f1)
2814 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
2815 wait_request_state $fid ARCHIVE SUCCEED
2816 # shutdown and restart MDS
2818 # check the copytool still gets messages from MDT
2819 local f2=$DIR/$tdir/2
2820 local fid=$(copy_file /etc/passwd $f2)
2821 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f2
2822 # main check of this sanity: this request MUST succeed
2823 wait_request_state $fid ARCHIVE SUCCEED
2826 run_test 107 "Copytool re-register after MDS restart"
2828 policy_set_and_test()
2832 do_facet $SINGLEMDS $LCTL set_param "$HSM_PARAM.policy=\\\"$change\\\""
2833 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2834 [[ "$policy" == "$target" ]] ||
2835 error "Wrong policy after '$change': '$policy' != '$target'"
2839 # to force default policy setting if error
2840 CDT_POLICY_HAD_CHANGED=true
2842 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2843 local default="NonBlockingRestore [NoRetryAction]"
2844 [[ "$policy" == "$default" ]] ||
2845 error "default policy has changed,"\
2846 " '$policy' != '$default' update the test"
2847 policy_set_and_test "+NBR" "[NonBlockingRestore] [NoRetryAction]"
2848 policy_set_and_test "+NRA" "[NonBlockingRestore] [NoRetryAction]"
2849 policy_set_and_test "-NBR" "NonBlockingRestore [NoRetryAction]"
2850 policy_set_and_test "-NRA" "NonBlockingRestore NoRetryAction"
2851 policy_set_and_test "NRA NBR" "[NonBlockingRestore] [NoRetryAction]"
2852 # useless bacause we know but safer for futur changes to use real value
2853 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
2854 echo "Next set_param must failed"
2855 policy_set_and_test "wrong" "$policy"
2858 echo "Back to default policy"
2859 cdt_set_sanity_policy
2861 run_test 109 "Policy display/change"
2864 # test needs a running copytool
2869 copy2archive /etc/passwd $tdir/$tfile
2871 local f=$DIR/$tdir/$tfile
2872 import_file $tdir/$tfile $f
2873 local fid=$(path2fid $f)
2875 cdt_set_non_blocking_restore
2880 wait_request_state $fid RESTORE SUCCEED
2881 cdt_clear_non_blocking_restore
2885 error "md5sum returns $st != 1, "\
2886 "should also perror ENODATA (No data available)"
2890 run_test 110a "Non blocking restore policy (import case)"
2893 # test needs a running copytool
2897 local f=$DIR/$tdir/$tfile
2898 local fid=$(copy_file /etc/passwd $f)
2899 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2900 wait_request_state $fid ARCHIVE SUCCEED
2903 cdt_set_non_blocking_restore
2908 wait_request_state $fid RESTORE SUCCEED
2909 cdt_clear_non_blocking_restore
2913 error "md5sum returns $st != 1, "\
2914 "should also perror ENODATA (No data available)"
2918 run_test 110b "Non blocking restore policy (release case)"
2921 # test needs a running copytool
2925 copy2archive /etc/passwd $tdir/$tfile
2927 local f=$DIR/$tdir/$tfile
2929 import_file $tdir/$tfile $f
2930 local fid=$(path2fid $f)
2934 copytool_remove_backend $fid
2937 wait_request_state $fid RESTORE FAILED
2944 [[ $st == 0 ]] || error "Restore does not failed"
2948 run_test 111a "No retry policy (import case), restore will error"\
2949 " (No such file or directory)"
2952 # test needs a running copytool
2956 local f=$DIR/$tdir/$tfile
2957 local fid=$(copy_file /etc/passwd $f)
2959 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2960 wait_request_state $fid ARCHIVE SUCCEED
2963 copytool_remove_backend $fid
2966 wait_request_state $fid RESTORE FAILED
2973 [[ $st == 0 ]] || error "Restore does not failed"
2977 run_test 111b "No retry policy (release case), restore will error"\
2978 " (No such file or directory)"
2981 # test needs a running copytool
2985 local f=$DIR/$tdir/$tfile
2986 local fid=$(copy_file /etc/passwd $f)
2988 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2989 local l=$($LFS hsm_action $f)
2991 local res=$(echo $l | cut -f 2- -d" " | grep ARCHIVE)
2995 wait_request_state $fid ARCHIVE SUCCEED
2998 [[ ! -z "$res" ]] || error "action is $l which is not an ARCHIVE"
3002 run_test 112 "State of recorded request"
3005 # test needs a running copytool
3009 local f=$DIR/$tdir/$tfile
3010 local fid=$(make_large_for_cancel $f)
3011 # test with cdt on is made in test_221
3013 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3016 wait_request_state $fid ARCHIVE CANCELED
3017 wait_request_state $fid CANCEL SUCCEED
3021 run_test 200 "Register/Cancel archive"
3024 # test needs a running copytool
3028 local f=$DIR/$tdir/$tfile
3029 make_archive $tdir/$tfile
3030 import_file $tdir/$tfile $f
3031 local fid=$(path2fid $f)
3033 # test with cdt on is made in test_222
3038 wait_request_state $fid RESTORE CANCELED
3039 wait_request_state $fid CANCEL SUCCEED
3043 run_test 201 "Register/Cancel restore"
3046 # test needs a running copytool
3050 local f=$DIR/$tdir/$tfile
3051 local fid=$(make_large_for_progress $f)
3052 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3053 wait_request_state $fid ARCHIVE SUCCEED
3059 wait_request_state $fid REMOVE CANCELED
3063 run_test 202 "Register/Cancel remove"
3066 # test needs a running copytool
3071 local f=$DIR/$tdir/$tfile
3072 local fid=$(copy_file /etc/passwd $f)
3076 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3077 wait_request_state $fid ARCHIVE SUCCEED
3079 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3083 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3087 run_test 220 "Changelog for archive"
3090 # test needs a running copytool
3095 local f=$DIR/$tdir/$tfile
3096 local fid=$(make_large_for_cancel $f)
3100 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3101 wait_request_state $fid ARCHIVE STARTED
3103 wait_request_state $fid ARCHIVE CANCELED
3104 wait_request_state $fid CANCEL SUCCEED
3106 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3109 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3113 run_test 221 "Changelog for archive canceled"
3116 # test needs a running copytool
3120 copy2archive /etc/passwd $tdir/$tfile
3122 local f=$DIR/$tdir/$tfile
3123 import_file $tdir/$tfile $f
3124 local fid=$(path2fid $f)
3129 wait_request_state $fid RESTORE SUCCEED
3131 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3134 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3138 run_test 222a "Changelog for explicit restore"
3141 # test needs a running copytool
3145 local f=$DIR/$tdir/$tfile
3146 local fid=$(copy_file /etc/passwd $f)
3149 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3150 wait_request_state $fid ARCHIVE SUCCEED
3155 wait_request_state $fid RESTORE SUCCEED
3157 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3160 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3164 run_test 222b "Changelog for implicit restore"
3167 # test needs a running copytool
3172 local f=$DIR/$tdir/$tfile
3173 make_archive $tdir/$tfile
3177 import_file $tdir/$tfile $f
3178 local fid=$(path2fid $f)
3181 wait_request_state $fid RESTORE STARTED
3183 wait_request_state $fid RESTORE CANCELED
3184 wait_request_state $fid CANCEL SUCCEED
3186 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3189 [[ $flags == $target ]] ||
3190 error "Changelog flag is $flags not $target"
3194 run_test 223a "Changelog for restore canceled (import case)"
3197 # test needs a running copytool
3202 local f=$DIR/$tdir/$tfile
3203 local fid=$(make_large_for_progress $f)
3206 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3207 wait_request_state $fid ARCHIVE SUCCEED
3210 wait_request_state $fid RESTORE STARTED
3212 wait_request_state $fid RESTORE CANCELED
3213 wait_request_state $fid CANCEL SUCCEED
3215 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3218 [[ $flags == $target ]] ||
3219 error "Changelog flag is $flags not $target"
3223 run_test 223b "Changelog for restore canceled (release case)"
3226 # test needs a running copytool
3231 local f=$DIR/$tdir/$tfile
3232 local fid=$(copy_file /etc/passwd $f)
3235 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3236 wait_request_state $fid ARCHIVE SUCCEED
3239 wait_request_state $fid REMOVE SUCCEED
3241 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -n 1)
3244 [[ $flags == $target ]] ||
3245 error "Changelog flag is $flags not $target"
3249 run_test 224 "Changelog for remove"
3252 # test needs a running copytool
3255 # test is not usable because remove request is too fast
3256 # so it is always finished before cancel can be done ...
3257 echo "Test disabled"
3262 local f=$DIR/$tdir/$tfile
3263 local fid=$(make_large_for_progress $f)
3266 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3267 wait_request_state $fid ARCHIVE SUCCEED
3269 # if cdt is on, it can serve too quickly the request
3274 wait_request_state $fid REMOVE CANCELED
3275 wait_request_state $fid CANCEL SUCCEED
3277 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3278 local flags=$($LFS changelog ${MDT[0]} | grep HSM | grep $fid |
3279 tail -n 1 | awk '{print $5}')
3282 [[ $flags == $target ]] ||
3283 error "Changelog flag is $flags not $target"
3287 run_test 225 "Changelog for remove canceled"
3290 # test needs a running copytool
3295 local f1=$DIR/$tdir/$tfile-1
3296 local f2=$DIR/$tdir/$tfile-2
3297 local f3=$DIR/$tdir/$tfile-3
3298 local fid1=$(copy_file /etc/passwd $f1)
3299 local fid2=$(copy_file /etc/passwd $f2)
3300 copy_file /etc/passwd $f3
3303 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
3304 wait_request_state $fid1 ARCHIVE SUCCEED
3306 $LFS hsm_archive $f2
3307 wait_request_state $fid2 ARCHIVE SUCCEED
3309 rm $f1 || error "rm $f1 failed"
3311 local flags=$(changelog_get_flags ${MDT[0]} UNLNK $fid1)
3314 [[ $flags == $target ]] ||
3315 error "Changelog flag is $flags not $target"
3317 mv $f3 $f2 || error "mv $f3 $f2 failed"
3319 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3322 [[ $flags == $target ]] ||
3323 error "Changelog flag is $flags not $target"
3327 run_test 226 "changelog for last rm/mv with exiting archive"
3329 check_flags_changes() {
3337 $LFS hsm_set --$hsm_flag $f ||
3338 error "Cannot set $hsm_flag on $f"
3339 local flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3340 local seen=${#flags[*]}
3342 [[ $seen == $cnt ]] ||
3343 error "set $hsm_flag: Changelog events $seen != $cnt"
3344 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3345 error "set $hsm_flag: Changelog flags are "\
3346 "${flags[$((cnt - 1))]} not $target"
3348 $LFS hsm_clear --$hsm_flag $f ||
3349 error "Cannot clear $hsm_flag on $f"
3350 flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3353 [[ $cnt == $seen ]] ||
3354 error "clear $hsm_flag: Changelog events $seen != $cnt"
3356 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3357 error "clear $hsm_flag: Changelog flag is "\
3358 "${flags[$((cnt - 1))]} not $target"
3362 # test needs a running copytool
3369 for i in norelease noarchive exists archived
3371 local f=$DIR/$tdir/$tfile-$i
3372 local fid=$(copy_file /etc/passwd $f)
3373 check_flags_changes $f $fid $i 0 1
3376 f=$DIR/$tdir/$tfile---lost
3377 fid=$(copy_file /etc/passwd $f)
3378 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3379 wait_request_state $fid ARCHIVE SUCCEED
3380 check_flags_changes $f $fid lost 3 1
3384 run_test 227 "changelog when explicit setting of HSM flags"
3387 # test needs a running copytool
3390 local fid=$(make_small_sync $DIR/$tfile)
3391 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tfile
3392 wait_request_state $fid ARCHIVE SUCCEED
3394 $LFS hsm_release $DIR/$tfile
3395 check_hsm_flags $DIR/$tfile "0x0000000d"
3397 filefrag $DIR/$tfile | grep " 1 extent found" ||
3398 error "filefrag on released file must return only one extent"
3400 # only newer versions of cp detect sparse files by stat/FIEMAP
3402 cp --sparse=auto $DIR/$tfile $DIR/$tfile.2 ||
3403 error "copying $DIR/$tfile"
3404 cmp $DIR/$tfile $DIR/$tfile.2 || error "comparing copied $DIR/$tfile"
3406 $LFS hsm_release $DIR/$tfile
3407 check_hsm_flags $DIR/$tfile "0x0000000d"
3409 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
3411 tar cf - --sparse $DIR/$tfile | tar xvf - -C $DIR/$tdir ||
3413 cmp $DIR/$tfile $DIR/$tdir/$DIR/$tfile ||
3414 error "comparing untarred $DIR/$tfile"
3416 rm -f $DIR/$tfile $DIR/$tfile.2 ||
3417 error "rm $DIR/$tfile or $DIR/$tfile.2 failed"
3420 run_test 228 "On released file, return extend to FIEMAP. For [cp,tar] --sparse"
3423 # test needs a running copytool
3427 local maxrequest=$(get_hsm_param max_requests)
3428 local rqcnt=$(($maxrequest * 3))
3432 for i in $(seq -w 1 $rqcnt); do
3434 dd if=/dev/urandom of=$DIR/$tdir/$i bs=1M count=10 conv=fsync
3436 # we do it in 2 steps, so all requests arrive at the same time
3437 for i in $(seq -w 1 $rqcnt); do
3438 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$i
3443 while [[ $cnt != 0 || $wt != 0 ]]; do
3445 cnt=$(do_facet $SINGLEMDS "$LCTL get_param -n\
3446 $HSM_PARAM.actions |\
3447 grep STARTED | grep -v CANCEL | wc -l")
3448 [[ $cnt -le $maxrequest ]] ||
3449 error "$cnt > $maxrequest too many started requests"
3450 wt=$(do_facet $SINGLEMDS "$LCTL get_param\
3451 $HSM_PARAM.actions |\
3452 grep WAITING | wc -l")
3453 echo "max=$maxrequest started=$cnt waiting=$wt"
3458 run_test 250 "Coordinator max request"
3461 # test needs a running copytool
3465 local f=$DIR/$tdir/$tfile
3466 local fid=$(make_large_for_cancel $f)
3469 # to have a short test
3470 local old_to=$(get_hsm_param active_request_timeout)
3471 set_hsm_param active_request_timeout 4
3472 # to be sure the cdt will wake up frequently so
3473 # it will be able to cancel the "old" request
3474 local old_loop=$(get_hsm_param loop_period)
3475 set_hsm_param loop_period 2
3478 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3479 wait_request_state $fid ARCHIVE STARTED
3481 wait_request_state $fid ARCHIVE CANCELED
3483 set_hsm_param active_request_timeout $old_to
3484 set_hsm_param loop_period $old_loop
3488 run_test 251 "Coordinator request timeout"
3491 # the only way to test ondisk conf is to restart MDS ...
3492 echo "Stop coordinator and remove coordinator state at mount"
3495 # clean on disk conf set by default
3496 cdt_clear_mount_state
3497 cdt_check_state stopped
3499 # check cdt still off after umount/remount
3501 cdt_check_state stopped
3503 echo "Set coordinator start at mount, and start coordinator"
3504 cdt_set_mount_state enabled
3507 cdt_check_state enabled
3509 # check cdt still on after umount/remount
3511 cdt_check_state enabled
3513 # we are back to original state (cdt started at mount)
3515 run_test 300 "On disk coordinator state kept between MDT umount/mount"
3518 local ai=$(get_hsm_param default_archive_id)
3519 local new=$((ai + 1))
3521 set_hsm_param default_archive_id $new -P
3523 local res=$(get_hsm_param default_archive_id)
3526 set_hsm_param default_archive_id "" "-P -d"
3528 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
3530 run_test 301 "HSM tunnable are persistent"
3533 local ai=$(get_hsm_param default_archive_id)
3534 local new=$((ai + 1))
3539 set_hsm_param default_archive_id $new -P
3542 for mdtno in $(seq 1 $MDSCOUNT); do
3547 cdt_check_state enabled
3549 local res=$(get_hsm_param default_archive_id)
3552 set_hsm_param default_archive_id "" "-P -d"
3554 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
3556 run_test 302 "HSM tunnable are persistent when CDT is off"
3559 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3565 local dir_mdt0=$DIR/$tdir/mdt0
3566 local dir_mdt1=$DIR/$tdir/mdt1
3568 # create 1 dir per MDT
3569 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3570 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
3572 # create 1 file in each MDT
3573 local fid1=$(make_small $dir_mdt0/$tfile)
3574 local fid2=$(make_small $dir_mdt1/$tfile)
3576 # check that hsm request on mdt0 is sent to the right MDS
3577 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
3578 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3579 echo "archive successful on mdt0"
3581 # check that hsm request on mdt1 is sent to the right MDS
3582 $LFS hsm_archive $dir_mdt1/$tfile || error "lfs hsm_archive"
3583 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
3584 echo "archive successful on mdt1"
3587 # clean test files and directories
3588 rm -rf $dir_mdt0 $dir_mdt1
3590 run_test 400 "Single request is sent to the right MDT"
3593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3599 local dir_mdt0=$DIR/$tdir/mdt0
3600 local dir_mdt1=$DIR/$tdir/mdt1
3602 # create 1 dir per MDT
3603 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3604 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
3606 # create 1 file in each MDT
3607 local fid1=$(make_small $dir_mdt0/$tfile)
3608 local fid2=$(make_small $dir_mdt1/$tfile)
3610 # check that compound requests are shunt to the rights MDTs
3611 $LFS hsm_archive $dir_mdt0/$tfile $dir_mdt1/$tfile ||
3612 error "lfs hsm_archive"
3613 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3614 echo "archive successful on mdt0"
3615 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
3616 echo "archive successful on mdt1"
3619 # clean test files and directories
3620 rm -rf $dir_mdt0 $dir_mdt1
3622 run_test 401 "Compound requests split and sent to their respective MDTs"
3624 mdc_change_state() # facet, MDT_pattern, activate|deactivate
3629 local node=$(facet_active_host $facet)
3631 for mdc in $(do_facet $facet "$LCTL dl | grep -E ${pattern}-mdc" |
3632 awk '{print $4}'); do
3633 echo "$3 $mdc on $node"
3634 do_facet $facet "$LCTL --device $mdc $state" || return 1
3639 # make sure there is no running copytool
3642 # deactivate all mdc on agent1
3643 mdc_change_state $SINGLEAGT "MDT000." "deactivate"
3645 copytool_setup $SINGLEAGT
3647 check_agent_unregistered "uuid" # match any agent
3649 # no expected running copytool
3650 search_copytools $agent && error "Copytool start should have failed"
3653 mdc_change_state $SINGLEAGT "MDT000." "activate"
3655 run_test 402 "Copytool start fails if all MDTs are inactive"
3658 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3660 # make sure there is no running copytool
3663 local agent=$(facet_active_host $SINGLEAGT)
3664 local uuid=$(do_rpc_nodes $agent get_client_uuid | cut -d' ' -f2)
3666 # deactivate all mdc for MDT0001
3667 mdc_change_state $SINGLEAGT "MDT0001" "deactivate"
3670 # check the agent is registered on MDT0000, and not on MDT0001
3671 check_agent_registered_by_mdt $uuid 0
3672 check_agent_unregistered_by_mdt $uuid 1
3674 # check running copytool process
3675 search_copytools $agent || error "No running copytools on $agent"
3677 # reactivate all mdc for MDT0001
3678 mdc_change_state $SINGLEAGT "MDT0001" "activate"
3680 # make sure the copytool is now registered to all MDTs
3681 check_agent_registered $uuid
3685 run_test 403 "Copytool starts with inactive MDT and register on reconnect"
3688 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3692 # create files on both MDT0000 and MDT0001
3695 local dir_mdt0=$DIR/$tdir/mdt0
3696 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
3698 # create 1 file on mdt0
3699 local fid1=$(make_small $dir_mdt0/$tfile)
3701 # deactivate all mdc for MDT0001
3702 mdc_change_state $SINGLEAGT "MDT0001" "deactivate"
3704 # send an HSM request for files in MDT0000
3705 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
3707 # check for completion of files in MDT0000
3708 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
3709 echo "archive successful on mdt0"
3711 # reactivate all mdc for MDT0001
3712 mdc_change_state $SINGLEAGT "MDT0001" "activate"
3715 # clean test files and directories
3718 run_test 404 "Inactive MDT does not block requests for active MDTs"
3723 check_and_cleanup_lustre