1#!/bin/ksh 2# SPDX-License-Identifier: CDDL-1.0 3 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 15# 16# Copyright (c) 2015 by Delphix. All rights reserved. 17# 18 19# 20# Description: 21# Verify that ZAPs are handled properly during mirror pool splitting. 22# 23# Strategy: 24# 1. Create a pool with a two-way mirror. 25# 2. Split the pool. 26# 3. Verify that the ZAPs in the old pool persisted. 27# 4. Import the new pool. 28# 5. Verify that the ZAPs in the new pool persisted. 29# 30 31. $STF_SUITE/include/libtest.shlib 32. $STF_SUITE/tests/functional/vdev_zaps/vdev_zaps.kshlib 33 34DISK_ARR=($DISKS) 35POOL2=${TESTPOOL}2 36log_must zpool create -f $TESTPOOL mirror ${DISK_ARR[0]} ${DISK_ARR[1]} 37 38log_assert "Per-vdev ZAPs persist correctly on the original pool after split." 39conf="$TESTDIR/vz007" 40log_must eval "zdb -PC $TESTPOOL > $conf" 41 42assert_has_sentinel "$conf" 43assert_root_zap $TESTPOOL "$conf" 44orig_top=$(get_top_vd_zap "type: 'mirror'" $conf) 45orig_leaf0=$(get_leaf_vd_zap ${DISK_ARR[0]} $conf) 46orig_leaf1=$(get_leaf_vd_zap ${DISK_ARR[1]} $conf) 47assert_zap_common $TESTPOOL "type: 'mirror'" "top" $orig_top 48assert_zap_common $TESTPOOL ${DISK_ARR[0]} "leaf" $orig_leaf0 49assert_zap_common $TESTPOOL ${DISK_ARR[1]} "leaf" $orig_leaf1 50 51log_must zpool split $TESTPOOL $POOL2 ${DISK_ARR[1]} 52 53# Make sure old pool's ZAPs are consistent. 54log_must eval "zdb -PC $TESTPOOL > $conf" 55new_leaf0=$(get_leaf_vd_zap ${DISK_ARR[0]} $conf) 56new_top_s0=$(get_top_vd_zap ${DISK_ARR[0]} $conf) 57 58[[ "$new_leaf0" -ne "$orig_leaf0" ]] && log_fail "Leaf ZAP in original pool "\ 59 "didn't persist (expected $orig_leaf0, got $new_leaf0)" 60[[ "$new_top_s0" -ne "$orig_top" ]] && log_fail "Top ZAP in original pool "\ 61 "didn't persist (expected $orig_top, got $new_top_s0)" 62 63log_assert "Per-vdev ZAPs persist on the new pool after import." 64 65# Import the split pool. 66log_must zpool import $POOL2 67log_must eval "zdb -PC $POOL2 > $conf" 68 69new_leaf1=$(get_leaf_vd_zap ${DISK_ARR[1]} $conf) 70new_top_s1=$(get_top_vd_zap ${DISK_ARR[1]} $conf) 71[[ "$new_leaf1" -ne "$orig_leaf1" ]] && log_fail "Leaf ZAP in new pool "\ 72 "didn't persist (expected $orig_leaf1, got $new_leaf1)" 73[[ "$new_top_s1" -ne "$orig_top" ]] && log_fail "Top ZAP in new pool "\ 74 "didn't persist (expected $orig_top, got $new_top_s1)" 75 76log_pass 77