tests: include: use already-set $UNAME instead of shelling out to uname each time
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13259
This commit is contained in:
parent
ff0fc5af12
commit
5c9f744b1a
|
@ -485,7 +485,7 @@ function get_pool_devices #testpool #devdir
|
||||||
typeset devdir=$2
|
typeset devdir=$2
|
||||||
typeset out=""
|
typeset out=""
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux|FreeBSD)
|
Linux|FreeBSD)
|
||||||
zpool status -P $testpool | awk -v d="$devdir" '$1 ~ d {sub(d "/", ""); printf("%s ", $1)}'
|
zpool status -P $testpool | awk -v d="$devdir" '$1 ~ d {sub(d "/", ""); printf("%s ", $1)}'
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
# Use is subject to license terms.
|
# Use is subject to license terms.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
. ${STF_SUITE}/include/tunables.cfg
|
||||||
|
|
||||||
. ${STF_TOOLS}/include/logapi.shlib
|
. ${STF_TOOLS}/include/logapi.shlib
|
||||||
. ${STF_SUITE}/include/math.shlib
|
. ${STF_SUITE}/include/math.shlib
|
||||||
. ${STF_SUITE}/include/blkdev.shlib
|
. ${STF_SUITE}/include/blkdev.shlib
|
||||||
|
|
||||||
. ${STF_SUITE}/include/tunables.cfg
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Apply constrained path when available. This is required since the
|
# Apply constrained path when available. This is required since the
|
||||||
# PATH may have been modified by sudo's secure_path behavior.
|
# PATH may have been modified by sudo's secure_path behavior.
|
||||||
|
@ -83,7 +83,7 @@ function linux_version
|
||||||
|
|
||||||
function is_linux
|
function is_linux
|
||||||
{
|
{
|
||||||
[ $(uname) = "Linux" ]
|
[ "$UNAME" = "Linux" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine if this is an illumos test system
|
# Determine if this is an illumos test system
|
||||||
|
@ -91,7 +91,7 @@ function is_linux
|
||||||
# Return 0 if platform illumos, 1 if otherwise
|
# Return 0 if platform illumos, 1 if otherwise
|
||||||
function is_illumos
|
function is_illumos
|
||||||
{
|
{
|
||||||
[ $(uname) = "illumos" ]
|
[ "$UNAME" = "illumos" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine if this is a FreeBSD test system
|
# Determine if this is a FreeBSD test system
|
||||||
|
@ -100,7 +100,7 @@ function is_illumos
|
||||||
|
|
||||||
function is_freebsd
|
function is_freebsd
|
||||||
{
|
{
|
||||||
[ $(uname) = "FreeBSD" ]
|
[ "$UNAME" = "FreeBSD" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine if this is a DilOS test system
|
# Determine if this is a DilOS test system
|
||||||
|
@ -880,7 +880,7 @@ function set_partition
|
||||||
typeset disk=${4#$DEV_DSKDIR/}
|
typeset disk=${4#$DEV_DSKDIR/}
|
||||||
disk=${disk#$DEV_RDSKDIR/}
|
disk=${disk#$DEV_RDSKDIR/}
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
if [[ -z $size || -z $disk ]]; then
|
if [[ -z $size || -z $disk ]]; then
|
||||||
log_fail "The size or disk name is unspecified."
|
log_fail "The size or disk name is unspecified."
|
||||||
|
@ -1033,7 +1033,7 @@ function get_endslice #<disk> <slice>
|
||||||
log_fail "The disk name or slice number is unspecified."
|
log_fail "The disk name or slice number is unspecified."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
endcyl=$(parted -s $DEV_DSKDIR/$disk -- unit cyl print | \
|
endcyl=$(parted -s $DEV_DSKDIR/$disk -- unit cyl print | \
|
||||||
awk "/part${slice}/"' {sub(/cyl/, "", $3); print $3}')
|
awk "/part${slice}/"' {sub(/cyl/, "", $3); print $3}')
|
||||||
|
@ -1259,7 +1259,7 @@ function is_shared
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD) is_shared_freebsd "$fs" ;;
|
FreeBSD) is_shared_freebsd "$fs" ;;
|
||||||
Linux) is_shared_linux "$fs" ;;
|
Linux) is_shared_linux "$fs" ;;
|
||||||
*) is_shared_illumos "$fs" ;;
|
*) is_shared_illumos "$fs" ;;
|
||||||
|
@ -1327,7 +1327,7 @@ function is_exported
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD) is_exported_freebsd "$fs" ;;
|
FreeBSD) is_exported_freebsd "$fs" ;;
|
||||||
Linux) is_exported_linux "$fs" ;;
|
Linux) is_exported_linux "$fs" ;;
|
||||||
*) is_exported_illumos "$fs" ;;
|
*) is_exported_illumos "$fs" ;;
|
||||||
|
@ -1348,7 +1348,7 @@ function is_shared_smb
|
||||||
if is_linux; then
|
if is_linux; then
|
||||||
net usershare list | grep -xFq "${fs//\//_}"
|
net usershare list | grep -xFq "${fs//\//_}"
|
||||||
else
|
else
|
||||||
log_note "SMB on $(uname) currently unsupported by the test framework"
|
log_note "SMB on $UNAME currently unsupported by the test framework"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1394,7 +1394,7 @@ function share_nfs #fs
|
||||||
|
|
||||||
is_shared "$fs" && return
|
is_shared "$fs" && return
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
log_must exportfs "*:$fs"
|
log_must exportfs "*:$fs"
|
||||||
;;
|
;;
|
||||||
|
@ -1421,7 +1421,7 @@ function unshare_nfs #fs
|
||||||
|
|
||||||
! is_shared "$fs" && return
|
! is_shared "$fs" && return
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
log_must exportfs -u "*:$fs"
|
log_must exportfs -u "*:$fs"
|
||||||
;;
|
;;
|
||||||
|
@ -1445,7 +1445,7 @@ function unshare_nfs #fs
|
||||||
#
|
#
|
||||||
function showshares_nfs
|
function showshares_nfs
|
||||||
{
|
{
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
exportfs -v
|
exportfs -v
|
||||||
;;
|
;;
|
||||||
|
@ -1474,7 +1474,7 @@ function showshares_smb
|
||||||
|
|
||||||
function check_nfs
|
function check_nfs
|
||||||
{
|
{
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
exportfs -s
|
exportfs -s
|
||||||
;;
|
;;
|
||||||
|
@ -2563,7 +2563,7 @@ function add_user #<group_name> <user_name> <basedir>
|
||||||
log_fail "group name or user name are not defined."
|
log_fail "group name or user name are not defined."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
add_user_freebsd "$group" "$user" "$basedir"
|
add_user_freebsd "$group" "$user" "$basedir"
|
||||||
;;
|
;;
|
||||||
|
@ -2593,7 +2593,7 @@ function del_user #<logname> <basedir>
|
||||||
log_fail "login name is necessary."
|
log_fail "login name is necessary."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
del_user_freebsd "$user"
|
del_user_freebsd "$user"
|
||||||
;;
|
;;
|
||||||
|
@ -2623,7 +2623,7 @@ function add_group #<group_name>
|
||||||
log_fail "group name is necessary."
|
log_fail "group name is necessary."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
add_group_freebsd "$group"
|
add_group_freebsd "$group"
|
||||||
;;
|
;;
|
||||||
|
@ -2651,7 +2651,7 @@ function del_group #<group_name>
|
||||||
log_fail "group name is necessary."
|
log_fail "group name is necessary."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
del_group_freebsd "$group"
|
del_group_freebsd "$group"
|
||||||
;;
|
;;
|
||||||
|
@ -3004,7 +3004,7 @@ function is_te_enabled
|
||||||
# Utility function to determine if a system has multiple cpus.
|
# Utility function to determine if a system has multiple cpus.
|
||||||
function is_mp
|
function is_mp
|
||||||
{
|
{
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
(($(grep -c '^processor' /proc/cpuinfo) > 1))
|
(($(grep -c '^processor' /proc/cpuinfo) > 1))
|
||||||
;;
|
;;
|
||||||
|
@ -3270,7 +3270,7 @@ function zed_rc_restore
|
||||||
function zed_setup
|
function zed_setup
|
||||||
{
|
{
|
||||||
if ! is_linux; then
|
if ! is_linux; then
|
||||||
log_unsupported "No zed on $(uname)"
|
log_unsupported "No zed on $UNAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d $ZEDLET_DIR ]]; then
|
if [[ ! -d $ZEDLET_DIR ]]; then
|
||||||
|
@ -3436,7 +3436,7 @@ function is_swap_inuse
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
swapon -s | grep -wq $(readlink -f $device)
|
swapon -s | grep -wq $(readlink -f $device)
|
||||||
;;
|
;;
|
||||||
|
@ -3456,7 +3456,7 @@ function swap_setup
|
||||||
{
|
{
|
||||||
typeset swapdev=$1
|
typeset swapdev=$1
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
log_must eval "mkswap $swapdev > /dev/null 2>&1"
|
log_must eval "mkswap $swapdev > /dev/null 2>&1"
|
||||||
log_must swapon $swapdev
|
log_must swapon $swapdev
|
||||||
|
@ -3524,7 +3524,7 @@ function set_tunable_impl
|
||||||
eval "typeset tunable=\$$name"
|
eval "typeset tunable=\$$name"
|
||||||
case "$tunable" in
|
case "$tunable" in
|
||||||
UNSUPPORTED)
|
UNSUPPORTED)
|
||||||
log_unsupported "Tunable '$name' is unsupported on $(uname)"
|
log_unsupported "Tunable '$name' is unsupported on $UNAME"
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
log_fail "Tunable '$name' must be added to tunables.cfg"
|
log_fail "Tunable '$name' must be added to tunables.cfg"
|
||||||
|
@ -3536,7 +3536,7 @@ function set_tunable_impl
|
||||||
[[ -z "$value" ]] && return 1
|
[[ -z "$value" ]] && return 1
|
||||||
[[ -z "$mdb_cmd" ]] && return 1
|
[[ -z "$mdb_cmd" ]] && return 1
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
typeset zfs_tunables="/sys/module/$module/parameters"
|
typeset zfs_tunables="/sys/module/$module/parameters"
|
||||||
echo "$value" >"$zfs_tunables/$tunable"
|
echo "$value" >"$zfs_tunables/$tunable"
|
||||||
|
@ -3569,7 +3569,7 @@ function get_tunable_impl
|
||||||
eval "typeset tunable=\$$name"
|
eval "typeset tunable=\$$name"
|
||||||
case "$tunable" in
|
case "$tunable" in
|
||||||
UNSUPPORTED)
|
UNSUPPORTED)
|
||||||
log_unsupported "Tunable '$name' is unsupported on $(uname)"
|
log_unsupported "Tunable '$name' is unsupported on $UNAME"
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
log_fail "Tunable '$name' must be added to tunables.cfg"
|
log_fail "Tunable '$name' must be added to tunables.cfg"
|
||||||
|
@ -3578,7 +3578,7 @@ function get_tunable_impl
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
typeset zfs_tunables="/sys/module/$module/parameters"
|
typeset zfs_tunables="/sys/module/$module/parameters"
|
||||||
cat $zfs_tunables/$tunable
|
cat $zfs_tunables/$tunable
|
||||||
|
@ -3600,7 +3600,7 @@ function md5digest
|
||||||
{
|
{
|
||||||
typeset file=$1
|
typeset file=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
md5 -q $file
|
md5 -q $file
|
||||||
;;
|
;;
|
||||||
|
@ -3620,7 +3620,7 @@ function sha256digest
|
||||||
{
|
{
|
||||||
typeset file=$1
|
typeset file=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
sha256 -q $file
|
sha256 -q $file
|
||||||
;;
|
;;
|
||||||
|
@ -3634,7 +3634,7 @@ function sha256digest
|
||||||
|
|
||||||
function new_fs #<args>
|
function new_fs #<args>
|
||||||
{
|
{
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
newfs "$@"
|
newfs "$@"
|
||||||
;;
|
;;
|
||||||
|
@ -3648,7 +3648,7 @@ function stat_size #<path>
|
||||||
{
|
{
|
||||||
typeset path=$1
|
typeset path=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
stat -f %z "$path"
|
stat -f %z "$path"
|
||||||
;;
|
;;
|
||||||
|
@ -3662,7 +3662,7 @@ function stat_ctime #<path>
|
||||||
{
|
{
|
||||||
typeset path=$1
|
typeset path=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
stat -f %c "$path"
|
stat -f %c "$path"
|
||||||
;;
|
;;
|
||||||
|
@ -3676,7 +3676,7 @@ function stat_crtime #<path>
|
||||||
{
|
{
|
||||||
typeset path=$1
|
typeset path=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
stat -f %B "$path"
|
stat -f %B "$path"
|
||||||
;;
|
;;
|
||||||
|
@ -3690,7 +3690,7 @@ function stat_generation #<path>
|
||||||
{
|
{
|
||||||
typeset path=$1
|
typeset path=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
getversion "${path}"
|
getversion "${path}"
|
||||||
;;
|
;;
|
||||||
|
@ -3735,7 +3735,7 @@ function get_xattr # name path
|
||||||
typeset name=$1
|
typeset name=$1
|
||||||
typeset path=$2
|
typeset path=$2
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
getextattr -qq user "${name}" "${path}"
|
getextattr -qq user "${name}" "${path}"
|
||||||
;;
|
;;
|
||||||
|
@ -3751,7 +3751,7 @@ function set_xattr # name value path
|
||||||
typeset value=$2
|
typeset value=$2
|
||||||
typeset path=$3
|
typeset path=$3
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
setextattr user "${name}" "${value}" "${path}"
|
setextattr user "${name}" "${value}" "${path}"
|
||||||
;;
|
;;
|
||||||
|
@ -3766,7 +3766,7 @@ function set_xattr_stdin # name value
|
||||||
typeset name=$1
|
typeset name=$1
|
||||||
typeset path=$2
|
typeset path=$2
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
setextattr -i user "${name}" "${path}"
|
setextattr -i user "${name}" "${path}"
|
||||||
;;
|
;;
|
||||||
|
@ -3781,7 +3781,7 @@ function rm_xattr # name path
|
||||||
typeset name=$1
|
typeset name=$1
|
||||||
typeset path=$2
|
typeset path=$2
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
rmextattr -q user "${name}" "${path}"
|
rmextattr -q user "${name}" "${path}"
|
||||||
;;
|
;;
|
||||||
|
@ -3795,7 +3795,7 @@ function ls_xattr # path
|
||||||
{
|
{
|
||||||
typeset path=$1
|
typeset path=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
lsextattr -qq user "${path}"
|
lsextattr -qq user "${path}"
|
||||||
;;
|
;;
|
||||||
|
@ -3810,7 +3810,7 @@ function kstat # stat flags?
|
||||||
typeset stat=$1
|
typeset stat=$1
|
||||||
typeset flags=${2-"-n"}
|
typeset flags=${2-"-n"}
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
sysctl $flags kstat.zfs.misc.$stat
|
sysctl $flags kstat.zfs.misc.$stat
|
||||||
;;
|
;;
|
||||||
|
@ -3827,7 +3827,7 @@ function get_arcstat # stat
|
||||||
{
|
{
|
||||||
typeset stat=$1
|
typeset stat=$1
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
kstat arcstats.$stat
|
kstat arcstats.$stat
|
||||||
;;
|
;;
|
||||||
|
@ -3846,7 +3846,7 @@ function punch_hole # offset length file
|
||||||
typeset length=$2
|
typeset length=$2
|
||||||
typeset file=$3
|
typeset file=$3
|
||||||
|
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
truncate -d -o $offset -l $length "$file"
|
truncate -d -o $offset -l $length "$file"
|
||||||
;;
|
;;
|
||||||
|
@ -4008,7 +4008,7 @@ function replay_directory_diff # dir_a dir_b
|
||||||
function push_coredump_pattern # dir
|
function push_coredump_pattern # dir
|
||||||
{
|
{
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
cat /proc/sys/kernel/core_pattern /proc/sys/kernel/core_uses_pid
|
cat /proc/sys/kernel/core_pattern /proc/sys/kernel/core_uses_pid
|
||||||
echo "$1/core.%e" >/proc/sys/kernel/core_pattern &&
|
echo "$1/core.%e" >/proc/sys/kernel/core_pattern &&
|
||||||
|
@ -4031,7 +4031,7 @@ function push_coredump_pattern # dir
|
||||||
function pop_coredump_pattern
|
function pop_coredump_pattern
|
||||||
{
|
{
|
||||||
[ -s "$1" ] || return 0
|
[ -s "$1" ] || return 0
|
||||||
case $(uname) in
|
case "$UNAME" in
|
||||||
Linux)
|
Linux)
|
||||||
typeset pat pid
|
typeset pat pid
|
||||||
{ read -r pat; read -r pid; } < "$1"
|
{ read -r pat; read -r pid; } < "$1"
|
||||||
|
|
|
@ -380,44 +380,56 @@ function get_directory
|
||||||
|
|
||||||
function get_min_arc_size
|
function get_min_arc_size
|
||||||
{
|
{
|
||||||
if is_freebsd; then
|
case "$UNAME" in
|
||||||
|
Linux)
|
||||||
|
awk '$1 == "c_min" { print $3 }' /proc/spl/kstat/zfs/arcstats
|
||||||
|
;;
|
||||||
|
FreeBSD)
|
||||||
sysctl -n kstat.zfs.misc.arcstats.c_min
|
sysctl -n kstat.zfs.misc.arcstats.c_min
|
||||||
elif is_illumos; then
|
;;
|
||||||
|
*)
|
||||||
dtrace -qn 'BEGIN {
|
dtrace -qn 'BEGIN {
|
||||||
printf("%u\n", `arc_stats.arcstat_c_min.value.ui64);
|
printf("%u\n", `arc_stats.arcstat_c_min.value.ui64);
|
||||||
exit(0);
|
exit(0);
|
||||||
}'
|
}'
|
||||||
elif is_linux; then
|
;;
|
||||||
awk '$1 == "c_min" { print $3 }' /proc/spl/kstat/zfs/arcstats
|
esac || log_fail "get_min_arc_size failed"
|
||||||
fi || log_fail "get_min_arc_size failed"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_max_arc_size
|
function get_max_arc_size
|
||||||
{
|
{
|
||||||
if is_freebsd; then
|
case "$UNAME" in
|
||||||
|
Linux)
|
||||||
|
awk '$1 == "c_max" { print $3 }' /proc/spl/kstat/zfs/arcstats
|
||||||
|
;;
|
||||||
|
FreeBSD)
|
||||||
sysctl -n kstat.zfs.misc.arcstats.c_max
|
sysctl -n kstat.zfs.misc.arcstats.c_max
|
||||||
elif is_illumos; then
|
;;
|
||||||
|
*)
|
||||||
dtrace -qn 'BEGIN {
|
dtrace -qn 'BEGIN {
|
||||||
printf("%u\n", `arc_stats.arcstat_c_max.value.ui64);
|
printf("%u\n", `arc_stats.arcstat_c_max.value.ui64);
|
||||||
exit(0);
|
exit(0);
|
||||||
}'
|
}'
|
||||||
elif is_linux; then
|
;;
|
||||||
awk '$1 == "c_max" { print $3 }' /proc/spl/kstat/zfs/arcstats
|
esac || log_fail "get_max_arc_size failed"
|
||||||
fi || log_fail "get_max_arc_size failed"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_arc_target
|
function get_arc_target
|
||||||
{
|
{
|
||||||
if is_freebsd; then
|
case "$UNAME" in
|
||||||
|
Linux)
|
||||||
|
awk '$1 == "c" { print $3 }' /proc/spl/kstat/zfs/arcstats
|
||||||
|
;;
|
||||||
|
FreeBSD)
|
||||||
sysctl -n kstat.zfs.misc.arcstats.c
|
sysctl -n kstat.zfs.misc.arcstats.c
|
||||||
elif is_illumos; then
|
;;
|
||||||
|
*)
|
||||||
dtrace -qn 'BEGIN {
|
dtrace -qn 'BEGIN {
|
||||||
printf("%u\n", `arc_stats.arcstat_c.value.ui64);
|
printf("%u\n", `arc_stats.arcstat_c.value.ui64);
|
||||||
exit(0);
|
exit(0);
|
||||||
}'
|
}'
|
||||||
elif is_linux; then
|
;;
|
||||||
awk '$1 == "c" { print $3 }' /proc/spl/kstat/zfs/arcstats
|
esac || log_fail "get_arc_target failed"
|
||||||
fi || log_fail "get_arc_target failed"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_dbuf_cache_size
|
function get_dbuf_cache_size
|
||||||
|
@ -535,32 +547,34 @@ function pool_to_lun_list
|
||||||
typeset ctd ctds devname lun
|
typeset ctd ctds devname lun
|
||||||
typeset lun_list=':'
|
typeset lun_list=':'
|
||||||
|
|
||||||
if is_illumos; then
|
case "$UNAME" in
|
||||||
ctds=$(zpool list -v $pool |
|
Linux)
|
||||||
awk '/c[0-9]*t[0-9a-fA-F]*d[0-9]*/ {print $1}')
|
|
||||||
|
|
||||||
for ctd in $ctds; do
|
|
||||||
# Get the device name as it appears in /etc/path_to_inst
|
|
||||||
devname=$(readlink -f /dev/dsk/${ctd}s0 | sed -n \
|
|
||||||
's/\/devices\([^:]*\):.*/\1/p')
|
|
||||||
# Add a string composed of the driver name and instance
|
|
||||||
# number to the list for comparison with dev_statname.
|
|
||||||
lun=$(sed 's/"//g' /etc/path_to_inst | grep \
|
|
||||||
$devname | awk '{print $3$2}')
|
|
||||||
lun_list="$lun_list$lun:"
|
|
||||||
done
|
|
||||||
elif is_freebsd; then
|
|
||||||
lun_list+=$(zpool list -HLv $pool | \
|
|
||||||
awk '/a?da[0-9]+|md[0-9]+|mfid[0-9]+|nda[0-9]+|nvd[0-9]+|vtbd[0-9]+/
|
|
||||||
{ printf "%s:", $1 }')
|
|
||||||
elif is_linux; then
|
|
||||||
ctds=$(zpool list -HLv $pool | \
|
ctds=$(zpool list -HLv $pool | \
|
||||||
awk '/sd[a-z]*|loop[0-9]*|dm-[0-9]*/ {print $1}')
|
awk '/sd[a-z]*|loop[0-9]*|dm-[0-9]*/ {print $1}')
|
||||||
|
|
||||||
for ctd in $ctds; do
|
for ctd in $ctds; do
|
||||||
lun_list="$lun_list$ctd:"
|
lun_list="$lun_list$ctd:"
|
||||||
done
|
done
|
||||||
fi
|
;;
|
||||||
|
FreeBSD)
|
||||||
|
lun_list+=$(zpool list -HLv $pool | \
|
||||||
|
awk '/a?da[0-9]+|md[0-9]+|mfid[0-9]+|nda[0-9]+|nvd[0-9]+|vtbd[0-9]+/
|
||||||
|
{ printf "%s:", $1 }')
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ctds=$(zpool list -v $pool |
|
||||||
|
awk '/c[0-9]*t[0-9a-fA-F]*d[0-9]*/ {print $1}')
|
||||||
|
|
||||||
|
for ctd in $ctds; do
|
||||||
|
# Get the device name as it appears in /etc/path_to_inst
|
||||||
|
devname=$(readlink -f /dev/dsk/${ctd}s0 | sed -n 's/\/devices\([^:]*\):.*/\1/p')
|
||||||
|
# Add a string composed of the driver name and instance
|
||||||
|
# number to the list for comparison with dev_statname.
|
||||||
|
lun=$(sed 's/"//g' /etc/path_to_inst | awk -v dn="$devname" '$0 ~ dn {print $3$2}')
|
||||||
|
lun_list="$lun_list$lun:"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
echo $lun_list
|
echo $lun_list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue