From patchwork Thu Jul 27 22:12:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13330824 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 C1A58C04A94 for ; Thu, 27 Jul 2023 22:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232699AbjG0WPL (ORCPT ); Thu, 27 Jul 2023 18:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbjG0WPK (ORCPT ); Thu, 27 Jul 2023 18:15:10 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00B9313E for ; Thu, 27 Jul 2023 15:15:09 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 45DB932000D7; Thu, 27 Jul 2023 18:15:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 27 Jul 2023 18:15:09 -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=fm1; t=1690496108; x= 1690582508; bh=1jI89jJpbcX+QlAxKYbnErOrqzmmXD3xHc3JW0HJ1/E=; b=m 3iyHf4jF4i43MbbqSoLQ5nwMM9H9Un21bKGfFOBUo9JFXWew5cCizB4sWZbYWq+d QPEAwbfGzeRlBIg5GtLn2xb8VV/cD4lF3+2b2YNwKlGNgapO6fQpat2068/rfpeM EdTwjsmkQJ8CKCdTqMXr0g/KgOxHZxeddJGVymGmlAaDqxGr5pRS20Uiep1Q3Qi8 EQOBAV4sm7voQZGmx6jKLS8qScGD9HERIw9dS/5IEPgxYz3XHwrhsq1BRLq7ZZuB hK54tzJ7xg38F6caBCdjvSXMudqFCVtvSFsc9TvEP2RK4DBWT0hUyGRdwiFd/MIx TJr8fixxq0+sSr48AXPmQ== 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=fm3; t=1690496108; x=1690582508; bh=1 jI89jJpbcX+QlAxKYbnErOrqzmmXD3xHc3JW0HJ1/E=; b=ycl1tWKsUkKdG9Kx9 0HZKYLfPw6+50CwqlSDb+/+nItZdfVUYeha4DBrU8EmXwpvX09Zqe40Oz58iQzOy b8hCHofZZn77es9b00joqtwFooLcNTzYk+2VB8tqGCcKQKrRJaen1An73+4cehr/ ZYGSTikhbkbOdMSSYO+Atj9zleBxe66AhHNf5j/JmVGTwOaK5m8vDd0csf/nJYfV 0iScPz2M6Z/PJ5oX/l6feXigjczNz6l6nKMLRxRoSD8o5nhaqkH7GxAKcQUxIxky yuYcyFcUIOpPSHs7vna6KDyU2ninMefW/b8h0+THt5SUWPtBC/3eWsgNdxxWoRFR ihapw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrieehgddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepsghorhhishessghurhdrihho X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Jul 2023 18:15:08 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v5 03/18] btrfs: expose quota mode via sysfs Date: Thu, 27 Jul 2023 15:12:50 -0700 Message-ID: <9c9d150a93e91a5a648840ef77240e81b70ff769.1690495785.git.boris@bur.io> 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 Add a new sysfs file /sys/fs/btrfs//qgroups/mode which prints out the mode qgroups is running in. The possible modes are disabled, qgroup, and squota Signed-off-by: Boris Burkov Reviewed-by: Josef Bacik --- fs/btrfs/sysfs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index b1d1ac25237b..e53614753391 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -2086,6 +2086,31 @@ static ssize_t qgroup_enabled_show(struct kobject *qgroups_kobj, } BTRFS_ATTR(qgroups, enabled, qgroup_enabled_show); +static ssize_t qgroup_mode_show(struct kobject *qgroups_kobj, + struct kobj_attribute *a, + char *buf) +{ + struct btrfs_fs_info *fs_info = to_fs_info(qgroups_kobj->parent); + char *mode = ""; + + spin_lock(&fs_info->qgroup_lock); + switch (btrfs_qgroup_mode(fs_info)) { + case BTRFS_QGROUP_MODE_DISABLED: + mode = "disabled"; + break; + case BTRFS_QGROUP_MODE_FULL: + mode = "qgroup"; + break; + case BTRFS_QGROUP_MODE_SIMPLE: + mode = "squota"; + break; + } + spin_unlock(&fs_info->qgroup_lock); + + return sysfs_emit(buf, "%s\n", mode); +} +BTRFS_ATTR(qgroups, mode, qgroup_mode_show); + static ssize_t qgroup_inconsistent_show(struct kobject *qgroups_kobj, struct kobj_attribute *a, char *buf) @@ -2148,6 +2173,7 @@ static struct attribute *qgroups_attrs[] = { BTRFS_ATTR_PTR(qgroups, enabled), BTRFS_ATTR_PTR(qgroups, inconsistent), BTRFS_ATTR_PTR(qgroups, drop_subtree_threshold), + BTRFS_ATTR_PTR(qgroups, mode), NULL }; ATTRIBUTE_GROUPS(qgroups);