mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 10:21:01 +03:00
a7004725d0
OpenZFS 7252 - compressed zfs send / receive OpenZFS 7628 - create long versions of ZFS send / receive options Authored by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: John Kennedy <john.kennedy@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com> Reviewed by: Sebastien Roy <sebastien.roy@delphix.com> Reviewed by: David Quigley <dpquigl@davequigley.com> Reviewed by: Thomas Caputi <tcaputi@datto.com> Approved by: Dan McDonald <danmcd@omniti.com> Reviewed by: David Quigley <dpquigl@davequigley.com> Reviewed-by: loli10K <ezomori.nozomu@gmail.com> Ported-by: bunder2015 <omfgbunder@gmail.com> Ported-by: Don Brady <don.brady@intel.com> Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> 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
69 lines
1.8 KiB
Plaintext
69 lines
1.8 KiB
Plaintext
#
|
|
# This file and its contents are supplied under the terms of the
|
|
# Common Development and Distribution License ("CDDL"), version 1.0.
|
|
# You may only use this file in accordance with the terms of version
|
|
# 1.0 of the CDDL.
|
|
#
|
|
# A full copy of the text of the CDDL should have accompanied this
|
|
# source. A copy of the CDDL is also available via the Internet at
|
|
# http://www.illumos.org/license/CDDL.
|
|
#
|
|
|
|
#
|
|
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
|
#
|
|
|
|
#
|
|
# Return 0 if the percentage difference between $a and $b is $percent or
|
|
# greater. Return 1 if the percentage is lower or if we would divide by
|
|
# zero. For use like this:
|
|
#
|
|
# Do $action if the calculated percentage is greater or equal to that passed in:
|
|
# within_percent A B P && $action
|
|
# Do $action if the calculated percentage is less than that passed in:
|
|
# within_percent A B P || $action
|
|
#
|
|
function within_percent
|
|
{
|
|
typeset a=$1
|
|
typeset b=$1
|
|
typeset percent=$3
|
|
|
|
# Set $a or $b to $2 such that a >= b
|
|
[[ '1' = $(echo "if ($2 > $a) 1" | bc) ]] && a=$2 || b=$2
|
|
|
|
# Prevent division by 0
|
|
[[ $a =~ [1-9] ]] || return 1
|
|
|
|
typeset p=$(echo "scale=2; $b * 100 / $a" | bc)
|
|
log_note "Comparing $a and $b given $percent% (calculated: $p%)"
|
|
[[ '1' = $(echo "scale=2; if ($p >= $percent) 1" | bc) ]] && return 0
|
|
|
|
return 1
|
|
}
|
|
|
|
#
|
|
# Return 0 if the human readable string of the form <value>[suffix] can
|
|
# be converted to bytes. Allow suffixes are shown in the table below.
|
|
#
|
|
function to_bytes
|
|
{
|
|
typeset size=$1
|
|
typeset value=$(echo "$size" | grep -o '[0-9]\+')
|
|
|
|
case $size in
|
|
*PB|*pb|*P|*p) factor='1024^5' ;;
|
|
*TB|*tb|*T|*t) factor='1024^4' ;;
|
|
*GB|*gb|*G|*g) factor='1024^3' ;;
|
|
*MB|*mb|*M|*m) factor='1024^2' ;;
|
|
*KB|*kb|*K|*k) factor='1024^1' ;;
|
|
*B|*b) factor='1024^0' ;;
|
|
*[!0-9.]*) return 1 ;;
|
|
*) factor='1024^0' ;;
|
|
esac
|
|
|
|
echo "$value * ($factor)" | bc
|
|
|
|
return 0
|
|
}
|