1eda14cbcSMatt Macy#!/bin/ksh -p
2eda14cbcSMatt Macy#
3eda14cbcSMatt Macy# This file and its contents are supplied under the terms of the
4eda14cbcSMatt Macy# Common Development and Distribution License ("CDDL"), version 1.0.
5eda14cbcSMatt Macy# You may only use this file in accordance with the terms of version
6eda14cbcSMatt Macy# 1.0 of the CDDL.
7eda14cbcSMatt Macy#
8eda14cbcSMatt Macy# A full copy of the text of the CDDL should have accompanied this
9eda14cbcSMatt Macy# source.  A copy of the CDDL is also available via the Internet at
10eda14cbcSMatt Macy# http://www.illumos.org/license/CDDL.
11eda14cbcSMatt Macy#
12eda14cbcSMatt Macy
13eda14cbcSMatt Macy#
14eda14cbcSMatt Macy# Copyright 2018 Joyent, Inc.
15eda14cbcSMatt Macy#
16eda14cbcSMatt Macy
17eda14cbcSMatt Macy. $STF_SUITE/include/libtest.shlib
18eda14cbcSMatt Macy. $STF_SUITE/tests/functional/reservation/reservation.shlib
19eda14cbcSMatt Macy
20eda14cbcSMatt Macy#
21eda14cbcSMatt Macy# DESCRIPTION:
22eda14cbcSMatt Macy#
23eda14cbcSMatt Macy# The use of refreservation=auto on a filesystem does not change the
24eda14cbcSMatt Macy# refreservation and results in an error.
25eda14cbcSMatt Macy#
26eda14cbcSMatt Macy# STRATEGY:
27eda14cbcSMatt Macy# 1) Create a filesystem
28eda14cbcSMatt Macy# 2) Verify that zfs set refreservation=auto fails without changing
29eda14cbcSMatt Macy# refreservation from none.
30eda14cbcSMatt Macy# 3) Set refreservation to a valid value.
31eda14cbcSMatt Macy# 4) Verify that zfs set refreservation=auto fails without changing
32eda14cbcSMatt Macy# refreservation from the previous value.
33eda14cbcSMatt Macy#
34eda14cbcSMatt Macy
35eda14cbcSMatt Macyverify_runnable "both"
36eda14cbcSMatt Macy
37*dae17134SMartin Matuskafs=$TESTPOOL/$TESTFS/${0##*/}.$$
38eda14cbcSMatt Macy
39eda14cbcSMatt Macyfunction cleanup
40eda14cbcSMatt Macy{
41eda14cbcSMatt Macy	destroy_dataset "$fs" "-f"
42eda14cbcSMatt Macy}
43eda14cbcSMatt Macy
44eda14cbcSMatt Macylog_onexit cleanup
45eda14cbcSMatt Macy
46eda14cbcSMatt Macylog_assert "refreservation=auto on a filesystem generates an error without" \
47eda14cbcSMatt Macy	"changing refreservation"
48eda14cbcSMatt Macy
49eda14cbcSMatt Macyspace_avail=$(get_prop available $TESTPOOL)
50eda14cbcSMatt Macy(( fs_size = space_avail / 4 ))
51eda14cbcSMatt Macy
52eda14cbcSMatt Macy# Create a filesystem with no refreservation
53eda14cbcSMatt Macylog_must zfs create $fs
54eda14cbcSMatt Macyresv=$(get_prop refreservation $fs)
55eda14cbcSMatt Macylog_must test $resv -eq 0
56eda14cbcSMatt Macy
57eda14cbcSMatt Macy# Verify that refreservation=auto fails without altering refreservation
58eda14cbcSMatt Macylog_mustnot zfs set refreservation=auto $fs
59eda14cbcSMatt Macyresv=$(get_prop refreservation $fs)
60eda14cbcSMatt Macylog_must test $resv -eq 0
61eda14cbcSMatt Macy
62eda14cbcSMatt Macy# Set refreservation and verify
63eda14cbcSMatt Macylog_must zfs set refreservation=$fs_size $fs
64eda14cbcSMatt Macyresv=$(get_prop refreservation $fs)
65eda14cbcSMatt Macylog_must test $resv -eq $fs_size
66eda14cbcSMatt Macy
67eda14cbcSMatt Macy# Verify that refreservation=auto fails without altering refreservation
68eda14cbcSMatt Macylog_mustnot zfs set refreservation=auto $fs
69eda14cbcSMatt Macyresv=$(get_prop refreservation $fs)
70eda14cbcSMatt Macylog_must test $resv -eq $fs_size
71eda14cbcSMatt Macy
72eda14cbcSMatt Macylog_pass "refreservation=auto does not work on filesystems, as expected"
73