]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/refquota/refquota_007_neg.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / refquota / refquota_007_neg.ksh
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
37 verify_runnable "both"
38
39 function 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
46 log_onexit cleanup
47
48 TESTFILE='testfile'
49 FS=$TESTPOOL/$TESTFS
50
51 mntpnt=$(get_prop mountpoint $FS)
52 log_must mkfile 20M $mntpnt/$TESTFILE
53 log_must zfs snapshot $FS@snap20M
54 log_must rm $mntpnt/$TESTFILE
55
56 log_must sync
57
58 log_must zfs set refquota=10M $FS
59 log_mustnot zfs rollback $FS@snap20M
60
61 log_pass "The rollback to the snapshot was restricted by refquota."