9286 want refreservation=auto
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / reservation / reservation_020_pos.sh
blob554f496b07940373d7d18997faaf2eea2d75a169
1 #!/usr/bin/bash -p
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.
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 2018 Joyent, Inc.
17 . $STF_SUITE/include/libtest.shlib
18 . $STF_SUITE/tests/functional/reservation/reservation.shlib
21 # DESCRIPTION:
23 # Cloning a thick provisioned volume results in a sparse volume
25 # STRATEGY:
26 # 1) Create a thick provisioned volume.
27 # 2) Snapshot and clone it.
28 # 3) Verify that the clone is sparse.
31 verify_runnable "global"
33 function cleanup
35 if datasetexists $TESTPOOL/$TESTVOL; then
36 # Destroy first vol and descendants in one go.
37 log_must zfs destroy -Rf $TESTPOOL/$TESTVOL
41 log_onexit cleanup
43 log_assert "Cloning a thick provisioned volume results in a sparse volume"
45 space_avail=$(get_prop available $TESTPOOL)
46 (( vol_size = (space_avail / 4) & ~(1024 * 1024 - 1) ))
48 vol=$TESTPOOL/$TESTVOL
49 snap=$vol@clone
50 vol2=$TESTPOOL/$TESTVOL2
52 # Create sparse vol and verify
53 log_must zfs create -V $vol_size $vol
54 resv=$(get_prop refreservation $vol)
55 expected=$(volsize_to_reservation $vol $vol_size)
56 log_must test $resv -eq $expected
58 # Clone it
59 log_must zfs snapshot $snap
60 log_must zfs clone $snap $vol2
62 # Verify
63 resv=$(get_prop refreservation $vol2)
64 log_must test $resv -eq 0
66 log_pass "Cloning a thick provisioned volume results in a sparse volume"