]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh
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
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.
15 # Copyright (c) 2015 by Delphix. All rights reserved.
20 # Verify that per-vdev ZAPs are properly transferred on attach/detach.
23 # 1. Create a pool with one disk. Verify that it has a top and leaf ZAP.
25 # 3. Verify that top-level and leaf-level ZAPs were transferred properly.
26 # 4. Verify that the newly-attached disk has a leaf ZAP.
27 # 5. Detach the original disk.
28 # 6. Verify that top-level and leaf-level ZAPs were transferred properly.
31 .
$STF_SUITE/include
/libtest.shlib
32 .
$STF_SUITE/tests
/functional
/vdev_zaps
/vdev_zaps.kshlib
34 log_assert
"Per-vdev ZAPs are transferred properly on attach/detach"
37 log_must zpool create
-f $TESTPOOL $DISK
41 log_must zdb
-PC $TESTPOOL > $conf
42 assert_has_sentinel
"$conf"
43 orig_top
=$
(get_top_vd_zap
$DISK $conf)
44 orig_leaf
=$
(get_leaf_vd_zap
$DISK $conf)
45 assert_zap_common
$TESTPOOL $DISK "top" $orig_top
51 disk2
=$
(echo $DISKS |
awk '{print $2}')
52 log_must zpool attach
$TESTPOOL $DISK $disk2
53 log_must zdb
-PC $TESTPOOL > $conf
55 # Ensure top-level ZAP was transferred successfully.
56 new_top
=$
(get_top_vd_zap
"type: 'mirror'" $conf)
57 if [[ "$new_top" -ne "$orig_top" ]]; then
58 log_fail
"Top-level ZAP wasn't transferred successfully on attach."
61 # Ensure leaf ZAP of original disk was transferred successfully.
62 new_leaf
=$
(get_leaf_vd_zap
$DISK $conf)
63 if [[ "$new_leaf" -ne "$orig_leaf" ]]; then
64 log_fail
"$DISK used to have leaf-level ZAP $orig_leaf, now has "\
67 # Ensure original disk no longer has top-level ZAP.
68 dsk1_top
=$
(get_top_vd_zap
$DISK $conf)
69 [[ -n "$dsk1_top" ]] && log_fail
"$DISK has top-level ZAP, but is only leaf."
71 # Ensure attached disk got a leaf-level ZAP but not a top-level ZAP.
72 dsk2_top
=$
(get_top_vd_zap
$disk2 $conf)
73 dsk2_leaf
=$
(get_leaf_vd_zap
$disk2 $conf)
74 [[ -n "$dsk2_top" ]] && log_fail
"Attached disk $disk2 has top ZAP."
75 [[ -z "$dsk2_leaf" ]] && log_fail
"Attached disk $disk2 has no leaf ZAP."
78 # Detach original disk.
81 log_must zpool detach
$TESTPOOL $DISK
82 log_must zdb
-PC $TESTPOOL > $conf
84 final_top
=$
(get_top_vd_zap
$disk2 $conf)
85 final_leaf
=$
(get_leaf_vd_zap
$disk2 $conf)
86 # Make sure top ZAP was successfully transferred.
87 [[ "$final_top" -ne "$orig_top" ]] && log_fail
"Lost top-level ZAP when "\
88 "promoting $disk2 (expected $orig_top, found $final_top)"
90 # Make sure leaf ZAP was successfully transferred.
91 [[ "$final_leaf" -ne "$dsk2_leaf" ]] && log_fail
"$disk2 lost its leaf ZAP "\
92 "on promotion (expected $dsk2_leaf, got $final_leaf)"