From patchwork Wed Sep 27 23:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13401805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45113E80ABC for ; Wed, 27 Sep 2023 23:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229472AbjI0XNn (ORCPT ); Wed, 27 Sep 2023 19:13:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjI0XNm (ORCPT ); Wed, 27 Sep 2023 19:13:42 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 577C8F4; Wed, 27 Sep 2023 16:13:41 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C735A5C290F; Wed, 27 Sep 2023 19:13:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 27 Sep 2023 19:13:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1695856420; x= 1695942820; bh=j+KD/sriX+e/wWHTpgo0NBnggBDG5I8dvFVim9K0Vrc=; b=V YxG2yI/3XOa0Ind2FBUSR3z0FIOzhH2p1lC9G2aFBOiUd0rxUIcspGdW960NutVH rA+jLuzhOSaeII0LTcm9tfoGHiSlbxY4r4Jlfz0BETZWsPr8SqS9MzksQt+Kdemx hi+PEDqEpKqOMo606unxWAvG8bOI7NIBQPIrVltaMRYecOpexxsEvqksAxQ152V7 GdOZHtt+szHLZoI4UC2ZclD7hrwzhdzc0iqHGzrInYsG0EIVP3Rb2jHBikXfJY84 jp1YhxdCEPvEWkSMfmAzkvpKEug6mRudw388pEr8yMP5fnbdjNvDNKJ6TEsNowRm aALuBD5Umc6h4PfIXvZ/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1695856420; x=1695942820; bh=j +KD/sriX+e/wWHTpgo0NBnggBDG5I8dvFVim9K0Vrc=; b=FCM/PSDxPpaonLtLx D1AhmvuAxQxdLo2neJNBZv2Uqy9OskTHdV72/jPxLCS8wJE5ubHh0Nw0TH1bnBFM fazjbcvRQD1Jo5sOFj1VBhVz+U2JO3YUCCPq67pjPwyL7NL+pn4sgiSh6E8NaH82 1nfg+Vk+dRbFetLT2g8zFeqklKsSMgeQhiqaOG2DrpD4HfGho6fPjHC3Q4nozoo6 /ymu4HklEkaxNeLvt18IRwkau2jfA+4dywRRS4dvz0THcjLT/E2n5cqFr5OIPROb DcEXks/kQ7RVvTcYjyXXci8VjnVUFpdqxHimEjThuVoZZlNEoTQpInMKgG0ESQEs /INaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtdehgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Sep 2023 19:13:40 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org Subject: [PATCH v3 1/6] common: refactor sysfs_attr functions Date: Wed, 27 Sep 2023 16:14:33 -0700 Message-ID: <0714f6b21000181ab43d3085903859b8ae1e1a32.1695856385.git.boris@bur.io> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Expand the has/get/require functions to allow passing a dev by parameter, and implement the test_dev specific one in terms of the new generic one. Signed-off-by: Boris Burkov --- common/rc | 127 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 82 insertions(+), 45 deletions(-) diff --git a/common/rc b/common/rc index 1618ded54..c3cd53546 100644 --- a/common/rc +++ b/common/rc @@ -4689,47 +4689,33 @@ run_fsx() rm -f $tmp.fsx } -# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +_require_statx() +{ + $here/src/stat_test --check-statx || + _notrun "This test requires the statx system call" +} + +# Get the path to the sysfs directory for the fs on a device # # Only one argument is needed: -# - attr: path name under /sys/fs/$FSTYP/DEV +# - dev: mounted block device for the fs # # Usage example: -# _require_fs_sysfs error/fail_at_unmount -_has_fs_sysfs() +# _fs_sysfs_dname /dev/mapper/scratch-dev +_fs_sysfs_dname() { - local attr=$1 - local dname + local dev=$1 + + if [ ! -b "$dev" ]; then + _fail "Usage: _fs_sysfs_dname " + fi case "$FSTYP" in btrfs) - dname=$(findmnt -n -o UUID $TEST_DEV) ;; + findmnt -n -o UUID ${dev} ;; *) - dname=$(_short_dev $TEST_DEV) ;; + _short_dev $dev ;; esac - - if [ -z "$attr" -o -z "$dname" ];then - _fail "Usage: _require_fs_sysfs " - fi - - test -e /sys/fs/${FSTYP}/${dname}/${attr} -} - -# Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR -_require_fs_sysfs() -{ - _has_fs_sysfs "$@" && return - - local attr=$1 - local dname=$(_short_dev $TEST_DEV) - - _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" -} - -_require_statx() -{ - $here/src/stat_test --check-statx || - _notrun "This test requires the statx system call" } # Write "content" into /sys/fs/$FSTYP/$DEV/$ATTR @@ -4753,13 +4739,7 @@ _set_fs_sysfs_attr() _fail "Usage: _set_fs_sysfs_attr " fi - local dname - case "$FSTYP" in - btrfs) - dname=$(findmnt -n -o UUID ${dev}) ;; - *) - dname=$(_short_dev $dev) ;; - esac + local dname=$(_fs_sysfs_dname $dev) echo "$content" > /sys/fs/${FSTYP}/${dname}/${attr} } @@ -4781,17 +4761,74 @@ _get_fs_sysfs_attr() _fail "Usage: _get_fs_sysfs_attr " fi - local dname - case "$FSTYP" in - btrfs) - dname=$(findmnt -n -o UUID ${dev}) ;; - *) - dname=$(_short_dev $dev) ;; - esac + local dname=$(_fs_sysfs_dname $dev) cat /sys/fs/${FSTYP}/${dname}/${attr} } +# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR +# +# All arguments are necessary, and in this order: +# - dev: device name, e.g. $SCRATCH_DEV +# - attr: path name under /sys/fs/$FSTYP/$dev +# +# Usage example: +# _has_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount +_has_fs_sysfs_attr() +{ + local dev=$1 + local attr=$2 + + if [ ! -b "$dev" -o -z "$attr" ];then + _fail "Usage: _get_fs_sysfs_attr " + fi + + local dname=$(_fs_sysfs_dname $dev) + + test -e /sys/fs/${FSTYP}/${dname}/${attr} +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR +# All arguments are necessary, and in this order: +# - dev: device name, e.g. $SCRATCH_DEV +# - attr: path name under /sys/fs/$FSTYP/$dev +# +# Usage example: +# _require_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount +_require_fs_sysfs_attr() +{ + _has_fs_sysfs_attr "$@" && return + + local dev=$1 + local attr=$2 + local dname=$(_fs_sysfs_dname $dev) + + _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" +} + +# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +# +# Only one argument is needed: +# - attr: path name under /sys/fs/$FSTYP/DEV +# +# Usage example: +# _has_fs_sysfs error/fail_at_unmount +_has_fs_sysfs() +{ + _has_fs_sysfs_attr $TEST_DEV "$@" +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +_require_fs_sysfs() +{ + _has_fs_sysfs "$@" && return + + local attr=$1 + local dname=$(_short_dev $TEST_DEV) + + _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" +} + # Generic test for specific filesystem feature. # Currently only implemented to test overlayfs features. _require_scratch_feature() From patchwork Wed Sep 27 23:14:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13401806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4F5CE80A8A for ; Wed, 27 Sep 2023 23:13:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229464AbjI0XNp (ORCPT ); Wed, 27 Sep 2023 19:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjI0XNo (ORCPT ); Wed, 27 Sep 2023 19:13:44 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1324DF4; Wed, 27 Sep 2023 16:13:43 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8399B5C290D; Wed, 27 Sep 2023 19:13:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 27 Sep 2023 19:13:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1695856422; x= 1695942822; bh=sRfaRBBkQ04rg2h5cwv6Nv4bH+399vIqUwVvDWHbYBs=; b=s Qy8AeD0kybNmmh33JoIG6zNwKIRfnNkWjNJ/SJ02V4SqPwMLD3Hfxga0rsFW8aVv VlIDG2fWbq6aPh6okDPOkID5X/qu0vWy0lhk3rNKHEMN3FDu1j9lLTrxyUSHFjRB wNITMrQiu8lB7BAhwsolLAIVdS3H34yJ3enmeSPrJjKoVMKGZ2Tx62K+n4k6j8fT 2sWWZ0LSdhvdcJQsnJOkrkEVhiJqtYqmhSV0HpCsbKn1lRuQVfxatTi0nabLW6GL bvHqzM6clinFIqSQ0skuIiXq5Ma+jC+HYRE7TYyDFttNPEHex9yJjPzpX3fm9d/m p15X03Pjynl2MUtie+J2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1695856422; x=1695942822; bh=s RfaRBBkQ04rg2h5cwv6Nv4bH+399vIqUwVvDWHbYBs=; b=UgfCJLkKxnJDWcN5J lz2PHdrQ2kdl8sINhwOP2LiOY0ustMlDOuUfyELHEm7Dr4GZivFPK0k/pXBAEqMT 16dAUo+h8ly0cwx37EjoLa/XcoHrQcHR6kbpBkLyg0TYydr0W3OwTPwy6ktL7ykI ZGIIxcxZZ6MjxhZcx4bZV9afehdSVbvs1XA6gDs5/6NldcPIpKz/AfGZXkEV1zBE 3xMdJFR0Jx848n9xjjbqS3/OeiuDac1DQukCgrjzqV1jf+u2XlIfZjivy6DMhKIS TWaoyVdrYaFruZBKAPd/nlhCZEGmGujOQnqdlQb9D9QjndqC+1+4O7ZO2GNtEhx2 HWSng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtdehgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Sep 2023 19:13:41 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org Subject: [PATCH v3 2/6] btrfs: quota mode helpers Date: Wed, 27 Sep 2023 16:14:34 -0700 Message-ID: <3c6f4cd053ccd2deb8ee459f5b0e5eb6fd877487.1695856385.git.boris@bur.io> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org To facilitate skipping tests depending on the qgroup mode after mkfs, add support for figuring out the mode. This cannot just rely on the new sysfs file, since it might not be present on older kernels. Signed-off-by: Boris Burkov --- common/btrfs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/common/btrfs b/common/btrfs index c9903a413..37796cc6e 100644 --- a/common/btrfs +++ b/common/btrfs @@ -689,3 +689,41 @@ _require_btrfs_scratch_logical_resolve_v2() fi _scratch_unmount } + +_qgroup_mode() +{ + local dev=$1 + + if [ ! -b "$dev" ]; then + _fail "Usage: _qgroup_mode " + fi + + if _has_fs_sysfs_attr $dev /qgroups/mode; then + _get_fs_sysfs_attr $dev qgroups/mode + else + echo "disabled" + fi +} + +_check_regular_qgroup() +{ + _qgroup_mode "$@" | grep -q 'qgroup' +} + +_require_scratch_qgroup() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT + _check_regular_qgroup $SCRATCH_DEV || _notrun "not running normal qgroups" + _scratch_unmount +} + +_require_scratch_enable_simple_quota() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _qgroup_mode $SCRATCH_DEV | grep 'squota' && _notrun "cannot enable simple quota; on by default" + $BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT || _notrun "simple quotas not available" + _scratch_unmount +} From patchwork Wed Sep 27 23:14:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13401807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05A5DE80A8A for ; Wed, 27 Sep 2023 23:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbjI0XNs (ORCPT ); Wed, 27 Sep 2023 19:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjI0XNr (ORCPT ); Wed, 27 Sep 2023 19:13:47 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDC71F4; Wed, 27 Sep 2023 16:13:44 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 35ED25C290D; Wed, 27 Sep 2023 19:13:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 27 Sep 2023 19:13:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1695856424; x= 1695942824; bh=tyNyhvTTmIo5w+mGmKoAp84+yMblo611ZQp16wug6UM=; b=f xVtkSe1DucgwQprNjV7bmJ6/3jxVId8igwl0m5gIdVt9nZhTka77PJp5F6PtSVnw Izdlnfygd2dODVnFuF+oLPDkdS6/+MEXuZ2I9095U4gRlfE0LxEH6ufAVOpkOt9E xVHjhwwVS+hhrZz6zR3YWrIhGuwA1gawDmHVerWDpwZR26xI+BeeeSTfFRVBzXRE E3bEsxxsjxlrJtDI+iX6+uapyFNiRk1/aDQF/xgvf3Jjka6k6tdnvms69e+r8Yfj XKkObJ8l3iREfzFtSB7uHTK0bAvX/u8NdE1lt2S9iqzX/yMmBNvCFws61+E2u7P3 c5Nv/gCjQruYQo4ogd3dw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1695856424; x=1695942824; bh=t yNyhvTTmIo5w+mGmKoAp84+yMblo611ZQp16wug6UM=; b=KYLMBbRNdug+Td7PW VWj1+qkYsggZVCCz1/4zpuoOcLbizSJCrFM3dS5QuUV5rgwTSJCB+C6KMxN3aufQ 9rLJjG2wa6gOhkiIEf5kCdZoWk9flLPkVQkG5PPYZfFrPoZ0jeVdLK1CvikjAXeR g6Sb7xxhW2DhQXuEznQYkqrYg00XpAlkdzdqXeRZjcRr+2Sl1SY53zM8p+qOVzxl tB0fVyy/gLeJzMzEIuH2uUhffI+MBpewi9AEYMcYENkHXy1VIKvaAYAXb7usytVy wnQpcVjb6jIjZNrpfKE5FnPut8ohLIz0BjbgVFwVyyDRRkYOnkDB/1Wu+NHd8QA7 Ui4SQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtdehgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Sep 2023 19:13:43 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org Subject: [PATCH v3 3/6] btrfs/301: new test for simple quotas Date: Wed, 27 Sep 2023 16:14:35 -0700 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Test some interesting basic and edge cases of simple quotas. To some extent, this is redundant with the alternate testing strategy of using MKFS_OPTIONS to enable simple quotas, running the full suite and relying on kernel warnings and fsck to surface issues. Signed-off-by: Boris Burkov --- tests/btrfs/301 | 418 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/301.out | 2 + 2 files changed, 420 insertions(+) create mode 100755 tests/btrfs/301 create mode 100644 tests/btrfs/301.out diff --git a/tests/btrfs/301 b/tests/btrfs/301 new file mode 100755 index 000000000..527c25230 --- /dev/null +++ b/tests/btrfs/301 @@ -0,0 +1,418 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 301 +# +# Test common btrfs simple quotas scenarios involving sharing extents and +# removing them in various orders. +# +. ./common/preamble +_begin_fstest auto quick qgroup copy_range snapshot + +# Import common functions. +# . ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs btrfs +_require_scratch +_require_scratch_enable_simple_quota + +subv=$SCRATCH_MNT/subv +nested=$SCRATCH_MNT/subv/nested +snap=$SCRATCH_MNT/snap +k=1024 +m=$(($k * $k)) +nr_fill=1024 +fill_sz=$((8 * $k)) +total_fill=$(($nr_fill * $fill_sz)) +eb_sz=$((16 * $k)) +ext_sz=$((128 * m)) +limit_nr=8 +limit=$(($ext_sz * $limit_nr)) + +get_qgroup_usage() +{ + local qgroupid=$1 + + $BTRFS_UTIL_PROG qgroup show --sync --raw $SCRATCH_MNT | grep "$qgroupid" | $AWK_PROG '{print $3}' +} + +get_subvol_usage() +{ + local subvolid=$1 + get_qgroup_usage "0/$subvolid" +} + +count_subvol_owned_metadata() +{ + local subvolid=$1 + # find nodes and leaves owned by the subvol, then get unique offsets + # to account for snapshots sharing metadata. + count=$($BTRFS_UTIL_PROG inspect-internal dump-tree $SCRATCH_DEV | \ + grep "owner $subvolid" | awk '{print $2}' | sort | uniq | wc -l) + # output bytes rather than number of metadata blocks + echo $(($count * $eb_sz)) +} + +check_qgroup_usage() +{ + local qgroupid=$1 + local expected=$2 + local actual=$(get_qgroup_usage $qgroupid) + + [ $expected -eq $actual ] || _fail "qgroup $qgroupid mismatched usage $actual vs $expected" +} + +check_subvol_usage() +{ + local subvolid=$1 + local expected_data=$2 + # need to sync to see updated usage numbers. + # could probably improve by placing syncs only where they are strictly + # needed after actual operations, but it is more error prone. + sync + + local expected_meta=$(count_subvol_owned_metadata $subvolid) + local actual=$(get_subvol_usage $subvolid) + local expected=$(($expected_data + $expected_meta)) + + [ $expected -eq $actual ] || _fail "subvol $subvolid mismatched usage $actual vs $expected (expected data $expected_data expected meta $expected_meta diff $(($actual - $expected)))" + echo "OK $subvolid $expected_data $expected_meta $actual" >> $seqres.full +} + +set_subvol_limit() +{ + local subvolid=$1 + local limit=$2 + + $BTRFS_UTIL_PROG qgroup limit $2 0/$1 $SCRATCH_MNT +} + +sync_check_subvol_usage() +{ + sync + check_subvol_usage $@ +} + +trigger_cleaner() +{ + $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT + sleep 1 + $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT +} + +cycle_mount_check_subvol_usage() +{ + _scratch_cycle_mount + check_subvol_usage $@ +} + + +do_write() +{ + local file=$1 + local sz=$2 + + $XFS_IO_PROG -fc "pwrite -q 0 $sz" $file + local ret=$? + return $ret +} + +do_enospc_write() +{ + local file=$1 + local sz=$2 + + do_write $file $sz 2>/dev/null && _fail "write expected enospc" +} + +do_falloc() +{ + local file=$1 + local sz=$2 + + $XFS_IO_PROG -fc "falloc 0 $sz" $file +} + +do_enospc_falloc() +{ + local file=$1 + local sz=$2 + + do_falloc $file $sz 2>/dev/null && _fail "falloc expected enospc" +} + +enable_quota() +{ + local mode=$1 + + [ $mode == "n" ] && return + arg=$([ $mode == "s" ] && echo "--simple") + + $BTRFS_UTIL_PROG quota enable $arg $SCRATCH_MNT +} + +prepare() +{ + _scratch_mkfs >> $seqres.full + _scratch_mount + enable_quota "s" + $BTRFS_UTIL_PROG subvolume create $subv >> $seqres.full + set_subvol_limit 256 $limit + check_subvol_usage 256 0 + + # Create a bunch of little filler files to generate several levels in + # the btree, to make snapshotting sharing scenarios complex enough. + $FIO_PROG --name=filler --directory=$subv --rw=randwrite --nrfiles=$nr_fill --filesize=$fill_sz >/dev/null 2>&1 + check_subvol_usage 256 $total_fill + + # Create a single file whose extents we will explicitly share/unshare. + do_write $subv/f $ext_sz + check_subvol_usage 256 $(($total_fill + $ext_sz)) +} + +prepare_snapshotted() +{ + prepare + $BTRFS_UTIL_PROG subvolume snapshot $subv $snap >> $seqres.full + echo "snapshot" >> $seqres.full + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 +} + +prepare_nested() +{ + prepare + $BTRFS_UTIL_PROG qgroup create 1/100 $SCRATCH_MNT + $BTRFS_UTIL_PROG qgroup assign 0/256 1/100 $SCRATCH_MNT >> $seqres.full + $BTRFS_UTIL_PROG subvolume create $nested >> $seqres.full + do_write $nested/f $ext_sz + check_subvol_usage 257 $ext_sz + check_subvol_usage 256 $(($total_fill + $ext_sz)) + local subv_usage=$(get_subvol_usage 256) + local nested_usage=$(get_subvol_usage 257) + check_qgroup_usage 1/100 $(($subv_usage + $nested_usage)) +} + +basic_accounting() +{ + prepare + echo "basic" >> $seqres.full + echo "delete file" >> $seqres.full + rm $subv/f + check_subvol_usage 256 $total_fill + cycle_mount_check_subvol_usage 256 $total_fill + do_write $subv/tmp 512M + rm $subv/tmp + do_write $subv/tmp 512M + rm $subv/tmp + do_enospc_falloc $subv/large_falloc 2G + do_enospc_write $subv/large 2G + _scratch_unmount +} + +reservation_accounting() +{ + prepare + for i in $(seq 10); do + do_write $subv/tmp 512M + rm $subv/tmp + done + do_enospc_write $subv/large 2G + _scratch_unmount +} + +snapshot_accounting() +{ + prepare_snapshotted + echo "unshare snapshot metadata" >> $seqres.full + touch $snap/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + echo "unshare snapshot data" >> $seqres.full + do_write $snap/f $ext_sz + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 $ext_sz + echo "delete snapshot file" >> $seqres.full + rm $snap/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + echo "delete original file" >> $seqres.full + rm $subv/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + _scratch_unmount +} + +delete_subvol_file() +{ + prepare_snapshotted + echo "delete subvol file first" >> $seqres.full + rm $subv/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + rm $snap/f + trigger_cleaner + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + _scratch_unmount +} + +delete_snapshot_file() +{ + prepare_snapshotted + echo "delete snapshot file first" >> $seqres.full + rm $snap/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + rm $subv/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + _scratch_unmount +} + +delete_subvol() +{ + echo "del sv" > /dev/ksmg + prepare_snapshotted + echo "delete subvol first" >> $seqres.full + $BTRFS_UTIL_PROG subvolume delete $subv >> $seqres.full + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + rm $snap/f + trigger_cleaner + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + $BTRFS_UTIL_PROG subvolume delete $snap >> $seqres.full + trigger_cleaner + check_subvol_usage 256 0 + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 0 + check_subvol_usage 257 0 + _scratch_unmount +} + +delete_snapshot() +{ + echo "del snap" > /dev/ksmg + prepare_snapshotted + echo "delete snapshot first" >> $seqres.full + $BTRFS_UTIL_PROG subvolume delete $snap >> $seqres.full + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + $BTRFS_UTIL_PROG subvolume delete $subv >> $seqres.full + trigger_cleaner + check_subvol_usage 256 0 + check_subvol_usage 257 0 + _scratch_unmount +} + +nested_accounting() +{ + echo "nested" > /dev/ksmg + prepare_nested + echo "nested" >> $seqres.full + echo "delete file" >> $seqres.full + rm $subv/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 $ext_sz + local subv_usage=$(get_subvol_usage 256) + local nested_usage=$(get_subvol_usage 257) + check_qgroup_usage 1/100 $(($subv_usage + $nested_usage)) + rm $nested/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + subv_usage=$(get_subvol_usage 256) + nested_usage=$(get_subvol_usage 257) + check_qgroup_usage 1/100 $(($subv_usage + $nested_usage)) + _scratch_unmount +} + +enable_mature() +{ + echo "mature" > /dev/ksmg + _scratch_mkfs >> $seqres.full + _scratch_mount + $BTRFS_UTIL_PROG subvolume create $subv >> $seqres.full + do_write $subv/f $ext_sz + sync + enable_quota "s" + set_subvol_limit 256 $limit + _scratch_cycle_mount + usage=$(get_subvol_usage 256) + [ $usage -lt $ext_sz ] || _fail "captured usage from before enable $usage" + do_write $subv/g $ext_sz + usage=$(get_subvol_usage 256) + [ $usage -lt $ext_sz ] && "failed to capture usage after enable $usage" + check_subvol_usage 256 $ext_sz + rm $subv/f + check_subvol_usage 256 $ext_sz + _scratch_cycle_mount + rm $subv/g + check_subvol_usage 256 0 + _scratch_unmount +} + +reflink_accounting() +{ + prepare + # do more reflinks than would fit + for i in $(seq $(($limit_nr * 2))); do + cp --reflink=always $subv/f $subv/f.i + done + # no additional data usage from reflinks + check_subvol_usage 256 $(($total_fill + $ext_sz)) + _scratch_unmount +} + +delete_link() +{ + prepare + cp --reflink=always $subv/f $subv/f.link + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f.link + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f + check_subvol_usage 256 $(($total_fill)) + _scratch_unmount +} + +delete_linked() +{ + prepare + cp --reflink=always $subv/f $subv/f.link + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f.link + check_subvol_usage 256 $(($total_fill)) + _scratch_unmount +} + +basic_accounting +reservation_accounting +snapshot_accounting +delete_subvol_file +delete_snapshot_file +delete_subvol +delete_snapshot +nested_accounting +enable_mature +reflink_accounting +delete_link +delete_linked + +echo "Silence is golden" + +# success, all done +status=0 +exit diff --git a/tests/btrfs/301.out b/tests/btrfs/301.out new file mode 100644 index 000000000..4025504e4 --- /dev/null +++ b/tests/btrfs/301.out @@ -0,0 +1,2 @@ +QA output created by 301 +Silence is golden From patchwork Wed Sep 27 23:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13401808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81297E80ABC for ; Wed, 27 Sep 2023 23:13:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbjI0XNt (ORCPT ); Wed, 27 Sep 2023 19:13:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjI0XNs (ORCPT ); Wed, 27 Sep 2023 19:13:48 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7597CF5; Wed, 27 Sep 2023 16:13:46 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E10695C2806; Wed, 27 Sep 2023 19:13:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 27 Sep 2023 19:13:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1695856425; x= 1695942825; bh=nKPcB7v/h+P6IKZebcF+3glNhmXxwFRSsv67QuHq9ik=; b=x X2V2fqQCJjyOywobUs9uCvhmKWMhDNgYNMftuGNcOsjDxBBHWd50U9ULdY15C1EJ UQQzVp9S4t994ncGTEqQK8gGjOB+d6J/W72L7KxwvCfBDRkMu/pQsYMMlSbCMGfc wrm5WIaQKP6aFPMPKtLzgniBWX7p+m7exVilEmFBA1fI10TGMX5z6ht5CZeDoPkv FQlfyGguMBnb3yVfyW1n7YiVC94mBXpnxesKtcmRdwzEFekyHLjjDd19L/5BFDKg c77KZZtQyvq9VHxulFagpAPTuMSHTys5dBi0MfKLuKamC8ht8oHZe/9ZNKDeQXXS ABNy91JKr/iVIDuB0ZUVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1695856425; x=1695942825; bh=n KPcB7v/h+P6IKZebcF+3glNhmXxwFRSsv67QuHq9ik=; b=bONNCpe4xjOcY/2ZM ycAJ/JS2u5MBiOQ1UUG6M/mRXC+tIp9HXXWZtdLG1ZTS4Maf1rvlpKIkyvVPfTBb iNgKF3EjK2ut+073em/TRkVpGrMmEHieB5jOgv9tKlrBcQKa/MhzzLGTYv9AhydL SRjkQDt0pX4ulmdIe8xMQxk3aEnv83L9NYGUJ1qs88Qvt1y19DO4cPv5BKxrQySg u7hcn1PdpwA98HpY5xOQ1aTmqwjhTYL/h/6A5keCc82n+/NRJZHu4WUa/3y0dh8+ u2uLIqQkLiQJlAM4OP8N1cnp7FGRrquFTqEgwZtkb30eta/DmzZsEwygzMqsCa3z LZTvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtdehgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Sep 2023 19:13:45 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org Subject: [PATCH v3 4/6] btrfs: quota rescan helpers Date: Wed, 27 Sep 2023 16:14:36 -0700 Message-ID: <1111e2f58d73dfe7571598cdd044211e15076a1b.1695856385.git.boris@bur.io> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Many btrfs tests explicitly trigger quota rescan. This is not a meaningful operation for simple quotas, so we wrap it in a helper that doesn't blow up quite so badly and lets us run those tests where the rescan is a qgroup detail. Signed-off-by: Boris Burkov --- common/btrfs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/common/btrfs b/common/btrfs index 37796cc6e..0053fec48 100644 --- a/common/btrfs +++ b/common/btrfs @@ -710,6 +710,24 @@ _check_regular_qgroup() _qgroup_mode "$@" | grep -q 'qgroup' } +_qgroup_rescan() +{ + local mnt=$1 + + _check_regular_qgroup $dev || return 1 + _run_btrfs_util_prog quota rescan -w $mnt +} + +_require_qgroup_rescan() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT + $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT || \ + _notrun "not able to run quota rescan" + _scratch_unmount +} + _require_scratch_qgroup() { _scratch_mkfs >>$seqres.full 2>&1 From patchwork Wed Sep 27 23:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13401809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0F39E80ABF for ; Wed, 27 Sep 2023 23:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjI0XNv (ORCPT ); Wed, 27 Sep 2023 19:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjI0XNt (ORCPT ); Wed, 27 Sep 2023 19:13:49 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34D9AF4; Wed, 27 Sep 2023 16:13:48 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9FD0E5C291A; Wed, 27 Sep 2023 19:13:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 27 Sep 2023 19:13:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1695856427; x= 1695942827; bh=jRmpQnQRDBNFYsmZr9zixenkAAlEEq75rTWdTPQkDAw=; b=a XH9NCIXssF4+KhUXmdGmmyJzP4ln2Z0a3MbqlahGxe2ZyCITSHQqStvli6pHDS6G 2XFP0H3BuiVYRkDKVGLl2Sb35lDfz/JRWOOYkl4ZWuauwrY6gIecjvTrDpFAvbOQ aIjfgGJf5vqfjWdxTtBrZaabL5NPlMc4xE7xXnK2LXjzV/Y7bJ8NgUbuQRVVQ9lK 1qr3DCEmGDidihtC1gkv2pDY0oNTlLinQ1Xh0WNf1Zj0sg10kR4XBNbuvieeqknI wxETycVA3QCvNa+Q/UWmdfLi/FaHBXv2Wzk0OAZpy5ewJbdvYLAayAXrrXfAby6W wPkam242PgPqWoSkdm2dA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1695856427; x=1695942827; bh=j RmpQnQRDBNFYsmZr9zixenkAAlEEq75rTWdTPQkDAw=; b=l4X7EORorpxHBgF2Q A/6L8nHoJJCxs/R3AlMjILdU3J41zFQaxnL6KO+8erCAlw7Q7sIFvBENEYFD/zfr pzinA+6svLPiof0aRBl5vZRtkWgHgS9VAG/VFUFzcZ1iSt5dmvi5AyUO2fXuKK1X KLOBzuYtcQqh+1JgRbkyRct5Aa3p/hicMn0QAp9oDxys7i7pdhxl8EycUhYY1/sQ ybA8NHOkauTml4ZSQvb/E4lD9WgT0KKAMQwur34y61VTHKuZW4gwgt+lE5JJ6Xnz OpROxOp3+A3RQNsuNAO+olfgU3+jVuttyfOCgZgGDGZJPKnTlvBOVYVZU4Ta9RR1 CPxbQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtdehgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Sep 2023 19:13:47 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org Subject: [PATCH v3 5/6] btrfs: use new rescan wrapper Date: Wed, 27 Sep 2023 16:14:37 -0700 Message-ID: <86d590831f38d12410e3fa0e4fef39e9188a0096.1695856385.git.boris@bur.io> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org These tests can pass in simple quota mode if we skip the rescans via the wrapper. Signed-off-by: Boris Burkov --- tests/btrfs/022 | 1 + tests/btrfs/028 | 2 +- tests/btrfs/104 | 2 +- tests/btrfs/123 | 2 +- tests/btrfs/126 | 2 +- tests/btrfs/139 | 2 +- tests/btrfs/153 | 2 +- tests/btrfs/171 | 6 +++--- tests/btrfs/179 | 2 +- tests/btrfs/180 | 2 +- tests/btrfs/190 | 2 +- tests/btrfs/193 | 2 +- tests/btrfs/210 | 2 +- tests/btrfs/224 | 6 +++--- tests/btrfs/230 | 2 +- tests/btrfs/232 | 2 +- 16 files changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/btrfs/022 b/tests/btrfs/022 index e2d37b094..b1ef2fdf7 100755 --- a/tests/btrfs/022 +++ b/tests/btrfs/022 @@ -14,6 +14,7 @@ _begin_fstest auto qgroup limit _supported_fs btrfs _require_scratch +_require_qgroup_rescan _require_btrfs_qgroup_report # Test to make sure we can actually turn it on and it makes sense diff --git a/tests/btrfs/028 b/tests/btrfs/028 index fe0678f86..c4080c950 100755 --- a/tests/btrfs/028 +++ b/tests/btrfs/028 @@ -25,7 +25,7 @@ _scratch_mkfs >/dev/null _scratch_mount _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT # Increase the probability of generating de-refer extent, and decrease # other. diff --git a/tests/btrfs/104 b/tests/btrfs/104 index 499de6bfb..c9528eb13 100755 --- a/tests/btrfs/104 +++ b/tests/btrfs/104 @@ -94,7 +94,7 @@ _explode_fs_tree 1 $SCRATCH_MNT/snap2/files-snap2 # Enable qgroups now that we have our filesystem prepared. This # will kick off a scan which we will have to wait for. _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT # Remount to clear cache, force everything to disk _scratch_cycle_mount diff --git a/tests/btrfs/123 b/tests/btrfs/123 index c179eeec9..4c5b7e116 100755 --- a/tests/btrfs/123 +++ b/tests/btrfs/123 @@ -39,7 +39,7 @@ sync # enable quota and rescan to get correct number _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT # now balance data block groups to corrupt qgroup _run_btrfs_balance_start -d $SCRATCH_MNT >> $seqres.full diff --git a/tests/btrfs/126 b/tests/btrfs/126 index 2b0edb65b..1bb24e00f 100755 --- a/tests/btrfs/126 +++ b/tests/btrfs/126 @@ -28,7 +28,7 @@ _scratch_mkfs >/dev/null _scratch_mount "-o enospc_debug" _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT _run_btrfs_util_prog qgroup limit 512K 0/5 $SCRATCH_MNT # The amount of written data may change due to different nodesize at mkfs time, diff --git a/tests/btrfs/139 b/tests/btrfs/139 index c4b09f9fc..f3d92ba46 100755 --- a/tests/btrfs/139 +++ b/tests/btrfs/139 @@ -30,7 +30,7 @@ SUBVOL=$SCRATCH_MNT/subvol _run_btrfs_util_prog subvolume create $SUBVOL _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT _run_btrfs_util_prog qgroup limit -e 1G $SUBVOL # Write and delete files within 1G limits, multiple times diff --git a/tests/btrfs/153 b/tests/btrfs/153 index 99fab1018..4a5fe2b8c 100755 --- a/tests/btrfs/153 +++ b/tests/btrfs/153 @@ -24,7 +24,7 @@ _scratch_mkfs >/dev/null _scratch_mount _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT _run_btrfs_util_prog qgroup limit 100M 0/5 $SCRATCH_MNT testfile1=$SCRATCH_MNT/testfile1 diff --git a/tests/btrfs/171 b/tests/btrfs/171 index 461cdd0fa..6a1ed1c1a 100755 --- a/tests/btrfs/171 +++ b/tests/btrfs/171 @@ -35,7 +35,7 @@ $BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/subvol" \ "$SCRATCH_MNT/snapshot" > /dev/null $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan $SCRATCH_MNT > /dev/null # Create high level qgroup $BTRFS_UTIL_PROG qgroup create 1/0 "$SCRATCH_MNT" @@ -45,7 +45,7 @@ $BTRFS_UTIL_PROG qgroup assign "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \ # Above assignment will mark qgroup inconsistent due to the shared extents # between subvol/snapshot/high level qgroup, do rescan here. -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan $SCRATCH_MNT > /dev/null # Now remove the qgroup relationship and make 1/0 childless # Due to the shared extent outside of 1/0, we will mark qgroup inconsistent @@ -54,7 +54,7 @@ $BTRFS_UTIL_PROG qgroup remove "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \ 2>&1 | _filter_btrfs_qgroup_assign_warnings # Above removal also marks qgroup inconsistent, rescan again -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan $SCRATCH_MNT > /dev/null # After the test, btrfs check will verify qgroup numbers to catch any # corruption. diff --git a/tests/btrfs/179 b/tests/btrfs/179 index 479667f05..00013af0a 100755 --- a/tests/btrfs/179 +++ b/tests/btrfs/179 @@ -33,7 +33,7 @@ _scratch_mount mkdir -p "$SCRATCH_MNT/snapshots" $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/src" > /dev/null $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null fill_workload() { diff --git a/tests/btrfs/180 b/tests/btrfs/180 index b7c8dac96..aa195f7b4 100755 --- a/tests/btrfs/180 +++ b/tests/btrfs/180 @@ -27,7 +27,7 @@ _scratch_mkfs > /dev/null _scratch_mount $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null $BTRFS_UTIL_PROG qgroup limit -e 1G "$SCRATCH_MNT" $XFS_IO_PROG -f -c "falloc 0 900M" "$SCRATCH_MNT/padding" diff --git a/tests/btrfs/190 b/tests/btrfs/190 index 974438c15..f78c14fe4 100755 --- a/tests/btrfs/190 +++ b/tests/btrfs/190 @@ -30,7 +30,7 @@ _log_writes_mkfs >> $seqres.full 2>&1 _log_writes_mount $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT >> $seqres.full -$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full +_qgroup_rescan $SCRATCH_MNT >> $seqres.full # Create enough metadata for later balance for ((i = 0; i < $nr_files; i++)); do diff --git a/tests/btrfs/193 b/tests/btrfs/193 index b4632ab0a..67220c7a5 100755 --- a/tests/btrfs/193 +++ b/tests/btrfs/193 @@ -26,7 +26,7 @@ _scratch_mkfs > /dev/null _scratch_mount $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null $BTRFS_UTIL_PROG qgroup limit -e 256M "$SCRATCH_MNT" # Create a file with the following layout: diff --git a/tests/btrfs/210 b/tests/btrfs/210 index 383a307ff..f3d769fa0 100755 --- a/tests/btrfs/210 +++ b/tests/btrfs/210 @@ -29,7 +29,7 @@ _pwrite_byte 0xcd 0 16M "$SCRATCH_MNT/src/file" > /dev/null # by qgroup sync $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null $BTRFS_UTIL_PROG qgroup create 1/0 "$SCRATCH_MNT" # Create a snapshot with qgroup inherit diff --git a/tests/btrfs/224 b/tests/btrfs/224 index d7ec57360..de10942fe 100755 --- a/tests/btrfs/224 +++ b/tests/btrfs/224 @@ -30,7 +30,7 @@ assign_shared_test() echo "=== qgroup assign shared test ===" >> $seqres.full $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full + _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full @@ -54,7 +54,7 @@ assign_no_shared_test() echo "=== qgroup assign no shared test ===" >> $seqres.full $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full + _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full @@ -75,7 +75,7 @@ snapshot_test() echo "=== qgroup snapshot test ===" >> $seqres.full $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full + _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1 diff --git a/tests/btrfs/230 b/tests/btrfs/230 index 46b0c6369..7a4cd18e9 100755 --- a/tests/btrfs/230 +++ b/tests/btrfs/230 @@ -31,7 +31,7 @@ _pwrite_byte 0xcd 0 1G $SCRATCH_MNT/file >> $seqres.full sync $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT -$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full +_qgroup_rescan $SCRATCH_MNT >> $seqres.full # Set the limit to just 512MiB, which is way below the existing usage $BTRFS_UTIL_PROG qgroup limit 512M 0/5 $SCRATCH_MNT diff --git a/tests/btrfs/232 b/tests/btrfs/232 index 02c7e49de..debe070bb 100755 --- a/tests/btrfs/232 +++ b/tests/btrfs/232 @@ -46,7 +46,7 @@ _pwrite_byte 0xcd 0 900m $SCRATCH_MNT/file >> $seqres.full sync $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT -$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full +_qgroup_rescan $SCRATCH_MNT >> $seqres.full # set the limit to 1 g, leaving us just 100mb of slack space $BTRFS_UTIL_PROG qgroup limit 1G 0/5 $SCRATCH_MNT From patchwork Wed Sep 27 23:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13401810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB73FE7F14F for ; Wed, 27 Sep 2023 23:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230036AbjI0XNx (ORCPT ); Wed, 27 Sep 2023 19:13:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbjI0XNv (ORCPT ); Wed, 27 Sep 2023 19:13:51 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBBCDF5; Wed, 27 Sep 2023 16:13:49 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 54EB15C2806; Wed, 27 Sep 2023 19:13:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 27 Sep 2023 19:13:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1695856429; x= 1695942829; bh=CuKeb7gcDG2KWgI3Hg1tmbpftN4qV0t4VFVG31vkJm0=; b=3 bKSDvIPfWPX97O5c+CL5hViKS/HLhaApdfGzJJITUbbSf5gc1CHAtQToBcdL2A33 /IP2OFtN5pea+PKFfNiVw5cLrH2mhqkMOI8YcvBiO3QVDL8CxA0GBb6gHSQy6pc+ oQX2N4LLPoPSUw9GOIf7iXk27aEk8TCTv7gmiFek3L9alYL+D+muMu+tE5qQO/Gj /ByFTWeDyDVJeMCu2lQs0gNf/N+Gycol3RCiv0AWuJCQOh/VJgsW0l0MgjfIi911 5eW4aAJT++ItWlEb3UQEZGAErsRX7S7iw6sQsCBVyfEyT8KcvRDqSj9ijrg+iT4/ sDi8mr1SoXCyzyGAvLroA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1695856429; x=1695942829; bh=C uKeb7gcDG2KWgI3Hg1tmbpftN4qV0t4VFVG31vkJm0=; b=o7hiyutEdcnM3cvSc lHCnz4D3RMgu3owix2lcWgCxw2b9CMHxEWqhrIa0YTkS4nJoKbbvffVQoK2WX30z kqbZaCX0CigolJ7XrcAzOdkxOEq+XQ/zNRZ2OCprFzde6LNJShoGMacacBG3zx+A /QpHL4/LYXcUJNI5XtY0LYER0g79vrdG+5RCYBM7ZMlHLodOakb4O63B1TxQ0Gga 05BSn+25Lsdlwn0u3Pl/PoxEkavFKKa84MIchjsm+Db/FXRnAQfgkVioa9TwEYpE HM7lN10F9pU4op0H3Yuup912pSmjpxUPALzJ8V7rHxZAC+TIXUXdgJ9W1GOgZv0N VwjMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtdehgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Sep 2023 19:13:48 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org Subject: [PATCH v3 6/6] btrfs: skip squota incompatible tests Date: Wed, 27 Sep 2023 16:14:38 -0700 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org These tests cannot succeed if mkfs enable squotas, as they either test the specifics of qgroups behavior or they test *enabling* squotas. Skip these in squota mode. Signed-off-by: Boris Burkov --- tests/btrfs/017 | 1 + tests/btrfs/057 | 1 + tests/btrfs/091 | 3 ++- tests/btrfs/301 | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/btrfs/017 b/tests/btrfs/017 index 622071018..496cc7df1 100755 --- a/tests/btrfs/017 +++ b/tests/btrfs/017 @@ -22,6 +22,7 @@ _begin_fstest auto quick qgroup _supported_fs btrfs _require_scratch +_require_scratch_qgroup _require_cloner # Currently in btrfs the node/leaf size can not be smaller than the page diff --git a/tests/btrfs/057 b/tests/btrfs/057 index 782d854a0..e932a6572 100755 --- a/tests/btrfs/057 +++ b/tests/btrfs/057 @@ -15,6 +15,7 @@ _begin_fstest auto quick # real QA test starts here _supported_fs btrfs _require_scratch +_require_qgroup_rescan _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1 diff --git a/tests/btrfs/091 b/tests/btrfs/091 index f2cd00b2e..a71e03406 100755 --- a/tests/btrfs/091 +++ b/tests/btrfs/091 @@ -19,6 +19,7 @@ _begin_fstest auto quick qgroup _supported_fs btrfs _require_scratch _require_cp_reflink +_require_scratch_qgroup # use largest node/leaf size (64K) to allow the test to be run on arch with # page size > 4k. @@ -35,7 +36,7 @@ _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv2 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv3 _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT $XFS_IO_PROG -f -c "pwrite 0 256K" $SCRATCH_MNT/subv1/file1 | _filter_xfs_io cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv2/file1 diff --git a/tests/btrfs/301 b/tests/btrfs/301 index 527c25230..f6b55c83f 100755 --- a/tests/btrfs/301 +++ b/tests/btrfs/301 @@ -33,6 +33,11 @@ ext_sz=$((128 * m)) limit_nr=8 limit=$(($ext_sz * $limit_nr)) +_scratch_mkfs >> $seqres.full +_scratch_mount +_qgroup_mode $SCRATCH_MNT | grep 'squota' && _notrun "test relies on starting without simple quotas enabled" +_scratch_unmount + get_qgroup_usage() { local qgroupid=$1