xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/projectquota/projectquota_001_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# Copyright 2019 Joyent, Inc.
31#
32
33. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
34
35#
36#
37# DESCRIPTION:
38#	Check the basic function of the project{obj}quota
39#
40#
41# STRATEGY:
42#	1. Set projectquota and overwrite the quota size.
43#	2. The write operation should fail with Disc quota exceeded
44#	3. Set projectobjquota and create up to the quota size.
45#	4. More create should fail with Disc quota exceeded
46#	5. More chattr to such project should fail with Disc quota exceeded
47#
48
49function cleanup
50{
51	cleanup_projectquota
52}
53
54log_onexit cleanup
55
56log_assert "If operation exceeds project{obj}quota size, it will fail"
57
58mkmount_writable $QFS
59
60log_note "Check the projectquota@$PRJID1"
61log_must user_run $PUSER mkdir $PRJDIR
62# log_must chattr +P -p $PRJID1 $PRJDIR
63log_must zfs project -s -p $PRJID1 $PRJDIR
64
65log_must zfs set projectquota@$PRJID1=$PQUOTA_LIMIT $QFS
66log_must user_run $PUSER mkfile $PQUOTA_LIMIT $PRJDIR/qf
67sync_pool
68log_mustnot user_run $PUSER mkfile 1 $PRJDIR/of
69
70log_must rm -rf $PRJDIR
71
72log_note "Check the projectobjquota@$PRJID2"
73log_must zfs set xattr=on $QFS
74log_must user_run $PUSER mkdir $PRJDIR
75# log_must chattr +P -p $PRJID2 $PRJDIR
76log_must zfs project -s -p $PRJID2 $PRJDIR
77
78log_must zfs set projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $QFS
79log_must user_run $PUSER mkfiles $PRJDIR/qf_ $((PQUOTA_OBJLIMIT - 1))
80sync_pool
81log_mustnot user_run $PUSER mkfile 1 $PRJDIR/of
82
83log_must user_run $PUSER touch $PRJFILE
84# log_must user_run $PUSER chattr -p 123 $PRJFILE
85log_must user_run $PUSER zfs project -s -p 123 $PRJFILE
86# log_mustnot user_run $PUSER chattr -p $PRJID2 $PRJFILE
87log_mustnot user_run $PUSER zfs project -s -p $PRJID2 $PRJFILE
88
89log_pass "Operation exceeds project{obj}quota size failed as expect"
90