1*f67950b2SNasf-Fan#!/bin/ksh -p
2*f67950b2SNasf-Fan#
3*f67950b2SNasf-Fan# CDDL HEADER START
4*f67950b2SNasf-Fan#
5*f67950b2SNasf-Fan# The contents of this file are subject to the terms of the
6*f67950b2SNasf-Fan# Common Development and Distribution License (the "License").
7*f67950b2SNasf-Fan# You may not use this file except in compliance with the License.
8*f67950b2SNasf-Fan#
9*f67950b2SNasf-Fan# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*f67950b2SNasf-Fan# or http://www.opensolaris.org/os/licensing.
11*f67950b2SNasf-Fan# See the License for the specific language governing permissions
12*f67950b2SNasf-Fan# and limitations under the License.
13*f67950b2SNasf-Fan#
14*f67950b2SNasf-Fan# When distributing Covered Code, include this CDDL HEADER in each
15*f67950b2SNasf-Fan# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*f67950b2SNasf-Fan# If applicable, add the following below this CDDL HEADER, with the
17*f67950b2SNasf-Fan# fields enclosed by brackets "[]" replaced with your own identifying
18*f67950b2SNasf-Fan# information: Portions Copyright [yyyy] [name of copyright owner]
19*f67950b2SNasf-Fan#
20*f67950b2SNasf-Fan# CDDL HEADER END
21*f67950b2SNasf-Fan#
22*f67950b2SNasf-Fan
23*f67950b2SNasf-Fan#
24*f67950b2SNasf-Fan# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25*f67950b2SNasf-Fan# Use is subject to license terms.
26*f67950b2SNasf-Fan#
27*f67950b2SNasf-Fan
28*f67950b2SNasf-Fan#
29*f67950b2SNasf-Fan# Copyright (c) 2017 by Fan Yong. All rights reserved.
30*f67950b2SNasf-Fan# Copyright 2019 Joyent, Inc.
31*f67950b2SNasf-Fan#
32*f67950b2SNasf-Fan
33*f67950b2SNasf-Fan. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
34*f67950b2SNasf-Fan
35*f67950b2SNasf-Fan#
36*f67950b2SNasf-Fan# DESCRIPTION:
37*f67950b2SNasf-Fan#	The project{obj}quota can be set during zpool or zfs creation
38*f67950b2SNasf-Fan#
39*f67950b2SNasf-Fan#
40*f67950b2SNasf-Fan# STRATEGY:
41*f67950b2SNasf-Fan#	1. Set project{obj}quota via "zpool -O or zfs create -o"
42*f67950b2SNasf-Fan#
43*f67950b2SNasf-Fan
44*f67950b2SNasf-Fanverify_runnable "global"
45*f67950b2SNasf-Fan
46*f67950b2SNasf-Fanfunction cleanup
47*f67950b2SNasf-Fan{
48*f67950b2SNasf-Fan	if poolexists $TESTPOOL1; then
49*f67950b2SNasf-Fan		log_must zpool destroy $TESTPOOL1
50*f67950b2SNasf-Fan	fi
51*f67950b2SNasf-Fan
52*f67950b2SNasf-Fan	if [[ -f $pool_vdev ]]; then
53*f67950b2SNasf-Fan		rm -f $pool_vdev
54*f67950b2SNasf-Fan	fi
55*f67950b2SNasf-Fan}
56*f67950b2SNasf-Fan
57*f67950b2SNasf-Fanlog_onexit cleanup
58*f67950b2SNasf-Fan
59*f67950b2SNasf-Fanlog_assert "The project{obj}quota can be set during zpool,zfs creation"
60*f67950b2SNasf-Fan
61*f67950b2SNasf-Fantypeset pool_vdev=$TEST_BASE_DIR/pool_dev.$$
62*f67950b2SNasf-Fan
63*f67950b2SNasf-Fanlog_must mkfile 500m $pool_vdev
64*f67950b2SNasf-Fan
65*f67950b2SNasf-Fanif poolexists $TESTPOOL1; then
66*f67950b2SNasf-Fan	zpool destroy $TESTPOOL1
67*f67950b2SNasf-Fanfi
68*f67950b2SNasf-Fan
69*f67950b2SNasf-Fanlog_must zpool create -O projectquota@$PRJID1=$PQUOTA_LIMIT \
70*f67950b2SNasf-Fan	-O projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $TESTPOOL1 $pool_vdev
71*f67950b2SNasf-Fan
72*f67950b2SNasf-Fanlog_must zfs create -o projectquota@$PRJID1=$PQUOTA_LIMIT \
73*f67950b2SNasf-Fan	-o projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $TESTPOOL1/fs
74*f67950b2SNasf-Fan
75*f67950b2SNasf-Fanlog_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
76*f67950b2SNasf-Fan	$TESTPOOL1 > /dev/null 2>&1"
77*f67950b2SNasf-Fan
78*f67950b2SNasf-Fanlog_must check_quota "projectquota@$PRJID1" $TESTPOOL1 "$PQUOTA_LIMIT"
79*f67950b2SNasf-Fanlog_must check_quota "projectobjquota@$PRJID2" $TESTPOOL1 "$PQUOTA_OBJLIMIT"
80*f67950b2SNasf-Fan
81*f67950b2SNasf-Fanlog_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
82*f67950b2SNasf-Fan	$TESTPOOL1 > /dev/null 2>&1"
83*f67950b2SNasf-Fan
84*f67950b2SNasf-Fanlog_must check_quota "projectquota@$PRJID1" $TESTPOOL1/fs "$PQUOTA_LIMIT"
85*f67950b2SNasf-Fanlog_must check_quota "projectobjquota@$PRJID2" $TESTPOOL1/fs "$PQUOTA_OBJLIMIT"
86*f67950b2SNasf-Fan
87*f67950b2SNasf-Fanlog_pass "The project{obj}quota can be set during zpool,zfs creation"
88