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
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.
14 # Copyright (c) 2018 by Delphix. All rights reserved.
18 # Verify zfs destroy test for clones with the livelist feature
22 # 1. One clone with an empty livelist
23 # - create the clone, check that livelist exists
24 # - delete the clone, check that livelist is eventually
26 # 2. One clone with populated livelist
27 # - create the clone, check that livelist exists
28 # - write multiple files to the clone
29 # - delete the clone, check that livelist is eventually
31 # 3. Multiple clones with empty livelists
32 # - same as 1. but with multiple clones
33 # 4. Multiple clones with populated livelists
34 # - same as 2. but with multiple clones
36 .
$STF_SUITE/include
/libtest.shlib
37 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_destroy
/zfs_destroy_common.kshlib
41 datasetexists
$TESTPOOL/$TESTFS1 && zfs destroy
-R $TESTPOOL/$TESTFS1
42 # reset the livelist sublist size to its original value
43 set_tunable64
$LIVELIST_MAX_ENTRIES $ORIGINAL_MAX
46 function clone_write_file
48 log_must mkfile
1m
/$TESTPOOL/$1/$2
49 log_must zpool sync
$TESTPOOL
52 function test_one_empty
54 clone_dataset
$TESTFS1 snap
$TESTCLONE
56 log_must zfs destroy
$TESTPOOL/$TESTCLONE
62 clone_dataset
$TESTFS1 snap
$TESTCLONE
64 clone_write_file
$TESTCLONE $TESTFILE0
65 clone_write_file
$TESTCLONE $TESTFILE1
66 clone_write_file
$TESTCLONE $TESTFILE2
67 log_must
rm /$TESTPOOL/$TESTCLONE/$TESTFILE0
68 log_must
rm /$TESTPOOL/$TESTCLONE/$TESTFILE2
69 check_livelist_exists
$TESTCLONE
71 log_must zfs destroy
$TESTPOOL/$TESTCLONE
75 function test_multiple_empty
77 clone_dataset
$TESTFS1 snap
$TESTCLONE
78 clone_dataset
$TESTFS1 snap
$TESTCLONE1
79 clone_dataset
$TESTFS1 snap
$TESTCLONE2
81 log_must zfs destroy
$TESTPOOL/$TESTCLONE
82 log_must zfs destroy
$TESTPOOL/$TESTCLONE1
83 log_must zfs destroy
$TESTPOOL/$TESTCLONE2
87 function test_multiple
89 clone_dataset
$TESTFS1 snap
$TESTCLONE
90 clone_dataset
$TESTFS1 snap
$TESTCLONE1
91 clone_dataset
$TESTFS1 snap
$TESTCLONE2
93 clone_write_file
$TESTCLONE $TESTFILE0
95 clone_write_file
$TESTCLONE1 $TESTFILE0
96 clone_write_file
$TESTCLONE1 $TESTFILE1
97 clone_write_file
$TESTCLONE1 $TESTFILE2
99 clone_write_file
$TESTCLONE2 $TESTFILE0
100 log_must
rm /$TESTPOOL/$TESTCLONE2/$TESTFILE0
101 clone_write_file
$TESTCLONE2 $TESTFILE1
102 log_must
rm /$TESTPOOL/$TESTCLONE2/$TESTFILE1
104 check_livelist_exists
$TESTCLONE
105 check_livelist_exists
$TESTCLONE1
106 check_livelist_exists
$TESTCLONE2
108 log_must zfs destroy
$TESTPOOL/$TESTCLONE
109 log_must zfs destroy
$TESTPOOL/$TESTCLONE1
110 log_must zfs destroy
$TESTPOOL/$TESTCLONE2
114 function test_promote
116 clone_dataset
$TESTFS1 snap
$TESTCLONE
118 log_must zfs promote
$TESTPOOL/$TESTCLONE
120 log_must zfs destroy
-R $TESTPOOL/$TESTCLONE
123 ORIGINAL_MAX
=$
(get_tunable
$LIVELIST_MAX_ENTRIES)
126 log_must zfs create
$TESTPOOL/$TESTFS1
127 log_must mkfile
20m
/$TESTPOOL/$TESTFS1/atestfile
128 log_must zfs snapshot
$TESTPOOL/$TESTFS1@snap
130 # set a small livelist entry size to more easily test multiple entry livelists
131 set_tunable64
$LIVELIST_MAX_ENTRIES 20
139 log_pass
"Clone with the livelist feature enabled could be destroyed," \
140 "also could be promoted and destroyed as expected."