From patchwork Wed Dec 27 14:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508591 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 747FA1375; Mon, 1 Jan 2024 01:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fEBrf9i9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFAC4C433C7; Mon, 1 Jan 2024 01:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071134; bh=uQgqtH9eeWV39z+CWK1TSEIoF1SZ0iUAoOrg3IIv73A=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=fEBrf9i9U+WzoFwDmtPCO0hrsYpO5JDgfmpS+vIaiKw+aKUCSiBYCFFmYzwPheBfd A0RGs3J2frksRDa4xBdemNs/InRNIdjNCScD7o7KamMvReEa7wa6fgpimor+kWTOaj rjY1LCpnrH8AXv01sLn8KnP+iNKm8CsFQKR2Mm+OffuI8dedNTbQjKUh5+6fu1M2bR gpUOLcOOvle4lO9kVOXYA/eU2Qj9A4HCAsisLrKK1yKyHJzVpzsOqBTpdEN+r/dA3D aDFxOpUvRNv5YsubvrLho4o9+a0hzSZxWvAHLbZ2mMT61XpzFzohl6LwAMO8++mSS7 mZ0KDSYFnNprw== Date: Sun, 31 Dec 2023 17:05:33 +9900 Subject: [PATCH 1/3] common: enable testing of realtime quota when supported From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405033132.1827880.10074394252232670734.stgit@frogsfrogsfrogs> In-Reply-To: <170405033118.1827880.4279631111094836504.stgit@frogsfrogsfrogs> References: <170405033118.1827880.4279631111094836504.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If the kernel advertises realtime quota support, test it. Signed-off-by: Darrick J. Wong --- common/populate | 2 +- common/quota | 12 ++++++------ common/xfs | 12 ++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/common/populate b/common/populate index 1e51eedddc..538cbc86fc 100644 --- a/common/populate +++ b/common/populate @@ -240,7 +240,7 @@ _populate_xfs_qmount_option() if [ ! -f /proc/fs/xfs/xqmstat ]; then # No quota support return - elif [ "${USE_EXTERNAL}" = "yes" ] && [ ! -z "${SCRATCH_RTDEV}" ]; then + elif [ "${USE_EXTERNAL}" = "yes" ] && [ ! -z "${SCRATCH_RTDEV}" ] && ! _xfs_supports_rtquota; then # Quotas not supported on rt filesystems return elif [ -z "${XFS_QUOTA_PROG}" ]; then diff --git a/common/quota b/common/quota index 6b529bf4b4..565057d932 100644 --- a/common/quota +++ b/common/quota @@ -23,10 +23,10 @@ _require_quota() if [ ! -f /proc/fs/xfs/xqmstat ]; then _notrun "Installed kernel does not support XFS quotas" fi - if [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ]; then + if [ "$USE_EXTERNAL" = yes ] && [ -n "$TEST_RTDEV" ] && ! _xfs_supports_rtquota; then _notrun "Quotas not supported on realtime test device" fi - if [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ]; then + if [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && ! _xfs_supports_rtquota; then _notrun "Quotas not supported on realtime scratch device" fi ;; @@ -44,10 +44,10 @@ _require_xfs_quota() { $here/src/feature -q $TEST_DEV [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota" - if [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ]; then + if [ "$USE_EXTERNAL" = yes ] && [ -n "$TEST_RTDEV" ] && ! _xfs_supports_rtquota; then _notrun "Quotas not supported on realtime test device" fi - if [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ]; then + if [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && ! _xfs_supports_rtquota; then _notrun "Quotas not supported on realtime scratch device" fi [ -n "$XFS_QUOTA_PROG" ] || _notrun "XFS quota user tools not installed" @@ -153,8 +153,8 @@ _require_prjquota() fi $here/src/feature -P $_dev [ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas" - if [ "$USE_EXTERNAL" = yes ]; then - if [ -n "$TEST_RTDEV" -o -n "$SCRATCH_RTDEV" ]; then + if [ "$FSTYP" = "xfs" ] && [ "$USE_EXTERNAL" = yes ]; then + if [ -n "$TEST_RTDEV" -o -n "$SCRATCH_RTDEV" ] && ! _xfs_supports_rtquota; then _notrun "Project quotas not supported on realtime filesystem" fi fi diff --git a/common/xfs b/common/xfs index 69a0eb620c..56c4b20889 100644 --- a/common/xfs +++ b/common/xfs @@ -2194,3 +2194,15 @@ _scratch_find_rt_metadir_entry() { return 1 } + +_xfs_supports_rtquota() { + test "$FSTYP" = "xfs" || return 1 + + local xqmfile="/proc/fs/xfs/xqm" + + test -e "$xqmfile" || modprobe xfs + test -e "$xqmfile" || return 1 + + local rtquota="$(cat "$xqmfile" | awk '{print $5}')" + test "$rtquota" = "1" +} From patchwork Wed Dec 27 14:05:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508592 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EAE31C01; Mon, 1 Jan 2024 01:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jA5H16/R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CD91C433C8; Mon, 1 Jan 2024 01:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071149; bh=D5x0sIj9yFkc/DEcY75b3vkIb+/2I7Zqk9MQ2jQUKF4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=jA5H16/RofI+WuyhJbJJG33HHEVlLlFVdX1nWTY685AtISOmURm4/5dl8yeRkmt6u l0mg+yNXzF/oIK5s5tLdiPIpE3n9YwIL/lRhvDQFmXvcUypKNzQYKY5QXNqzrXguL5 DmGZL29ka1Po/jDzqJycYljj+uhIC0BHB6IAQj25/UFKvpY4O8KLtBz3X38WAxNbGj FUgb1xxmtsIT3jZ9hgg+FxX4VuftjNPzMmIDq1Y/p9hgOxYp1NbLJmefdeSfT1JX4f RZ0BkAAOMqLb2Nebie2QXIotN06Hchbey4k+dU+/5HhpLg9BXaQ7KtHBl/cwTL6Dmp 07oWHHoA4v6DQ== Date: Sun, 31 Dec 2023 17:05:49 +9900 Subject: [PATCH 2/3] xfs: fix quota tests to adapt to realtime quota From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405033144.1827880.13287566217666431895.stgit@frogsfrogsfrogs> In-Reply-To: <170405033118.1827880.4279631111094836504.stgit@frogsfrogsfrogs> References: <170405033118.1827880.4279631111094836504.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Fix or limit the scope of tests so that we can turn on testing for realtime quotas. Signed-off-by: Darrick J. Wong --- common/quota | 22 ++++++++++++++++++++++ tests/generic/219 | 1 + tests/generic/230 | 1 + tests/generic/305 | 1 + tests/generic/326 | 1 + tests/generic/327 | 1 + tests/generic/328 | 1 + tests/generic/566 | 4 +++- tests/generic/587 | 1 + tests/generic/603 | 1 + tests/generic/691 | 2 ++ tests/generic/710 | 4 +++- tests/xfs/050 | 2 ++ tests/xfs/106 | 1 + tests/xfs/108 | 2 ++ tests/xfs/152 | 1 + tests/xfs/153 | 2 ++ tests/xfs/161 | 2 ++ tests/xfs/213 | 1 + tests/xfs/214 | 1 + tests/xfs/220 | 2 ++ tests/xfs/299 | 2 ++ tests/xfs/330 | 1 + tests/xfs/434 | 1 + tests/xfs/435 | 1 + tests/xfs/441 | 1 + tests/xfs/442 | 1 + tests/xfs/508 | 2 ++ tests/xfs/511 | 10 +++++++++- tests/xfs/720 | 5 +++++ 30 files changed, 75 insertions(+), 3 deletions(-) diff --git a/common/quota b/common/quota index 565057d932..06179eb8c8 100644 --- a/common/quota +++ b/common/quota @@ -467,5 +467,27 @@ _restore_project_quota() fi } +# Reconfigure the mounted fs as needed so that we can test the VFS quota +# utilities. They do not support realtime block limits or reporting, so +# we forcibly inhibit rtinherit on XFS filesystems. +_force_vfs_quota_testing() +{ + local mount="${1:-$TEST_DIR}" + + test "$FSTYP" = "xfs" && _xfs_force_bdev data "$mount" +} + +# Does the scratch filesystem have a realtime volume wherein quota works? +_scratch_supports_rtquota() +{ + if [ "$FSTYP" = "xfs" ]; then + test "$USE_EXTERNAL" = yes && \ + test -n "$SCRATCH_RTDEV" && \ + _xfs_supports_rtquota + else + return 1 + fi +} + # make sure this script returns success /bin/true diff --git a/tests/generic/219 b/tests/generic/219 index 71da25e352..a38dc7d84a 100755 --- a/tests/generic/219 +++ b/tests/generic/219 @@ -83,6 +83,7 @@ test_accounting() _scratch_unmount 2>/dev/null _scratch_mkfs >> $seqres.full 2>&1 _scratch_mount "-o usrquota,grpquota" +_force_vfs_quota_testing $SCRATCH_MNT quotacheck -u -g $SCRATCH_MNT 2>/dev/null quotaon $SCRATCH_MNT 2>/dev/null _scratch_unmount diff --git a/tests/generic/230 b/tests/generic/230 index e49e0da25c..8a0aac1e7b 100755 --- a/tests/generic/230 +++ b/tests/generic/230 @@ -103,6 +103,7 @@ _qmount_option 'defaults' _scratch_mkfs >> $seqres.full 2>&1 _scratch_mount "-o usrquota,grpquota" +_force_vfs_quota_testing $SCRATCH_MNT BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT) quotacheck -u -g $SCRATCH_MNT 2>/dev/null quotaon $SCRATCH_MNT 2>/dev/null diff --git a/tests/generic/305 b/tests/generic/305 index b46d512742..7c8f7692c1 100755 --- a/tests/generic/305 +++ b/tests/generic/305 @@ -27,6 +27,7 @@ echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null diff --git a/tests/generic/326 b/tests/generic/326 index f5c557b3a0..b5e4100f4a 100755 --- a/tests/generic/326 +++ b/tests/generic/326 @@ -28,6 +28,7 @@ echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null diff --git a/tests/generic/327 b/tests/generic/327 index 92540b19dd..dcdf2b3130 100755 --- a/tests/generic/327 +++ b/tests/generic/327 @@ -26,6 +26,7 @@ echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null diff --git a/tests/generic/328 b/tests/generic/328 index db7fd3db41..26c89fff62 100755 --- a/tests/generic/328 +++ b/tests/generic/328 @@ -27,6 +27,7 @@ echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null diff --git a/tests/generic/566 b/tests/generic/566 index 52b01f6d9e..052fabeb0e 100755 --- a/tests/generic/566 +++ b/tests/generic/566 @@ -37,7 +37,9 @@ _qmount dir="$SCRATCH_MNT/dummy" mkdir -p $dir chown $qa_user $dir -$XFS_QUOTA_PROG -x -c "limit -g bsoft=100k bhard=100k $qa_user" $SCRATCH_MNT +_scratch_supports_rtquota && \ + extra_limits="rtbsoft=100k rtbhard=100k" +$XFS_QUOTA_PROG -x -c "limit -g bsoft=100k bhard=100k $extra_limits $qa_user" $SCRATCH_MNT $XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m' $dir/foo >> $seqres.full chown $qa_user "${dir}/foo" diff --git a/tests/generic/587 b/tests/generic/587 index ebfeea1d17..183ec1cad7 100755 --- a/tests/generic/587 +++ b/tests/generic/587 @@ -58,6 +58,7 @@ _scratch_mkfs > $seqres.full # This test must have user quota enabled _qmount_option usrquota _qmount >> $seqres.full +_force_vfs_quota_testing $SCRATCH_MNT testfile=$SCRATCH_MNT/test-$seq touch $testfile diff --git a/tests/generic/603 b/tests/generic/603 index 08ddcbf2ec..15dc2293a1 100755 --- a/tests/generic/603 +++ b/tests/generic/603 @@ -120,6 +120,7 @@ _scratch_mkfs >$seqres.full 2>&1 _scratch_enable_pquota _qmount_option "usrquota,grpquota,prjquota" _qmount +_force_vfs_quota_testing $SCRATCH_MNT _require_prjquota $SCRATCH_DEV BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT) rm -rf $SCRATCH_MNT/t diff --git a/tests/generic/691 b/tests/generic/691 index 6432834f9f..3d43ea5b04 100755 --- a/tests/generic/691 +++ b/tests/generic/691 @@ -39,6 +39,7 @@ _scratch_mkfs >$seqres.full 2>&1 _scratch_enable_pquota _qmount_option "prjquota" _qmount +_force_vfs_quota_testing $SCRATCH_MNT _require_prjquota $SCRATCH_DEV filter_quota() @@ -66,6 +67,7 @@ exercise() _scratch_enable_pquota fi _qmount + _force_vfs_quota_testing $SCRATCH_MNT if [ "$type" = "P" ];then _create_project_quota $SCRATCH_MNT/t 100 $qa_user file=$SCRATCH_MNT/t/testfile diff --git a/tests/generic/710 b/tests/generic/710 index c7fca05d4c..2f793e03fb 100755 --- a/tests/generic/710 +++ b/tests/generic/710 @@ -33,7 +33,9 @@ $XFS_IO_PROG -f -c 'pwrite -S 0x59 0 64k -b 64k' -c 'truncate 256k' $SCRATCH_MNT chown nobody $SCRATCH_MNT/b # Set up a quota limit -$XFS_QUOTA_PROG -x -c "limit -u bhard=70k nobody" $SCRATCH_MNT +_scratch_supports_rtquota && \ + extra_limits="rtbhard=70k" +$XFS_QUOTA_PROG -x -c "limit -u bhard=70k $extra_limits nobody" $SCRATCH_MNT echo before swapext >> $seqres.full $XFS_QUOTA_PROG -x -c 'report -a' $SCRATCH_MNT >> $seqres.full diff --git a/tests/xfs/050 b/tests/xfs/050 index 10294e3f6d..03cc534bc7 100755 --- a/tests/xfs/050 +++ b/tests/xfs/050 @@ -35,6 +35,7 @@ _scratch_mkfs >/dev/null 2>&1 orig_mntopts="$MOUNT_OPTIONS" _qmount_option "uquota" _scratch_mount +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage bsize=$(_get_file_block_size $SCRATCH_MNT) # needs quota enabled to compute the number of metadata dir files HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT) @@ -77,6 +78,7 @@ _exercise() . $tmp.mkfs _qmount + _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage # Figure out whether we're doing large allocations # (bail out if they're so large they stuff the test up) diff --git a/tests/xfs/106 b/tests/xfs/106 index 388873bdee..9f00b3adb5 100755 --- a/tests/xfs/106 +++ b/tests/xfs/106 @@ -197,6 +197,7 @@ test_xfs_quota() { _qmount_option $1 _qmount + _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage if [ $type == "p" ]; then _require_prjquota $SCRATCH_DEV diff --git a/tests/xfs/108 b/tests/xfs/108 index 8593edbdd2..7f2578aa28 100755 --- a/tests/xfs/108 +++ b/tests/xfs/108 @@ -65,6 +65,7 @@ test_accounting() export MOUNT_OPTIONS="-opquota" _scratch_mkfs_xfs >> $seqres.full _qmount +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage _require_prjquota $SCRATCH_DEV # real QA test starts here @@ -73,6 +74,7 @@ _scratch_unmount 2>/dev/null _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs cat $tmp.mkfs >>$seqres.full _scratch_mount +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage uid=1 gid=2 diff --git a/tests/xfs/152 b/tests/xfs/152 index 325a05c141..f9a0bee12f 100755 --- a/tests/xfs/152 +++ b/tests/xfs/152 @@ -242,6 +242,7 @@ qmount_idmapped() { wipe_mounts _try_scratch_mount || _fail "qmount failed" + _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage mkdir -p "${SCRATCH_MNT}/unmapped" mkdir -p "${SCRATCH_MNT}/idmapped" diff --git a/tests/xfs/153 b/tests/xfs/153 index 9def579bba..304e0f11cc 100755 --- a/tests/xfs/153 +++ b/tests/xfs/153 @@ -40,6 +40,7 @@ _scratch_mkfs >/dev/null 2>&1 orig_mntopts="$MOUNT_OPTIONS" _qmount_option "uquota" _scratch_mount +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage bsize=$(_get_file_block_size $SCRATCH_MNT) # needs quota enabled to compute the number of metadata dir files HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT) @@ -82,6 +83,7 @@ run_tests() . $tmp.mkfs _qmount + _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage # Figure out whether we're doing large allocations # (bail out if they're so large they stuff the test up) diff --git a/tests/xfs/161 b/tests/xfs/161 index 486fa6ca0e..57cfe5b003 100755 --- a/tests/xfs/161 +++ b/tests/xfs/161 @@ -38,6 +38,8 @@ _qmount_option "usrquota" _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full _scratch_mount >> $seqres.full +_xfs_force_bdev data $SCRATCH_MNT + # Force the block counters for uid 1 and 2 above zero _pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full _pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full diff --git a/tests/xfs/213 b/tests/xfs/213 index e184962452..7f3b1b4f4a 100755 --- a/tests/xfs/213 +++ b/tests/xfs/213 @@ -30,6 +30,7 @@ echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT # repquota quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null diff --git a/tests/xfs/214 b/tests/xfs/214 index 84ba838f3a..858ac7ea4b 100755 --- a/tests/xfs/214 +++ b/tests/xfs/214 @@ -31,6 +31,7 @@ echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT # repquota quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null diff --git a/tests/xfs/220 b/tests/xfs/220 index 88eedf5161..77008bf80b 100755 --- a/tests/xfs/220 +++ b/tests/xfs/220 @@ -39,6 +39,7 @@ _scratch_mkfs_xfs >/dev/null 2>&1 # mount with quotas enabled _scratch_mount -o uquota +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage # turn off quota $XFS_QUOTA_PROG -x -c off $SCRATCH_DEV @@ -51,6 +52,7 @@ _scratch_mkfs_xfs >/dev/null 2>&1 # mount with quotas enabled _scratch_mount -o uquota +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage # turn off quota accounting... $XFS_QUOTA_PROG -x -c off $SCRATCH_DEV diff --git a/tests/xfs/299 b/tests/xfs/299 index 49a6527255..84fb76120d 100755 --- a/tests/xfs/299 +++ b/tests/xfs/299 @@ -157,6 +157,7 @@ projid_file="$tmp.projid" echo "*** user, group, and project" _qmount_option "uquota,gquota,pquota" _qmount +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage bsize=$(_get_file_block_size $SCRATCH_MNT) HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT) @@ -184,6 +185,7 @@ cat $tmp.mkfs >>$seqres.full echo "*** uqnoenforce, gqnoenforce, and pqnoenforce" _qmount_option "uqnoenforce,gqnoenforce,pqnoenforce" _qmount +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage _exercise uno _exercise gno _exercise pno diff --git a/tests/xfs/330 b/tests/xfs/330 index 7ebbffff2a..7c18514923 100755 --- a/tests/xfs/330 +++ b/tests/xfs/330 @@ -38,6 +38,7 @@ echo "Format and mount" _scratch_mkfs > "$seqres.full" 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> "$seqres.full" 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT) quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null diff --git a/tests/xfs/434 b/tests/xfs/434 index 12d1a0c9da..ef7652f7f3 100755 --- a/tests/xfs/434 +++ b/tests/xfs/434 @@ -47,6 +47,7 @@ _scratch_mount -o noquota >> "$seqres.full" 2>&1 testdir="$SCRATCH_MNT/test-$seq" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz blks=3 mkdir "$testdir" diff --git a/tests/xfs/435 b/tests/xfs/435 index 44135c7653..c68d7a126a 100755 --- a/tests/xfs/435 +++ b/tests/xfs/435 @@ -38,6 +38,7 @@ _scratch_mount -o quota >> "$seqres.full" 2>&1 testdir="$SCRATCH_MNT/test-$seq" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz blks=3 mkdir "$testdir" diff --git a/tests/xfs/441 b/tests/xfs/441 index 82654bf332..04682796b5 100755 --- a/tests/xfs/441 +++ b/tests/xfs/441 @@ -32,6 +32,7 @@ check_quota() { echo "Format and mount (noquota)" _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount "-o noquota" >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT # _check_quota_usage uses repquota echo "Create files" _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full diff --git a/tests/xfs/442 b/tests/xfs/442 index b04b1c8349..4a0608a095 100755 --- a/tests/xfs/442 +++ b/tests/xfs/442 @@ -70,6 +70,7 @@ _qmount_option "usrquota,grpquota,prjquota" # tests now have separate faster-running regression tests. _scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1 +_force_vfs_quota_testing $SCRATCH_MNT # _check_quota_usage uses repquota nr_cpus=$((LOAD_FACTOR * 4)) nr_ops=$((25000 * nr_cpus * TIME_FACTOR)) diff --git a/tests/xfs/508 b/tests/xfs/508 index 47c04f89de..28d5be484c 100755 --- a/tests/xfs/508 +++ b/tests/xfs/508 @@ -59,6 +59,8 @@ _require_prjquota $SCRATCH_DEV mkdir $SCRATCH_MNT/dir $QUOTA_CMD -x -c 'project -s test' $SCRATCH_MNT >>$seqres.full 2>&1 $QUOTA_CMD -x -c 'limit -p bsoft=1m bhard=2m test' $SCRATCH_MNT +_scratch_supports_rtquota && \ + $QUOTA_CMD -x -c 'limit -p rtbsoft=1m rtbhard=2m test' $SCRATCH_MNT # test the Project inheritance bit is a directory only flag, and it's set on # directory by default. Expect no complain about "project inheritance flag is diff --git a/tests/xfs/511 b/tests/xfs/511 index d2550404b0..ce7d40300c 100755 --- a/tests/xfs/511 +++ b/tests/xfs/511 @@ -40,11 +40,19 @@ $XFS_IO_PROG -f -c "pwrite 0 65536" -c sync $SCRATCH_MNT/t/file >>$seqres.full quota_cmd="$XFS_QUOTA_PROG -x" $quota_cmd -c "project -s -p $SCRATCH_MNT/t 42" $SCRATCH_MNT >/dev/null 2>&1 $quota_cmd -c 'limit -p isoft=53 bsoft=100m 42' $SCRATCH_MNT +_scratch_supports_rtquota && \ + $quota_cmd -c 'limit -p rtbsoft=100m 42' $SCRATCH_MNT + +# The golden output for this test was written with the assumption that the file +# allocation unit divides 64k evenly, so the file block usage would be exactly +# 64k. On realtime filesystems this isn't always true (e.g. -rextsize=28k) so +# we'll accept the space usage being the same as what du reports for the file. +file_nblocks=$(du -B 1024 $SCRATCH_MNT/t/file | awk '{print $1}') # The itotal and size should be 53 and 102400(k), as above project quota limit. # The isued and used should be 2 and 64(k), as this case takes. df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \ - _filter_scratch | _filter_spaces + _filter_scratch | _filter_spaces | sed -e "s|$file_nblocks$|64|" # success, all done status=0 diff --git a/tests/xfs/720 b/tests/xfs/720 index 3242a19b02..e36dc23948 100755 --- a/tests/xfs/720 +++ b/tests/xfs/720 @@ -32,6 +32,11 @@ _scratch_mkfs > "$seqres.full" 2>&1 _qmount_option usrquota _qmount +# This test tries to exceed quota limits by creating an N>2 block bmbt, setting +# the block limit to 2N, and rebuilding the bmbt. Hence we must force the +# files to be created on the data device. +_xfs_force_bdev data $SCRATCH_MNT + blocksize=$(_get_block_size $SCRATCH_MNT) alloc_unit=$(_get_file_block_size $SCRATCH_MNT) From patchwork Wed Dec 27 14:06:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508593 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94CC02F39; Mon, 1 Jan 2024 01:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gd8Z4DC5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20FE0C433C7; Mon, 1 Jan 2024 01:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071165; bh=5zgyZ17a5IknhENhiiVxqRL6/XoLCEBBODZzNSJc0jc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=gd8Z4DC57+ncwnmKSeAq+84Gb8ilAbeHKjEdFXMap+S11IJ47sahjCoFnAFXBdJ1a fOUUVrU5+HnfFMHLu9HlGSJjI+LnVmFi3iYJCvGaAkCdCU/Co/PZgxb7424KytjiMU IEg40o3eRxw/JM2pLlYQO7nvqcqM/qyepzg7H/AU3VrAf5xO+/UBt/ZaPeQpewah/j 6FLlBg8O/eUUy1oCLCK3oG89ECx4yCUxdo7slu2jQiKYkrMDWejcSEh4m4ikiBEN40 ou+OzS99kZgiAVwuzrCGBbX6STr19L8M4TO3eJy7FbeX8GnlL+VAowPoKtMCauRc7U EBZEgyT+SN4Jw== Date: Sun, 31 Dec 2023 17:06:04 +9900 Subject: [PATCH 3/3] xfs: regression testing of quota on the realtime device From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405033158.1827880.14668210590480843609.stgit@frogsfrogsfrogs> In-Reply-To: <170405033118.1827880.4279631111094836504.stgit@frogsfrogsfrogs> References: <170405033118.1827880.4279631111094836504.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Make sure that quota accounting and enforcement work correctly for realtime volumes on XFS. Signed-off-by: Darrick J. Wong --- common/quota | 30 +++++++++ tests/xfs/1858 | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1858.out | 41 +++++++++++++ 3 files changed, 239 insertions(+) create mode 100755 tests/xfs/1858 create mode 100644 tests/xfs/1858.out diff --git a/common/quota b/common/quota index 06179eb8c8..da016896ac 100644 --- a/common/quota +++ b/common/quota @@ -117,6 +117,36 @@ _require_xfs_quota_acct_enabled() _notrun "$qtype: accounting not enabled on $fsname filesystem." } +# Decide if the mounted filesystem supports realtime quotas. +_require_rtquota() +{ + local dev="$1" + test -z "$dev" && dev="$TEST_DEV" + local rtdev="$2" + test -z "$rtdev" && rtdev="$TEST_RTDEV" + + test "$FSTYP" = "xfs" || \ + _notrun "Realtime quota only supported on xfs" + + [ -n "$XFS_QUOTA_PROG" ] || \ + _notrun "xfs_quota user tool not installed" + + $here/src/feature -q $dev || \ + _notrun "Installed kernel does not support XFS quotas" + + test -b "$rtdev" || \ + _notrun "No realtime device supplied?" + + test "$USE_EXTERNAL" = "yes" || \ + _notrun "Realtime requires USE_EXTERNAL='yes'" + + $here/src/feature -U $dev || \ + $here/src/feature -G $dev || \ + $here/src/feature -P $dev || \ + _notrun "Mounted rt filesystem does not have quotas enabled" + +} + # # checks that xfs_quota can operate on foreign (non-xfs) filesystems # Skips check on xfs filesystems, old xfs_quota is fine there. diff --git a/tests/xfs/1858 b/tests/xfs/1858 new file mode 100755 index 0000000000..12c9cb392a --- /dev/null +++ b/tests/xfs/1858 @@ -0,0 +1,168 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1858 +# +# Functional testing for realtime quotas. + +. ./common/preamble +_begin_fstest auto quick quota realtime + +# Import common functions. +. ./common/quota +. ./common/filter + +# real QA test starts here +_supported_fs xfs +_require_test_program "punch-alternating" +_require_scratch +_require_user + +echo "Format filesystem" | tee -a $seqres.full +_scratch_mkfs > $seqres.full +_qmount_option 'usrquota' +_qmount +_require_rtquota $SCRATCH_DEV $SCRATCH_RTDEV + +# Make sure all our files are on the rt device +_xfs_force_bdev realtime $SCRATCH_MNT +chmod a+rwx $SCRATCH_MNT + +# Record rt geometry +bmbt_blksz=$(_get_block_size $SCRATCH_MNT) +file_blksz=$(_get_file_block_size $SCRATCH_MNT) +rextsize=$((file_blksz / bmbt_blksz)) +echo "bmbt_blksz $bmbt_blksz" >> $seqres.full +echo "file_blksz $file_blksz" >> $seqres.full +echo "rextsize $rextsize" >> $seqres.full + +note() { + echo -e "\n$*" | tee -a $seqres.full +} + +# Report on the user's block and rt block usage, soft limit, hard limit, and +# warning count for rt volumes +report_rtusage() { + local user="$1" + local timeout_arg="$2" + local print_timeout=0 + + test -z "$user" && user=$qa_user + test -n "$timeout_arg" && print_timeout=1 + + $XFS_QUOTA_PROG -c "quota -u -r -n -N $user" $SCRATCH_MNT | \ + sed -e 's/ days/_days/g' >> $seqres.full + + $XFS_QUOTA_PROG -c "quota -u -r -n -N $user" $SCRATCH_MNT | \ + sed -e 's/ days/_days/g' | \ + awk -v user=$user -v print_timeout=$print_timeout -v file_blksz=$file_blksz \ + '{printf("%s[real] %d %d %d %d %s\n", user, $2 * 1024 / file_blksz, $3 * 1024 / file_blksz, $4 * 1024 / file_blksz, $5, print_timeout ? $6 : "---");}' +} + +note "Write 128rx to root" +$XFS_IO_PROG -f -c "pwrite 0 $((128 * file_blksz))" $SCRATCH_MNT/file1 > /dev/null +chmod a+r $SCRATCH_MNT/file1 +sync +report_rtusage 0 + +note "Write 64rx to root, 4444, and 5555." +$XFS_IO_PROG -f -c "pwrite 0 $((64 * file_blksz))" $SCRATCH_MNT/file3.5555 > /dev/null +chown 5555 $SCRATCH_MNT/file3.5555 +$XFS_IO_PROG -f -c "pwrite 0 $((64 * file_blksz))" $SCRATCH_MNT/file3.4444 > /dev/null +chown 4444 $SCRATCH_MNT/file3.4444 +$XFS_IO_PROG -f -c "pwrite 0 $((64 * file_blksz))" $SCRATCH_MNT/file3 > /dev/null +sync +report_rtusage 0 +report_rtusage 4444 +report_rtusage 5555 + +note "Move 64rx from root to 5555" +chown 5555 $SCRATCH_MNT/file3 +report_rtusage 0 +report_rtusage 4444 +report_rtusage 5555 + +note "Move 64rx from 5555 to 4444" +chown 4444 $SCRATCH_MNT/file3 +report_rtusage 0 +report_rtusage 4444 +report_rtusage 5555 + +note "Set hard limit of 1024rx and check enforcement" +$XFS_QUOTA_PROG -x -c "limit -u rtbhard=$((1024 * file_blksz)) $qa_user" $SCRATCH_MNT +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite 0 $((2048 * file_blksz))' $SCRATCH_MNT/file2" +report_rtusage + +note "Set soft limit of 512rx and check timelimit enforcement" +rm -f $SCRATCH_MNT/file2 $SCRATCH_MNT/file2.1 +period=6 # seconds +$XFS_QUOTA_PROG -x -c "limit -u rtbsoft=$((512 * file_blksz)) rtbhard=0 $qa_user" $SCRATCH_MNT +$XFS_QUOTA_PROG -x -c "timer -u -r -d $period" $SCRATCH_MNT +$XFS_QUOTA_PROG -x -c 'state -u' $SCRATCH_MNT >> $seqres.full + +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite 0 $((512 * file_blksz))' $SCRATCH_MNT/file2" > /dev/null +report_rtusage + +overflow=$(date +%s) +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -b $file_blksz 0 $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage +sleep $((period / 2)) +echo "Try again after $((period / 2))s" +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -b $file_blksz $file_blksz $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage +sleep $period +echo "Try again after another ${period}s" +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -b $file_blksz $((2 * file_blksz)) $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage + +note "Extend time limits and warnings" +rm -f $SCRATCH_MNT/file2 $SCRATCH_MNT/file2.1 +$XFS_QUOTA_PROG -x -c "limit -u rtbsoft=$((512 * file_blksz)) rtbhard=0 $qa_user" $SCRATCH_MNT +$XFS_QUOTA_PROG -x -c "timer -u -r -d 49h" $SCRATCH_MNT +$XFS_QUOTA_PROG -x -c 'state -u' $SCRATCH_MNT >> $seqres.full + +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite 0 $((512 * file_blksz))' $SCRATCH_MNT/file2" > /dev/null +report_rtusage $qa_user want_timeout + +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -b $file_blksz 0 $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage $qa_user want_timeout + +$XFS_QUOTA_PROG -x -c "timer -u -r 73h $qa_user" $SCRATCH_MNT + +su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -b $file_blksz $file_blksz $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage $qa_user want_timeout + +note "Test quota applied to bmbt" + +# Testing quota enforcement for bmbt shape changes is tricky. The block +# reservation will be for enough blocks to handle the maximal btree split. +# This is (approximately) 9 blocks no matter the size of the existing extent +# map structure, so we set the hard limit to one more than this quantity. +# +# However, that means that we need to make a file of at least twice that size +# to ensure that we create enough extent records even in the rextsize==1 case +# where punching doesn't just create unwritten records. +# +# Unfortunately, it's very difficult to predict when exactly the EDQUOT will +# come down, so we just look for the error message. +extent_records=$(( (25 * bmbt_blksz) / 16)) +echo "extent_records $extent_records" >> $seqres.full + +rm -f $SCRATCH_MNT/file2 +$XFS_QUOTA_PROG -x -c "limit -u rtbsoft=0 rtbhard=0 $qa_user" $SCRATCH_MNT +$XFS_QUOTA_PROG -x -c "limit -u bhard=$((bmbt_blksz * 10)) bsoft=0 $qa_user" $SCRATCH_MNT +$XFS_QUOTA_PROG -x -c 'state -u' $SCRATCH_MNT >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x58 -b 64m 0 $((extent_records * file_blksz))" $SCRATCH_MNT/file2 > /dev/null +sync +chown $qa_user $SCRATCH_MNT/file2 +$here/src/punch-alternating $SCRATCH_MNT/file2 2>&1 | _filter_scratch + +$XFS_QUOTA_PROG -c "quota -u -r -n -N $qa_user" -c "quota -u -b -n -N $qa_user" $SCRATCH_MNT >> $seqres.full +$XFS_IO_PROG -c "bmap -e -l -p -v" $SCRATCH_MNT/file2 >> $seqres.full + +# success, all done +$XFS_QUOTA_PROG -x -c 'report -a -u' -c 'report -a -u -r' $SCRATCH_MNT >> $seqres.full +ls -latr $SCRATCH_MNT >> $seqres.full +status=0 +exit diff --git a/tests/xfs/1858.out b/tests/xfs/1858.out new file mode 100644 index 0000000000..1edee3f422 --- /dev/null +++ b/tests/xfs/1858.out @@ -0,0 +1,41 @@ +QA output created by 1858 +Format filesystem + +Write 128rx to root +0[real] 128 0 0 0 --- + +Write 64rx to root, 4444, and 5555. +0[real] 192 0 0 0 --- +4444[real] 64 0 0 0 --- +5555[real] 64 0 0 0 --- + +Move 64rx from root to 5555 +0[real] 128 0 0 0 --- +4444[real] 64 0 0 0 --- +5555[real] 128 0 0 0 --- + +Move 64rx from 5555 to 4444 +0[real] 128 0 0 0 --- +4444[real] 128 0 0 0 --- +5555[real] 64 0 0 0 --- + +Set hard limit of 1024rx and check enforcement +pwrite: Disk quota exceeded +fsgqa[real] 1024 0 1024 0 --- + +Set soft limit of 512rx and check timelimit enforcement +fsgqa[real] 512 512 0 0 --- +fsgqa[real] 513 512 0 0 --- +Try again after 3s +fsgqa[real] 514 512 0 0 --- +Try again after another 6s +pwrite: Disk quota exceeded +fsgqa[real] 514 512 0 0 --- + +Extend time limits and warnings +fsgqa[real] 512 512 0 0 [--------] +fsgqa[real] 513 512 0 0 [2_days] +fsgqa[real] 514 512 0 0 [3_days] + +Test quota applied to bmbt +SCRATCH_MNT/file2: Disk quota exceeded