]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_dev_removal.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_destroy / zfs_destroy_dev_removal.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source.  A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright (c) 2018 by Delphix. All rights reserved.
15 #
16
17 # DESCRIPTION
18 # Verify that livelists tracking remapped blocks can be
19 # properly destroyed.
20
21 # STRATEGY
22 # 1. Create a pool with disk1 and create a filesystem, snapshot
23 # and clone. Write several files to the clone.
24 # 2. Add disk2 to the pool and then remove disk1, triggering a
25 # remap of the blkptrs tracked in the livelist.
26 # 3. Delete the clone
27
28 . $STF_SUITE/include/libtest.shlib
29 . $STF_SUITE/tests/functional/removal/removal.kshlib
30
31 function cleanup
32 {
33         poolexists $TESTPOOL2 && zpool destroy $TESTPOOL2
34         [[ -f $VIRTUAL_DISK1 ]] && log_must rm $VIRTUAL_DISK1
35         [[ -f $VIRTUAL_DISK2 ]] && log_must rm $VIRTUAL_DISK2
36 }
37
38 log_onexit cleanup
39
40 VIRTUAL_DISK1=$TEST_BASE_DIR/disk1
41 VIRTUAL_DISK2=$TEST_BASE_DIR/disk2
42 log_must truncate -s $(($MINVDEVSIZE * 8)) $VIRTUAL_DISK1
43 log_must truncate -s $(($MINVDEVSIZE * 16)) $VIRTUAL_DISK2
44
45 log_must zpool create $TESTPOOL2 $VIRTUAL_DISK1
46 log_must poolexists $TESTPOOL2
47
48 log_must zfs create $TESTPOOL2/$TESTFS
49 log_must mkfile 25m /$TESTPOOL2/$TESTFS/atestfile
50 log_must zfs snapshot $TESTPOOL2/$TESTFS@snap
51
52 log_must zfs clone $TESTPOOL2/$TESTFS@snap $TESTPOOL2/$TESTCLONE
53
54 log_must mkfile 1m /$TESTPOOL2/$TESTCLONE/$TESTFILE0
55 log_must mkfile 1m /$TESTPOOL2/$TESTCLONE/$TESTFILE1
56 log_must mkfile 1m /$TESTPOOL2/$TESTCLONE/$TESTFILE2
57
58 log_must zpool add $TESTPOOL2 $VIRTUAL_DISK2
59 log_must zpool remove $TESTPOOL2 $VIRTUAL_DISK1
60 wait_for_removal $TESTPOOL2
61
62 log_must rm /$TESTPOOL2/$TESTCLONE/$TESTFILE0
63 log_must rm /$TESTPOOL2/$TESTCLONE/$TESTFILE1
64
65 log_must zfs destroy $TESTPOOL2/$TESTCLONE
66
67 log_pass "Clone with the livelist feature and remapped blocks," \
68         "can be destroyed."