From patchwork Wed Sep 27 17:46:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13401462 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 2EC6FE82CA1 for ; Wed, 27 Sep 2023 17:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229565AbjI0RqN (ORCPT ); Wed, 27 Sep 2023 13:46:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjI0RqM (ORCPT ); Wed, 27 Sep 2023 13:46:12 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07A831A7 for ; Wed, 27 Sep 2023 10:46:11 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 4A1453200A31; Wed, 27 Sep 2023 13:46:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 27 Sep 2023 13:46:10 -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=1695836769; x= 1695923169; bh=EAJzeNrebYA4fz8wK/r/eveCHdguJ+mKDlTqNvzszqw=; b=B iE/HyrvSk7rdOxRt3rjM4qV3ixRoFqAn0LX6A0LGsb1IWpFRgP2rVMEbcHgAmkT1 5NfxVKzSVkfYP481jDbJdXGZe1RJmeK3bxpfUkAFoL+3f6CDK5OvqvbYJz3jvE6c yMzIgAfDC1/Tk1QhqEGBANFuY9W/tF6G71Qnt3mCuGbpZsKgFyevzHxibA4oL85B t45ara6B4174DpIp4LDyfY28tEqvx2ae44SsIaVc1mRAQL8+ecGFThg89RfITrfO kbj5HGZQKCPHdTxjXvVktJHExnysLELMDbhwHERvplWgrMebvqgIuiPDwZwBlYiO 5SQ0OoypdXYcUFipR7h/A== 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=1695836769; x=1695923169; bh=E AJzeNrebYA4fz8wK/r/eveCHdguJ+mKDlTqNvzszqw=; b=ZGjW0WjvoReljf/Qf +FJIHav0meCqMJMTMqzmBTvnBZxmmquwWFb0vZmr3jPsFmtsHVvNG0eQas9FgRBU Aj4QAAzmdmVvaP03L8aydXTacq9vC8gNTH0e75Kfns/KdhFJUwXAROZde6bnYicW nqR4UhbrMNxaxekpBWcMela1PfZ5KJLsuc/YKTz66oxSgYKOV865wkAIlfuyaUif h1i3G4KxyzVPx7OrVeLSANIKWZj/KqvSt/lhA1fPGLHdmihk6AlUrUHe0VyeeXPV /zUW+LoL8qD7ZR5HFKPWdoppV9uaUPF4h5m8Tlf/P9KXPrdgIS3ZbjDWe2ZdctGa nhh9A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtdeggdehgecutefuodetggdotefrodftvf 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 13:46:09 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 7/8] btrfs-progs: simple quotas enable cmd Date: Wed, 27 Sep 2023 10:46:48 -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: linux-btrfs@vger.kernel.org Add a --simple flag to btrfs quota enable. If set, this enables simple quotas instead of full qgroups by using the new ioctl command value. Signed-off-by: Boris Burkov --- cmds/quota.c | 39 ++++++++++++++++++++++++++++++-------- kernel-shared/uapi/btrfs.h | 2 ++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/cmds/quota.c b/cmds/quota.c index cd874f9ed..a7d032a03 100644 --- a/cmds/quota.c +++ b/cmds/quota.c @@ -34,17 +34,13 @@ static const char * const quota_cmd_group_usage[] = { NULL }; -static int quota_ctl(int cmd, int argc, char **argv) +static int quota_ctl(int cmd, char *path) { int ret = 0; int fd; - char *path = argv[1]; struct btrfs_ioctl_quota_ctl_args args; DIR *dirstream = NULL; - if (check_argc_exact(argc, 2)) - return -1; - memset(&args, 0, sizeof(args)); args.cmd = cmd; @@ -67,16 +63,40 @@ static const char * const cmd_quota_enable_usage[] = { "Any data already present on the filesystem will not count towards", "the space usage numbers. It is recommended to enable quota for a", "filesystem before writing any data to it.", + "", + "-s|--simple simple qgroups account ownership by extent lifetime rather than backref walks", NULL }; static int cmd_quota_enable(const struct cmd_struct *cmd, int argc, char **argv) { int ret; + int ctl_cmd = BTRFS_QUOTA_CTL_ENABLE; - clean_args_no_options(cmd, argc, argv); + optind = 0; + while (1) { + static const struct option long_options[] = { + {"simple", no_argument, NULL, 's'}, + {NULL, 0, NULL, 0} + }; + int c; - ret = quota_ctl(BTRFS_QUOTA_CTL_ENABLE, argc, argv); + c = getopt_long(argc, argv, "s", long_options, NULL); + if (c < 0) + break; + + switch (c) { + case 's': + ctl_cmd = BTRFS_QUOTA_CTL_ENABLE_SIMPLE_QUOTA; + break; + default: + usage_unknown_option(cmd, argv); + } + } + if (check_argc_exact(argc - optind, 1)) + return -1; + + ret = quota_ctl(ctl_cmd, argv[optind]); if (ret < 0) usage(cmd, 1); @@ -97,7 +117,10 @@ static int cmd_quota_disable(const struct cmd_struct *cmd, clean_args_no_options(cmd, argc, argv); - ret = quota_ctl(BTRFS_QUOTA_CTL_DISABLE, argc, argv); + if (check_argc_exact(argc, 2)) + return -1; + + ret = quota_ctl(BTRFS_QUOTA_CTL_DISABLE, argv[1]); if (ret < 0) usage(cmd, 1); diff --git a/kernel-shared/uapi/btrfs.h b/kernel-shared/uapi/btrfs.h index 7e0078a5d..11ffd54d4 100644 --- a/kernel-shared/uapi/btrfs.h +++ b/kernel-shared/uapi/btrfs.h @@ -786,9 +786,11 @@ struct btrfs_ioctl_get_dev_stats { }; _static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032); +/* cmd values */ #define BTRFS_QUOTA_CTL_ENABLE 1 #define BTRFS_QUOTA_CTL_DISABLE 2 #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3 +#define BTRFS_QUOTA_CTL_ENABLE_SIMPLE_QUOTA 4 struct btrfs_ioctl_quota_ctl_args { __u64 cmd; __u64 status;