c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#!/bin/ksh
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# This file and its contents are supplied under the terms of the
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# Common Development and Distribution License ("CDDL"), version 1.0.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# You may only use this file in accordance with the terms of version
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# 1.0 of the CDDL.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# A full copy of the text of the CDDL should have accompanied this
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# source. A copy of the CDDL is also available via the Internet at
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# http://www.illumos.org/license/CDDL.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# Copyright (c) 2015 by Delphix. All rights reserved.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens. $STF_SUITE/include/libtest.shlib
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# Description:
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# zdb will accurately count the feature refcount for pools with and without
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# features enabled.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# Strategy:
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# 1. Create a pool, and collect zdb output for the pool.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# 2. Verify there are no 'feature refcount mismatch' messages.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens# 3. Repeat for a pool with features disabled.
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens#
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrenslog_assert "Verify zdb accurately counts feature refcounts."
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrenslog_onexit cleanup
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrenstypeset errstr="feature refcount mismatch"
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrenstypeset tmpfile="/var/tmp/zdb-feature-mismatch"
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrensfunction cleanup
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens{
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens datasetexists $TESTPOOL && destroy_pool $TESTPOOL
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens grep "$errstr" $tmpfile
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens rm -f $tmpfile
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens}
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrensfor opt in '' -d; do
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens log_must zpool create -f $opt $TESTPOOL ${DISKS%% *}
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens log_must eval "zdb $TESTPOOL >$tmpfile"
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens grep -q "$errstr" $tmpfile && \
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens log_fail "Found feature refcount mismatches in zdb output."
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens destroy_pool $TESTPOOL
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrensdone
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrens
c5d1600c3eb0a58e493be9019c5fb8eaec72cb81Matthew Ahrenslog_pass "zdb accurately counts feature refcounts."