From patchwork Wed Jul 5 23:42:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13303064 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 44345EB64DA for ; Wed, 5 Jul 2023 23:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232642AbjGEXnj (ORCPT ); Wed, 5 Jul 2023 19:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjGEXni (ORCPT ); Wed, 5 Jul 2023 19:43:38 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B609129; Wed, 5 Jul 2023 16:43:37 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 132F25C0225; Wed, 5 Jul 2023 19:43:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 05 Jul 2023 19:43:37 -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=1688600617; x= 1688687017; bh=rTQsD8RxB2wP7/jpatNWxh24EyNHQD+1wCTHp9DkLyA=; b=K xi0FEJUtaMYLuVPbP64y6k85yu8XqADQ9S/klavIIWOW2zejcKuOYkGJjL1R3g9T r+5M1UW9ofYLWZLl39F+ABwUkfNJM76rBkLHzPW5T4z0p2i91nOn531GpQw7tzxA fB4SOpd/QGO+zzuASaRNctqpv1AtcgHYz/pKuk0I9qpPZEzttuS3uIAduN3S6FTT uM+A/SXGrClDuuaAQU69/fFKaXJRBVFuGu5/entrYrJkBE/QwSYYhM+gyiqjSa3o 32bikUhSnNcIlssLTUjPnvcqiUzQKkCK0nPLEONWWlrMuHBwxE57pgAMH+poQCXl VkJrlVlpycSzUCnh85qUg== 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=1688600617; x=1688687017; bh=r TQsD8RxB2wP7/jpatNWxh24EyNHQD+1wCTHp9DkLyA=; b=Teyqg3wKdQgov7XuU Hl08rLl5KrmzC1L47Eczy3fyXV0cDNCV6aOFHq4sJIx/u26koblrRZGGtXbHxmry FSniXpyfQySTFt0S64sHwdimw2X4RzfIAi25zdSJJQZpNknw/0KYPhL3L5I/DNLA JUdd6wD9JyErJD1Hm8yT3XCrrtKOsFd6WOo9vETpD2a8OUg0glQZ1O5KXNSzW6Ig Gl/ru4UAUb20cjLjzwUmR/u55RVSuQtjdUnpGScqi2PrVDZKmv5LX35Na/bFTWyl oWDIfGeAXBJQbqJRX+NUnKt4KUx1vHFRy9TSPO/fDn5jLlo+DNznwTTg0/J74Aep 8JblQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 5 Jul 2023 19:43:36 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org Subject: [PATCH 2/5] common/btrfs: quota mode helpers Date: Wed, 5 Jul 2023 16:42:24 -0700 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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 | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/common/btrfs b/common/btrfs index 175b33aee..66c065a10 100644 --- a/common/btrfs +++ b/common/btrfs @@ -680,3 +680,46 @@ _require_btrfs_scratch_logical_resolve_v2() fi _scratch_unmount } + +_qgroup_mode_file() +{ + local mnt=$1 + + uuid=$(findmnt -n -o UUID $mnt) + echo /sys/fs/btrfs/${uuid}/qgroups/mode +} + +_qgroup_enabled_file() +{ + local mnt=$1 + + uuid=$(findmnt -n -o UUID $mnt) + echo /sys/fs/btrfs/${uuid}/qgroups/enabled +} + +_qgroup_mode() +{ + local mnt=$1 + + if [ ! -f "$(_qgroup_enabled_file $mnt)" ]; then + echo "disabled" + return + fi + + if [ -f "$(_qgroup_mode_file $mnt)" ]; then + cat $(_qgroup_mode_file $mnt) + elif [ $(cat $(_qgroup_enabled_file $mnt)) -eq "1" ]; then + echo "qgroup" + else + echo "disabled" # should not be reachable, the enabled file won't exist. + fi +} + +_require_scratch_qgroup() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT + _check_regular_qgroup $SCRATCH_MNT || _notrun "not running normal qgroups" + _scratch_unmount +}