1 #!/bin/ksh -p
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 2015, OmniTI Computer Consulting, Inc. All rights reserved.
19 #
20
21 . $STF_SUITE/include/libtest.shlib
22
23 #
24 # DESCRIPTION:
25 # refquota should be sent-and-received, but it should not interfere with
26 # the receipt of intermediate snapshots that may have proceeded the
27 # final snapshot, where the refquota should hold.
28 #
29 # STRATEGY:
30 # 1. Create a filesystem.
31 # 2. Create two equal-sized large files.
32 # 3. Snapshot the filesystem.
33 # 4. Remove one of the two large files.
34 # 5. Create a refquota larger than one file, but smaller than both.
35 # 6. Snapshot the filesystem again.
36 # 7. Send a replication stream of the second snapshot to a new filesystem.
37 #
38 #
39 # NOTE: illumos bug 4986 used the above strategy to demonstrate a failure.
40 # This test will fail until illumos 4986 is fixed.
41 #
42
43 verify_runnable "both"
44
45 function cleanup
46 {
47 log_must $ZFS destroy -rf $TESTPOOL/$TESTFS1
48 log_must $ZFS destroy -rf $TESTPOOL/$TESTFS2
49 }
50
51 log_assert "refquota is properly sent-and-received, regardless of any " \
52 "intermediate snapshots sent by a replication stream."
53 log_onexit cleanup
54
55 orig=$TESTPOOL/$TESTFS1
56 dest=$TESTPOOL/$TESTFS2
57 # 1. Create a filesystem.
58 log_must $ZFS create $orig
59 origdir=$(get_prop mountpoint $orig)
60
61 # 2. Create two equal-sized large files.
62 log_must $MKFILE 25M $origdir/file1
63 log_must $MKFILE 25M $origdir/file2
64 log_must $SYNC
65
66 # 3. Snapshot the filesystem.
67 log_must $ZFS snapshot $orig@1
68
69 # 4. Remove one of the two large files.
70 log_must $RM $origdir/file2
71 log_must $SYNC
72
73 # 5. Create a refquota larger than one file, but smaller than both.
74 log_must $ZFS set refquota=38M $orig
75
76 # 6. Snapshot the filesystem again.
77 log_must $ZFS snapshot $orig@2
78
79 # 7. Send a replication stream of the second snapshot to a new filesystem.
80 log_must $ZFS send -R $orig@2 | $ZFS recv $dest
81
82 log_pass "refquota is properly sent-and-received, regardless of any " \
83 "intermediate snapshots sent by a replication stream."