From patchwork Mon Apr 12 11:57:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 12197857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23024C433ED for ; Mon, 12 Apr 2021 11:58:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC2476134F for ; Mon, 12 Apr 2021 11:58:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240790AbhDLL6t (ORCPT ); Mon, 12 Apr 2021 07:58:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:40658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240800AbhDLL6s (ORCPT ); Mon, 12 Apr 2021 07:58:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1E06A6121E; Mon, 12 Apr 2021 11:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618228711; bh=lW/RvRvgB21EpGukDnLmq2WJYHCWFxAD7uiU6NGIpww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0qID5xARgZnXST+F/7j2UIS4H7fJrPSeAUBp7vcOVbtbTNXTbia8yCFkD9jH1HCF N//AxftIWb0GUm30EDzy9RaTppQsbITqmPT0qiIkSYWYkHFkLFI+p/1Ti2934eTvKR 1ykq3pachZEYVOrKx/SyCq5L3uaX5ypHsubHstk3s7PEXt51v8t1zM9wAn4KcLNUfW buRXR4L5reygAKZh3q4fgxo7IgCF1j6vMIiPNqebGgkxiBkN810Ks1OrIuHp6XAQQ5 qBlbhXbQnOnHGm6eZDMIHYEvizJxEGCQ3Ds5xHkWZXm93vFSMXSaYbaaRQmv6c8v0D 8xe9qHzLwlzaw== From: Christian Brauner To: Eryu Guan , fstests@vger.kernel.org, Christoph Hellwig Cc: "Darrick J . Wong" , David Howells , Christian Brauner Subject: [PATCH v13 6/6] xfs/530: quotas on idmapped mounts Date: Mon, 12 Apr 2021 13:57:08 +0200 Message-Id: <20210412115708.1628386-7-brauner@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210412115708.1628386-1-brauner@kernel.org> References: <20210412115708.1628386-1-brauner@kernel.org> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=cOLF8OTvRYXC3y485VSv6ujk3GSawMtRMrE2w7da8uQ=; m=NSojVSEcGmHs17du71gAqBeEPUmyNa+aTP10K3+zNDY=; p=YmyKZ3x+HfbhSpUZ22s0BYgon4xXsSTU2/r666AZn3Q=; g=449fa117ecf05392fede090ee1450662b6410bcc X-Patch-Sig: m=pgp; i=christian.brauner@ubuntu.com; s=0x0x91C61BC06578DCA2; b=iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCYHQ1gwAKCRCRxhvAZXjcoiCaAP4k5JO ff5o5tannkUqtJV/OJsPFQFD8rxFGWR5YCwGW4AEAyIvMul01hgzHV7OZoID4yzBMUqHoo7I8ojXE l11XAws= Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Christian Brauner 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 Cc: Darrick J. Wong Cc: fstests@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Christian Brauner --- /* v1 - v8 */ patch not present /* v9 */ - Christian Brauner : - Rebased onto current master. /* v10 */ - Eryu Guan : - Remove leading "_" from local helpers. - Use newly introduced _scratch_{u}mount_idmapped() helpers /* v11 */ - Amir Goldstein : - Add a dedicated "idmapped" tag for idmapped mounts tests. /* v12 */ unchanged /* v13 */ - Eryu Guan : - Change mode of newly created files to match others. --- tests/xfs/530 | 212 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/530.out | 129 ++++++++++++++++++++++++++++ tests/xfs/group | 1 + 3 files changed, 342 insertions(+) create mode 100755 tests/xfs/530 create mode 100644 tests/xfs/530.out diff --git a/tests/xfs/530 b/tests/xfs/530 new file mode 100755 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 +# 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 <$tmp.projid <