From: Christian Brauner <brauner@kernel.org>
To: Eryu Guan <guan@eryu.me>,
fstests@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
David Howells <dhowells@redhat.com>,
Christian Brauner <christian.brauner@ubuntu.com>
Subject: [PATCH v12 6/6] xfs/530: quotas on idmapped mounts
Date: Mon, 29 Mar 2021 00:34:00 +0200 [thread overview]
Message-ID: <20210328223400.1800301-7-brauner@kernel.org> (raw)
In-Reply-To: <20210328223400.1800301-1-brauner@kernel.org>
From: Christian Brauner <christian.brauner@ubuntu.com>
This is basically a re-implementation of xfs/050 but each file creation
call is done through an idmapped mount which verifies that the semantics
are identical even when the mount is idmapped.
Cc: Eryu Guan <guan@eryu.me>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
/* v1 - v8 */
patch not present
/* v9 */
- Christian Brauner <christian.brauner@ubuntu.com>:
- Rebased onto current master.
/* v10 */
- Eryu Guan <guan@eryu.me>:
- Remove leading "_" from local helpers.
- Use newly introduced _scratch_{u}mount_idmapped() helpers
/* v11 */
- Amir Goldstein <amir73il@gmail.com>:
- Add a dedicated "idmapped" tag for idmapped mounts tests.
/* v12 */
unchanged
---
tests/xfs/530 | 212 ++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/530.out | 129 ++++++++++++++++++++++++++++
tests/xfs/group | 1 +
3 files changed, 342 insertions(+)
create mode 100644 tests/xfs/530
create mode 100644 tests/xfs/530.out
diff --git a/tests/xfs/530 b/tests/xfs/530
new file mode 100644
index 00000000..7d2e8771
--- /dev/null
+++ b/tests/xfs/530
@@ -0,0 +1,212 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2021 Christian Brauner <christian.brauner@ubuntu.com>
+# All Rights Reserved.
+#
+# FS QA Test No. 530
+#
+# Exercises basic XFS quota functionality
+# uquota, gquota, uqnoenforce, gqnoenforce
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+_cleanup()
+{
+ cd /
+ _scratch_unmount 2>/dev/null
+ rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# real QA test starts here
+_supported_fs xfs
+
+cp /dev/null $seqres.full
+chmod a+rwx $seqres.full # arbitrary users will write here
+
+_require_scratch
+_require_xfs_quota
+_require_user fsgqa
+_require_test_program "idmapped-mounts/mount-idmapped"
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+bsize=$(_get_file_block_size $SCRATCH_MNT)
+_scratch_unmount
+
+bsoft=$(( 200 * $bsize ))
+bhard=$(( 1000 * $bsize ))
+isoft=4
+ihard=10
+
+# The actual point at which limit enforcement takes place for the
+# hard block limit is variable depending on filesystem blocksize,
+# and iosize. What we want to test is that the limit is enforced
+# (ie. blksize less than limit but not unduly less - ~85% is kind)
+# nowadays we actually get much closer to the limit before EDQUOT.
+#
+_filter_and_check_blks()
+{
+ perl -npe '
+ if (/^\#'$id'\s+(\d+)/ && '$enforce') {
+ $maximum = '$bhard';
+ $minimum = '$bhard' * 85/100;
+ $used = $1 * 1024;
+ if (($used < $minimum || $used > $maximum) && '$noextsz') {
+ printf(" URK %d: %d is out of range! [%d,%d]\n",
+ '$id', $used, $minimum, $maximum);
+ }
+ s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
+ }
+ ' | _filter_quota_report
+}
+
+run_tests()
+{
+ _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
+ cat $tmp.mkfs >>$seqres.full
+
+ # keep the blocksize and data size for dd later
+ . $tmp.mkfs
+
+ _qmount
+
+ # Figure out whether we're doing large allocations
+ # (bail out if they're so large they stuff the test up)
+ _test_inode_flag extsz-inherit $SCRATCH_MNT
+ noextsz=$?
+ extsize=`_test_inode_extsz $SCRATCH_MNT`
+ [ $extsize -ge 512000 ] && \
+ _notrun "Extent size hint is too large ($extsize bytes)"
+
+ _qsetup $1
+
+ echo "Using type=$type id=$id" >>$seqres.full
+
+ $XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
+
+ echo
+ echo "*** report no quota settings" | tee -a $seqres.full
+ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+ -c "repquota -birnN -$type" $SCRATCH_DEV |
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
+
+ echo
+ echo "*** report initial settings" | tee -a $seqres.full
+ _scratch_mount_idmapped $type $id
+ _file_as_id $SCRATCH_MNT/initme 0 $type 1024 0
+ _scratch_umount_idmapped
+ echo "ls -l $SCRATCH_MNT" >>$seqres.full
+ ls -l $SCRATCH_MNT >>$seqres.full
+ $XFS_QUOTA_PROG -D $tmp.projects -P $temp.projid -x \
+ -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
+ -c "limit -$type isoft=$isoft ihard=$ihard $id" \
+ $SCRATCH_DEV
+ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+ -c "repquota -birnN -$type" $SCRATCH_DEV |
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
+
+ echo
+ echo "*** push past the soft inode limit" | tee -a $seqres.full
+ _scratch_mount_idmapped $type $id
+ _file_as_id $SCRATCH_MNT/softie1 0 $type 1024 0
+ _file_as_id $SCRATCH_MNT/softie2 0 $type 1024 0
+ _file_as_id $SCRATCH_MNT/softie3 0 $type 1024 0
+ _file_as_id $SCRATCH_MNT/softie4 0 $type 1024 0
+ _scratch_umount_idmapped
+ _qmount
+ $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
+ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+ -c "repquota -birnN -$type" $SCRATCH_DEV |
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
+
+ echo
+ echo "*** push past the soft block limit" | tee -a $seqres.full
+ _scratch_mount_idmapped $type $id
+ _file_as_id $SCRATCH_MNT/softie 0 $type $bsize 300
+ _scratch_umount_idmapped
+ _qmount
+ $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
+ -c "warn -b -$type 0 $id" $SCRATCH_DEV
+ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+ -c "repquota -birnN -$type" $SCRATCH_DEV |
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
+
+ echo
+ # Note: for quota accounting (not enforcement), EDQUOT is not expected
+ echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
+ for i in 1 2 3 4 5 6 7 8 9 10 11 12
+ do
+ _scratch_mount_idmapped $type $id
+ _file_as_id $SCRATCH_MNT/hard$i 0 $type 1024 0
+ _scratch_umount_idmapped
+ done
+ _qmount
+ $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" \
+ -c "warn -i -$type 0 $id" $SCRATCH_DEV
+ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+ -c "repquota -birnN -$type" $SCRATCH_DEV |
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
+
+ echo
+ # Note: for quota accounting (not enforcement), EDQUOT is not expected
+ echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
+ _scratch_mount_idmapped $type $id
+ _file_as_id $SCRATCH_MNT/softie 0 $type $bsize 1200
+ _scratch_umount_idmapped
+ echo "ls -l $SCRATCH_MNT" >>$seqres.full
+ ls -l $SCRATCH_MNT >>$seqres.full
+ _qmount
+ $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
+ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+ -c "repquota -birnN -$type" $SCRATCH_DEV |
+ _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
+
+ echo
+ echo "*** unmount"
+ _scratch_unmount
+
+}
+
+cat >$tmp.projects <<EOF
+1:$SCRATCH_MNT
+EOF
+
+cat >$tmp.projid <<EOF
+root:0
+scrach:1
+EOF
+
+projid_file="$tmp.projid"
+
+echo "*** user"
+_qmount_option "uquota"
+run_tests u
+
+echo "*** group"
+_qmount_option "gquota"
+run_tests g
+
+echo "*** uqnoenforce"
+_qmount_option "uqnoenforce"
+run_tests uno
+
+echo "*** gqnoenforce"
+_qmount_option "gqnoenforce"
+run_tests gno
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/530.out b/tests/xfs/530.out
new file mode 100644
index 00000000..39266b38
--- /dev/null
+++ b/tests/xfs/530.out
@@ -0,0 +1,129 @@
+QA output created by 530
+*** user
+meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks
+data = bsize=XXX blocks=XXX, imaxpct=PCT
+ = sunit=XXX swidth=XXX, unwritten=X
+naming =VERN bsize=XXX
+log =LDEV bsize=XXX blocks=XXX
+realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX
+
+*** report no quota settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+
+*** report initial settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 1 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the soft inode limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 5 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** push past the soft block limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [7 days] 6 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** push past the hard inode limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [7 days] 10 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** push past the hard block limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] =OK= 200 1000 0 [7 days] 10 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** unmount
+*** group
+meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks
+data = bsize=XXX blocks=XXX, imaxpct=PCT
+ = sunit=XXX swidth=XXX, unwritten=X
+naming =VERN bsize=XXX
+log =LDEV bsize=XXX blocks=XXX
+realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX
+
+*** report no quota settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+
+*** report initial settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 1 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the soft inode limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 5 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** push past the soft block limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [7 days] 6 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** push past the hard inode limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [7 days] 10 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** push past the hard block limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] =OK= 200 1000 0 [7 days] 10 4 10 00 [7 days] 0 0 0 00 [--------]
+
+*** unmount
+*** uqnoenforce
+meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks
+data = bsize=XXX blocks=XXX, imaxpct=PCT
+ = sunit=XXX swidth=XXX, unwritten=X
+naming =VERN bsize=XXX
+log =LDEV bsize=XXX blocks=XXX
+realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX
+
+*** report no quota settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+
+*** report initial settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 1 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the soft inode limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 5 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the soft block limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [--------] 6 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the hard inode limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [--------] 18 4 10 00 [--none--] 0 0 0 00 [--------]
+
+*** push past the hard block limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 1200 200 1000 00 [--none--] 18 4 10 00 [--none--] 0 0 0 00 [--------]
+
+*** unmount
+*** gqnoenforce
+meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks
+data = bsize=XXX blocks=XXX, imaxpct=PCT
+ = sunit=XXX swidth=XXX, unwritten=X
+naming =VERN bsize=XXX
+log =LDEV bsize=XXX blocks=XXX
+realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX
+
+*** report no quota settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+
+*** report initial settings
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 1 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the soft inode limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 0 200 1000 00 [--------] 5 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the soft block limit
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [--------] 6 4 10 00 [--------] 0 0 0 00 [--------]
+
+*** push past the hard inode limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 300 200 1000 00 [--------] 18 4 10 00 [--none--] 0 0 0 00 [--------]
+
+*** push past the hard block limit (expect EDQUOT)
+[ROOT] 0 0 0 00 [--------] 3 0 0 00 [--------] 0 0 0 00 [--------]
+[NAME] 1200 200 1000 00 [--none--] 18 4 10 00 [--none--] 0 0 0 00 [--------]
+
+*** unmount
diff --git a/tests/xfs/group b/tests/xfs/group
index 03b447c7..0b4d1b21 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -506,3 +506,4 @@
527 auto quick quota
528 auto quick rw realtime
529 auto quick quota idmapped
+530 auto quick quota idmapped
--
2.27.0
next prev parent reply other threads:[~2021-03-28 22:35 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-28 22:33 [PATCH v12 0/6] fstests: add idmapped mounts tests Christian Brauner
2021-03-28 22:33 ` [PATCH v12 1/6] generic/631: add test for detached mount propagation Christian Brauner
2021-03-28 22:33 ` [PATCH v12 3/6] common/rc: add _scratch_{u}mount_idmapped() helpers Christian Brauner
2021-03-28 22:33 ` [PATCH v12 4/6] common/quota: move _qsetup() helper to common code Christian Brauner
2021-03-28 22:33 ` [PATCH v12 5/6] xfs/529: quotas and idmapped mounts Christian Brauner
2021-03-28 22:34 ` Christian Brauner [this message]
[not found] ` <20210328223400.1800301-3-brauner@kernel.org>
2021-04-11 14:30 ` [PATCH v12 2/6] generic/632: add fstests for " Eryu Guan
2021-04-11 15:12 ` Christian Brauner
2021-04-11 15:18 ` Christian Brauner
2021-04-11 15:21 ` Eryu Guan
2021-04-11 15:32 ` Christian Brauner
2021-04-12 0:40 ` Theodore Ts'o
2021-04-12 11:54 ` Christian Brauner
2021-04-12 22:41 ` Theodore Ts'o
2021-04-14 20:47 ` [PATCH -RFC] ext4: add feature file to advertise that ext4 supports " Theodore Ts'o
2021-04-15 5:54 ` Christoph Hellwig
2021-04-15 7:49 ` Christian Brauner
2021-04-15 7:55 ` Christoph Hellwig
2021-04-15 8:13 ` Christian Brauner
2021-04-15 14:59 ` Theodore Ts'o
2021-04-12 7:22 ` [PATCH v12 2/6] generic/632: add fstests for " Christoph Hellwig
2021-04-12 7:30 ` Christian Brauner
2021-04-11 15:19 ` Eryu Guan
2021-04-11 14:37 ` [PATCH v12 0/6] fstests: add idmapped mounts tests Eryu Guan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210328223400.1800301-7-brauner@kernel.org \
--to=brauner@kernel.org \
--cc=christian.brauner@ubuntu.com \
--cc=dhowells@redhat.com \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=hch@lst.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).