4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/tests/functional/quota/quota.cfg
33 # BLOCK_SIZE, QUOTA_VALUE and TOLERANCE set in quota.cfg
37 # Function to fill the quota of a zfs filesystem
39 # $1 - The File system or container to fill.
40 # $2 - The mountpoint to use.
44 typeset FILESYSTEM="$1"
47 log_must zfs set quota=$QUOTA_VALUE $FILESYSTEM
49 typeset -i write_size=0
50 (( write_size = 2 * QUOTA_VALUE ))
53 file_write -o create -f $MNTPT/$TESTFILE1 -b $BLOCK_SIZE \
56 [[ $zret -ne EDQUOT ]] && \
57 log_fail "Returned error code: $zret. Expected: $EDQUOT."
59 typeset -i file_size=`ls -ls $MNTPT/$TESTFILE1 | awk '{ print $1 }'`
61 (( file_size = file_size * 512 ))
62 (( limit = QUOTA_VALUE + TOLERANCE ))
63 (( file_size > limit )) && \
64 log_fail "File was created larger than the quota value, aborting!!!"
69 # Function attempts to write another file in a ZFS filesystem
70 # that has already filled its quota
74 typeset FILESYSTEM="$1"
77 log_must fill_quota $FILESYSTEM $MNTPT
78 typeset -i write_size=0
79 (( write_size = 2 * QUOTA_VALUE ))
82 # Writing a file without API to access return code
84 log_note "Creating a file in a FS that has already exceeded its quota"
85 file_write -o create -f $MNTPT/$TESTFILE2 \
86 -b $BLOCK_SIZE -c $write_size -d 0
88 [[ $zret -ne EDQUOT ]] && \
89 log_fail "Returned error code: $zret. Expected: EDQUOT."