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: LU-3815
15 ALWAYS_EXCEPT="$SANITY_HSM_EXCEPT 34 35 36"
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
20 . $LUSTRE/tests/test-framework.sh
22 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
25 MULTIOP=${MULTIOP:-multiop}
26 OPENFILE=${OPENFILE:-openfile}
27 MOUNT_2=${MOUNT_2:-"yes"}
30 # script only handles up to 10 MDTs (because of MDT_PREFIX)
31 [ $MDSCOUNT -gt 9 ] &&
32 error "script cannot handle more than 9 MDTs, please fix" && exit
34 check_and_setup_lustre
36 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ]]; then
37 skip_env "Need MDS version at least 2.4.53" && exit
40 # $RUNAS_ID may get set incorrectly somewhere else
41 if [[ $UID -eq 0 && $RUNAS_ID -eq 0 ]]; then
42 skip_env "\$RUNAS_ID set to 0, but \$UID is also 0!" && exit
44 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
49 # In order to test multiple remote HSM agents, a new facet type named "AGT" and
50 # the following associated variables are added:
52 # AGTCOUNT: number of agents
53 # AGTDEV{N}: target HSM mount point (root path of the backend)
54 # agt{N}_HOST: hostname of the agent agt{N}
55 # SINGLEAGT: facet of the single agent
57 # The number of agents is initialized as the number of remote client nodes.
58 # By default, only single copytool is started on a remote client/agent. If there
59 # was no remote client, then the copytool will be started on the local client.
65 export AGTCOUNT=${AGTCOUNT:-$((CLIENTCOUNT - 1))}
66 [[ $AGTCOUNT -gt 0 ]] || AGTCOUNT=1
68 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-$TMP}
69 if [[ $CLIENTCOUNT -gt 1 ]] &&
70 ! check_shared_dir $SHARED_DIRECTORY $CLIENTS; then
71 skip_env "SHARED_DIRECTORY should be accessible"\
76 # We used to put the HSM archive in $SHARED_DIRECTORY but that
77 # meant NFS issues could hose sanity-hsm sessions. So now we
79 for n in $(seq $AGTCOUNT); do
80 eval export AGTDEV$n=\$\{AGTDEV$n:-"$TMP/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_EVENT_FIFO=${HSMTOOL_EVENT_FIFO:=""}
95 export HSMTOOL_TESTDIR
96 export HSMTOOL_BASE=$(basename "$HSMTOOL" | cut -f1 -d" ")
97 HSM_ARCHIVE=$(copytool_device $SINGLEAGT)
100 # The test only support up to 10 MDTs
101 MDT_PREFIX="mdt.$FSNAME-MDT000"
102 HSM_PARAM="${MDT_PREFIX}0.hsm"
104 # archive is purged at copytool setup
105 HSM_ARCHIVE_PURGE=true
107 # Don't allow copytool error upon start/setup
108 HSMTOOL_NOERROR=false
111 # Get the backend root path for the given agent facet.
114 local dev=AGTDEV$(facet_number $facet)
119 # Stop copytool and unregister an existing changelog user.
121 copytool_monitor_cleanup
124 cdt_set_sanity_policy
129 # get MDT device for each mdc
130 for mdtno in $(seq 1 $MDSCOUNT); do
131 local idx=$(($mdtno - 1))
132 MDT[$idx]=$($LCTL get_param -n \
133 mdc.$FSNAME-MDT000${idx}-mdc-*.mds_server_uuid |
134 awk '{gsub(/_UUID/,""); print $1}' | head -n1)
139 local agents=${1:-$(facet_active_host $SINGLEAGT)}
140 do_nodesv $agents "pgrep -x $HSMTOOL_BASE"
143 search_and_kill_copytool() {
144 local agents=${1:-$(facet_active_host $SINGLEAGT)}
146 echo "Killing existing copytools on $agents"
147 do_nodesv $agents "killall -q $HSMTOOL_BASE" || true
150 copytool_monitor_setup() {
151 local facet=${1:-$SINGLEAGT}
152 local agent=$(facet_active_host $facet)
154 local cmd="mktemp --tmpdir=/tmp -d ${TESTSUITE}.${TESTNAME}.XXXX"
155 local test_dir=$(do_node $agent "$cmd") ||
156 error "Failed to create tempdir on $agent"
157 export HSMTOOL_MONITOR_DIR=$test_dir
159 # Create the fifo and a monitor (cat dies when copytool dies)
160 do_node $agent "mkfifo -m 0644 $test_dir/fifo" ||
161 error "failed to create copytool fifo on $agent"
162 cmd="cat $test_dir/fifo > $test_dir/events &"
163 cmd+=" echo \\\$! > $test_dir/monitor_pid"
165 if [[ $PDSH == *Rmrsh* ]]; then
166 # This is required for pdsh -Rmrsh and its handling of remote
168 # Regular ssh and pdsh -Rssh work fine without this
169 # backgrounded subshell nonsense.
170 (do_node $agent "$cmd") &
171 export HSMTOOL_MONITOR_PDSH=$!
173 # Slightly racy, but just making a best-effort to catch obvious
176 ps -p $HSMTOOL_MONITOR_PDSH >&- ||
177 error "Failed to start copytool monitor on $agent"
179 do_node $agent "$cmd"
181 error "Failed to start copytool monitor on $agent"
186 copytool_monitor_cleanup() {
187 local facet=${1:-$SINGLEAGT}
188 local agent=$(facet_active_host $facet)
190 if [ -n "$HSMTOOL_MONITOR_DIR" ]; then
191 # Should die when the copytool dies, but just in case.
192 local cmd="kill \\\$(cat $HSMTOOL_MONITOR_DIR/monitor_pid)"
193 cmd+=" 2>/dev/null || true"
194 do_node $agent "$cmd"
195 do_node $agent "rm -fr $HSMTOOL_MONITOR_DIR"
196 export HSMTOOL_MONITOR_DIR=
199 # The pdsh should die on its own when the monitor dies. Just
200 # in case, though, try to clean up to avoid any cruft.
201 if [ -n "$HSMTOOL_MONITOR_PDSH" ]; then
202 kill $HSMTOOL_MONITOR_PDSH 2>/dev/null
203 export HSMTOOL_MONITOR_PDSH=
208 local facet=${1:-$SINGLEAGT}
209 local lustre_mntpnt=${2:-$MOUNT}
211 local hsm_root=${4:-$(copytool_device $facet)}
212 local agent=$(facet_active_host $facet)
214 if [[ -z "$arc_id" ]] &&
215 do_facet $facet "pkill -CONT -x $HSMTOOL_BASE"; then
216 echo "Only wakeup running copytool $facet on $agent"
220 if $HSM_ARCHIVE_PURGE; then
221 echo "Purging archive on $agent"
222 do_facet $facet "rm -rf $hsm_root/*"
225 echo "Starting copytool $facet on $agent"
226 do_facet $facet "mkdir -p $hsm_root" || error "mkdir '$hsm_root' failed"
227 # bandwidth is limited to 1MB/s so the copy time is known and
228 # independent of hardware
229 local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --hsm-root $hsm_root"
230 [[ -z "$arc_id" ]] || cmd+=" --archive $arc_id"
231 [[ -z "$HSMTOOL_UPDATE_INTERVAL" ]] ||
232 cmd+=" --update-interval $HSMTOOL_UPDATE_INTERVAL"
233 [[ -z "$HSMTOOL_EVENT_FIFO" ]] ||
234 cmd+=" --event-fifo $HSMTOOL_EVENT_FIFO"
235 cmd+=" --bandwidth 1 $lustre_mntpnt"
237 # Redirect the standard output and error to a log file which
238 # can be uploaded to Maloo.
239 local prefix=$TESTLOG_PREFIX
240 [[ -z "$TESTNAME" ]] || prefix=$prefix.$TESTNAME
241 local copytool_log=$prefix.copytool${arc_id}_log.$agent.log
243 do_facet $facet "$cmd < /dev/null > $copytool_log 2>&1"
244 if [[ $? != 0 ]]; then
245 [[ $HSMTOOL_NOERROR == true ]] ||
246 error "start copytool $facet on $agent failed"
247 echo "start copytool $facet on $agent failed"
253 get_copytool_event_log() {
254 local facet=${1:-$SINGLEAGT}
255 local agent=$(facet_active_host $facet)
257 [ -z "$HSMTOOL_MONITOR_DIR" ] &&
258 error "Can't get event log: No monitor directory!"
260 do_node $agent "cat $HSMTOOL_MONITOR_DIR/events" ||
261 error "Could not collect event log from $agent"
266 local facet=$SINGLEAGT
267 local agents=${1:-$(facet_active_host $facet)}
272 local hsm_root=$(copytool_device $facet)
273 local end_wait=$(( SECONDS + TIMEOUT ))
275 do_nodesv $agents "pkill -INT -x $HSMTOOL_BASE" || return 0
277 while (( SECONDS < end_wait )); do
279 do_nodesv $agents "pgrep -x $HSMTOOL_BASE"
280 if [ $? -ne 0 ]; then
281 echo "Copytool is stopped on $agents"
284 echo "Copytool still running on $agents"
286 if do_nodesv $agents "pgrep -x $HSMTOOL_BASE"; then
287 error "Copytool failed to stop in ${TIMEOUT}s ..."
289 echo "Copytool has stopped in " \
290 "$((TIMEOUT - (end_wait - SECONDS)))s."
293 # clean all CDTs orphans requests from previous tests
294 # that would otherwise need to timeout to clear.
295 for mdtno in $(seq 1 $MDSCOUNT); do
297 mdt_hsmctrl="mdt.$FSNAME-MDT000${idx}.hsm_control"
298 oldstate=$(do_facet mds${mdtno} "$LCTL get_param -n " \
300 # skip already stop[ed,ing] CDTs
301 echo $oldstate | grep stop && continue
303 do_facet mds${mdtno} "$LCTL set_param $mdt_hsmctrl=shutdown"
304 wait_result mds${mdtno} "$LCTL get_param -n $mdt_hsmctrl" \
306 error "mds${mdtno} cdt state is not stopped"
307 do_facet mds${mdtno} "$LCTL set_param $mdt_hsmctrl=$oldstate"
308 wait_result mds${mdtno} "$LCTL get_param -n $mdt_hsmctrl" \
310 error "mds${mdtno} cdt state is not $oldstate"
312 if do_facet $facet "df $hsm_root" >/dev/null 2>&1 ; then
313 do_facet $facet "rm -rf $hsm_root/*"
318 local agents=${1:-$(facet_active_host $SINGLEAGT)}
320 do_nodesv $agents "pkill -STOP -x $HSMTOOL_BASE" || return 0
321 echo "Copytool is suspended on $agents"
324 copytool_remove_backend() {
326 local be=$(do_facet $SINGLEAGT find $HSM_ARCHIVE -name $fid)
327 echo "Remove from backend: $fid = $be"
328 do_facet $SINGLEAGT rm -f $be
332 do_facet $SINGLEAGT \
333 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
334 --import $1 $2 $MOUNT" ||
335 error "import of $1 to $2 failed"
339 local file=$HSM_ARCHIVE/$1
340 do_facet $SINGLEAGT mkdir -p $(dirname $file)
341 do_facet $SINGLEAGT dd if=/dev/urandom of=$file count=32 bs=1000000 ||
342 file_creation_failure dd $file $?
346 local file=$HSM_ARCHIVE/$2
347 do_facet $SINGLEAGT mkdir -p $(dirname $file)
348 do_facet $SINGLEAGT cp -p $1 $file || error "cannot copy $1 to $file"
357 if [[ "$value" != "" ]]; then
360 for mdtno in $(seq 1 $MDSCOUNT); do
361 local idx=$(($mdtno - 1))
362 local facet=mds${mdtno}
363 # if $arg include -P option, run 1 set_param per MDT on the MGS
364 # else, run set_param on each MDT
365 [[ $arg = *"-P"* ]] && facet=mgs
366 do_facet $facet $LCTL set_param $arg mdt.${MDT[$idx]}.$key$value
367 [[ $? != 0 ]] && rc=1
377 for mdtno in $(seq 1 $MDSCOUNT); do
378 local idx=$(($mdtno - 1))
379 wait_result mds${mdtno} \
380 "$LCTL get_param -n $MDT_PREFIX${idx}.$key" "$target" \
382 error "$key state is not '$target' on mds${mdtno}"
389 for mdtno in $(seq 1 $MDSCOUNT); do
390 local idx=$(($mdtno - 1))
391 local cl_user=$(do_facet mds${mdtno} $LCTL \
392 --device ${MDT[$idx]} \
393 changelog_register -n)
395 do_facet mds${mdtno} lctl set_param \
396 mdd.${MDT[$idx]}.changelog_mask="+hsm"
397 $LFS changelog_clear ${MDT[$idx]} $cl_user 0
401 changelog_cleanup() {
403 for mdtno in $(seq 1 $MDSCOUNT); do
404 local idx=$(($mdtno - 1))
405 [[ -z ${CL_USERS[$idx]} ]] && continue
406 $LFS changelog_clear ${MDT[$idx]} ${CL_USERS[$idx]} 0
407 do_facet mds${mdtno} lctl --device ${MDT[$idx]} \
408 changelog_deregister ${CL_USERS[$idx]}
413 changelog_get_flags() {
418 $LFS changelog $mdt | awk "/$cltype/ && /t=\[$fid\]/ {print \$5}"
423 local val=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.$param)
431 mdts_set_param "$opt -n" "hsm.$param" "$value"
438 mdts_set_param "" hsm_control "$cmd"
439 mdts_check_param hsm_control "$target" 10
442 cdt_set_sanity_policy() {
443 if [[ "$CDT_POLICY_HAD_CHANGED" ]]
446 mdts_set_param "" hsm.policy "+NRA"
447 mdts_set_param "" hsm.policy "-NBR"
448 CDT_POLICY_HAD_CHANGED=
453 mdts_set_param "" hsm.policy "+NRA"
454 CDT_POLICY_HAD_CHANGED=true
457 cdt_clear_no_retry() {
458 mdts_set_param "" hsm.policy "-NRA"
459 CDT_POLICY_HAD_CHANGED=true
462 cdt_set_non_blocking_restore() {
463 mdts_set_param "" hsm.policy "+NBR"
464 CDT_POLICY_HAD_CHANGED=true
467 cdt_clear_non_blocking_restore() {
468 mdts_set_param "" hsm.policy "-NBR"
469 CDT_POLICY_HAD_CHANGED=true
472 cdt_clear_mount_state() {
473 mdts_set_param "-P -d" hsm_control ""
476 cdt_set_mount_state() {
477 mdts_set_param "-P" hsm_control "$1"
481 mdts_check_param hsm_control "$1" 20
485 set_test_state disabled disabled
489 set_test_state enabled enabled
493 set_test_state shutdown stopped
497 set_test_state purge enabled
503 cdt_set_sanity_policy
507 local client_count=$1
508 if [[ $CLIENTCOUNT -lt $client_count ]]; then
509 skip "Need $client_count or more clients, have $CLIENTCOUNT"
516 $LFS path2fid $1 | tr -d '[]'
517 return ${PIPESTATUS[0]}
525 if [[ $u == "user" ]]; then
526 st=$($RUNAS $LFS hsm_state $f)
529 st=$($LFS hsm_state $f)
532 [[ $? == 0 ]] || error "$LFS hsm_state $f failed (run as $u)"
534 st=$(echo $st | cut -f 2 -d" " | tr -d "()," )
538 get_hsm_archive_id() {
541 st=$($LFS hsm_state $f)
542 [[ $? == 0 ]] || error "$LFS hsm_state $f failed"
544 local ar=$(echo $st | grep "archive_id" | cut -f5 -d" " |
553 local st=$(get_hsm_flags $f)
554 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
557 check_hsm_flags_user() {
561 local st=$(get_hsm_flags $f user)
562 [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
565 file_creation_failure() {
570 df $MOUNT $MOUNT2 >&2
571 error "cannot create $f with $cmd, status=$err"
583 if [[ "$3" != 1 ]]; then
587 cp $1 $f || file_creation_failure cp $f $?
589 path2fid $f || error "cannot get fid on $f"
593 local file2=${1/$DIR/$DIR2}
594 dd if=/dev/urandom of=$file2 count=2 bs=1M conv=fsync ||
595 file_creation_failure dd $file2 $?
597 path2fid $1 || error "cannot get fid on $1"
601 dd if=/dev/urandom of=$1 count=1 bs=1M conv=sync ||
602 file_creation_failure dd $1 $?
603 path2fid $1 || error "cannot get fid on $1"
606 cleanup_large_files() {
607 local ratio=$(df -P $MOUNT | tail -1 | awk '{print $5}' |
609 [ $ratio -gt 50 ] && find $MOUNT -size +10M -exec rm -f {} \;
612 check_enough_free_space() {
615 local need=$((nb * unit /1024))
616 local free=$(df -kP $MOUNT | tail -1 | awk '{print $4}')
617 (( $need >= $free )) && return 1
621 make_large_for_striping() {
622 local file2=${1/$DIR/$DIR2}
623 local sz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -n1)
627 check_enough_free_space 5 $sz
628 [ $? != 0 ] && return $?
630 dd if=/dev/urandom of=$file2 count=5 bs=$sz conv=fsync ||
631 file_creation_failure dd $file2 $?
633 path2fid $1 || error "cannot get fid on $1"
636 make_large_for_progress() {
637 local file2=${1/$DIR/$DIR2}
641 check_enough_free_space 39 1000000
642 [ $? != 0 ] && return $?
644 # big file is large enough, so copy time is > 30s
645 # so copytool make 1 progress
646 # size is not a multiple of 1M to avoid stripe
648 dd if=/dev/urandom of=$file2 count=39 bs=1000000 conv=fsync ||
649 file_creation_failure dd $file2 $?
651 path2fid $1 || error "cannot get fid on $1"
654 make_large_for_progress_aligned() {
655 local file2=${1/$DIR/$DIR2}
659 check_enough_free_space 33 1048576
660 [ $? != 0 ] && return $?
662 # big file is large enough, so copy time is > 30s
663 # so copytool make 1 progress
664 # size is a multiple of 1M to have stripe
666 dd if=/dev/urandom of=$file2 count=33 bs=1M conv=fsync ||
667 file_creation_failure dd $file2 $?
668 path2fid $1 || error "cannot get fid on $1"
671 make_large_for_cancel() {
672 local file2=${1/$DIR/$DIR2}
676 check_enough_free_space 103 1048576
677 [ $? != 0 ] && return $?
679 # Copy timeout is 100s. 105MB => 105s
680 dd if=/dev/urandom of=$file2 count=103 bs=1M conv=fsync ||
681 file_creation_failure dd $file2 $?
682 path2fid $1 || error "cannot get fid on $1"
688 wait_update --verbose $(facet_active_host $facet) "$@"
691 wait_request_state() {
695 # 4th arg (mdt index) is optional
697 local mds=mds$(($mdtidx + 1))
699 local cmd="$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.actions"
700 cmd+=" | awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
702 wait_result $mds "$cmd" $state 200 ||
703 error "request on $fid is not $state on $mds"
706 get_request_state() {
710 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.actions |"\
711 "awk '/'$fid'.*action='$request'/ {print \\\$13}' | cut -f2 -d="
714 get_request_count() {
718 do_facet $SINGLEMDS "$LCTL get_param -n $HSM_PARAM.actions |"\
719 "awk -vn=0 '/'$fid'.*action='$request'/ {n++}; END {print n}'"
726 local cmd="$LCTL get_param -n $HSM_PARAM.actions"
727 [[ -n $fid ]] && cmd+=" | grep '$fid'"
728 cmd+=" | egrep 'WAITING|STARTED'"
730 wait_result $SINGLEMDS "$cmd" "" $timeout ||
731 error "requests did not complete"
734 wait_for_grace_delay() {
735 local val=$(get_hsm_param grace_delay)
742 # python2.6 in EL6 includes an internal json module
743 local json_parser='import json; import fileinput;'
744 json_parser+=' print "\n".join(["local %s=\"%s\"" % tuple for tuple in '
745 json_parser+='json.loads([line for line in '
746 json_parser+='fileinput.input()][0]).items()])'
748 echo $raw_event | python -c "$json_parser"
751 # populate MDT device array
757 # cleanup from previous bad setup
758 search_and_kill_copytool
760 # for recovery tests, coordinator needs to be started at mount
762 # the lustre conf must be without hsm on (like for sanity.sh)
763 echo "Set HSM on and start"
764 cdt_set_mount_state enabled
765 cdt_check_state enabled
767 echo "Start copytool"
770 echo "Set sanity-hsm HSM policy"
771 cdt_set_sanity_policy
773 # finished requests are quickly removed from list
774 set_hsm_param grace_delay 10
780 local f=$DIR/$tdir/$tfile
784 check_hsm_flags_user $f "0x00000000"
786 $RUNAS $LFS hsm_set --norelease $f ||
787 error "user could not change hsm flags"
788 check_hsm_flags_user $f "0x00000010"
790 $RUNAS $LFS hsm_clear --norelease $f ||
791 error "user could not clear hsm flags"
792 check_hsm_flags_user $f "0x00000000"
794 # User could not change those flags...
795 $RUNAS $LFS hsm_set --exists $f &&
796 error "user should not set this flag"
797 check_hsm_flags_user $f "0x00000000"
800 $LFS hsm_set --exists $f ||
801 error "root could not change hsm flags"
802 check_hsm_flags_user $f "0x00000001"
804 $LFS hsm_clear --exists $f ||
805 error "root could not clear hsm state"
806 check_hsm_flags_user $f "0x00000000"
809 run_test 1 "lfs hsm flags root/non-root access"
813 local f=$DIR/$tdir/$tfile
815 # New files are not dirty
816 check_hsm_flags $f "0x00000000"
818 # For test, we simulate an archived file.
819 $LFS hsm_set --exists $f || error "user could not change hsm flags"
820 check_hsm_flags $f "0x00000001"
822 # chmod do not put the file dirty
823 chmod 600 $f || error "could not chmod test file"
824 check_hsm_flags $f "0x00000001"
826 # chown do not put the file dirty
827 chown $RUNAS_ID $f || error "could not chown test file"
828 check_hsm_flags $f "0x00000001"
830 # truncate put the file dirty
831 $TRUNCATE $f 1 || error "could not truncate test file"
832 check_hsm_flags $f "0x00000003"
834 $LFS hsm_clear --dirty $f || error "could not clear hsm flags"
835 check_hsm_flags $f "0x00000001"
837 run_test 2 "Check file dirtyness when doing setattr"
843 # New files are not dirty
845 check_hsm_flags $f "0x00000000"
847 # For test, we simulate an archived file.
848 $LFS hsm_set --exists $f ||
849 error "user could not change hsm flags"
850 check_hsm_flags $f "0x00000001"
852 # Reading a file, does not set dirty
853 cat $f > /dev/null || error "could not read file"
854 check_hsm_flags $f "0x00000001"
856 # Open for write without modifying data, does not set dirty
857 openfile -f O_WRONLY $f || error "could not open test file"
858 check_hsm_flags $f "0x00000001"
860 # Append to a file sets it dirty
861 cp -p /etc/passwd $f.append || error "could not create file"
862 $LFS hsm_set --exists $f.append ||
863 error "user could not change hsm flags"
864 dd if=/etc/passwd of=$f.append bs=1 count=3\
865 conv=notrunc oflag=append status=noxfer ||
866 file_creation_failure dd $f.append $?
867 check_hsm_flags $f.append "0x00000003"
869 # Modify a file sets it dirty
870 cp -p /etc/passwd $f.modify || error "could not create file"
871 $LFS hsm_set --exists $f.modify ||
872 error "user could not change hsm flags"
873 dd if=/dev/zero of=$f.modify bs=1 count=3\
874 conv=notrunc status=noxfer ||
875 file_creation_failure dd $f.modify $?
876 check_hsm_flags $f.modify "0x00000003"
878 # Open O_TRUNC sets dirty
879 cp -p /etc/passwd $f.trunc || error "could not create file"
880 $LFS hsm_set --exists $f.trunc ||
881 error "user could not change hsm flags"
882 cp /etc/group $f.trunc || error "could not override a file"
883 check_hsm_flags $f.trunc "0x00000003"
885 # Mmapped a file sets dirty
886 cp -p /etc/passwd $f.mmap || error "could not create file"
887 $LFS hsm_set --exists $f.mmap ||
888 error "user could not change hsm flags"
889 multiop $f.mmap OSMWUc || error "could not mmap a file"
890 check_hsm_flags $f.mmap "0x00000003"
892 run_test 3 "Check file dirtyness when opening for write"
896 local f=$DIR/$tdir/$tfile
897 local fid=$(make_small $f)
900 local st=$(get_request_state $fid CANCEL)
901 [[ -z "$st" ]] || error "hsm_cancel must not be registered (state=$st)"
903 run_test 4 "Useless cancel must not be registered"
906 # test needs a running copytool
910 local f=$DIR/$tdir/$tfile
911 local fid=$(copy_file /etc/passwd $f)
913 wait_request_state $fid ARCHIVE SUCCEED
915 check_hsm_flags $f "0x00000009"
919 run_test 8 "Test default archive number"
923 local f=$DIR/$tdir/$tfile
924 local fid=$(copy_file /etc/passwd $f)
925 # we do not use the default one to be sure
926 local new_an=$((HSM_ARCHIVE_NUMBER + 1))
928 copytool_setup $SINGLEAGT $MOUNT $new_an
929 $LFS hsm_archive --archive $new_an $f
930 wait_request_state $fid ARCHIVE SUCCEED
932 check_hsm_flags $f "0x00000009"
936 run_test 9 "Use of explicit archive number, with dedicated copytool"
939 needclients 3 || return 0
945 copytool_cleanup $(comma_list $(agts_nodes))
947 # start all of the copytools
948 for n in $(seq $AGTCOUNT); do
952 trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
955 for n in $(seq $AGTCOUNT); do
956 file=$DIR/$tdir/$tfile.$n
957 fid=$(make_small $file)
959 $LFS hsm_archive $file || error "could not archive file $file"
960 wait_request_state $fid ARCHIVE SUCCEED
961 check_hsm_flags $file "0x00000009"
965 copytool_cleanup $(comma_list $(agts_nodes))
967 run_test 9a "Multiple remote agents"
970 # test needs a running copytool
973 mkdir -p $DIR/$tdir/d1
974 local f=$DIR/$tdir/$tfile
975 local fid=$(copy_file /etc/hosts $f)
976 $LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f ||
977 error "hsm_archive failed"
978 wait_request_state $fid ARCHIVE SUCCEED
980 local AFILE=$(do_facet $SINGLEAGT ls $HSM_ARCHIVE'/*/*/*/*/*/*/'$fid) ||
981 error "fid $fid not in archive $HSM_ARCHIVE"
982 echo "Verifying content"
983 do_facet $SINGLEAGT diff $f $AFILE || error "archived file differs"
984 echo "Verifying hsm state "
985 check_hsm_flags $f "0x00000009"
987 echo "Verifying archive number is $HSM_ARCHIVE_NUMBER"
988 local st=$(get_hsm_archive_id $f)
989 [[ $st == $HSM_ARCHIVE_NUMBER ]] ||
990 error "Wrong archive number, $st != $HSM_ARCHIVE_NUMBER"
995 run_test 10a "Archive a file"
998 # test needs a running copytool
1002 local f=$DIR/$tdir/$tfile
1003 local fid=$(copy_file /etc/hosts $f)
1004 $LFS hsm_archive $f || error "archive request failed"
1005 wait_request_state $fid ARCHIVE SUCCEED
1007 $LFS hsm_archive $f || error "archive of non dirty file failed"
1008 local cnt=$(get_request_count $fid ARCHIVE)
1009 [[ "$cnt" == "1" ]] ||
1010 error "archive of non dirty file must not make a request"
1014 run_test 10b "Archive of non dirty file must work without doing request"
1017 # test needs a running copytool
1021 local f=$DIR/$tdir/$tfile
1022 local fid=$(copy_file /etc/hosts $f)
1023 $LFS hsm_set --noarchive $f
1024 $LFS hsm_archive $f && error "archive a noarchive file must fail"
1028 run_test 10c "Check forbidden archive"
1031 # test needs a running copytool
1035 local f=$DIR/$tdir/$tfile
1036 local fid=$(copy_file /etc/hosts $f)
1037 $LFS hsm_archive $f || error "cannot archive $f"
1038 wait_request_state $fid ARCHIVE SUCCEED
1040 local ar=$(get_hsm_archive_id $f)
1041 local dflt=$(get_hsm_param default_archive_id)
1042 [[ $ar == $dflt ]] ||
1043 error "archived file is not on default archive: $ar != $dflt"
1047 run_test 10d "Archive a file on the default archive id"
1051 copy2archive /etc/hosts $tdir/$tfile
1052 local f=$DIR/$tdir/$tfile
1054 import_file $tdir/$tfile $f
1055 echo -n "Verifying released state: "
1056 check_hsm_flags $f "0x0000000d"
1058 local LSZ=$(stat -c "%s" $f)
1059 local ASZ=$(do_facet $SINGLEAGT stat -c "%s" $HSM_ARCHIVE/$tdir/$tfile)
1061 echo "Verifying imported size $LSZ=$ASZ"
1062 [[ $LSZ -eq $ASZ ]] || error "Incorrect size $LSZ != $ASZ"
1063 echo -n "Verifying released pattern: "
1064 local PTRN=$($GETSTRIPE -L $f)
1066 [[ $PTRN == 80000001 ]] || error "Is not released"
1067 local fid=$(path2fid $f)
1068 echo "Verifying new fid $fid in archive"
1070 local AFILE=$(do_facet $SINGLEAGT ls $HSM_ARCHIVE'/*/*/*/*/*/*/'$fid) ||
1071 error "fid $fid not in archive $HSM_ARCHIVE"
1073 run_test 11a "Import a file"
1076 # test needs a running copytool
1080 local f=$DIR/$tdir/$tfile
1081 local fid=$(copy_file /etc/hosts $f)
1082 $LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f ||
1083 error "hsm_archive failed"
1084 wait_request_state $fid ARCHIVE SUCCEED
1086 local FILE_HASH=$(md5sum $f)
1091 echo "$FILE_HASH" | md5sum -c
1093 [[ $? -eq 0 ]] || error "Restored file differs"
1097 run_test 11b "Import a deleted file using its FID"
1100 # test needs a running copytool
1104 copy2archive /etc/hosts $tdir/$tfile
1106 local f=$DIR/$tdir/$tfile
1107 import_file $tdir/$tfile $f
1108 local f2=$DIR2/$tdir/$tfile
1109 echo "Verifying released state: "
1110 check_hsm_flags $f2 "0x0000000d"
1112 local fid=$(path2fid $f2)
1113 $LFS hsm_restore $f2
1114 wait_request_state $fid RESTORE SUCCEED
1116 echo "Verifying file state: "
1117 check_hsm_flags $f2 "0x00000009"
1119 do_facet $SINGLEAGT diff -q $HSM_ARCHIVE/$tdir/$tfile $f
1121 [[ $? -eq 0 ]] || error "Restored file differs"
1125 run_test 12a "Restore an imported file explicitly"
1128 # test needs a running copytool
1132 copy2archive /etc/hosts $tdir/$tfile
1134 local f=$DIR/$tdir/$tfile
1135 import_file $tdir/$tfile $f
1136 echo "Verifying released state: "
1137 check_hsm_flags $f "0x0000000d"
1139 cat $f > /dev/null || error "File read failed"
1141 echo "Verifying file state after restore: "
1142 check_hsm_flags $f "0x00000009"
1144 do_facet $SINGLEAGT diff -q $HSM_ARCHIVE/$tdir/$tfile $f
1146 [[ $? -eq 0 ]] || error "Restored file differs"
1150 run_test 12b "Restore an imported file implicitly"
1153 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1155 # test needs a running copytool
1159 local f=$DIR/$tdir/$tfile
1160 $LFS setstripe -c 2 $f
1162 fid=$(make_large_for_striping $f)
1163 [ $? != 0 ] && skip "not enough free space" && return
1165 local FILE_CRC=$(md5sum $f)
1167 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1168 wait_request_state $fid ARCHIVE SUCCEED
1169 $LFS hsm_release $f || error "release $f failed"
1171 echo "$FILE_CRC" | md5sum -c
1173 [[ $? -eq 0 ]] || error "Restored file differs"
1177 run_test 12c "Restore a file with stripe of 2"
1180 # test needs a running copytool
1185 local f=$DIR/$tdir/$tfile
1186 local fid=$(copy_file /etc/hosts $f)
1187 $LFS hsm_restore $f || error "restore of non archived file failed"
1188 local cnt=$(get_request_count $fid RESTORE)
1189 [[ "$cnt" == "0" ]] ||
1190 error "restore non archived must not make a request"
1191 $LFS hsm_archive $f ||
1192 error "archive request failed"
1193 wait_request_state $fid ARCHIVE SUCCEED
1194 $LFS hsm_restore $f ||
1195 error "restore of non released file failed"
1196 local cnt=$(get_request_count $fid RESTORE)
1197 [[ "$cnt" == "0" ]] ||
1198 error "restore a non dirty file must not make a request"
1202 run_test 12d "Restore of a non archived, non released file must work"\
1203 " without doing request"
1206 # test needs a running copytool
1209 mkdir -p $DIR/$tdir $HSM_ARCHIVE/$tdir
1210 local f=$DIR/$tdir/$tfile
1211 local fid=$(copy_file /etc/hosts $f)
1212 $LFS hsm_archive $f || error "archive request failed"
1213 wait_request_state $fid ARCHIVE SUCCEED
1216 cat /etc/hosts >> $f
1220 $LFS hsm_restore $f && error "restore a dirty file must fail"
1224 run_test 12e "Check forbidden restore"
1227 # test needs a running copytool
1231 local f=$DIR/$tdir/$tfile
1232 local fid=$(copy_file /etc/hosts $f)
1234 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1235 wait_request_state $fid ARCHIVE SUCCEED
1236 $LFS hsm_release $f || error "release of $f failed"
1238 wait_request_state $fid RESTORE SUCCEED
1240 echo -n "Verifying file state: "
1241 check_hsm_flags $f "0x00000009"
1243 diff -q /etc/hosts $f
1245 [[ $? -eq 0 ]] || error "Restored file differs"
1249 run_test 12f "Restore a released file explicitly"
1252 # test needs a running copytool
1256 local f=$DIR/$tdir/$tfile
1257 local fid=$(copy_file /etc/hosts $f)
1259 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1260 wait_request_state $fid ARCHIVE SUCCEED
1261 $LFS hsm_release $f || error "release of $f failed"
1263 diff -q /etc/hosts $f
1266 # we check we had a restore done
1267 wait_request_state $fid RESTORE SUCCEED
1269 [[ $st -eq 0 ]] || error "Restored file differs"
1273 run_test 12g "Restore a released file implicitly"
1276 needclients 2 || return 0
1278 # test needs a running copytool
1282 local f=$DIR/$tdir/$tfile
1283 local fid=$(copy_file /etc/hosts $f)
1285 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1286 wait_request_state $fid ARCHIVE SUCCEED
1287 $LFS hsm_release $f || error "release of $f failed"
1289 do_node $CLIENT2 diff -q /etc/hosts $f
1292 # we check we had a restore done
1293 wait_request_state $fid RESTORE SUCCEED
1295 [[ $st -eq 0 ]] || error "Restored file differs"
1299 run_test 12h "Restore a released file implicitly from a second node"
1302 # test needs a running copytool
1306 local f=$DIR/$tdir/$tfile
1307 local fid=$(copy_file /etc/passwd $f)
1308 $LFS hsm_archive $f || error "archive of $f failed"
1309 wait_request_state $fid ARCHIVE SUCCEED
1311 $LFS hsm_release $f || error "release of $f failed"
1315 [[ $? -eq 0 ]] || error "Restored file differs"
1319 run_test 12m "Archive/release/implicit restore"
1322 # test needs a running copytool
1326 copy2archive /etc/hosts $tdir/$tfile
1328 local f=$DIR/$tdir/$tfile
1329 import_file $tdir/$tfile $f
1331 do_facet $SINGLEAGT cmp /etc/hosts $f ||
1332 error "Restored file differs"
1334 $LFS hsm_release $f || error "release of $f failed"
1338 run_test 12n "Import/implicit restore/release"
1341 # test needs a running copytool
1345 local f=$DIR/$tdir/$tfile
1346 local fid=$(copy_file /etc/hosts $f)
1348 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1349 wait_request_state $fid ARCHIVE SUCCEED
1350 $LFS hsm_release $f || error "release of $f failed"
1352 #define OBD_FAIL_MDS_HSM_SWAP_LAYOUTS 0x152
1353 do_facet $SINGLEMDS lctl set_param fail_loc=0x152
1355 # set no retry action mode
1358 diff -q /etc/hosts $f
1361 # we check we had a restore failure
1362 wait_request_state $fid RESTORE FAILED
1364 [[ $st -eq 0 ]] && error "Restore must fail"
1366 # remove no retry action mode
1369 # check file is still released
1370 check_hsm_flags $f "0x0000000d"
1372 # retry w/o failure injection
1373 do_facet $SINGLEMDS lctl set_param fail_loc=0
1375 # to be sure previous RESTORE result is gone
1377 wait_for_grace_delay
1379 diff -q /etc/hosts $f
1382 # we check we had a restore done
1383 wait_request_state $fid RESTORE SUCCEED
1385 [[ $st -eq 0 ]] || error "Restored file differs"
1389 run_test 12o "Layout-swap failure during Restore leaves file released"
1392 # test needs a running copytool
1396 local f=$DIR/$tdir/$tfile
1397 local fid=$(copy_file /etc/hosts $f)
1399 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
1400 wait_request_state $fid ARCHIVE SUCCEED
1401 do_facet $SINGLEAGT cat $f > /dev/null || error "cannot cat $f"
1402 $LFS hsm_release $f || error "cannot release $f"
1403 do_facet $SINGLEAGT cat $f > /dev/null || error "cannot cat $f"
1404 $LFS hsm_release $f || error "cannot release $f"
1405 do_facet $SINGLEAGT cat $f > /dev/null || error "cannot cat $f"
1409 run_test 12p "implicit restore of a file on copytool mount point"
1412 # test needs a running copytool
1415 local ARC_SUBDIR="import.orig"
1419 # populate directory to be imported
1420 for d in $(seq 1 10); do
1421 local CURR_DIR="$HSM_ARCHIVE/$ARC_SUBDIR/dir.$d"
1422 do_facet $SINGLEAGT mkdir -p "$CURR_DIR"
1423 for f in $(seq 1 10); do
1424 CURR_FILE="$CURR_DIR/$tfile.$f"
1425 # write file-specific data
1426 do_facet $SINGLEAGT \
1427 "echo d=$d, f=$f, dir=$CURR_DIR, "\
1428 "file=$CURR_FILE > $CURR_FILE"
1432 import_file "$ARC_SUBDIR" $DIR/$tdir
1433 # diff lustre content and origin (triggers file restoration)
1434 # there must be 10x10 identical files, and no difference
1435 local cnt_ok=$(do_facet $SINGLEAGT diff -rs $HSM_ARCHIVE/$ARC_SUBDIR \
1436 $DIR/$tdir/$ARC_SUBDIR | grep identical | wc -l)
1437 local cnt_diff=$(do_facet $SINGLEAGT diff -r $HSM_ARCHIVE/$ARC_SUBDIR \
1438 $DIR/$tdir/$ARC_SUBDIR | wc -l)
1440 [ $cnt_diff -eq 0 ] ||
1441 error "$cnt_diff imported files differ from read data"
1442 [ $cnt_ok -eq 100 ] ||
1443 error "not enough identical files ($cnt_ok != 100)"
1447 run_test 13 "Recursively import and restore a directory"
1450 # test needs a running copytool
1455 local f=$DIR/$tdir/$tfile
1456 local fid=$(make_small $f)
1457 local sum=$(md5sum $f | awk '{print $1}')
1458 $LFS hsm_archive $f || error "could not archive file"
1459 wait_request_state $fid ARCHIVE SUCCEED
1463 # create released file (simulate llapi_hsm_import call)
1465 local fid2=$(path2fid $f)
1466 $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
1467 $LFS hsm_release $f || error "could not release file"
1469 # rebind the archive to the newly created file
1470 echo "rebind $fid to $fid2"
1472 do_facet $SINGLEAGT \
1473 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1474 --rebind $fid $fid2 $DIR" || error "could not rebind file"
1476 # restore file and compare md5sum
1477 local sum2=$(md5sum $f | awk '{print $1}')
1479 [[ $sum == $sum2 ]] || error "md5sum mismatch after restore"
1483 run_test 14 "Rebind archived file to a new fid"
1486 # test needs a running copytool
1491 local f=$DIR/$tdir/$tfile
1493 local tmpfile=$SHARED_DIRECTORY/tmp.$$
1497 for i in $(seq 1 $count); do
1498 fids[$i]=$(make_small $f.$i)
1499 sums[$i]=$(md5sum $f.$i | awk '{print $1}')
1500 $LFS hsm_archive $f.$i || error "could not archive file"
1502 wait_all_done $(($count*60))
1506 for i in $(seq 1 $count); do
1509 local fid2=$(path2fid $f.$i)
1510 # add the rebind operation to the list
1511 echo ${fids[$i]} $fid2 >> $tmpfile
1513 # set it released (simulate llapi_hsm_import call)
1514 $LFS hsm_set --archived --exists $f.$i ||
1515 error "could not force hsm flags"
1516 $LFS hsm_release $f.$i || error "could not release file"
1518 nl=$(wc -l < $tmpfile)
1519 [[ $nl == $count ]] || error "$nl files in list, $count expected"
1521 echo "rebind list of files"
1522 do_facet $SINGLEAGT \
1523 "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
1524 --rebind $tmpfile $DIR" || error "could not rebind file list"
1526 # restore files and compare md5sum
1527 for i in $(seq 1 $count); do
1528 local sum2=$(md5sum $f.$i | awk '{print $1}')
1529 [[ $sum2 == ${sums[$i]} ]] ||
1530 error "md5sum mismatch after restore ($sum2 != ${sums[$i]})"
1536 run_test 15 "Rebind a list of files"
1539 # test needs a running copytool
1543 # create a known size file so we can verify transfer speed
1546 dd if=/dev/zero of=$ref bs=1M count=20
1549 local f=$DIR/$tdir/$tfile
1550 local fid=$(copy_file $ref $f)
1552 local start=$(date +%s)
1554 wait_request_state $fid ARCHIVE SUCCEED
1555 local end=$(date +%s)
1556 local duration=$((end - start))
1558 [[ $duration -ge $goal ]] ||
1559 error "Transfer is too fast $duration < $goal"
1563 run_test 16 "Test CT bandwith control option"
1568 local f=$DIR/$tdir/$tfile
1569 touch $f || error "touch $f failed"
1571 # Could not release a non-archived file
1572 $LFS hsm_release $f && error "release should not succeed"
1574 # For following tests, we must test them with HS_ARCHIVED set
1575 $LFS hsm_set --exists --archived $f || error "could not add flag"
1577 # Could not release a file if no-release is set
1578 $LFS hsm_set --norelease $f || error "could not add flag"
1579 $LFS hsm_release $f && error "release should not succeed"
1580 $LFS hsm_clear --norelease $f || error "could not remove flag"
1582 # Could not release a file if lost
1583 $LFS hsm_set --lost $f || error "could not add flag"
1584 $LFS hsm_release $f && error "release should not succeed"
1585 $LFS hsm_clear --lost $f || error "could not remove flag"
1587 # Could not release a file if dirty
1588 $LFS hsm_set --dirty $f || error "could not add flag"
1589 $LFS hsm_release $f && error "release should not succeed"
1590 $LFS hsm_clear --dirty $f || error "could not remove flag"
1592 run_test 20 "Release is not permitted"
1595 # test needs a running copytool
1599 local f=$DIR/$tdir/test_release
1601 # Create a file and check its states
1602 local fid=$(make_small $f)
1603 check_hsm_flags $f "0x00000000"
1605 # LU-4388/LU-4389 - ZFS does not report full number of blocks
1606 # used until file is flushed to disk
1607 if [ $(facet_fstype ost1) == "zfs" ]; then
1608 # this causes an OST_SYNC rpc to be sent
1609 dd if=/dev/zero of=$f bs=512 count=1 oflag=sync conv=notrunc,fsync
1610 # clear locks to reread file data
1611 cancel_lru_locks osc
1614 local orig_size=$(stat -c "%s" $f)
1615 local orig_blocks=$(stat -c "%b" $f)
1617 start_full_debug_logging
1619 $LFS hsm_archive $f || error "could not archive file"
1620 wait_request_state $fid ARCHIVE SUCCEED
1622 local blocks=$(stat -c "%b" $f)
1623 [ $blocks -eq $orig_blocks ] ||
1624 error "$f: wrong block number after archive: " \
1625 "$blocks != $orig_blocks"
1626 local size=$(stat -c "%s" $f)
1627 [ $size -eq $orig_size ] ||
1628 error "$f: wrong size after archive: $size != $orig_size"
1630 # Release and check states
1631 $LFS hsm_release $f || error "could not release file"
1632 check_hsm_flags $f "0x0000000d"
1634 blocks=$(stat -c "%b" $f)
1635 [ $blocks -gt 5 ] &&
1636 error "$f: too many blocks after release: $blocks > 5"
1637 size=$(stat -c "%s" $f)
1638 [ $size -ne $orig_size ] &&
1639 error "$f: wrong size after release: $size != $orig_size"
1641 # Check we can release an file without stripe info
1645 check_hsm_flags $f "0x00000000"
1646 $LFS hsm_archive $f || error "could not archive file"
1647 wait_request_state $fid ARCHIVE SUCCEED
1649 # Release and check states
1650 $LFS hsm_release $f || error "could not release file"
1651 check_hsm_flags $f "0x0000000d"
1653 # Release again a file that is already released is OK
1654 $LFS hsm_release $f || fail "second release should succeed"
1655 check_hsm_flags $f "0x0000000d"
1657 stop_full_debug_logging
1661 run_test 21 "Simple release tests"
1664 # test needs a running copytool
1669 local f=$DIR/$tdir/test_release
1670 local swap=$DIR/$tdir/test_swap
1672 # Create a file and check its states
1673 local fid=$(make_small $f)
1674 check_hsm_flags $f "0x00000000"
1676 $LFS hsm_archive $f || error "could not archive file"
1677 wait_request_state $fid ARCHIVE SUCCEED
1679 # Release and check states
1680 $LFS hsm_release $f || error "could not release file"
1681 check_hsm_flags $f "0x0000000d"
1684 $LFS swap_layouts $swap $f && error "swap_layouts should failed"
1689 run_test 22 "Could not swap a release file"
1692 # test needs a running copytool
1697 local f=$DIR/$tdir/test_mtime
1699 # Create a file and check its states
1700 local fid=$(make_small $f)
1701 check_hsm_flags $f "0x00000000"
1703 $LFS hsm_archive $f || error "could not archive file"
1704 wait_request_state $fid ARCHIVE SUCCEED
1706 # Set modification time in the past
1707 touch -m -a -d @978261179 $f
1709 # Release and check states
1710 $LFS hsm_release $f || error "could not release file"
1711 check_hsm_flags $f "0x0000000d"
1713 local MTIME=$(stat -c "%Y" $f)
1714 local ATIME=$(stat -c "%X" $f)
1715 [ $MTIME -eq "978261179" ] || fail "bad mtime: $MTIME"
1716 [ $ATIME -eq "978261179" ] || fail "bad atime: $ATIME"
1720 run_test 23 "Release does not change a/mtime (utime)"
1723 local file=$DIR/$tdir/$tfile
1732 # test needs a running copytool
1737 fid=$(make_small $file)
1739 # Create a file and check its states
1740 check_hsm_flags $file "0x00000000"
1742 # Ensure atime is less than mtime and ctime.
1746 atime0=$(stat -c "%X" $file)
1747 mtime0=$(stat -c "%Y" $file)
1748 ctime0=$(stat -c "%Z" $file)
1750 [ $atime0 -lt $mtime0 ] ||
1751 error "atime $atime0 is not less than mtime $mtime0"
1753 [ $atime0 -lt $ctime0 ] ||
1754 error "atime $atime0 is not less than ctime $ctime0"
1756 # Archive should not change any timestamps.
1757 $LFS hsm_archive $file || error "cannot archive '$file'"
1758 wait_request_state $fid ARCHIVE SUCCEED
1760 atime1=$(stat -c "%X" $file)
1761 mtime1=$(stat -c "%Y" $file)
1762 ctime1=$(stat -c "%Z" $file)
1764 [ $atime0 -eq $atime1 ] ||
1765 error "archive changed atime from $atime0 to $atime1"
1767 [ $mtime0 -eq $mtime1 ] ||
1768 error "archive changed mtime from $mtime0 to $mtime1"
1770 [ $ctime0 -eq $ctime1 ] ||
1771 error "archive changed ctime from $ctime0 to $ctime1"
1773 # Release should not change any timestamps.
1774 $LFS hsm_release $file || error "cannot release '$file'"
1775 check_hsm_flags $file "0x0000000d"
1777 atime1=$(stat -c "%X" $file)
1778 mtime1=$(stat -c "%Y" $file)
1779 ctime1=$(stat -c "%Z" $file)
1781 [ $atime0 -eq $atime1 ] ||
1782 error "release changed atime from $atime0 to $atime1"
1784 [ $mtime0 -eq $mtime1 ] ||
1785 error "release changed mtime from $mtime0 to $mtime1"
1787 [ $ctime0 -eq $ctime1 ] ||
1788 error "release changed ctime from $ctime0 to $ctime1"
1790 # Restore should not change atime or mtime and should not
1792 $LFS hsm_restore $file
1793 wait_request_state $fid RESTORE SUCCEED
1795 atime1=$(stat -c "%X" $file)
1796 mtime1=$(stat -c "%Y" $file)
1797 ctime1=$(stat -c "%Z" $file)
1799 [ $atime0 -eq $atime1 ] ||
1800 error "restore changed atime from $atime0 to $atime1"
1802 [ $mtime0 -eq $mtime1 ] ||
1803 error "restore changed mtime from $mtime0 to $mtime1"
1805 [ $ctime0 -le $ctime1 ] ||
1806 error "restore changed ctime from $ctime0 to $ctime1"
1810 # Once more, after unmount and mount.
1811 umount_client $MOUNT || error "cannot unmount '$MOUNT'"
1812 mount_client $MOUNT || error "cannot mount '$MOUNT'"
1814 atime1=$(stat -c "%X" $file)
1815 mtime1=$(stat -c "%Y" $file)
1816 ctime1=$(stat -c "%Z" $file)
1818 [ $atime0 -eq $atime1 ] ||
1819 error "remount changed atime from $atime0 to $atime1"
1821 [ $mtime0 -eq $mtime1 ] ||
1822 error "remount changed mtime from $mtime0 to $mtime1"
1824 [ $ctime0 -le $ctime1 ] ||
1825 error "remount changed ctime from $ctime0 to $ctime1"
1827 run_test 24a "Archive, release, and restore does not change a/mtime (i/o)"
1830 local file=$DIR/$tdir/$tfile
1836 # Test needs a running copytool.
1840 # Check that root can do HSM actions on a regular user's file.
1842 fid=$(make_small $file)
1843 sum0=$(md5sum $file)
1845 chown $RUNAS_ID:$RUNAS_GID $file ||
1846 error "cannot chown '$file' to '$RUNAS_ID'"
1848 chmod ugo-w $DIR/$tdir ||
1849 error "cannot chmod '$DIR/$tdir'"
1851 $LFS hsm_archive $file
1852 wait_request_state $fid ARCHIVE SUCCEED
1854 $LFS hsm_release $file
1855 check_hsm_flags $file "0x0000000d"
1857 $LFS hsm_restore $file
1858 wait_request_state $fid RESTORE SUCCEED
1860 # Check that ordinary user can get HSM state.
1861 $RUNAS $LFS hsm_state $file ||
1862 error "user '$RUNAS_ID' cannot get HSM state of '$file'"
1864 $LFS hsm_release $file
1865 check_hsm_flags $file "0x0000000d"
1867 # Check that ordinary user can accessed released file.
1868 sum1=$($RUNAS md5sum $file) ||
1869 error "user '$RUNAS_ID' cannot read '$file'"
1871 [ "$sum0" == "$sum1" ] ||
1872 error "md5sum mismatch for '$file'"
1876 run_test 24b "root can archive, release, and restore user files"
1878 cleanup_test_24c() {
1880 set_hsm_param user_request_mask RESTORE
1881 set_hsm_param group_request_mask RESTORE
1882 set_hsm_param other_request_mask RESTORE
1886 local file=$DIR/$tdir/$tfile
1887 local action=archive
1892 # test needs a running copytool
1897 # Save the default masks and check that cleanup_24c will
1898 # restore the request masks correctly.
1899 user_save=$(get_hsm_param user_request_mask)
1900 group_save=$(get_hsm_param group_request_mask)
1901 other_save=$(get_hsm_param other_request_mask)
1903 [ "$user_save" == RESTORE ] ||
1904 error "user_request_mask is '$user_save' expected 'RESTORE'"
1905 [ "$group_save" == RESTORE ] ||
1906 error "group_request_mask is '$group_save' expected 'RESTORE'"
1907 [ "$other_save" == RESTORE ] ||
1908 error "other_request_mask is '$other_save' expected 'RESTORE'"
1910 trap cleanup_test_24c EXIT
1915 chown $RUNAS_ID:nobody $file ||
1916 error "cannot chown '$file' to '$RUNAS_ID:nobody'"
1918 set_hsm_param user_request_mask ""
1919 $RUNAS $LFS hsm_$action $file &&
1920 error "$action by user should fail"
1922 set_hsm_param user_request_mask $action
1923 $RUNAS $LFS hsm_$action $file ||
1924 error "$action by user should succeed"
1929 chown nobody:$RUNAS_GID $file ||
1930 error "cannot chown '$file' to 'nobody:$RUNAS_GID'"
1932 set_hsm_param group_request_mask ""
1933 $RUNAS $LFS hsm_$action $file &&
1934 error "$action by group should fail"
1936 set_hsm_param group_request_mask $action
1937 $RUNAS $LFS hsm_$action $file ||
1938 error "$action by group should succeed"
1943 chown nobody:nobody $file ||
1944 error "cannot chown '$file' to 'nobody:nobody'"
1946 set_hsm_param other_request_mask ""
1947 $RUNAS $LFS hsm_$action $file &&
1948 error "$action by other should fail"
1950 set_hsm_param other_request_mask $action
1951 $RUNAS $LFS hsm_$action $file ||
1952 error "$action by other should succeed"
1957 run_test 24c "check that user,group,other request masks work"
1959 cleanup_test_24d() {
1961 mount -o remount,rw $MOUNT2
1965 local file1=$DIR/$tdir/$tfile
1966 local file2=$DIR2/$tdir/$tfile
1974 fid1=$(make_small $file1)
1976 trap cleanup_test_24d EXIT
1978 mount -o remount,ro $MOUNT2
1980 fid2=$(path2fid $file2)
1981 [ "$fid1" == "$fid2" ] ||
1982 error "FID mismatch '$fid1' != '$fid2'"
1984 $LFS hsm_archive $file2 &&
1985 error "archive should fail on read-only mount"
1986 check_hsm_flags $file1 "0x00000000"
1988 $LFS hsm_archive $file1
1989 wait_request_state $fid1 ARCHIVE SUCCEED
1991 $LFS hsm_release $file1
1992 $LFS hsm_restore $file2
1993 wait_request_state $fid1 RESTORE SUCCEED
1995 $LFS hsm_release $file1 || error "cannot release '$file1'"
1996 dd if=$file2 of=/dev/null bs=1M || "cannot read '$file2'"
1998 $LFS hsm_release $file2 &&
1999 error "release should fail on read-only mount"
2004 run_test 24d "check that read-only mounts are respected"
2007 # test needs a running copytool
2011 copy2archive /etc/hosts $tdir/$tfile
2013 local f=$DIR/$tdir/$tfile
2015 import_file $tdir/$tfile $f
2017 $LFS hsm_set --lost $f
2022 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
2026 run_test 25a "Restore lost file (HS_LOST flag) from import"\
2027 " (Operation not permitted)"
2030 # test needs a running copytool
2035 local f=$DIR/$tdir/$tfile
2036 local fid=$(copy_file /etc/passwd $f)
2038 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2039 wait_request_state $fid ARCHIVE SUCCEED
2042 $LFS hsm_set --lost $f
2046 [[ $st == 1 ]] || error "lost file access should failed (returns $st)"
2050 run_test 25b "Restore lost file (HS_LOST flag) after release"\
2051 " (Operation not permitted)"
2054 # test needs a running copytool
2058 local f=$DIR/$tdir/$tfile
2060 fid=$(make_large_for_progress $f)
2061 [ $? != 0 ] && skip "not enough free space" && return
2063 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2064 wait_request_state $fid ARCHIVE SUCCEED
2067 wait_request_state $fid REMOVE SUCCEED
2069 check_hsm_flags $f "0x00000000"
2073 run_test 26 "Remove the archive of a valid file"
2076 # test needs a running copytool
2080 make_archive $tdir/$tfile
2081 local f=$DIR/$tdir/$tfile
2082 import_file $tdir/$tfile $f
2083 local fid=$(path2fid $f)
2087 [[ $? != 0 ]] || error "Remove of a released file should fail"
2091 run_test 27a "Remove the archive of an imported file (Operation not permitted)"
2094 # test needs a running copytool
2098 local f=$DIR/$tdir/$tfile
2100 fid=$(make_large_for_progress $f)
2101 [ $? != 0 ] && skip "not enough free space" && return
2103 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2104 wait_request_state $fid ARCHIVE SUCCEED
2109 [[ $? != 0 ]] || error "Remove of a released file should fail"
2113 run_test 27b "Remove the archive of a relased file (Operation not permitted)"
2116 # test needs a running copytool
2120 local f=$DIR/$tdir/$tfile
2122 fid=$(make_large_for_progress $f)
2123 [ $? != 0 ] && skip "not enough free space" && return
2125 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2126 wait_request_state $fid ARCHIVE SUCCEED
2135 wait_request_state $fid REMOVE SUCCEED
2139 run_test 28 "Concurrent archive/file remove"
2142 # Tests --mntpath and --archive options
2145 copytool_setup $SINGLEAGT $MOUNT $archive_id
2147 # Bad archive number
2148 $LFS hsm_remove -m $MOUNT -a 33 0x857765760:0x8:0x2 2>&1 |
2149 grep "Invalid argument" ||
2150 error "unexpected hsm_remove failure (1)"
2152 # mntpath is present but file is given
2153 $LFS hsm_remove --mntpath $MOUNT --archive 30 /qwerty/uyt 2>&1 |
2154 grep "hsm: '/qwerty/uyt' is not a valid FID" ||
2155 error "unexpected hsm_remove failure (2)"
2159 run_test 29a "Tests --mntpath and --archive options"
2162 # test needs a running copytool
2166 local f=$DIR/$tdir/$tfile
2167 local fid=$(make_small $f)
2169 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2170 wait_request_state $fid ARCHIVE SUCCEED
2174 $LFS hsm_remove -m $MOUNT -a $HSM_ARCHIVE_NUMBER $fid
2175 wait_request_state $fid REMOVE SUCCEED
2179 run_test 29b "Archive/delete/remove by FID from the archive."
2182 # test needs a running copytool
2186 local fid1=$(make_small $DIR/$tdir/$tfile-1)
2187 local fid2=$(make_small $DIR/$tdir/$tfile-2)
2188 local fid3=$(make_small $DIR/$tdir/$tfile-3)
2190 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$tfile-[1-3]
2191 wait_request_state $fid1 ARCHIVE SUCCEED
2192 wait_request_state $fid2 ARCHIVE SUCCEED
2193 wait_request_state $fid3 ARCHIVE SUCCEED
2195 rm -f $DIR/$tdir/$tfile-[1-3]
2197 echo $fid1 > $DIR/$tdir/list
2198 echo $fid2 >> $DIR/$tdir/list
2199 echo $fid3 >> $DIR/$tdir/list
2201 $LFS hsm_remove -m $MOUNT -a $HSM_ARCHIVE_NUMBER \
2202 --filelist $DIR/$tdir/list
2203 wait_request_state $fid1 REMOVE SUCCEED
2204 wait_request_state $fid2 REMOVE SUCCEED
2205 wait_request_state $fid3 REMOVE SUCCEED
2209 run_test 29c "Archive/delete/remove by FID, using a file list."
2212 # restore at exec cannot work on agent node (because of Linux kernel
2213 # protection of executables)
2214 needclients 2 || return 0
2216 # test needs a running copytool
2220 copy2archive /bin/true $tdir/$tfile
2222 local f=$DIR/$tdir/true
2223 import_file $tdir/$tfile $f
2225 local fid=$(path2fid $f)
2227 # set no retry action mode
2233 # remove no try action mode
2237 [[ $st == 0 ]] || error "Failed to exec a released file"
2241 run_test 30a "Restore at exec (import case)"
2244 # restore at exec cannot work on agent node (because of Linux kernel
2245 # protection of executables)
2246 needclients 2 || return 0
2248 # test needs a running copytool
2252 local f=$DIR/$tdir/true
2253 local fid=$(copy_file /bin/true $f)
2255 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2256 wait_request_state $fid ARCHIVE SUCCEED
2259 # set no retry action mode
2265 # remove no try action mode
2269 [[ $st == 0 ]] || error "Failed to exec a released file"
2273 run_test 30b "Restore at exec (release case)"
2276 needclients 2 || return 0
2278 # test needs a running copytool
2282 local f=$DIR/$tdir/SLEEP
2283 local slp_sum1=$(md5sum /bin/sleep)
2284 local fid=$(copy_file /bin/sleep $f)
2286 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2287 wait_request_state $fid ARCHIVE SUCCEED
2289 check_hsm_flags $f "0x0000000d"
2290 # set no retry action mode
2292 do_node $CLIENT2 "$f 10" &
2296 [[ $? == 0 ]] && error "Update during exec of released file must fail"
2298 [[ $? == 0 ]] || error "Execution failed during run"
2300 if [[ $? != 0 ]]; then
2301 local slp_sum2=$(md5sum /bin/sleep)
2302 # in case sleep file is modified during the test
2303 [[ $slp_sum1 == $slp_sum2 ]] &&
2304 error "Binary overwritten during exec"
2308 # remove no try action mode
2310 check_hsm_flags $f "0x00000009"
2314 run_test 30c "Update during exec of released file must fail"
2316 restore_and_check_size() {
2319 local s=$(stat -c "%s" $f)
2321 local st=$(get_hsm_flags $f)
2325 while [[ "$st" != "0x00000009" && $cpt -le 10 ]]
2327 n=$(stat -c "%s" $f)
2328 # we echo in both cases to show stat is not
2330 if [[ $n != $s ]]; then
2331 echo "size seen is $n != $s"
2334 echo "size seen is right: $n == $s"
2336 st=$(get_hsm_flags $f)
2340 if [[ $cpt -lt 10 ]]; then
2343 echo " restore is too long"
2344 wait_request_state $fid RESTORE SUCCEED
2350 # test needs a running copytool
2355 make_archive $tdir/$tfile
2356 local f=$DIR/$tdir/$tfile
2357 import_file $tdir/$tfile $f
2358 local fid=$($LFS path2fid $f)
2359 HSM_ARCHIVE_PURGE=false copytool_setup
2361 restore_and_check_size $f $fid
2364 [[ $err -eq 0 ]] || error "File size changed during restore"
2368 run_test 31a "Import a large file and check size during restore"
2372 # test needs a running copytool
2377 local f=$DIR/$tdir/$tfile
2379 fid=$(make_large_for_progress $f)
2380 [ $? != 0 ] && skip "not enough free space" && return
2382 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2383 wait_request_state $fid ARCHIVE SUCCEED
2386 restore_and_check_size $f $fid
2389 [[ $err -eq 0 ]] || error "File size changed during restore"
2393 run_test 31b "Restore a large unaligned file and check size during restore"
2396 # test needs a running copytool
2401 local f=$DIR/$tdir/$tfile
2403 fid=$(make_large_for_progress_aligned $f)
2404 [ $? != 0 ] && skip "not enough free space" && return
2406 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2407 wait_request_state $fid ARCHIVE SUCCEED
2410 restore_and_check_size $f $fid
2413 [[ $err -eq 0 ]] || error "File size changed during restore"
2417 run_test 31c "Restore a large aligned file and check size during restore"
2420 # test needs a running copytool
2425 local f=$DIR/$tdir/$tfile
2427 fid=$(make_large_for_progress $f)
2428 [ $? != 0 ] && skip "not enough free space" && return
2430 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2431 wait_request_state $fid ARCHIVE SUCCEED
2434 # to be sure wait_all_done will not be mislead by previous tests
2437 wait_for_grace_delay
2438 # Also raise grace_delay significantly so the Canceled
2439 # Restore action will stay enough long avail.
2440 local old_grace=$(get_hsm_param grace_delay)
2441 set_hsm_param grace_delay 100
2443 md5sum $f >/dev/null &
2445 wait_request_state $fid RESTORE STARTED
2450 # Check restore trigger process was killed
2451 local killed=$(ps -o pid,comm hp $pid >/dev/null)
2455 # instead of waiting+checking both Restore and Cancel ops
2456 # sequentially, wait for both to be finished and then check
2458 wait_all_done 100 $fid
2459 local rstate=$(get_request_state $fid RESTORE)
2460 local cstate=$(get_request_state $fid CANCEL)
2462 # restore orig grace_delay.
2463 set_hsm_param grace_delay $old_grace
2465 if [[ "$rstate" == "CANCELED" ]] ; then
2466 [[ "$cstate" == "SUCCEED" ]] ||
2467 error "Restore state is CANCELED and Cancel state " \
2468 "is not SUCCEED but $cstate"
2469 echo "Restore state is CANCELED, Cancel state is SUCCEED"
2470 elif [[ "$rstate" == "SUCCEED" ]] ; then
2471 [[ "$cstate" == "FAILED" ]] ||
2472 error "Restore state is SUCCEED and Cancel state " \
2473 "is not FAILED but $cstate"
2474 echo "Restore state is SUCCEED, Cancel state is FAILED"
2476 error "Restore state is $rstate and Cancel state is $cstate"
2480 error "Cannot kill process waiting for restore ($killed)"
2484 run_test 33 "Kill a restore waiting process"
2487 # test needs a running copytool
2492 local f=$DIR/$tdir/$tfile
2494 fid=$(make_large_for_progress $f)
2495 [ $? != 0 ] && skip "not enough free space" && return
2497 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2498 wait_request_state $fid ARCHIVE SUCCEED
2501 md5sum $f >/dev/null &
2503 wait_request_state $fid RESTORE STARTED
2505 rm $f || error "rm $f failed"
2506 # rm must not block during restore
2507 wait_request_state $fid RESTORE STARTED
2509 wait_request_state $fid RESTORE SUCCEED
2510 # check md5sum pgm finished
2511 local there=$(ps -o pid,comm hp $pid >/dev/null)
2512 [[ -z $there ]] || error "Restore initiator does not exit"
2514 local rc=$(wait $pid)
2515 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2519 run_test 34 "Remove file during restore"
2522 # test needs a running copytool
2527 local f=$DIR/$tdir/$tfile
2528 local f1=$DIR/$tdir/$tfile-1
2530 fid=$(make_large_for_progress $f)
2531 [ $? != 0 ] && skip "not enough free space" && return
2533 local fid1=$(copy_file /etc/passwd $f1)
2534 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2535 wait_request_state $fid ARCHIVE SUCCEED
2538 md5sum $f >/dev/null &
2540 wait_request_state $fid RESTORE STARTED
2542 mv $f1 $f || error "mv $f1 $f failed"
2543 # mv must not block during restore
2544 wait_request_state $fid RESTORE STARTED
2546 wait_request_state $fid RESTORE SUCCEED
2547 # check md5sum pgm finished
2548 local there=$(ps -o pid,comm hp $pid >/dev/null)
2549 [[ -z $there ]] || error "Restore initiator does not exit"
2551 local rc=$(wait $pid)
2552 [[ $rc -eq 0 ]] || error "Restore initiator failed with $rc"
2555 [[ $fid2 == $fid1 ]] || error "Wrong fid after mv $fid2 != $fid1"
2559 run_test 35 "Overwrite file during restore"
2562 # test needs a running copytool
2567 local f=$DIR/$tdir/$tfile
2569 fid=$(make_large_for_progress $f)
2570 [ $? != 0 ] && skip "not enough free space" && return
2572 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2573 wait_request_state $fid ARCHIVE SUCCEED
2576 md5sum $f >/dev/null &
2578 wait_request_state $fid RESTORE STARTED
2581 # rm must not block during restore
2582 wait_request_state $fid RESTORE STARTED
2584 wait_request_state $fid RESTORE SUCCEED
2585 # check md5sum pgm finished
2586 local there=$(ps -o pid,comm hp $pid >/dev/null)
2588 error "Restore initiator does not exit"
2590 local rc=$(wait $pid)
2592 error "Restore initiator failed with $rc"
2596 run_test 36 "Move file during restore"
2599 # LU-5683: check that an archived dirty file can be rearchived.
2601 copytool_setup $SINGLEAGT $MOUNT2
2604 local f=$DIR/$tdir/$tfile
2607 fid=$(make_small $f) || error "cannot create small file"
2609 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2610 wait_request_state $fid ARCHIVE SUCCEED
2611 $LFS hsm_release $f || error "cannot release $f"
2614 dd if=/dev/urandom of=$f bs=1M count=1 || error "cannot dirty file"
2616 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
2617 wait_request_state $fid ARCHIVE SUCCEED
2621 run_test 37 "re-archive a dirty file"
2628 for n in $(seq 1 $count); do
2629 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $prefix.$n
2631 echo "$count archive requests submitted"
2635 local stream_count=4
2636 local file_count=100
2638 local f=$DIR/$tdir/$tfile
2643 for i in $(seq 1 $file_count); do
2644 for p in $(seq 1 $stream_count); do
2645 fid=$(copy_file /etc/hosts $f.$p.$i)
2648 # force copytool to use a local/temp archive dir to ensure best
2649 # performance vs remote/NFS mounts used in auto-tests
2650 if do_facet $SINGLEAGT "df --local $HSM_ARCHIVE" >/dev/null 2>&1 ; then
2653 copytool_setup $SINGLEAGT $MOUNT $HSM_ARCHIVE_NUMBER $TMP/$tdir
2655 # to be sure wait_all_done will not be mislead by previous tests
2657 wait_for_grace_delay
2659 # start archive streams in background (archive files in parallel)
2660 for p in $(seq 1 $stream_count); do
2661 multi_archive $f.$p $file_count &
2664 echo -n "Wait for all requests being enqueued..."
2670 run_test 40 "Parallel archive requests"
2673 # test needs a running copytool
2677 local f=$DIR/$tdir/$tfile
2678 local fid=$(copy_file /etc/motd $f 1)
2680 $LFS hsm_archive $f || error "could not archive file"
2681 wait_request_state $fid ARCHIVE SUCCEED
2682 check_hsm_flags $f "0x00000009"
2684 multiop_bg_pause $f O_c || error "multiop failed"
2688 client_up || client_up || true
2690 kill -USR1 $MULTIPID
2691 wait $MULTIPID || error "multiop close failed"
2693 check_hsm_flags $f "0x0000000b"
2697 run_test 52 "Opened for write file on an evicted client should be set dirty"
2700 # test needs a running copytool
2704 local f=$DIR/$tdir/$tfile
2705 local fid=$(copy_file /etc/motd $f 1)
2707 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2708 error "could not archive file"
2709 wait_request_state $fid ARCHIVE SUCCEED
2710 check_hsm_flags $f "0x00000009"
2712 multiop_bg_pause $f o_c || error "multiop failed"
2716 client_up || client_up || true
2718 kill -USR1 $MULTIPID
2719 wait $MULTIPID || error "multiop close failed"
2721 check_hsm_flags $f "0x00000009"
2725 run_test 53 "Opened for read file on an evicted client should not be set dirty"
2728 # test needs a running copytool
2732 local f=$DIR/$tdir/$tfile
2733 local fid=$(make_large_for_progress $f)
2735 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2736 error "could not archive file"
2737 wait_request_state $fid ARCHIVE STARTED
2739 check_hsm_flags $f "0x00000001"
2741 # Avoid coordinator resending this request as soon it has failed.
2746 wait_request_state $fid ARCHIVE FAILED
2748 check_hsm_flags $f "0x00000003"
2753 run_test 54 "Write during an archive cancels it"
2756 # test needs a running copytool
2760 local f=$DIR/$tdir/$tfile
2761 local fid=$(make_large_for_progress $f)
2763 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2764 error "could not archive file"
2765 wait_request_state $fid ARCHIVE STARTED
2767 check_hsm_flags $f "0x00000001"
2769 # Avoid coordinator resending this request as soon it has failed.
2772 $TRUNCATE $f 1024 || error "truncate failed"
2774 wait_request_state $fid ARCHIVE FAILED
2776 check_hsm_flags $f "0x00000003"
2781 run_test 55 "Truncate during an archive cancels it"
2784 # test needs a running copytool
2788 local f=$DIR/$tdir/$tfile
2790 fid=$(make_large_for_progress $f)
2791 [ $? != 0 ] && skip "not enough free space" && return
2793 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2794 error "could not archive file"
2795 wait_request_state $fid ARCHIVE STARTED
2797 check_hsm_flags $f "0x00000001"
2799 # Change metadata and sync to be sure we are not changing only
2804 wait_request_state $fid ARCHIVE SUCCEED
2806 check_hsm_flags $f "0x00000009"
2810 run_test 56 "Setattr during an archive is ok"
2813 # Need one client for I/O, one for request
2814 needclients 2 || return 0
2816 # test needs a running copytool
2820 local f=$DIR/$tdir/test_archive_remote
2821 # Create a file on a remote node
2822 do_node $CLIENT2 "dd if=/dev/urandom of=$f bs=1M "\
2823 "count=2 conv=fsync"
2826 do_node $CLIENT2 "$LFS hsm_archive -a $HSM_ARCHIVE_NUMBER $f" ||
2827 error "hsm_archive failed"
2828 local fid=$(path2fid $f)
2829 wait_request_state $fid ARCHIVE SUCCEED
2831 # Release and implicit restore it
2832 do_node $CLIENT2 "$LFS hsm_release $f" ||
2833 error "hsm_release failed"
2834 do_node $CLIENT2 "md5sum $f" ||
2835 error "hsm_restore failed"
2837 wait_request_state $fid RESTORE SUCCEED
2841 run_test 57 "Archive a file with dirty cache on another node"
2843 truncate_released_file() {
2847 local sz=$(stat -c %s $src_file)
2848 local f=$DIR/$tdir/$tfile
2849 local fid=$(copy_file $1 $f)
2853 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2854 error "could not archive file"
2855 wait_request_state $fid ARCHIVE SUCCEED
2857 $LFS hsm_release $f || error "could not release file"
2859 $TRUNCATE $f $trunc_to || error "truncate failed"
2862 local sz1=$(stat -c %s $f)
2863 [[ $sz1 == $trunc_to ]] ||
2864 error "size after trunc: $sz1 expect $trunc_to, original $sz"
2867 check_hsm_flags $f "0x0000000b"
2869 local state=$(get_request_state $fid RESTORE)
2870 [[ "$state" == "SUCCEED" ]] ||
2871 error "truncate $sz does not trig restore, state = $state"
2873 $TRUNCATE $ref $trunc_to
2874 cmp $ref $f || error "file data wrong after truncate"
2880 # test needs a running copytool
2885 local sz=$(stat -c %s /etc/passwd)
2887 echo "truncate up from $sz to $((sz*2))"
2888 truncate_released_file /etc/passwd $((sz*2))
2890 echo "truncate down from $sz to $((sz/2))"
2891 truncate_released_file /etc/passwd $((sz/2))
2893 echo "truncate to 0"
2894 truncate_released_file /etc/passwd 0
2898 run_test 58 "Truncate a released file will trigger restore"
2901 # This test validates the fix for LU-4512. Ensure that the -u
2902 # option changes the progress reporting interval from the
2903 # default (30 seconds) to the user-specified interval.
2905 local progress_timeout=$((interval * 4))
2907 # test needs a new running copytool
2909 HSMTOOL_UPDATE_INTERVAL=$interval copytool_setup
2912 local f=$DIR/$tdir/$tfile
2914 fid=$(make_large_for_progress $f)
2915 [ $? != 0 ] && skip "not enough free space" && return
2918 local mdt=${MDT_PREFIX}${mdtidx}
2919 local mds=mds$((mdtidx + 1))
2921 # Wait for copytool to register
2922 wait_update_facet $mds \
2923 "$LCTL get_param -n ${mdt}.hsm.agents | grep -o ^uuid" \
2924 uuid 100 || error "coyptool failed to register with $mdt"
2926 local start_at=$(date +%s)
2927 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
2928 error "could not archive file"
2930 local agent=$(facet_active_host $SINGLEAGT)
2931 local prefix=$TESTLOG_PREFIX
2932 [[ -z "$TESTNAME" ]] || prefix=$prefix.$TESTNAME
2933 local copytool_log=$prefix.copytool_log.$agent.log
2936 wait_update $agent \
2937 "grep -o start.copy $copytool_log" "start copy" 100 ||
2938 error "copytool failed to start"
2940 local cmd="$LCTL get_param -n ${mdt}.hsm.active_requests"
2941 cmd+=" | awk '/'$fid'.*action=ARCHIVE/ {print \\\$12}' | cut -f2 -d="
2947 echo -n "Expecting a progress update within $progress_timeout seconds... "
2949 RESULT=$(do_node $(facet_active_host $mds) "$cmd")
2950 if [ $RESULT -gt 0 ]; then
2951 echo "$RESULT bytes copied in $WAIT seconds."
2953 elif [ $WAIT -ge $progress_timeout ]; then
2954 error "Timed out waiting for progress update!"
2957 WAIT=$((WAIT + sleep))
2961 local finish_at=$(date +%s)
2962 local elapsed=$((finish_at - start_at))
2964 # Ensure that the progress update occurred within the expected window.
2965 if [ $elapsed -lt $interval ]; then
2966 error "Expected progress update after at least $interval seconds"
2972 run_test 60 "Changing progress update interval from default"
2975 # test needs a new running copytool
2977 copytool_monitor_setup
2978 HSMTOOL_EVENT_FIFO=$HSMTOOL_MONITOR_DIR/fifo copytool_setup
2980 # Just start and stop the copytool to generate events.
2983 # Wait for the copytool to register.
2984 wait_update --verbose $(facet_active_host mds1) \
2985 "$LCTL get_param -n ${MDT_PREFIX}0.hsm.agents | grep -o ^uuid" \
2987 error "copytool failed to register with MDT0000"
2991 local REGISTER_EVENT
2992 local UNREGISTER_EVENT
2993 while read event; do
2994 local parsed=$(parse_json_event "$event")
2995 if [ -z "$parsed" ]; then
2996 error "Copytool sent malformed event: $event"
3000 if [ $event_type == "REGISTER" ]; then
3001 REGISTER_EVENT=$event
3002 elif [ $event_type == "UNREGISTER" ]; then
3003 UNREGISTER_EVENT=$event
3005 done < <(echo $"$(get_copytool_event_log)")
3007 if [ -z "$REGISTER_EVENT" ]; then
3008 error "Copytool failed to send register event to FIFO"
3011 if [ -z "$UNREGISTER_EVENT" ]; then
3012 error "Copytool failed to send unregister event to FIFO"
3015 copytool_monitor_cleanup
3016 echo "Register/Unregister events look OK."
3018 run_test 70 "Copytool logs JSON register/unregister events to FIFO"
3021 # Bump progress interval for livelier events.
3024 # test needs a new running copytool
3026 copytool_monitor_setup
3027 HSMTOOL_UPDATE_INTERVAL=$interval \
3028 HSMTOOL_EVENT_FIFO=$HSMTOOL_MONITOR_DIR/fifo copytool_setup
3031 local f=$DIR/$tdir/$tfile
3033 fid=$(make_large_for_progress $f)
3034 [ $? != 0 ] && skip "not enough free space" && return
3036 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
3037 error "could not archive file"
3038 wait_request_state $fid ARCHIVE SUCCEED
3040 local expected_fields="event_time data_fid source_fid"
3041 expected_fields+=" total_bytes current_bytes"
3045 while read event; do
3046 # Make sure we're not getting anything from previous events.
3047 for field in $expected_fields; do
3051 local parsed=$(parse_json_event "$event")
3052 if [ -z "$parsed" ]; then
3053 error "Copytool sent malformed event: $event"
3057 if [ $event_type == "ARCHIVE_START" ]; then
3060 elif [ $event_type == "ARCHIVE_FINISH" ]; then
3063 elif [ $event_type != "ARCHIVE_RUNNING" ]; then
3067 # Do some simple checking of the progress update events.
3068 for expected_field in $expected_fields; do
3069 if [ -z ${!expected_field+x} ]; then
3070 error "Missing $expected_field field in event"
3074 if [ $total_bytes -eq 0 ]; then
3075 error "Expected total_bytes to be > 0"
3078 # These should be identical throughout an archive
3080 if [ $source_fid != $data_fid ]; then
3081 error "Expected source_fid to equal data_fid"
3083 done < <(echo $"$(get_copytool_event_log)")
3085 if [ -z "$START_EVENT" ]; then
3086 error "Copytool failed to send archive start event to FIFO"
3089 if [ -z "$FINISH_EVENT" ]; then
3090 error "Copytool failed to send archive finish event to FIFO"
3093 echo "Archive events look OK."
3097 copytool_monitor_cleanup
3099 run_test 71 "Copytool logs JSON archive events to FIFO"
3102 # Bump progress interval for livelier events.
3105 # test needs a new running copytool
3107 copytool_monitor_setup
3108 HSMTOOL_UPDATE_INTERVAL=$interval \
3109 HSMTOOL_EVENT_FIFO=$HSMTOOL_MONITOR_DIR/fifo copytool_setup
3110 local test_file=$HSMTOOL_MONITOR_DIR/file
3112 local cmd="dd if=/dev/urandom of=$test_file count=16 bs=1000000 "
3114 do_facet $SINGLEAGT "$cmd" ||
3115 error "cannot create $test_file on $SINGLEAGT"
3116 copy2archive $test_file $tdir/$tfile
3119 local f=$DIR/$tdir/$tfile
3120 import_file $tdir/$tfile $f
3121 f=$DIR2/$tdir/$tfile
3122 echo "Verifying released state: "
3123 check_hsm_flags $f "0x0000000d"
3125 local fid=$(path2fid $f)
3127 wait_request_state $fid RESTORE SUCCEED
3129 local expected_fields="event_time data_fid source_fid"
3130 expected_fields+=" total_bytes current_bytes"
3134 while read event; do
3135 # Make sure we're not getting anything from previous events.
3136 for field in $expected_fields; do
3140 local parsed=$(parse_json_event "$event")
3141 if [ -z "$parsed" ]; then
3142 error "Copytool sent malformed event: $event"
3146 if [ $event_type == "RESTORE_START" ]; then
3148 if [ $source_fid != $data_fid ]; then
3149 error "source_fid should == data_fid at start"
3152 elif [ $event_type == "RESTORE_FINISH" ]; then
3154 if [ $source_fid != $data_fid ]; then
3155 error "source_fid should == data_fid at finish"
3158 elif [ $event_type != "RESTORE_RUNNING" ]; then
3162 # Do some simple checking of the progress update events.
3163 for expected_field in $expected_fields; do
3164 if [ -z ${!expected_field+x} ]; then
3165 error "Missing $expected_field field in event"
3169 if [ $total_bytes -eq 0 ]; then
3170 error "Expected total_bytes to be > 0"
3173 # When a restore starts out, the data fid is the same as the
3174 # source fid. After the restore has gotten going, we learn
3175 # the new data fid. Once the restore has finished, the source
3176 # fid is set to the new data fid.
3178 # We test this because some monitoring software may depend on
3179 # this behavior. If it changes, then the consumers of these
3180 # events may need to be modified.
3181 if [ $source_fid == $data_fid ]; then
3182 error "source_fid should != data_fid during restore"
3184 done < <(echo $"$(get_copytool_event_log)")
3186 if [ -z "$START_EVENT" ]; then
3187 error "Copytool failed to send restore start event to FIFO"
3190 if [ -z "$FINISH_EVENT" ]; then
3191 error "Copytool failed to send restore finish event to FIFO"
3194 echo "Restore events look OK."
3198 copytool_monitor_cleanup
3202 run_test 72 "Copytool logs JSON restore events to FIFO"
3205 file_count=51 # Max number of files constrained by LNET message size
3206 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3207 local f=$DIR/$tdir/$tfile
3208 local FILELIST=/tmp/filelist.txt
3212 for i in $(seq 1 $file_count); do
3213 fid=$(copy_file /etc/hosts $f.$i)
3214 echo $f.$i >> $FILELIST
3216 # force copytool to use a local/temp archive dir to ensure best
3217 # performance vs remote/NFS mounts used in auto-tests
3218 if do_facet $SINGLEAGT "df --local $HSM_ARCHIVE" >/dev/null 2>&1 ; then
3221 local dai=$(get_hsm_param default_archive_id)
3222 copytool_setup $SINGLEAGT $MOUNT $dai $TMP/$tdir
3224 # to be sure wait_all_done will not be mislead by previous tests
3226 wait_for_grace_delay
3227 $LFS hsm_archive --filelist $FILELIST ||
3228 error "cannot archive a file list"
3230 $LFS hsm_release --filelist $FILELIST ||
3231 error "cannot release a file list"
3232 $LFS hsm_restore --filelist $FILELIST ||
3233 error "cannot restore a file list"
3237 run_test 90 "Archive/restore a file list"
3239 double_verify_reset_hsm_param() {
3241 echo "Testing $HSM_PARAM.$p"
3242 local val=$(get_hsm_param $p)
3244 local val2=$(($val * 2))
3245 set_hsm_param $p $val2
3246 val=$(get_hsm_param $p)
3247 [[ $val == $val2 ]] ||
3248 error "$HSM_PARAM.$p: $val != $val2 should be (2 * $save)"
3249 echo "Set $p to 0 must failed"
3253 set_hsm_param $p $save
3255 if [[ $rc == 0 ]]; then
3256 error "we must not be able to set $HSM_PARAM.$p to 0"
3261 double_verify_reset_hsm_param loop_period
3262 double_verify_reset_hsm_param grace_delay
3263 double_verify_reset_hsm_param active_request_timeout
3264 double_verify_reset_hsm_param max_requests
3265 double_verify_reset_hsm_param default_archive_id
3267 run_test 100 "Set coordinator /proc tunables"
3274 run_test 102 "Verify coordinator control"
3277 # test needs a running copytool
3284 for i in $(seq 1 20); do
3285 fid=$(copy_file /etc/passwd $DIR/$tdir/$i)
3287 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/*
3291 echo "Current requests"
3292 local res=$(do_facet $SINGLEMDS "$LCTL get_param -n\
3293 $HSM_PARAM.actions |\
3294 grep -v CANCELED | grep -v SUCCEED | grep -v FAILED")
3296 [[ -z "$res" ]] || error "Some request have not been canceled"
3300 run_test 103 "Purge all requests"
3305 # test needs a running copytool
3309 local f=$DIR/$tdir/$tfile
3311 fid=$(make_large_for_progress $f)
3312 [ $? != 0 ] && skip "not enough free space" && return
3314 # if cdt is on, it can serve too quickly the request
3316 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER --data $DATA $f
3317 local data1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
3318 $HSM_PARAM.actions |\
3319 grep $fid | cut -f16 -d=")
3322 [[ "$data1" == "$DATAHEX" ]] ||
3323 error "Data field in records is ($data1) and not ($DATAHEX)"
3327 run_test 104 "Copy tool data field"
3334 for i in $(seq -w 1 10); do
3335 cp /etc/passwd $DIR/$tdir/$i
3336 $LFS hsm_archive $DIR/$tdir/$i
3338 local reqcnt1=$(do_facet $SINGLEMDS "$LCTL get_param -n\
3339 $HSM_PARAM.actions |\
3340 grep WAITING | wc -l")
3343 local reqcnt2=$(do_facet $SINGLEMDS "$LCTL get_param -n\
3344 $HSM_PARAM.actions |\
3345 grep WAITING | wc -l")
3348 [[ "$reqcnt1" == "$reqcnt2" ]] ||
3349 error "Requests count after shutdown $reqcnt2 != "\
3350 "before shutdown $reqcnt1"
3352 run_test 105 "Restart of coordinator"
3354 get_agent_by_uuid_mdt() {
3357 local mds=mds$(($mdtidx + 1))
3358 do_facet $mds "$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.agents |\
3362 check_agent_registered_by_mdt() {
3365 local mds=mds$(($mdtidx + 1))
3366 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
3367 if [[ ! -z "$agent" ]]; then
3368 echo "found agent $agent on $mds"
3370 error "uuid $uuid not found in agent list on $mds"
3374 check_agent_unregistered_by_mdt() {
3377 local mds=mds$(($mdtidx + 1))
3378 local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
3379 if [[ -z "$agent" ]]; then
3380 echo "uuid not found in agent list on $mds"
3382 error "uuid found in agent list on $mds: $agent"
3386 check_agent_registered() {
3389 for mdsno in $(seq 1 $MDSCOUNT); do
3390 check_agent_registered_by_mdt $uuid $((mdsno - 1))
3394 check_agent_unregistered() {
3397 for mdsno in $(seq 1 $MDSCOUNT); do
3398 check_agent_unregistered_by_mdt $uuid $((mdsno - 1))
3403 local uuid=$(do_rpc_nodes $(facet_active_host $SINGLEAGT) \
3404 get_client_uuid $MOUNT | cut -d' ' -f2)
3407 check_agent_registered $uuid
3409 search_copytools || error "No copytool found"
3412 check_agent_unregistered $uuid
3415 check_agent_registered $uuid
3419 run_test 106 "Copytool register/unregister"
3422 # test needs a running copytool
3424 # create and archive file
3426 local f1=$DIR/$tdir/$tfile
3427 local fid=$(copy_file /etc/passwd $f1)
3428 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
3429 wait_request_state $fid ARCHIVE SUCCEED
3430 # shutdown and restart MDS
3432 # check the copytool still gets messages from MDT
3433 local f2=$DIR/$tdir/2
3434 local fid=$(copy_file /etc/passwd $f2)
3435 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f2
3436 # main check of this sanity: this request MUST succeed
3437 wait_request_state $fid ARCHIVE SUCCEED
3440 run_test 107 "Copytool re-register after MDS restart"
3442 policy_set_and_test()
3446 do_facet $SINGLEMDS $LCTL set_param "$HSM_PARAM.policy=\\\"$change\\\""
3447 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
3448 [[ "$policy" == "$target" ]] ||
3449 error "Wrong policy after '$change': '$policy' != '$target'"
3453 # to force default policy setting if error
3454 CDT_POLICY_HAD_CHANGED=true
3456 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
3457 local default="NonBlockingRestore [NoRetryAction]"
3458 [[ "$policy" == "$default" ]] ||
3459 error "default policy has changed,"\
3460 " '$policy' != '$default' update the test"
3461 policy_set_and_test "+NBR" "[NonBlockingRestore] [NoRetryAction]"
3462 policy_set_and_test "+NRA" "[NonBlockingRestore] [NoRetryAction]"
3463 policy_set_and_test "-NBR" "NonBlockingRestore [NoRetryAction]"
3464 policy_set_and_test "-NRA" "NonBlockingRestore NoRetryAction"
3465 policy_set_and_test "NRA NBR" "[NonBlockingRestore] [NoRetryAction]"
3466 # useless bacause we know but safer for futur changes to use real value
3467 local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
3468 echo "Next set_param must failed"
3469 policy_set_and_test "wrong" "$policy"
3472 echo "Back to default policy"
3473 cdt_set_sanity_policy
3475 run_test 109 "Policy display/change"
3478 # test needs a running copytool
3483 copy2archive /etc/passwd $tdir/$tfile
3485 local f=$DIR/$tdir/$tfile
3486 import_file $tdir/$tfile $f
3487 local fid=$(path2fid $f)
3489 cdt_set_non_blocking_restore
3494 wait_request_state $fid RESTORE SUCCEED
3495 cdt_clear_non_blocking_restore
3499 error "md5sum returns $st != 1, "\
3500 "should also perror ENODATA (No data available)"
3504 run_test 110a "Non blocking restore policy (import case)"
3507 # test needs a running copytool
3511 local f=$DIR/$tdir/$tfile
3512 local fid=$(copy_file /etc/passwd $f)
3513 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3514 wait_request_state $fid ARCHIVE SUCCEED
3517 cdt_set_non_blocking_restore
3522 wait_request_state $fid RESTORE SUCCEED
3523 cdt_clear_non_blocking_restore
3527 error "md5sum returns $st != 1, "\
3528 "should also perror ENODATA (No data available)"
3532 run_test 110b "Non blocking restore policy (release case)"
3535 # test needs a running copytool
3539 copy2archive /etc/passwd $tdir/$tfile
3541 local f=$DIR/$tdir/$tfile
3543 import_file $tdir/$tfile $f
3544 local fid=$(path2fid $f)
3548 copytool_remove_backend $fid
3551 wait_request_state $fid RESTORE FAILED
3558 [[ $st == 0 ]] || error "Restore does not failed"
3562 run_test 111a "No retry policy (import case), restore will error"\
3563 " (No such file or directory)"
3566 # test needs a running copytool
3570 local f=$DIR/$tdir/$tfile
3571 local fid=$(copy_file /etc/passwd $f)
3573 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3574 wait_request_state $fid ARCHIVE SUCCEED
3577 copytool_remove_backend $fid
3580 wait_request_state $fid RESTORE FAILED
3587 [[ $st == 0 ]] || error "Restore does not failed"
3591 run_test 111b "No retry policy (release case), restore will error"\
3592 " (No such file or directory)"
3595 # test needs a running copytool
3599 local f=$DIR/$tdir/$tfile
3600 local fid=$(copy_file /etc/passwd $f)
3602 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3603 local l=$($LFS hsm_action $f)
3605 local res=$(echo $l | cut -f 2- -d" " | grep ARCHIVE)
3609 wait_request_state $fid ARCHIVE SUCCEED
3612 [[ ! -z "$res" ]] || error "action is $l which is not an ARCHIVE"
3616 run_test 112 "State of recorded request"
3619 # test needs a running copytool
3623 local f=$DIR/$tdir/$tfile
3625 fid=$(make_large_for_cancel $f)
3626 [ $? != 0 ] && skip "not enough free space" && return
3628 # test with cdt on is made in test_221
3630 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3633 wait_request_state $fid ARCHIVE CANCELED
3634 wait_request_state $fid CANCEL SUCCEED
3638 run_test 200 "Register/Cancel archive"
3641 # test needs a running copytool
3645 local f=$DIR/$tdir/$tfile
3646 make_archive $tdir/$tfile
3647 import_file $tdir/$tfile $f
3648 local fid=$(path2fid $f)
3650 # test with cdt on is made in test_222
3655 wait_request_state $fid RESTORE CANCELED
3656 wait_request_state $fid CANCEL SUCCEED
3660 run_test 201 "Register/Cancel restore"
3663 # test needs a running copytool
3667 local f=$DIR/$tdir/$tfile
3669 fid=$(make_large_for_progress $f)
3670 [ $? != 0 ] && skip "not enough free space" && return
3672 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3673 wait_request_state $fid ARCHIVE SUCCEED
3679 wait_request_state $fid REMOVE CANCELED
3683 run_test 202 "Register/Cancel remove"
3686 # test needs a running copytool
3691 local f=$DIR/$tdir/$tfile
3692 local fid=$(copy_file /etc/passwd $f)
3696 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3697 wait_request_state $fid ARCHIVE SUCCEED
3699 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3703 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3707 run_test 220 "Changelog for archive"
3710 # test needs a running copytool
3715 local f=$DIR/$tdir/$tfile
3717 fid=$(make_large_for_cancel $f)
3718 [ $? != 0 ] && skip "not enough free space" && return
3722 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3723 wait_request_state $fid ARCHIVE STARTED
3725 wait_request_state $fid ARCHIVE CANCELED
3726 wait_request_state $fid CANCEL SUCCEED
3728 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3731 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3735 run_test 221 "Changelog for archive canceled"
3738 # test needs a running copytool
3742 copy2archive /etc/passwd $tdir/$tfile
3744 local f=$DIR/$tdir/$tfile
3745 import_file $tdir/$tfile $f
3746 local fid=$(path2fid $f)
3751 wait_request_state $fid RESTORE SUCCEED
3753 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3756 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3760 run_test 222a "Changelog for explicit restore"
3763 # test needs a running copytool
3767 local f=$DIR/$tdir/$tfile
3768 local fid=$(copy_file /etc/passwd $f)
3771 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3772 wait_request_state $fid ARCHIVE SUCCEED
3777 wait_request_state $fid RESTORE SUCCEED
3779 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3782 [[ $flags == $target ]] || error "Changelog flag is $flags not $target"
3786 run_test 222b "Changelog for implicit restore"
3789 # test needs a running copytool
3794 local f=$DIR/$tdir/$tfile
3795 make_archive $tdir/$tfile
3799 import_file $tdir/$tfile $f
3800 local fid=$(path2fid $f)
3803 wait_request_state $fid RESTORE STARTED
3805 wait_request_state $fid RESTORE CANCELED
3806 wait_request_state $fid CANCEL SUCCEED
3808 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3811 [[ $flags == $target ]] ||
3812 error "Changelog flag is $flags not $target"
3816 run_test 223a "Changelog for restore canceled (import case)"
3819 # test needs a running copytool
3824 local f=$DIR/$tdir/$tfile
3826 fid=$(make_large_for_progress $f)
3827 [ $? != 0 ] && skip "not enough free space" && return
3830 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3831 wait_request_state $fid ARCHIVE SUCCEED
3834 wait_request_state $fid RESTORE STARTED
3836 wait_request_state $fid RESTORE CANCELED
3837 wait_request_state $fid CANCEL SUCCEED
3839 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -1)
3842 [[ $flags == $target ]] ||
3843 error "Changelog flag is $flags not $target"
3847 run_test 223b "Changelog for restore canceled (release case)"
3850 # test needs a running copytool
3855 local f=$DIR/$tdir/$tfile
3856 local fid=$(copy_file /etc/passwd $f)
3859 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3860 wait_request_state $fid ARCHIVE SUCCEED
3863 wait_request_state $fid REMOVE SUCCEED
3865 local flags=$(changelog_get_flags ${MDT[0]} HSM $fid | tail -n 1)
3868 [[ $flags == $target ]] ||
3869 error "Changelog flag is $flags not $target"
3873 run_test 224 "Changelog for remove"
3876 # test needs a running copytool
3879 # test is not usable because remove request is too fast
3880 # so it is always finished before cancel can be done ...
3881 echo "Test disabled"
3886 local f=$DIR/$tdir/$tfile
3888 fid=$(make_large_for_progress $f)
3889 [ $? != 0 ] && skip "not enough free space" && return
3892 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
3893 wait_request_state $fid ARCHIVE SUCCEED
3895 # if cdt is on, it can serve too quickly the request
3900 wait_request_state $fid REMOVE CANCELED
3901 wait_request_state $fid CANCEL SUCCEED
3903 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3904 local flags=$($LFS changelog ${MDT[0]} | grep HSM | grep $fid |
3905 tail -n 1 | awk '{print $5}')
3908 [[ $flags == $target ]] ||
3909 error "Changelog flag is $flags not $target"
3913 run_test 225 "Changelog for remove canceled"
3916 # test needs a running copytool
3921 local f1=$DIR/$tdir/$tfile-1
3922 local f2=$DIR/$tdir/$tfile-2
3923 local f3=$DIR/$tdir/$tfile-3
3924 local fid1=$(copy_file /etc/passwd $f1)
3925 local fid2=$(copy_file /etc/passwd $f2)
3926 copy_file /etc/passwd $f3
3929 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f1
3930 wait_request_state $fid1 ARCHIVE SUCCEED
3932 $LFS hsm_archive $f2
3933 wait_request_state $fid2 ARCHIVE SUCCEED
3935 rm $f1 || error "rm $f1 failed"
3937 local flags=$(changelog_get_flags ${MDT[0]} UNLNK $fid1)
3940 [[ $flags == $target ]] ||
3941 error "Changelog flag is $flags not $target"
3943 mv $f3 $f2 || error "mv $f3 $f2 failed"
3945 flags=$(changelog_get_flags ${MDT[0]} RENME $fid2)
3948 [[ $flags == $target ]] ||
3949 error "Changelog flag is $flags not $target"
3953 run_test 226 "changelog for last rm/mv with exiting archive"
3955 check_flags_changes() {
3963 $LFS hsm_set --$hsm_flag $f ||
3964 error "Cannot set $hsm_flag on $f"
3965 local flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3966 local seen=${#flags[*]}
3968 [[ $seen == $cnt ]] ||
3969 error "set $hsm_flag: Changelog events $seen != $cnt"
3970 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3971 error "set $hsm_flag: Changelog flags are "\
3972 "${flags[$((cnt - 1))]} not $target"
3974 $LFS hsm_clear --$hsm_flag $f ||
3975 error "Cannot clear $hsm_flag on $f"
3976 flags=($(changelog_get_flags ${MDT[0]} HSM $fid))
3979 [[ $cnt == $seen ]] ||
3980 error "clear $hsm_flag: Changelog events $seen != $cnt"
3982 [[ ${flags[$((cnt - 1))]} == $target ]] ||
3983 error "clear $hsm_flag: Changelog flag is "\
3984 "${flags[$((cnt - 1))]} not $target"
3988 # test needs a running copytool
3995 for i in norelease noarchive exists archived
3997 local f=$DIR/$tdir/$tfile-$i
3998 local fid=$(copy_file /etc/passwd $f)
3999 check_flags_changes $f $fid $i 0 1
4002 f=$DIR/$tdir/$tfile---lost
4003 fid=$(copy_file /etc/passwd $f)
4004 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
4005 wait_request_state $fid ARCHIVE SUCCEED
4006 check_flags_changes $f $fid lost 3 1
4010 run_test 227 "changelog when explicit setting of HSM flags"
4013 # test needs a running copytool
4016 local fid=$(make_small_sync $DIR/$tfile)
4017 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tfile
4018 wait_request_state $fid ARCHIVE SUCCEED
4020 $LFS hsm_release $DIR/$tfile
4021 check_hsm_flags $DIR/$tfile "0x0000000d"
4023 filefrag $DIR/$tfile | grep " 1 extent found" ||
4024 error "filefrag on released file must return only one extent"
4026 # only newer versions of cp detect sparse files by stat/FIEMAP
4028 cp --sparse=auto $DIR/$tfile $DIR/$tfile.2 ||
4029 error "copying $DIR/$tfile"
4030 cmp $DIR/$tfile $DIR/$tfile.2 || error "comparing copied $DIR/$tfile"
4032 $LFS hsm_release $DIR/$tfile
4033 check_hsm_flags $DIR/$tfile "0x0000000d"
4035 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
4037 tar cf - --sparse $DIR/$tfile | tar xvf - -C $DIR/$tdir ||
4039 cmp $DIR/$tfile $DIR/$tdir/$DIR/$tfile ||
4040 error "comparing untarred $DIR/$tfile"
4042 rm -f $DIR/$tfile $DIR/$tfile.2 ||
4043 error "rm $DIR/$tfile or $DIR/$tfile.2 failed"
4046 run_test 228 "On released file, return extend to FIEMAP. For [cp,tar] --sparse"
4049 # test needs a running copytool
4053 local maxrequest=$(get_hsm_param max_requests)
4054 local rqcnt=$(($maxrequest * 3))
4058 for i in $(seq -w 1 $rqcnt); do
4060 dd if=/dev/urandom of=$DIR/$tdir/$i bs=1M count=10 conv=fsync
4062 # we do it in 2 steps, so all requests arrive at the same time
4063 for i in $(seq -w 1 $rqcnt); do
4064 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$i
4069 while [[ $cnt != 0 || $wt != 0 ]]; do
4071 cnt=$(do_facet $SINGLEMDS "$LCTL get_param -n\
4072 $HSM_PARAM.actions |\
4073 grep STARTED | grep -v CANCEL | wc -l")
4074 [[ $cnt -le $maxrequest ]] ||
4075 error "$cnt > $maxrequest too many started requests"
4076 wt=$(do_facet $SINGLEMDS "$LCTL get_param\
4077 $HSM_PARAM.actions |\
4078 grep WAITING | wc -l")
4079 echo "max=$maxrequest started=$cnt waiting=$wt"
4084 run_test 250 "Coordinator max request"
4087 # test needs a running copytool
4091 local f=$DIR/$tdir/$tfile
4093 fid=$(make_large_for_cancel $f)
4094 [ $? != 0 ] && skip "not enough free space" && return
4097 # to have a short test
4098 local old_to=$(get_hsm_param active_request_timeout)
4099 set_hsm_param active_request_timeout 4
4100 # to be sure the cdt will wake up frequently so
4101 # it will be able to cancel the "old" request
4102 local old_loop=$(get_hsm_param loop_period)
4103 set_hsm_param loop_period 2
4106 # clear locks to avoid extra delay caused by flush/cancel
4107 # and thus prevent early copytool death to timeout.
4108 cancel_lru_locks osc
4110 $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
4111 wait_request_state $fid ARCHIVE STARTED
4113 wait_request_state $fid ARCHIVE CANCELED
4115 set_hsm_param active_request_timeout $old_to
4116 set_hsm_param loop_period $old_loop
4120 run_test 251 "Coordinator request timeout"
4123 # the only way to test ondisk conf is to restart MDS ...
4124 echo "Stop coordinator and remove coordinator state at mount"
4127 # clean on disk conf set by default
4128 cdt_clear_mount_state
4129 cdt_check_state stopped
4131 # check cdt still off after umount/remount
4133 cdt_check_state stopped
4135 echo "Set coordinator start at mount, and start coordinator"
4136 cdt_set_mount_state enabled
4139 cdt_check_state enabled
4141 # check cdt still on after umount/remount
4143 cdt_check_state enabled
4145 # we are back to original state (cdt started at mount)
4147 run_test 300 "On disk coordinator state kept between MDT umount/mount"
4150 local ai=$(get_hsm_param default_archive_id)
4151 local new=$((ai + 1))
4153 set_hsm_param default_archive_id $new -P
4155 local res=$(get_hsm_param default_archive_id)
4158 set_hsm_param default_archive_id "" "-P -d"
4160 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
4162 run_test 301 "HSM tunnable are persistent"
4165 local ai=$(get_hsm_param default_archive_id)
4166 local new=$((ai + 1))
4171 set_hsm_param default_archive_id $new -P
4174 for mdtno in $(seq 1 $MDSCOUNT); do
4179 cdt_check_state enabled
4181 local res=$(get_hsm_param default_archive_id)
4184 set_hsm_param default_archive_id "" "-P -d"
4186 [[ $new == $res ]] || error "Value after MDS restart is $res != $new"
4188 run_test 302 "HSM tunnable are persistent when CDT is off"
4191 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4197 local dir_mdt0=$DIR/$tdir/mdt0
4198 local dir_mdt1=$DIR/$tdir/mdt1
4200 # create 1 dir per MDT
4201 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
4202 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
4204 # create 1 file in each MDT
4205 local fid1=$(make_small $dir_mdt0/$tfile)
4206 local fid2=$(make_small $dir_mdt1/$tfile)
4208 # check that hsm request on mdt0 is sent to the right MDS
4209 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
4210 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
4211 echo "archive successful on mdt0"
4213 # check that hsm request on mdt1 is sent to the right MDS
4214 $LFS hsm_archive $dir_mdt1/$tfile || error "lfs hsm_archive"
4215 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
4216 echo "archive successful on mdt1"
4219 # clean test files and directories
4220 rm -rf $dir_mdt0 $dir_mdt1
4222 run_test 400 "Single request is sent to the right MDT"
4225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4231 local dir_mdt0=$DIR/$tdir/mdt0
4232 local dir_mdt1=$DIR/$tdir/mdt1
4234 # create 1 dir per MDT
4235 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
4236 $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
4238 # create 1 file in each MDT
4239 local fid1=$(make_small $dir_mdt0/$tfile)
4240 local fid2=$(make_small $dir_mdt1/$tfile)
4242 # check that compound requests are shunt to the rights MDTs
4243 $LFS hsm_archive $dir_mdt0/$tfile $dir_mdt1/$tfile ||
4244 error "lfs hsm_archive"
4245 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
4246 echo "archive successful on mdt0"
4247 wait_request_state $fid2 ARCHIVE SUCCEED 1 &&
4248 echo "archive successful on mdt1"
4251 # clean test files and directories
4252 rm -rf $dir_mdt0 $dir_mdt1
4254 run_test 401 "Compound requests split and sent to their respective MDTs"
4256 mdc_change_state() # facet, MDT_pattern, activate|deactivate
4261 local node=$(facet_active_host $facet)
4263 for mdc in $(do_facet $facet "$LCTL dl | grep -E ${pattern}-mdc" |
4264 awk '{print $4}'); do
4265 echo "$3 $mdc on $node"
4266 do_facet $facet "$LCTL --device $mdc $state" || return 1
4271 # make sure there is no running copytool
4274 # deactivate all mdc on agent1
4275 mdc_change_state $SINGLEAGT "$FSNAME-MDT000." "deactivate"
4277 HSMTOOL_NOERROR=true copytool_setup $SINGLEAGT
4279 check_agent_unregistered "uuid" # match any agent
4281 # no expected running copytool
4282 search_copytools $agent && error "Copytool start should have failed"
4285 mdc_change_state $SINGLEAGT "$FSNAME-MDT000." "activate"
4287 run_test 402 "Copytool start fails if all MDTs are inactive"
4290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4292 # make sure there is no running copytool
4295 local agent=$(facet_active_host $SINGLEAGT)
4296 local uuid=$(do_rpc_nodes $agent get_client_uuid | cut -d' ' -f2)
4298 # deactivate all mdc for MDT0001
4299 mdc_change_state $SINGLEAGT "$FSNAME-MDT0001" "deactivate"
4302 # check the agent is registered on MDT0000, and not on MDT0001
4303 check_agent_registered_by_mdt $uuid 0
4304 check_agent_unregistered_by_mdt $uuid 1
4306 # check running copytool process
4307 search_copytools $agent || error "No running copytools on $agent"
4309 # reactivate all mdc for MDT0001
4310 mdc_change_state $SINGLEAGT "$FSNAME-MDT0001" "activate"
4312 # make sure the copytool is now registered to all MDTs
4313 check_agent_registered $uuid
4317 run_test 403 "Copytool starts with inactive MDT and register on reconnect"
4320 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4324 # create files on both MDT0000 and MDT0001
4327 local dir_mdt0=$DIR/$tdir/mdt0
4328 $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
4330 # create 1 file on mdt0
4331 local fid1=$(make_small $dir_mdt0/$tfile)
4333 # deactivate all mdc for MDT0001
4334 mdc_change_state $SINGLEAGT "$FSNAME-MDT0001" "deactivate"
4336 # send an HSM request for files in MDT0000
4337 $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
4339 # check for completion of files in MDT0000
4340 wait_request_state $fid1 ARCHIVE SUCCEED 0 &&
4341 echo "archive successful on mdt0"
4343 # reactivate all mdc for MDT0001
4344 mdc_change_state $SINGLEAGT "$FSNAME-MDT0001" "activate"
4347 # clean test files and directories
4350 run_test 404 "Inactive MDT does not block requests for active MDTs"
4353 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4359 local striped_dir=$DIR/$tdir/striped_dir
4361 # create striped dir on all of MDTs
4362 $LFS mkdir -i 0 -c $MDSCOUNT $striped_dir || error "lfs mkdir"
4364 local fid1=$(make_small_sync $striped_dir/${tfile}_0)
4365 local fid2=$(make_small_sync $striped_dir/${tfile}_1)
4366 local fid3=$(make_small_sync $striped_dir/${tfile}_2)
4367 local fid4=$(make_small_sync $striped_dir/${tfile}_3)
4369 local idx1=$($LFS getstripe -M $striped_dir/${tfile}_0)
4370 local idx2=$($LFS getstripe -M $striped_dir/${tfile}_1)
4371 local idx3=$($LFS getstripe -M $striped_dir/${tfile}_2)
4372 local idx4=$($LFS getstripe -M $striped_dir/${tfile}_3)
4374 # check that compound requests are shunt to the rights MDTs
4375 $LFS hsm_archive $striped_dir/${tfile}_0 $striped_dir/${tfile}_1 \
4376 $striped_dir/${tfile}_2 $striped_dir/${tfile}_3 ||
4377 error "lfs hsm_archive"
4379 wait_request_state $fid1 ARCHIVE SUCCEED $idx1 &&
4380 echo "archive successful on $fid1"
4381 wait_request_state $fid2 ARCHIVE SUCCEED $idx2 &&
4382 echo "archive successful on $fid2"
4383 wait_request_state $fid3 ARCHIVE SUCCEED $idx3 &&
4384 echo "archive successful on $fid3"
4385 wait_request_state $fid4 ARCHIVE SUCCEED $idx4 &&
4386 echo "archive successful on $fid4"
4388 $LFS hsm_release $striped_dir/${tfile}_0 || error "lfs hsm_release 1"
4389 $LFS hsm_release $striped_dir/${tfile}_1 || error "lfs hsm_release 2"
4390 $LFS hsm_release $striped_dir/${tfile}_2 || error "lfs hsm_release 3"
4391 $LFS hsm_release $striped_dir/${tfile}_3 || error "lfs hsm_release 4"
4393 cat $striped_dir/${tfile}_0 > /dev/null || error "cat ${tfile}_0 failed"
4394 cat $striped_dir/${tfile}_1 > /dev/null || error "cat ${tfile}_1 failed"
4395 cat $striped_dir/${tfile}_2 > /dev/null || error "cat ${tfile}_2 failed"
4396 cat $striped_dir/${tfile}_3 > /dev/null || error "cat ${tfile}_3 failed"
4400 run_test 405 "archive and release under striped directory"
4404 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
4405 skip "HSM migrate is not supported" && return
4407 # Stop the existing copytool
4410 test_mkdir -p $DIR/$tdir
4411 llapi_hsm_test -d $DIR/$tdir || error "One llapi HSM test failed"
4413 run_test 500 "various LLAPI HSM tests"
4418 check_and_cleanup_lustre