+ # set a long grace_delay vs short loop_period
+ local orig_loop_period=$(get_hsm_param loop_period)
+ local orig_grace_delay=$(get_hsm_param grace_delay)
+ set_hsm_param loop_period 10
+ set_hsm_param grace_delay 100
+
+ set_hsm_param remove_archive_on_last_unlink 1
+
+ multiop_bg_pause $f O_c || error "open $f failed"
+ local pid=$!
+
+ rm -f $f
+ rm -f $f2
+
+ wait_request_state $fid2 REMOVE SUCCEED
+ assert_request_count $fid REMOVE 0 \
+ "Unexpected archived data remove request for $f"
+
+ kill -USR1 $pid || error "multiop early exit"
+ # should reach autotest timeout if multiop fails to trap
+ # signal, close file, and exit ...
+ wait $pid || error
+
+ set_hsm_param remove_archive_on_last_unlink 0
+
+ wait_request_state $fid REMOVE SUCCEED
+
+ cleanup_test_26c
+}
+run_test 26c "RAoLU effective when file closed"
+
+cleanup_test_26d() {
+ trap 0
+ set_hsm_param remove_archive_on_last_unlink 0
+ set_hsm_param loop_period $orig_loop_period
+ set_hsm_param grace_delay $orig_grace_delay
+ copytool_cleanup
+}
+
+test_26d() {
+
+ # test needs a running copytool
+ copytool_setup
+
+ mkdir -p $DIR/$tdir
+ local f=$DIR/$tdir/$tfile
+ local fid=$(copy_file /etc/motd $f 1)
+
+ $LFS hsm_archive $f || error "could not archive file"
+ wait_request_state $fid ARCHIVE SUCCEED
+
+ trap cleanup_test_26d EXIT
+
+ # set a long grace_delay vs short loop_period
+ local orig_loop_period=$(get_hsm_param loop_period)
+ local orig_grace_delay=$(get_hsm_param grace_delay)
+ set_hsm_param loop_period 10
+ set_hsm_param grace_delay 100
+
+ set_hsm_param remove_archive_on_last_unlink 1
+
+ multiop_bg_pause $f O_c || error "multiop failed"
+ local MULTIPID=$!
+
+ rm -f $f
+
+ mds_evict_client
+
+ set_hsm_param remove_archive_on_last_unlink 0
+
+ wait_request_state $fid REMOVE SUCCEED
+
+ client_up || client_up || true
+
+ kill -USR1 $MULTIPID
+ wait $MULTIPID || error "multiop close failed"
+
+ cleanup_test_26d
+}
+run_test 26d "RAoLU when Client eviction"
+
+test_27a() {
+ # test needs a running copytool
+ copytool_setup
+
+ mkdir -p $DIR/$tdir
+ make_archive $tdir/$tfile
+ local f=$DIR/$tdir/$tfile
+ import_file $tdir/$tfile $f
+ local fid=$(path2fid $f)
+
+ $LFS hsm_remove $f
+
+ [[ $? != 0 ]] || error "Remove of a released file should fail"
+
+ copytool_cleanup
+}
+run_test 27a "Remove the archive of an imported file (Operation not permitted)"
+
+test_27b() {
+ # test needs a running copytool
+ copytool_setup
+
+ mkdir -p $DIR/$tdir
+ local f=$DIR/$tdir/$tfile
+ local fid
+ fid=$(make_custom_file_for_progress $f 39 1000000)
+ [ $? != 0 ] && skip "not enough free space" && return
+
+ $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
+ wait_request_state $fid ARCHIVE SUCCEED
+ $LFS hsm_release $f
+
+ $LFS hsm_remove $f
+
+ [[ $? != 0 ]] || error "Remove of a released file should fail"
+
+ copytool_cleanup
+}
+run_test 27b "Remove the archive of a relased file (Operation not permitted)"
+
+test_28() {
+ # test needs a running copytool
+ copytool_setup
+
+ mkdir -p $DIR/$tdir
+ local f=$DIR/$tdir/$tfile
+ local fid
+ fid=$(make_custom_file_for_progress $f 39 1000000)
+ [ $? != 0 ] && skip "not enough free space" && return
+
+ $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
+ wait_request_state $fid ARCHIVE SUCCEED
+
+ cdt_disable
+ $LFS hsm_remove $f
+
+ rm -f $f
+
+ cdt_enable
+
+ wait_request_state $fid REMOVE SUCCEED
+
+ copytool_cleanup
+}
+run_test 28 "Concurrent archive/file remove"
+
+test_29a() {
+ # Tests --mntpath and --archive options
+
+ local archive_id=7
+ copytool_setup $SINGLEAGT $MOUNT $archive_id
+
+ # Bad archive number
+ $LFS hsm_remove -m $MOUNT -a 33 0x857765760:0x8:0x2 2>&1 |
+ grep "Invalid argument" ||
+ error "unexpected hsm_remove failure (1)"
+
+ # mntpath is present but file is given
+ $LFS hsm_remove --mntpath $MOUNT --archive 30 /qwerty/uyt 2>&1 |
+ grep "hsm: '/qwerty/uyt' is not a valid FID" ||
+ error "unexpected hsm_remove failure (2)"
+
+ copytool_cleanup
+}
+run_test 29a "Tests --mntpath and --archive options"
+
+test_29b() {
+ # test needs a running copytool
+ copytool_setup
+
+ mkdir -p $DIR/$tdir
+ local f=$DIR/$tdir/$tfile
+ local fid=$(make_small $f)
+
+ $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
+ wait_request_state $fid ARCHIVE SUCCEED
+
+ rm -f $f
+
+ $LFS hsm_remove -m $MOUNT -a $HSM_ARCHIVE_NUMBER $fid
+ wait_request_state $fid REMOVE SUCCEED
+
+ copytool_cleanup
+}
+run_test 29b "Archive/delete/remove by FID from the archive."
+
+test_29c() {
+ # test needs a running copytool
+ copytool_setup
+
+ mkdir -p $DIR/$tdir
+ local fid1=$(make_small $DIR/$tdir/$tfile-1)
+ local fid2=$(make_small $DIR/$tdir/$tfile-2)
+ local fid3=$(make_small $DIR/$tdir/$tfile-3)
+
+ $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$tfile-[1-3]
+ wait_request_state $fid1 ARCHIVE SUCCEED
+ wait_request_state $fid2 ARCHIVE SUCCEED
+ wait_request_state $fid3 ARCHIVE SUCCEED
+
+ rm -f $DIR/$tdir/$tfile-[1-3]
+
+ echo $fid1 > $DIR/$tdir/list