1#! /bin/ksh -p
2#
3# CDDL HEADER START
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9#
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14# CDDL HEADER END
15#
16
17#
18# Copyright (c) 2014, 2017 by Delphix. All rights reserved.
19#
20
21. $STF_SUITE/include/libtest.shlib
22. $STF_SUITE/tests/functional/removal/removal.kshlib
23
24zdbout=${TMPDIR:-$TEST_BASE_DIR}/zdbout.$$
25
26if is_linux; then
27	log_unsupported "ZDB fails during concurrent pool activity."
28fi
29
30function cleanup
31{
32	default_cleanup_noexit
33	log_must rm -f $zdbout
34}
35
36default_setup_noexit "$DISKS"
37log_onexit cleanup
38FIRSTDISK=${DISKS%% *}
39
40DISKPATH=/dev
41case $FIRSTDISK in
42	/*)
43		DISKPATH=$(dirname $FIRSTDISK)
44		;;
45esac
46
47function callback
48{
49	typeset count=$1
50	typeset zdbstat
51
52	log_must zpool set cachefile=none $TESTPOOL
53	zdb -e -p $DISKPATH -cudi $TESTPOOL >$zdbout 2>&1
54	zdbstat=$?
55	log_must zpool set cachefile= $TESTPOOL
56	if [[ $zdbstat != 0 ]]; then
57		log_note "Output: zdb -e -p $DISKPATH -cudi $TESTPOOL"
58		cat $zdbout
59		log_note "zdb detected errors with exist status $zdbstat."
60	fi
61	log_note "zdb -e -p $DISKPATH -cudi $TESTPOOL >zdbout 2>&1"
62	return 0
63}
64
65test_removal_with_operation callback
66
67log_must zpool set cachefile=none $TESTPOOL
68zdb -e -p $DISKPATH -cudi $TESTPOOL >$zdbout 2>&1
69zdbstat=$?
70log_must zpool set cachefile= $TESTPOOL
71if [[ $zdbstat != 0 ]]; then
72	log_note "Output following removal: zdb -cudi $TESTPOOL"
73	cat $zdbout
74	log_fail "zdb detected errors with exit status " \
75	    "$zdbstat following removal."
76fi
77
78log_pass "Can use zdb during removal"
79