diff options
author | Dan Kimmel <[email protected]> | 2017-04-11 21:56:54 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-04-26 12:31:43 -0700 |
commit | a7004725d0ad52fa005c29f68ce55273f11d95ac (patch) | |
tree | c91bcf6ef57512d1188ded6009dde602286cab3a /tests/zfs-tests/include/libtest.shlib | |
parent | 7a25f0891eef4adbe00dd03e26b6128dc99e170d (diff) |
OpenZFS 7252 - compressed zfs send / receive
OpenZFS 7252 - compressed zfs send / receive
OpenZFS 7628 - create long versions of ZFS send / receive options
Authored by: Dan Kimmel <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: John Kennedy <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Paul Dagnelie <[email protected]>
Reviewed by: Pavel Zakharov <[email protected]>
Reviewed by: Sebastien Roy <[email protected]>
Reviewed by: David Quigley <[email protected]>
Reviewed by: Thomas Caputi <[email protected]>
Approved by: Dan McDonald <[email protected]>
Reviewed by: David Quigley <[email protected]>
Reviewed-by: loli10K <[email protected]>
Ported-by: bunder2015 <[email protected]>
Ported-by: Don Brady <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>
Porting Notes:
- Most of 7252 was already picked up during ABD work. This
commit represents the gap from the final commit to openzfs.
- Fixed split_large_blocks check in do_dump()
- An alternate version of the write_compressible() function was
implemented for Linux which does not depend on fio. The behavior
of fio differs significantly based on the exact version.
- mkholes was replaced with truncate for Linux.
OpenZFS-issue: https://www.illumos.org/issues/7252
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/5602294
Closes #6067
Diffstat (limited to 'tests/zfs-tests/include/libtest.shlib')
-rw-r--r-- | tests/zfs-tests/include/libtest.shlib | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 8984071c8..07cf9a1e6 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -29,6 +29,7 @@ # . ${STF_TOOLS}/include/logapi.shlib +. ${STF_SUITE}/include/math.shlib # # Apply constrained path when available. This is required since the @@ -3112,6 +3113,73 @@ function get_min } # +# Generate a random number between 1 and the argument. +# +function random +{ + typeset max=$1 + echo $(( ($RANDOM % $max) + 1 )) +} + +# Write data that can be compressed into a directory +function write_compressible +{ + typeset dir=$1 + typeset megs=$2 + typeset nfiles=${3:-1} + typeset bs=${4:-1024k} + typeset fname=${5:-file} + + [[ -d $dir ]] || log_fail "No directory: $dir" + + # Under Linux fio is not currently used since its behavior can + # differ significantly across versions. This includes missing + # command line options and cases where the --buffer_compress_* + # options fail to behave as expected. + if is_linux; then + typeset file_bytes=$(to_bytes $megs) + typeset bs_bytes=4096 + typeset blocks=$(($file_bytes / $bs_bytes)) + + for (( i = 0; i < $nfiles; i++ )); do + truncate -s $file_bytes $dir/$fname.$i + + # Write every third block to get 66% compression. + for (( j = 0; j < $blocks; j += 3 )); do + dd if=/dev/urandom of=$dir/$fname.$i \ + seek=$j bs=$bs_bytes count=1 \ + conv=notrunc >/dev/null 2>&1 + done + done + else + log_must eval "fio \ + --name=job \ + --fallocate=0 \ + --minimal \ + --randrepeat=0 \ + --buffer_compress_percentage=66 \ + --buffer_compress_chunk=4096 \ + --directory=$dir \ + --numjobs=$nfiles \ + --nrfiles=$nfiles \ + --rw=write \ + --bs=$bs \ + --filesize=$megs \ + --filename_format='$fname.\$jobnum' >/dev/null" + fi +} + +function get_objnum +{ + typeset pathname=$1 + typeset objnum + + [[ -e $pathname ]] || log_fail "No such file or directory: $pathname" + objnum=$(stat -c %i $pathname) + echo $objnum +} + +# # Synchronize all the data in pool # # $1 pool name |