]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/reservation/reservation_019_pos.sh
kernel timer API rework
[mirror_zfs.git] / tests / zfs-tests / tests / functional / reservation / reservation_019_pos.sh
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 # A thin provisioned volume can become thick provisioned with 'zfs set
24 # refreservation=auto'.
25 #
26 # STRATEGY:
27 # 1) Create a sparse value.
28 # 2) Use zfs set refreservation=auto to make it thick provisioned.
29 # 3) Verify that refreservation is now the size predicted by
30 # volsize_to_reservation().
31 #
32
33 verify_runnable "global"
34
35 function cleanup
36 {
37 destroy_dataset "$TESTPOOL/$TESTVOL" "-f"
38 }
39
40 log_onexit cleanup
41
42 log_assert "A thin provisioned volume can become thick provisioned with" \
43 "'zfs set refreservation=auto'."
44
45 space_avail=$(get_prop available $TESTPOOL)
46 (( vol_size = (space_avail / 2) & ~(1024 * 1024 - 1) ))
47
48 vol=$TESTPOOL/$TESTVOL
49
50 # Create sparse vol and verify
51 log_must zfs create -V $vol_size -s $vol
52 resv=$(get_prop refreservation $vol)
53 log_must test $resv -eq 0
54
55 # Set refreservation
56 log_must zfs set refreservation=auto $vol
57
58 # Verify
59 resv=$(get_prop refreservation $vol)
60 expected=$(volsize_to_reservation $vol $vol_size)
61 log_must test $resv -eq $expected
62
63 log_pass "Setting refreservation=auto set refreservation to expected value"