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 can be set during zpool or zfs creation 37# 38# 39# STRATEGY: 40# 1. Set project{obj}quota via "zpool -O or zfs create -o" 41# 42 43verify_runnable "global" 44 45function cleanup 46{ 47 if poolexists $TESTPOOL1; then 48 log_must zpool destroy $TESTPOOL1 49 fi 50 51 if [[ -f $pool_vdev ]]; then 52 rm -f $pool_vdev 53 fi 54} 55 56log_onexit cleanup 57 58log_assert "The project{obj}quota can be set during zpool,zfs creation" 59 60typeset pool_vdev=$TEST_BASE_DIR/pool_dev.$$ 61 62log_must mkfile 500m $pool_vdev 63 64if poolexists $TESTPOOL1; then 65 zpool destroy $TESTPOOL1 66fi 67 68log_must zpool create -O projectquota@$PRJID1=$PQUOTA_LIMIT \ 69 -O projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $TESTPOOL1 $pool_vdev 70 71log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \ 72 $TESTPOOL1 > /dev/null 2>&1" 73 74log_must check_quota "projectquota@$PRJID1" $TESTPOOL1 "$PQUOTA_LIMIT" 75log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL1 "$PQUOTA_OBJLIMIT" 76 77log_must zfs create -o projectquota@$PRJID1=$PQUOTA_LIMIT \ 78 -o projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $TESTPOOL1/fs 79 80log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \ 81 $TESTPOOL1 > /dev/null 2>&1" 82 83log_must check_quota "projectquota@$PRJID1" $TESTPOOL1/fs "$PQUOTA_LIMIT" 84log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL1/fs "$PQUOTA_OBJLIMIT" 85 86log_pass "The project{obj}quota can be set during zpool,zfs creation" 87