diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index ff82e0c83..a6185f982 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -179,12 +179,16 @@ tests = ['procfs_list_basic', 'procfs_list_concurrent_readers', tags = ['functional', 'procfs'] [tests/functional/projectquota:Linux] -tests = ['projectid_001_pos', 'projectid_002_pos', 'projectid_003_pos', +tests = ['defaultprojectquota_001_pos', 'defaultprojectquota_002_pos', + 'defaultprojectquota_003_neg', 'defaultprojectquota_004_pos', + 'defaultprojectquota_005_pos', 'defaultprojectquota_006_pos', + 'defaultprojectquota_007_pos', + 'projectid_001_pos', 'projectid_002_pos', 'projectid_003_pos', 'projectquota_001_pos', 'projectquota_002_pos', 'projectquota_003_pos', 'projectquota_004_neg', 'projectquota_005_pos', 'projectquota_006_pos', 'projectquota_007_pos', 'projectquota_008_pos', 'projectquota_009_pos', 'projectspace_001_pos', 'projectspace_002_pos', 'projectspace_003_pos', - 'projectspace_004_pos', + 'projectspace_004_pos', 'projectspace_005_pos', 'projecttree_001_pos', 'projecttree_002_pos', 'projecttree_003_neg'] tags = ['functional', 'projectquota'] diff --git a/tests/zfs-tests/tests/Makefile.am b/tests/zfs-tests/tests/Makefile.am index 2f71783ba..beed1a3ee 100644 --- a/tests/zfs-tests/tests/Makefile.am +++ b/tests/zfs-tests/tests/Makefile.am @@ -1761,10 +1761,18 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ functional/projectquota/projectquota_007_pos.ksh \ functional/projectquota/projectquota_008_pos.ksh \ functional/projectquota/projectquota_009_pos.ksh \ + functional/projectquota/defaultprojectquota_001_pos.ksh \ + functional/projectquota/defaultprojectquota_002_pos.ksh \ + functional/projectquota/defaultprojectquota_003_neg.ksh \ + functional/projectquota/defaultprojectquota_004_pos.ksh \ + functional/projectquota/defaultprojectquota_005_pos.ksh \ + functional/projectquota/defaultprojectquota_006_pos.ksh \ + functional/projectquota/defaultprojectquota_007_pos.ksh \ functional/projectquota/projectspace_001_pos.ksh \ functional/projectquota/projectspace_002_pos.ksh \ functional/projectquota/projectspace_003_pos.ksh \ functional/projectquota/projectspace_004_pos.ksh \ + functional/projectquota/projectspace_005_pos.ksh \ functional/projectquota/projecttree_001_pos.ksh \ functional/projectquota/projecttree_002_pos.ksh \ functional/projectquota/projecttree_003_neg.ksh \ diff --git a/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_001_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_001_pos.ksh new file mode 100755 index 000000000..337f474b9 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_001_pos.ksh @@ -0,0 +1,88 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# +# DESCRIPTION: +# Check the basic function of the defaultproject{obj}quota +# +# +# STRATEGY: +# 1. Set defaultprojectquota and overwrite the quota size. +# 2. The write operation should fail. +# 3. Set defaultprojectobjquota and overcreate the quota size. +# 4. More create should fail. +# 5. More chattr to such project should fail. +# + +function cleanup +{ + cleanup_projectquota +} + +if ! lsattr -pd > /dev/null 2>&1; then + log_unsupported "Current e2fsprogs does not support set/show project ID" +fi + +log_onexit cleanup + +log_assert "If operation overwrite defaultproject{obj}quota size, it will fail" + +mkmount_writable $QFS + +log_note "Check the defaultprojectquota" +log_must user_run $PUSER mkdir $PRJDIR +log_must chattr +P -p $PRJID1 $PRJDIR + +log_must zfs set defaultprojectquota=$PQUOTA_LIMIT $QFS +log_must user_run $PUSER mkfile $PQUOTA_LIMIT $PRJDIR/qf +sync_pool +log_mustnot user_run $PUSER mkfile 1 $PRJDIR/of + +log_must rm -rf $PRJDIR + +log_note "Check the defaultprojectobjquota" +log_must zfs set xattr=sa $QFS +log_must user_run $PUSER mkdir $PRJDIR +log_must chattr +P -p $PRJID2 $PRJDIR + +log_must zfs set defaultprojectobjquota=$PQUOTA_OBJLIMIT $QFS +log_must user_run $PUSER mkfiles $PRJDIR/qf_ $((PQUOTA_OBJLIMIT - 1)) +sync_pool +log_mustnot user_run $PUSER mkfile 1 $PRJDIR/of + +log_must user_run $PUSER touch $PRJFILE +log_must user_run $PUSER chattr -p 123 $PRJFILE +log_mustnot user_run $PUSER chattr -p $PRJID2 $PRJFILE + +log_pass "Operation overwrite defaultproject{obj}quota size failed as expect" diff --git a/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_002_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_002_pos.ksh new file mode 100755 index 000000000..aeaca2590 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_002_pos.ksh @@ -0,0 +1,86 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# DESCRIPTION: +# The defaultproject{obj}quota can be set during zpool or zfs creation +# +# +# STRATEGY: +# 1. Set defaultproject{obj}quota via "zpool -O or zfs create -o" +# + +verify_runnable "global" + +function cleanup +{ + if poolexists $TESTPOOL1; then + log_must zpool destroy $TESTPOOL1 + fi + + if [[ -f $pool_vdev ]]; then + rm -f $pool_vdev + fi +} + +log_onexit cleanup + +log_assert "The defaultproject{obj}quota can be set during zpool,zfs creation" + +typeset pool_vdev=$TEST_BASE_DIR/pool_dev.$$ + +log_must mkfile 500m $pool_vdev + +if poolexists $TESTPOOL1; then + zpool destroy $TESTPOOL1 +fi + +log_must zpool create -O defaultprojectquota=$PQUOTA_LIMIT \ + -O defaultprojectobjquota=$PQUOTA_OBJLIMIT $TESTPOOL1 $pool_vdev + +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL1 > /dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL1 "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL1 "$PQUOTA_OBJLIMIT" + +log_must zfs create -o defaultprojectquota=$PQUOTA_LIMIT \ + -o defaultprojectobjquota=$PQUOTA_OBJLIMIT $TESTPOOL1/fs + +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL1 > /dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL1/fs "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL1/fs "$PQUOTA_OBJLIMIT" + +log_pass "The defaultproject{obj}quota can be set during zpool,zfs creation" diff --git a/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_003_neg.ksh b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_003_neg.ksh new file mode 100755 index 000000000..0111e5e98 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_003_neg.ksh @@ -0,0 +1,76 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# DESCRIPTION: +# Check the invalid parameter of zfs set defaultproject{obj}quota +# +# +# STRATEGY: +# 1. check the invalid zfs set defaultproject{obj}quota to fs +# 2. check the valid zfs set defaultproject{obj}quota to snapshots +# + +function cleanup +{ + datasetexists $snap_fs && destroy_dataset $snap_fs + + log_must cleanup_projectquota +} + +log_onexit cleanup + +log_assert "Check the invalid parameter of zfs set defaultproject{obj}quota" +typeset snap_fs=$QFS@snap + +log_must zfs snapshot $snap_fs + +log_note "can set all numeric id even if that id does not exist" +log_must zfs set defaultprojectquota=100m $QFS + +set -A sizes "100mfsd" "m0.12m" "GGM" "-1234-m" "123m-m" +for size in "${sizes[@]}"; do + log_note "can not set defaultprojectquota with invalid size parameter" + log_mustnot zfs set defaultprojectquota=$size $QFS +done + +log_note "can not set defaultprojectquota to snapshot $snap_fs" +log_mustnot zfs set defaultprojectquota=100m $snap_fs + +log_note "can not set defaultprojectobjquota with invalid size parameter" +log_mustnot zfs set defaultprojectobjquota=100msfsd $QFS + +log_note "can not set defaultprojectobjquota to snapshot $snap_fs" +log_mustnot zfs set defaultprojectobjquota=100m $snap_fs + +log_pass "Check the invalid parameter of zfs set defaultproject{obj}quota" diff --git a/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_004_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_004_pos.ksh new file mode 100755 index 000000000..b833e96b5 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_004_pos.ksh @@ -0,0 +1,66 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# DESCRIPTION: +# Check the invalid parameter of zfs get defaultproject{obj}quota +# +# +# STRATEGY: +# 1. check the invalid zfs get defaultproject{obj}quota to fs +# 2. check the valid zfs get defaultproject{obj}quota to snapshots +# + +function cleanup +{ + datasetexists $snap_fs && destroy_dataset $snap_fs + + log_must cleanup_projectquota +} + +log_onexit cleanup + +log_assert "Check the invalid parameter of zfs get defaultproject{obj}quota" +typeset snap_fs=$QFS@snap + +log_must zfs snapshot $snap_fs + +set -A no_prjs "mms1234" "ss@#" "root-122" +for prj in "${no_prjs[@]}"; do + log_must eval "zfs get defaultprojectquota $QFS >/dev/null 2>&1" + log_must eval "zfs get defaultprojectquota $snap_fs >/dev/null 2>&1" + log_must eval "zfs get defaultprojectobjquota $QFS >/dev/null 2>&1" + log_must eval "zfs get defaultprojectobjquota $snap_fs >/dev/null 2>&1" +done + +log_pass "Check the invalid parameter of zfs get defaultproject{obj}quota" diff --git a/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_005_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_005_pos.ksh new file mode 100755 index 000000000..b828b4645 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_005_pos.ksh @@ -0,0 +1,75 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# DESCRIPTION: +# defaultprojectquota can be set beyond the fs quota. +# defaultprojectquota can be set at a smaller size than its current usage. +# +# STRATEGY: +# 1. set quota to a fs and set a larger size of defaultprojectquota +# 2. write some data to the fs and set a smaller defaultprojectquota +# + +function cleanup +{ + log_must cleanup_projectquota + log_must zfs set quota=none $QFS +} + +if ! lsattr -pd > /dev/null 2>&1; then + log_unsupported "Current e2fsprogs does not support set/show project ID" +fi + +log_onexit cleanup + +log_assert "Check set defaultprojectquota to larger than the quota size of a fs" + +log_must zfs set quota=200m $QFS +log_must zfs set defaultprojectquota=500m $QFS + +log_must zfs get defaultprojectquota $QFS + +log_note "write some data to the $QFS" +mkmount_writable $QFS +log_must user_run $PUSER mkdir $PRJDIR +log_must chattr +P -p $PRJID1 $PRJDIR +log_must user_run $PUSER mkfile 100m $PRJDIR/qf +sync_all_pools + +log_note "set defaultprojectquota at a smaller size than it current usage" +log_must zfs set defaultprojectquota=90m $QFS + +log_must zfs get defaultprojectquota $QFS + +log_pass "set defaultprojectquota to larger than quota size of a fs" diff --git a/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_006_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_006_pos.ksh new file mode 100755 index 000000000..e49fe64c9 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_006_pos.ksh @@ -0,0 +1,89 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# DESCRIPTION: +# Check defaultproject{obj}quota to snapshot that: +# 1) can not set defaultproject{obj}quota to snapshot directly +# 2) snapshot can inherit the parent fs's defaultproject{obj}quota +# 3) the defaultproject{obj}quota will not change even the parent quota changed. +# +# +# STRATEGY: +# 1. create a snapshot of a fs +# 2. set the defaultproject{obj}quota to snapshot and expect fail +# 3. set defaultproject{obj}quota to fs and check the snapshot +# 4. re-set defaultproject{obj}quota to fs and check the snapshot's value +# + +function cleanup +{ + datasetexists $snap_fs && destroy_dataset $snap_fs + + log_must cleanup_projectquota +} + +log_onexit cleanup + +log_assert "Check the snapshot's defaultproject{obj}quota" +typeset snap_fs=$QFS@snap + + +log_must zfs set defaultprojectquota=$PQUOTA_LIMIT $QFS +log_must check_quota "defaultprojectquota" $QFS "$PQUOTA_LIMIT" + +log_must zfs set defaultprojectobjquota=$PQUOTA_OBJLIMIT $QFS +log_must check_quota "defaultprojectobjquota" $QFS "$PQUOTA_OBJLIMIT" + +log_must zfs snapshot $snap_fs + +log_note "check the snapshot $snap_fs defaultproject{obj}quota" +log_must check_quota "defaultprojectquota" $snap_fs "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $snap_fs "$PQUOTA_OBJLIMIT" + +log_note "set defaultproject{obj}quota to $snap_fs which will fail" +log_mustnot zfs set defaultprojectquota=100m $snap_fs +log_mustnot zfs set defaultprojectobjquota=100 $snap_fs + +log_note "change the parent's project{obj}quota" +log_must zfs set defaultprojectquota=$((PQUOTA_LIMIT * 2)) $QFS +log_must zfs set defaultprojectobjquota=50 $QFS + +log_must check_quota "defaultprojectquota" $QFS $((PQUOTA_LIMIT * 2)) +log_must check_quota "defaultprojectobjquota" $QFS 50 + +log_note "check the snapshot $snap_fs defaultproject{obj}quota" +log_must check_quota "defaultprojectquota" $snap_fs "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $snap_fs "$PQUOTA_OBJLIMIT" + +log_pass "Check the snapshot's defaultproject{obj}quota" diff --git a/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_007_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_007_pos.ksh new file mode 100755 index 000000000..970018444 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/defaultprojectquota_007_pos.ksh @@ -0,0 +1,129 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# DESCRIPTION: +# The defaultproject{obj}quota will not change during zfs actions, such as +# snapshot,clone,rename,upgrade,send,receive. +# +# +# STRATEGY: +# 1. Create a pool, and create fs with preset defaultproject{obj}quota +# 2. Check set defaultproject{obj}quota via zfs snapshot|clone|list -o +# 3. Check the defaultproject{obj}quota can not change during zfs +# rename|upgrade|promote +# 4. Check the defaultproject{obj}quota can not change during zfs clone +# 5. Check the defaultproject{obj}quota can not change during zfs send/receive +# + +function cleanup +{ + for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do + datasetexists $ds && destroy_dataset $ds -rRf + done +} + +log_onexit cleanup + +log_assert "the defaultproject{obj}quota can't change during zfs actions" + +cleanup + +log_must zfs create -o defaultprojectquota=$PQUOTA_LIMIT \ + -o defaultprojectobjquota=$PQUOTA_OBJLIMIT $TESTPOOL/fs + +log_must zfs snapshot $TESTPOOL/fs@snap +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL >/dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL/fs@snap "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL/fs@snap \ + "$PQUOTA_OBJLIMIT" + + +log_note "clone fs gets its parent's defaultproject{obj}quota initially" +log_must zfs clone -o defaultprojectquota=$PQUOTA_LIMIT \ + -o defaultprojectobjquota=$PQUOTA_OBJLIMIT \ + $TESTPOOL/fs@snap $TESTPOOL/fs-clone + +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL >/dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL/fs-clone "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL/fs-clone \ + "$PQUOTA_OBJLIMIT" + +log_must eval "zfs list -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL/fs-clone >/dev/null 2>&1" + +log_note "zfs promote can not change the previously set defaultproject{obj}quota" +log_must zfs promote $TESTPOOL/fs-clone + +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL >/dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL/fs-clone "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL/fs-clone \ + "$PQUOTA_OBJLIMIT" + +log_note "zfs send receive can not change the previously set defaultproject{obj}quota" +log_must zfs send $TESTPOOL/fs-clone@snap | zfs receive $TESTPOOL/fs-rev + +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL >/dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL/fs-rev "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL/fs-rev \ + "$PQUOTA_OBJLIMIT" + +log_note "zfs rename can not change the previously set defaultproject{obj}quota" +log_must zfs rename $TESTPOOL/fs-rev $TESTPOOL/fs-rename + +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL >/dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL/fs-rename "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL/fs-rename \ + "$PQUOTA_OBJLIMIT" + +log_note "zfs upgrade can not change the previously set defaultproject{obj}quota" +log_must zfs upgrade $TESTPOOL/fs-rename + +log_must eval "zfs list -r -o defaultprojectquota,defaultprojectobjquota \ + $TESTPOOL >/dev/null 2>&1" + +log_must check_quota "defaultprojectquota" $TESTPOOL/fs-rename "$PQUOTA_LIMIT" +log_must check_quota "defaultprojectobjquota" $TESTPOOL/fs-rename \ + "$PQUOTA_OBJLIMIT" + +log_pass "the defaultproject{obj}quota can't change during zfs actions" diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_007_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectquota_007_pos.ksh index a12893e25..e3711229c 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_007_pos.ksh @@ -53,7 +53,7 @@ log_assert "Check zfs get all will not print out project{obj}quota" log_must zfs set projectquota@$PRJID1=50m $QFS log_must zfs set projectobjquota@$PRJID2=100 $QFS -log_mustnot eval "zfs get all $QFS | grep projectquota" -log_mustnot eval "zfs get all $QFS | grep projectobjquota" +log_mustnot eval "zfs get all $QFS | grep -w projectquota" +log_mustnot eval "zfs get all $QFS | grep -w projectobjquota" log_pass "zfs get all will not print out project{obj}quota" diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib b/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib index 9a77dfddb..7776c8f40 100644 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib @@ -44,6 +44,8 @@ function cleanup_projectquota log_must zfs set projectobjquota@$PRJID1=none $QFS log_must zfs set projectquota@$PRJID2=none $QFS log_must zfs set projectobjquota@$PRJID2=none $QFS + log_must zfs set defaultprojectquota=none $QFS + log_must zfs set defaultprojectobjquota=none $QFS log_must chmod 0755 $mntp fi diff --git a/tests/zfs-tests/tests/functional/projectquota/projectspace_005_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectspace_005_pos.ksh new file mode 100755 index 000000000..e22fbf7a9 --- /dev/null +++ b/tests/zfs-tests/tests/functional/projectquota/projectspace_005_pos.ksh @@ -0,0 +1,83 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2017 by Fan Yong. All rights reserved. +# + +. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib + +# +# DESCRIPTION: +# Check the project used size and quota in zfs projectspace +# +# +# STRATEGY: +# 1. set zfs defaultprojectquota to a fs +# 2. write some data to the fs with specified project and size +# 3. use zfs projectspace to check the used size and quota size +# + +function cleanup +{ + datasetexists $snapfs && destroy_dataset $snapfs + + log_must cleanup_projectquota +} + +if ! lsattr -pd > /dev/null 2>&1; then + log_unsupported "Current e2fsprogs does not support set/show project ID" +fi + +log_onexit cleanup + +log_assert "Check the zfs projectspace used and quota" + +log_must zfs set defaultprojectquota=100m $QFS + +mkmount_writable $QFS +log_must user_run $PUSER mkdir $PRJDIR +log_must chattr +P -p $PRJID1 $PRJDIR +log_must user_run $PUSER mkfile 50m $PRJDIR/qf +sync_all_pools + +typeset snapfs=$QFS@snap + +log_must zfs snapshot $snapfs + +log_must eval "zfs projectspace $QFS >/dev/null 2>&1" +log_must eval "zfs projectspace $snapfs >/dev/null 2>&1" + +for fs in "$QFS" "$snapfs"; do + log_note "check the quota size in zfs projectspace $fs" + log_must eval "zfs projectspace $fs | grep $PRJID1 | grep 100M" + + log_note "check the project used size in zfs projectspace $fs" + log_must eval "zfs projectspace $fs | grep $PRJID1 | grep 50\\.\*M" +done + +log_pass "Check the zfs projectspace used and quota"