Whamcloud - gitweb
LU-8950 tests: standardize file creation in sanity-hsm 04/24704/8
authorQuentin Bouget <quentin.bouget@cea.fr>
Thu, 8 Dec 2016 15:30:44 +0000 (16:30 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 29 Nov 2017 05:59:25 +0000 (05:59 +0000)
sanity-hsm exposed several functions to create files:
 - make_small()
 - make_small_sync()
 - make_archive()

This patch renames all these functions (respectively):
 - create_small_file()
 - create_small_sync_file()
 - create_archive()

And adds a new one: create_empty_file() which creates an empty file

The actual file_creation is now abstracted in the create_file()
function used by all the aforementionned functions.

Test-Parameters: trivial testlist=sanity-hsm
Signed-off-by: Quentin Bouget <quentin.bouget@cea.fr>
Change-Id: Ib4267827eb2e31ed396da1d711419f45f9e0ef16
Reviewed-on: https://review.whamcloud.com/24704
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity-hsm.sh

index 7ea4766..0afa7e1 100755 (executable)
@@ -394,11 +394,82 @@ import_file() {
                error "import of $1 to $2 failed"
 }
 
-make_archive() {
-       local file=$HSM_ARCHIVE/$1
-       do_facet $SINGLEAGT mkdir -p $(dirname $file)
-       do_facet $SINGLEAGT dd if=/dev/urandom of=$file count=32 bs=1000000 ||
-               file_creation_failure dd $file $?
+file_creation_failure() {
+       local cmd=$1
+       local file=$2
+       local err=$3
+
+       case $err in
+       28)
+               df $MOUNT $MOUNT2 >&2
+               error "Not enough space to create $file with $cmd"
+               ;;
+       *)
+               error "cannot create $file with $cmd, status=$err"
+               ;;
+       esac
+}
+
+# Creates a file using dd
+create_file() {
+       local file=$1
+       local bs=$2
+       local count=$3
+       local conv=$4
+       local if=${5:-/dev/zero}
+       local facet=$SINGLEAGT
+
+       local cmd
+       printf -v cmd 'do_facet "%s" dd if="%s" of="%s" count=%s bs=%s' \
+               "$facet" "$if" "$file" "$count" "$bs"
+       [ -n "$conv" ] && cmd+=" conv=$conv"
+
+       # Create the directory in case it does not exist
+       do_facet "$facet" mkdir -p "$(dirname "$file")"
+       # Delete the file in case it already exist
+       do_facet "$facet" rm -f "$file"
+
+       if eval "$cmd"; then
+               # print the FID if the file is not an archive
+               [[ "$file" =~ ^$HSM_ARCHIVE ]] || path2fid "$file" ||
+                       error "cannot get fid on '$file'"
+       else
+               local err=$?
+               printf "$cmd failed with $err\n" >&2;
+               # Let the caller decide what to do on error
+               return $err;
+       fi
+}
+
+create_empty_file() {
+       create_file "${1/$DIR/$DIR2}" 1M 0 ||
+               file_creation_failure dd "${1/$DIR/$DIR2}" $?
+}
+
+create_small_file() {
+       local source_file=/dev/urandom
+       local count=1
+       local bs=1M
+       local conv=${2:-fsync}
+
+       create_file "${1/$DIR/$DIR2}" $bs $count $conv $source_file ||
+               file_creation_failure dd "${1/$DIR/$DIR2}" $?
+}
+
+create_small_sync_file() {
+       create_small_file "$1" sync
+}
+
+create_archive_file() {
+       local if=/dev/urandom
+       local count=${2:-39}
+       local bs=1M
+       local facet=$SINGLEAGT
+
+       # Create the counterpart directory of the archive
+       do_facet "$facet" mkdir -p "$DIR2/$(dirname "$1")"
+       create_file "${HSM_ARCHIVE}/$1" $bs $count "" $if ||
+               file_creation_failure dd "${HSM_ARCHIVE}/$1" $?
 }
 
 copy2archive() {
@@ -628,15 +699,6 @@ check_hsm_flags_user() {
        [[ $st == $fl ]] || error "hsm flags on $f are $st != $fl"
 }
 
-file_creation_failure() {
-       local cmd=$1
-       local f=$2
-       local err=$3
-
-       df $MOUNT $MOUNT2 >&2
-       error "cannot create $f with $cmd, status=$err"
-}
-
 copy_file() {
        local f=
 
@@ -655,49 +717,31 @@ copy_file() {
        path2fid $f || error "cannot get fid on $f"
 }
 
-make_small() {
-        local file2=${1/$DIR/$DIR2}
-        dd if=/dev/urandom of=$file2 count=2 bs=1M conv=fsync ||
-               file_creation_failure dd $file2 $?
-
-        path2fid $1 || error "cannot get fid on $1"
-}
-
-make_small_sync() {
-       dd if=/dev/urandom of=$1 count=1 bs=1M conv=sync ||
-               file_creation_failure dd $1 $?
-       path2fid $1 || error "cannot get fid on $1"
-}
-
-cleanup_large_files() {
-       local ratio=$(df -P $MOUNT | tail -1 | awk '{print $5}' |
-                     sed 's/%//g')
-       [ $ratio -gt 50 ] && find $MOUNT -size +10M -exec rm -f {} \;
-}
-
-check_enough_free_space() {
-       local nb=$1
-       local unit=$2
-       local need=$((nb * unit /1024))
-       local free=$(df -kP $MOUNT | tail -1 | awk '{print $4}')
-       (( $need >= $free )) && return 1
-       return 0
+# Delete any file bigger than 10M under $MOUNT and wait for deletes to complete
+#
+# Note that this might lead to surprising behaviours such as deleting an
+# important file for the currently running test
+delete_large_files() {
+       printf "Deleting large files...\n" >&2
+       find $MOUNT -size +10M -delete
+       wait_delete_completed
 }
 
 make_custom_file_for_progress() {
-       local file2=${1/$DIR/$DIR2}
-       local fsize=${2:-"39"}
-       local blksz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -n1)
-       blksz=${3:-$blksz}
-
-       [[ $fsize -gt  0 ]] || error "Invalid file size"
-       [[ $blksz -gt 0 ]] || error "Invalid stripe size"
-
-       cleanup_large_files
-       check_enough_free_space $fsize $blksz || return $?
-       dd if=/dev/zero of=$file2 count=$fsize bs=$blksz conv=fsync ||
-               file_creation_failure dd $file2 $?
-       path2fid $1 || error "cannot get fid on $1"
+       local count=${2:-"39"}
+       local bs=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -n1)
+       bs=${3:-$bs}
+
+       [[ $count -gt  0 ]] || error "Invalid file size"
+       [[ $bs -gt 0 ]] || error "Invalid stripe size"
+
+       if ! create_file "${1/$DIR/$DIR2}" $bs $count fsync; then
+               echo "The creation of '${1/$DIR/$DIR2}' failed" >&2
+               echo "It might be due to a lack of space in the filesystem" >&2
+               delete_large_files >&2
+               create_file "${1/$DIR/$DIR2}" $bs $count fsync ||
+                       file_creation_failure dd "${1/$DIR/$DIR2}" $?
+       fi
 }
 
 wait_result() {
@@ -898,9 +942,8 @@ test_1() {
 run_test 1 "lfs hsm flags root/non-root access"
 
 test_1a() {
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
 
        copytool_setup
 
@@ -951,9 +994,9 @@ test_1b() {
 run_test 1b "Archive, Release & Restore composite file"
 
 test_2() {
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       touch $f
+
+       create_empty_file "$f"
        # New files are not dirty
        check_hsm_flags $f "0x00000000"
 
@@ -1034,9 +1077,8 @@ test_3() {
 run_test 3 "Check file dirtyness when opening for write"
 
 test_4() {
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
 
        $LFS hsm_cancel $f
        local st=$(get_request_state $fid CANCEL)
@@ -1099,10 +1141,9 @@ test_9a() {
 
        trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
        # archive files
-       mkdir -p $DIR/$tdir
        for n in $(seq $AGTCOUNT); do
                file=$DIR/$tdir/$tfile.$n
-               fid=$(make_small $file)
+               fid=$(create_small_file $file)
 
                $LFS hsm_archive $file || error "could not archive file $file"
                wait_request_state $fid ARCHIVE SUCCEED
@@ -1303,9 +1344,9 @@ test_12c() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       $LFS setstripe -c 2 $f
+       mkdir -p $DIR/$tdir
+       $LFS setstripe -c 2 "$f"
        local fid
        fid=$(make_custom_file_for_progress $f 5)
        [ $? != 0 ] && skip "not enough free space" && return
@@ -1574,10 +1615,9 @@ test_12q() {
        # test needs a running copytool
        copytool_setup $SINGLEAGT $MOUNT3
 
-       mkdir $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local f2=$DIR2/$tdir/$tfile
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
        local orig_size=$(stat -c "%s" $f)
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -1670,18 +1710,14 @@ test_14() {
        copytool_setup
 
        # archive a file
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
        local sum=$(md5sum $f | awk '{print $1}')
        $LFS hsm_archive $f || error "could not archive file"
        wait_request_state $fid ARCHIVE SUCCEED
 
-       # delete the file
-       rm -f $f
        # create released file (simulate llapi_hsm_import call)
-       touch $f
-       local fid2=$(path2fid $f)
+       local fid2=$(create_empty_file "$f")
        $LFS hsm_set --archived --exists $f || error "could not force hsm flags"
        $LFS hsm_release $f || error "could not release file"
 
@@ -1706,7 +1742,6 @@ test_15() {
        copytool_setup
 
        # archive files
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local count=5
        local tmpfile=$SHARED_DIRECTORY/tmp.$$
@@ -1714,7 +1749,7 @@ test_15() {
        local fids=()
        local sums=()
        for i in $(seq 1 $count); do
-               fids[$i]=$(make_small $f.$i)
+               fids[$i]=$(create_small_file $f.$i)
                sums[$i]=$(md5sum $f.$i | awk '{print $1}')
                $LFS hsm_archive $f.$i || error "could not archive file"
        done
@@ -1723,9 +1758,7 @@ test_15() {
        :>$tmpfile
        # delete the files
        for i in $(seq 1 $count); do
-               rm -f $f.$i
-               touch $f.$i
-               local fid2=$(path2fid $f.$i)
+               local fid2=$(create_empty_file "${f}.${i}")
                # add the rebind operation to the list
                echo ${fids[$i]} $fid2 >> $tmpfile
 
@@ -1783,10 +1816,8 @@ test_16() {
 run_test 16 "Test CT bandwith control option"
 
 test_20() {
-       mkdir -p $DIR/$tdir
-
        local f=$DIR/$tdir/$tfile
-       touch $f || error "touch $f failed"
+       create_empty_file "$f"
 
        # Could not release a non-archived file
        $LFS hsm_release $f && error "release should not succeed"
@@ -1815,11 +1846,10 @@ test_21() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/test_release
 
        # Create a file and check its states
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
        check_hsm_flags $f "0x00000000"
 
        # LU-4388/LU-4389 - ZFS does not report full number of blocks
@@ -1884,13 +1914,11 @@ test_22() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-
        local f=$DIR/$tdir/test_release
        local swap=$DIR/$tdir/test_swap
 
        # Create a file and check its states
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
        check_hsm_flags $f "0x00000000"
 
        $LFS hsm_archive $f || error "could not archive file"
@@ -1900,7 +1928,7 @@ test_22() {
        $LFS hsm_release $f || error "could not release file"
        check_hsm_flags $f "0x0000000d"
 
-       make_small $swap
+       create_small_file $swap
        $LFS swap_layouts $swap $f && error "swap_layouts should failed"
 
        true
@@ -1912,12 +1940,10 @@ test_23() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-
        local f=$DIR/$tdir/test_mtime
 
        # Create a file and check its states
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
        check_hsm_flags $f "0x00000000"
 
        $LFS hsm_archive $f || error "could not archive file"
@@ -1952,9 +1978,7 @@ test_24a() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-       rm -f $file
-       fid=$(make_small $file)
+       fid=$(create_small_file $file)
 
        # Create a file and check its states
        check_hsm_flags $file "0x00000000"
@@ -2054,11 +2078,9 @@ test_24b() {
 
        # Test needs a running copytool.
        copytool_setup
-       mkdir -p $DIR/$tdir
 
        # Check that root can do HSM actions on a regular user's file.
-       rm -f $file
-       fid=$(make_small $file)
+       fid=$(create_small_file $file)
        sum0=$(md5sum $file)
 
        chown $RUNAS_ID:$RUNAS_GID $file ||
@@ -2129,8 +2151,7 @@ test_24c() {
        trap cleanup_test_24c EXIT
 
        # User.
-       rm -f $file
-       make_small $file
+       create_small_file $file
        chown $RUNAS_ID:nobody $file ||
                error "cannot chown '$file' to '$RUNAS_ID:nobody'"
 
@@ -2142,8 +2163,7 @@ test_24c() {
                error "$action by user should succeed"
 
        # Group.
-       rm -f $file
-       make_small $file
+       create_small_file $file
        chown nobody:$RUNAS_GID $file ||
                error "cannot chown '$file' to 'nobody:$RUNAS_GID'"
 
@@ -2155,8 +2175,7 @@ test_24c() {
                error "$action by group should succeed"
 
        # Other.
-       rm -f $file
-       make_small $file
+       create_small_file $file
        chown nobody:nobody $file ||
                error "cannot chown '$file' to 'nobody:nobody'"
 
@@ -2183,9 +2202,7 @@ test_24d() {
        local fid1
        local fid2
 
-       mkdir -p $DIR/$tdir
-       rm -f $file1
-       fid1=$(make_small $file1)
+       fid1=$(create_small_file $file1)
 
        echo $fid1
        $LFS getstripe $file1
@@ -2228,12 +2245,10 @@ run_test 24d "check that read-only mounts are respected"
 test_24e() {
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-
        local f=$DIR/$tdir/$tfile
        local fid
 
-       fid=$(make_small $f) || error "cannot create $f"
+       fid=$(create_small_file $f) || error "cannot create $f"
        $LFS hsm_archive $f || error "cannot archive $f"
        wait_request_state $fid ARCHIVE SUCCEED
        $LFS hsm_release $f || error "cannot release $f"
@@ -2325,7 +2340,6 @@ test_26() {
        # 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)
@@ -2563,8 +2577,7 @@ test_27a() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-       make_archive $tdir/$tfile
+       create_archive_file $tdir/$tfile
        local f=$DIR/$tdir/$tfile
        import_file $tdir/$tfile $f
        local fid=$(path2fid $f)
@@ -2581,7 +2594,6 @@ 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)
@@ -2603,7 +2615,6 @@ 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)
@@ -2649,9 +2660,8 @@ test_29b() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       local fid=$(make_small $f)
+       local fid=$(create_small_file $f)
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
        wait_request_state $fid ARCHIVE SUCCEED
@@ -2669,10 +2679,9 @@ 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)
+       local fid1=$(create_small_file $DIR/$tdir/$tfile-1)
+       local fid2=$(create_small_file $DIR/$tdir/$tfile-2)
+       local fid3=$(create_small_file $DIR/$tdir/$tfile-3)
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tdir/$tfile-[1-3]
        wait_request_state $fid1 ARCHIVE SUCCEED
@@ -2712,9 +2721,8 @@ test_29d() {
 
        trap "copytool_cleanup $(comma_list $(agts_nodes))" EXIT
        # archive files
-       mkdir -p $DIR/$tdir
        file=$DIR/$tdir/$tfile
-       fid=$(make_small $file)
+       fid=$(create_small_file $file)
 
        $LFS hsm_archive $file
        wait_request_state $fid ARCHIVE SUCCEED
@@ -2908,9 +2916,7 @@ test_31a() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-
-       make_archive $tdir/$tfile
+       create_archive_file $tdir/$tfile
        local f=$DIR/$tdir/$tfile
        import_file $tdir/$tfile $f
        local fid=$($LFS path2fid $f)
@@ -2930,8 +2936,6 @@ test_31b() {
        # 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)
@@ -2954,8 +2958,6 @@ test_31c() {
        # 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 33 1048576)
@@ -2978,8 +2980,6 @@ test_33() {
        # 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)
@@ -3045,8 +3045,6 @@ test_34() {
        # 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)
@@ -3079,8 +3077,6 @@ test_35() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-
        local f=$DIR/$tdir/$tfile
        local f1=$DIR/$tdir/$tfile-1
        local fid
@@ -3118,8 +3114,6 @@ test_36() {
        # 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)
@@ -3154,11 +3148,10 @@ test_37() {
        copytool_cleanup
        copytool_setup $SINGLEAGT $MOUNT2
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
 
-       fid=$(make_small $f) || error "cannot create small file"
+       fid=$(create_small_file $f) || error "cannot create small file"
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
        wait_request_state $fid ARCHIVE SUCCEED
@@ -3303,7 +3296,6 @@ test_54() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid=$(make_custom_file_for_progress $f 39 1000000)
 
@@ -3331,7 +3323,6 @@ test_55() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid=$(make_custom_file_for_progress $f 39 1000000)
 
@@ -3359,7 +3350,6 @@ test_56() {
        # 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)
@@ -3500,7 +3490,6 @@ test_60() {
        copytool_cleanup
        HSMTOOL_UPDATE_INTERVAL=$interval copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
        fid=$(make_custom_file_for_progress $f 10)
@@ -3640,7 +3629,6 @@ test_71() {
        HSMTOOL_UPDATE_INTERVAL=$interval \
        HSMTOOL_EVENT_FIFO=$HSMTOOL_MONITOR_DIR/fifo copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
        fid=$(make_custom_file_for_progress $f 39 1000000)
@@ -3916,7 +3904,6 @@ DATA=CEA
 DATAHEX='[434541]'
 test_104() {
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
        fid=$(make_custom_file_for_progress $f 39 1000000)
@@ -4200,7 +4187,6 @@ test_200() {
        # 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 103 1048576)
@@ -4224,9 +4210,8 @@ test_201() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       make_archive $tdir/$tfile
+       create_archive_file $tdir/$tfile
        import_file $tdir/$tfile $f
        local fid=$(path2fid $f)
 
@@ -4248,7 +4233,6 @@ test_202() {
        # 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)
@@ -4334,8 +4318,6 @@ test_221() {
        # 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 103 1048576)
@@ -4479,10 +4461,8 @@ test_223a() {
        # test needs a running copytool
        copytool_setup
 
-       mkdir -p $DIR/$tdir
-
        local f=$DIR/$tdir/$tfile
-       make_archive $tdir/$tfile
+       create_archive_file $tdir/$tfile
 
        changelog_setup
 
@@ -4509,8 +4489,6 @@ test_223b() {
        # 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)
@@ -4613,7 +4591,6 @@ test_225() {
        copytool_cleanup
        return 0
 
-       mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
        fid=$(make_custom_file_for_progress $f 39 1000000)
@@ -4744,7 +4721,7 @@ test_228() {
        # test needs a running copytool
        copytool_setup
 
-       local fid=$(make_small_sync $DIR/$tfile)
+       local fid=$(create_small_sync_file $DIR/$tfile)
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tfile
        wait_request_state $fid ARCHIVE SUCCEED
 
@@ -4818,7 +4795,6 @@ test_251() {
        # 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 103 1048576)
@@ -4970,8 +4946,8 @@ test_400() {
        $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
 
        # create 1 file in each MDT
-       local fid1=$(make_small $dir_mdt0/$tfile)
-       local fid2=$(make_small $dir_mdt1/$tfile)
+       local fid1=$(create_small_file $dir_mdt0/$tfile)
+       local fid2=$(create_small_file $dir_mdt1/$tfile)
 
        # check that hsm request on mdt0 is sent to the right MDS
        $LFS hsm_archive $dir_mdt0/$tfile || error "lfs hsm_archive"
@@ -5004,8 +4980,8 @@ test_401() {
        $LFS mkdir -i 1 $dir_mdt1 || error "lfs mkdir"
 
        # create 1 file in each MDT
-       local fid1=$(make_small $dir_mdt0/$tfile)
-       local fid2=$(make_small $dir_mdt1/$tfile)
+       local fid1=$(create_small_file $dir_mdt0/$tfile)
+       local fid2=$(create_small_file $dir_mdt1/$tfile)
 
        # check that compound requests are shunt to the rights MDTs
        $LFS hsm_archive $dir_mdt0/$tfile $dir_mdt1/$tfile ||
@@ -5123,7 +5099,7 @@ test_404() {
        $LFS mkdir -i 0 $dir_mdt0 || error "lfs mkdir"
 
        # create 1 file on mdt0
-       local fid1=$(make_small $dir_mdt0/$tfile)
+       local fid1=$(create_small_file $dir_mdt0/$tfile)
 
        # deactivate all mdc for MDT0001
        mdc_change_state $SINGLEAGT "$FSNAME-MDT0001" "deactivate"
@@ -5156,10 +5132,10 @@ test_405() {
        # create striped dir on all of MDTs
        $LFS mkdir -i 0 -c $MDSCOUNT $striped_dir || error "lfs mkdir"
 
-       local fid1=$(make_small_sync $striped_dir/${tfile}_0)
-       local fid2=$(make_small_sync $striped_dir/${tfile}_1)
-       local fid3=$(make_small_sync $striped_dir/${tfile}_2)
-       local fid4=$(make_small_sync $striped_dir/${tfile}_3)
+       local fid1=$(create_small_sync_file $striped_dir/${tfile}_0)
+       local fid2=$(create_small_sync_file $striped_dir/${tfile}_1)
+       local fid3=$(create_small_sync_file $striped_dir/${tfile}_2)
+       local fid4=$(create_small_sync_file $striped_dir/${tfile}_3)
 
        local idx1=$($LFS getstripe -M $striped_dir/${tfile}_0)
        local idx2=$($LFS getstripe -M $striped_dir/${tfile}_1)
@@ -5204,8 +5180,7 @@ test_406() {
        local mdt_index
 
        copytool_setup
-       mkdir -p $DIR/$tdir
-       fid=$(make_small $DIR/$tdir/$tfile)
+       fid=$(create_small_file $DIR/$tdir/$tfile)
        echo "old fid $fid"
 
        $LFS hsm_archive $DIR/$tdir/$tfile