1#!/bin/ksh
2#
3# CDDL HEADER START
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14# CDDL HEADER END
15#
16
17#
18# Copyright (c) 2013 by Delphix. All rights reserved.
19#
20
21. $STF_SUITE/include/libtest.shlib
22
23#
24# DESCRIPTION:
25#       refquota limits the amount of space a dataset can consume,
26#       snapshot rollback should be limited by refquota.
27#
28# STRATEGY:
29#       1. Create a file in a filesystem
30#       2. Create a snapshot of the filesystem
31#       3. Remove the file
32#       4. Set a refquota of size half of the file
33#       5. Rollback the filesystem from the snapshot
34#       6. Rollback should fail
35#
36
37verify_runnable "both"
38
39function cleanup
40{
41	log_must zfs destroy -rf $TESTPOOL/$TESTFS
42	log_must zfs create $TESTPOOL/$TESTFS
43	log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
44}
45
46log_onexit cleanup
47
48TESTFILE='testfile'
49FS=$TESTPOOL/$TESTFS
50
51mntpnt=$(get_prop mountpoint $FS)
52log_must mkfile 20M $mntpnt/$TESTFILE
53log_must zfs snapshot $FS@snap20M
54log_must rm $mntpnt/$TESTFILE
55
56sync_all_pools
57
58log_must zfs set refquota=10M $FS
59log_mustnot zfs rollback $FS@snap20M
60
61log_pass "The rollback to the snapshot was restricted by refquota."
62