xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/projectquota/projectquota_009_pos.ksh (revision f67950b21e185934ccabe311516f4dcbdb00ef79)
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27
28#
29# Copyright (c) 2017 by Fan Yong. All rights reserved.
30#
31
32. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
33
34#
35# DESCRIPTION:
36#	The project{obj}quota will not change during zfs actions, such as
37#	snapshot,clone,rename,upgrade,send,receive.
38#
39#
40# STRATEGY:
41#	1. Create a pool, and create fs with preset project{obj}quota
42#	2. Check set project{obj}quota via zfs snapshot|clone|list -o
43#	3. Check the project{obj}quota can not change during zfs
44#	   rename|upgrade|promote
45#	4. Check the project{obj}quota can not change during zfs clone
46#	5. Check the project{obj}quota can not change during zfs send/receive
47#
48
49function cleanup
50{
51	for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do
52		if datasetexists $ds; then
53			log_must zfs destroy -rRf $ds
54		fi
55	done
56}
57
58log_onexit cleanup
59
60log_assert "the project{obj}quota can't change during zfs actions"
61
62cleanup
63
64log_must zfs create -o projectquota@$PRJID1=$PQUOTA_LIMIT \
65	-o projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $TESTPOOL/fs
66
67log_must zfs snapshot $TESTPOOL/fs@snap
68log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
69	$TESTPOOL >/dev/null 2>&1"
70
71log_must check_quota "projectquota@$PRJID1" $TESTPOOL/fs@snap "$PQUOTA_LIMIT"
72log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL/fs@snap \
73	"$PQUOTA_OBJLIMIT"
74
75
76log_note "clone fs gets its parent's project{obj}quota initially"
77log_must zfs clone  -o projectquota@$PRJID1=$PQUOTA_LIMIT \
78		-o projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT \
79		$TESTPOOL/fs@snap $TESTPOOL/fs-clone
80
81log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
82	$TESTPOOL >/dev/null 2>&1"
83
84log_must check_quota "projectquota@$PRJID1" $TESTPOOL/fs-clone "$PQUOTA_LIMIT"
85log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL/fs-clone \
86	"$PQUOTA_OBJLIMIT"
87
88log_must eval "zfs list -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
89	$TESTPOOL/fs-clone >/dev/null 2>&1"
90
91log_note "zfs promote can not change the previously set project{obj}quota"
92log_must zfs promote $TESTPOOL/fs-clone
93
94log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
95	$TESTPOOL >/dev/null 2>&1"
96
97log_must check_quota "projectquota@$PRJID1" $TESTPOOL/fs-clone "$PQUOTA_LIMIT"
98log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL/fs-clone \
99	"$PQUOTA_OBJLIMIT"
100
101log_note "zfs send receive can not change the previously set project{obj}quota"
102log_must zfs send $TESTPOOL/fs-clone@snap | zfs receive $TESTPOOL/fs-rev
103
104log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
105	$TESTPOOL >/dev/null 2>&1"
106
107log_must check_quota "projectquota@$PRJID1" $TESTPOOL/fs-rev "$PQUOTA_LIMIT"
108log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL/fs-rev \
109	"$PQUOTA_OBJLIMIT"
110
111log_note "zfs rename can not change the previously set project{obj}quota"
112log_must zfs rename $TESTPOOL/fs-rev $TESTPOOL/fs-rename
113
114log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
115	$TESTPOOL  >/dev/null 2>&1"
116
117log_must check_quota "projectquota@$PRJID1" $TESTPOOL/fs-rename "$PQUOTA_LIMIT"
118log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL/fs-rename \
119	"$PQUOTA_OBJLIMIT"
120
121log_note "zfs upgrade can not change the previously set project{obj}quota"
122log_must zfs upgrade $TESTPOOL/fs-rename
123
124log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
125	$TESTPOOL >/dev/null 2>&1"
126
127log_must check_quota "projectquota@$PRJID1" $TESTPOOL/fs-rename "$PQUOTA_LIMIT"
128log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL/fs-rename \
129	"$PQUOTA_OBJLIMIT"
130
131log_pass "the project{obj}quota can't change during zfs actions"
132