2016-04-11 20:16:57 +00:00
|
|
|
#
|
|
|
|
# CDDL HEADER START
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# CDDL HEADER END
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
2017-04-06 00:18:22 +00:00
|
|
|
# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
|
2016-04-11 20:16:57 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
function get_conf_section # regex conf
|
|
|
|
{
|
|
|
|
typeset regex="$1"
|
|
|
|
typeset conf="$2"
|
|
|
|
|
2022-03-09 22:54:26 +00:00
|
|
|
awk -v r="$1" '$0 ~ r, 0 {if($0 ~ r) next; if(/children\[/) exit; print}' "$conf"
|
2016-04-11 20:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_leaf_vd_zap # dsk conf
|
|
|
|
{
|
2022-03-09 22:54:26 +00:00
|
|
|
get_conf_section "$1" "$2" | awk '/com.delphix:vdev_zap_leaf: [0-9]+/ {print $2}'
|
2016-04-11 20:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_top_vd_zap # dsk conf
|
|
|
|
{
|
2022-03-09 22:54:26 +00:00
|
|
|
get_conf_section "$1" "$2" | awk '/com.delphix:vdev_zap_top: [0-9]+/ {print $2}'
|
2016-04-11 20:16:57 +00:00
|
|
|
}
|
2023-04-20 17:07:56 +00:00
|
|
|
function get_root_vd_zap # conf
|
|
|
|
{
|
|
|
|
awk '/com.klarasystems:vdev_zap_root: [0-9]+/ {print $2}' "$1"
|
|
|
|
}
|
2016-04-11 20:16:57 +00:00
|
|
|
|
|
|
|
function assert_has_sentinel # conf
|
|
|
|
{
|
2022-03-09 22:54:26 +00:00
|
|
|
log_must grep -q "com.delphix:has_per_vdev_zaps" "$1"
|
2016-04-11 20:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function assert_zap_common # pool vd lvl zapobj
|
|
|
|
{
|
|
|
|
typeset pool=$1
|
|
|
|
typeset vd="$2"
|
|
|
|
typeset lvl=$3
|
|
|
|
typeset zapobj=$4
|
|
|
|
|
2022-03-09 22:54:26 +00:00
|
|
|
if [ -z "$zapobj" ]; then
|
2016-04-11 20:16:57 +00:00
|
|
|
log_fail "$vd on $pool has no $lvl ZAP in config"
|
2022-03-09 22:54:26 +00:00
|
|
|
elif ! zdb -d $pool $zapobj | grep -q 'zap'; then
|
2016-04-11 20:16:57 +00:00
|
|
|
log_fail "$vd on $pool has no $lvl ZAP in MOS"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-04-20 17:07:56 +00:00
|
|
|
function assert_root_zap # pool conf
|
|
|
|
{
|
|
|
|
typeset pool=$1
|
|
|
|
typeset conf=$2
|
|
|
|
|
|
|
|
root_zap=$(get_root_vd_zap $conf)
|
|
|
|
assert_zap_common $pool "root vdev" "root" $root_zap
|
|
|
|
}
|
|
|
|
|
2016-04-11 20:16:57 +00:00
|
|
|
function assert_top_zap # pool vd conf
|
|
|
|
{
|
|
|
|
typeset pool=$1
|
|
|
|
typeset vd="$2"
|
|
|
|
typeset conf=$3
|
|
|
|
|
|
|
|
top_zap=$(get_top_vd_zap "$vd" $conf)
|
|
|
|
assert_zap_common $pool "$vd" "top" $top_zap
|
|
|
|
}
|
|
|
|
|
|
|
|
function assert_leaf_zap # pool vd conf
|
|
|
|
{
|
|
|
|
typeset pool=$1
|
|
|
|
typeset vd="$2"
|
|
|
|
typeset conf=$3
|
|
|
|
|
|
|
|
leaf_zap=$(get_leaf_vd_zap "$vd" $conf)
|
|
|
|
assert_zap_common $pool "$vd" "leaf" $leaf_zap
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Code common to setup/teardown for each test.
|
|
|
|
#
|
|
|
|
|
|
|
|
function cleanup
|
|
|
|
{
|
2022-03-09 22:54:26 +00:00
|
|
|
datasetexists $TESTPOOL && log_must zpool destroy -f $TESTPOOL
|
|
|
|
[ -e $conf ] && log_must rm -f "$conf"
|
|
|
|
poolexists $POOL2 && log_must zpool destroy -f $POOL2
|
2016-04-11 20:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
log_onexit cleanup
|