]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / vdev_zaps / vdev_zaps_007_pos.ksh
1 #!/bin/ksh
2
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source.  A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13
14 #
15 # Copyright (c) 2015 by Delphix. All rights reserved.
16 #
17
18 #
19 # Description:
20 # Verify that ZAPs are handled properly during mirror pool splitting.
21 #
22 # Strategy:
23 # 1. Create a pool with a two-way mirror.
24 # 2. Split the pool.
25 # 3. Verify that the ZAPs in the old pool persisted.
26 # 4. Import the new pool.
27 # 5. Verify that the ZAPs in the new pool persisted.
28 #
29
30 . $STF_SUITE/include/libtest.shlib
31 . $STF_SUITE/tests/functional/vdev_zaps/vdev_zaps.kshlib
32
33 DISK_ARR=($DISKS)
34 POOL2=${TESTPOOL}2
35 log_must zpool create -f $TESTPOOL mirror ${DISK_ARR[0]} ${DISK_ARR[1]}
36
37 log_assert "Per-vdev ZAPs persist correctly on the original pool after split."
38 conf="$TESTDIR/vz007"
39 log_must zdb -PC $TESTPOOL > $conf
40
41 assert_has_sentinel "$conf"
42 orig_top=$(get_top_vd_zap "type: 'mirror'" $conf)
43 orig_leaf0=$(get_leaf_vd_zap ${DISK_ARR[0]} $conf)
44 orig_leaf1=$(get_leaf_vd_zap ${DISK_ARR[1]} $conf)
45 assert_zap_common $TESTPOOL "type: 'mirror'" "top" $orig_top
46 assert_zap_common $TESTPOOL ${DISK_ARR[0]} "leaf" $orig_leaf0
47 assert_zap_common $TESTPOOL ${DISK_ARR[1]} "leaf" $orig_leaf1
48
49 log_must zpool split $TESTPOOL $POOL2 ${DISK_ARR[1]}
50
51 # Make sure old pool's ZAPs are consistent.
52 log_must zdb -PC $TESTPOOL > $conf
53 new_leaf0=$(get_leaf_vd_zap ${DISK_ARR[0]} $conf)
54 new_top_s0=$(get_top_vd_zap ${DISK_ARR[0]} $conf)
55
56 [[ "$new_leaf0" -ne "$orig_leaf0" ]] && log_fail "Leaf ZAP in original pool "\
57         "didn't persist (expected $orig_leaf0, got $new_leaf0)"
58 [[ "$new_top_s0" -ne "$orig_top" ]] && log_fail "Top ZAP in original pool "\
59         "didn't persist (expected $orig_top, got $new_top_s0)"
60
61 log_assert "Per-vdev ZAPs persist on the new pool after import."
62
63 # Import the split pool.
64 log_must zpool import $POOL2
65 log_must zdb -PC $TESTPOOL > $conf
66
67 new_leaf1=$(get_leaf_vd_zap ${DISK_ARR[1]} $conf)
68 new_top_s1=$(get_top_vd_zap ${DISK_ARR[1]} $conf)
69 [[ "$new_leaf1" -ne "$orig_leaf1" ]] && log_fail "Leaf ZAP in new pool "\
70         "didn't persist (expected $orig_leaf1, got $new_leaf1)"
71 [[ "$new_top_s1" -ne "$orig_top" ]] && log_fail "Top ZAP in new pool "\
72         "didn't persist (expected $orig_top, got $new_top_s1)"
73
74 log_pass