]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/reservation/reservation_020_pos.ksh
Rename reservation tests from *.sh to *.ksh
[mirror_zfs.git] / tests / zfs-tests / tests / functional / reservation / reservation_020_pos.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 2018 Joyent, Inc.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18 . $STF_SUITE/tests/functional/reservation/reservation.shlib
19
20 #
21 # DESCRIPTION:
22 #
23 # Cloning a thick provisioned volume results in a sparse volume
24 #
25 # STRATEGY:
26 # 1) Create a thick provisioned volume.
27 # 2) Snapshot and clone it.
28 # 3) Verify that the clone is sparse.
29 #
30
31 verify_runnable "global"
32
33 function cleanup
34 {
35 # Destroy first vol and descendants in one go.
36 destroy_dataset "$TESTPOOL/$TESTVOL" "-Rf"
37 }
38
39 log_onexit cleanup
40
41 log_assert "Cloning a thick provisioned volume results in a sparse volume"
42
43 space_avail=$(get_prop available $TESTPOOL)
44 (( vol_size = (space_avail / 4) & ~(1024 * 1024 - 1) ))
45
46 vol=$TESTPOOL/$TESTVOL
47 snap=$vol@clone
48 vol2=$TESTPOOL/$TESTVOL2
49
50 # Create sparse vol and verify
51 log_must zfs create -V $vol_size $vol
52 resv=$(get_prop refreservation $vol)
53 expected=$(volsize_to_reservation $vol $vol_size)
54 log_must test $resv -eq $expected
55
56 # Clone it
57 log_must zfs snapshot $snap
58 log_must zfs clone $snap $vol2
59
60 # Verify
61 resv=$(get_prop refreservation $vol2)
62 log_must test $resv -eq 0
63
64 log_pass "Cloning a thick provisioned volume results in a sparse volume"