From: Boris Burkov <boris@bur.io>
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 [thread overview]
Message-ID: <aab56bfb675a0ce87e9d4b4d18b354880262f139.1695836680.git.boris@bur.io> (raw)
In-Reply-To: <cover.1695836680.git.boris@bur.io>
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 <boris@bur.io>
---
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;
--
2.42.0
next prev parent reply other threads:[~2023-09-27 17:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 17:46 [PATCH v3 0/8] btrfs-progs: simple quotas Boris Burkov
2023-09-27 17:46 ` [PATCH v3 1/8] btrfs-progs: document squotas Boris Burkov
2023-09-27 17:46 ` [PATCH v3 2/8] btrfs-progs: simple quotas kernel definitions Boris Burkov
2023-09-27 17:46 ` [PATCH v3 3/8] btrfs-progs: simple quotas dump commands Boris Burkov
2023-09-27 17:46 ` [PATCH v3 4/8] btrfs-progs: simple quotas fsck Boris Burkov
2023-09-27 17:46 ` [PATCH v3 5/8] btrfs-progs: simple quotas mkfs Boris Burkov
2023-10-02 16:11 ` David Sterba
2023-09-27 17:46 ` [PATCH v3 6/8] btrfs-progs: simple quotas btrfstune Boris Burkov
2023-09-27 17:46 ` Boris Burkov [this message]
2023-09-27 17:46 ` [PATCH v3 8/8] btrfs-progs: tree-checker: handle owner ref items Boris Burkov
2023-10-02 16:20 ` [PATCH v3 0/8] btrfs-progs: simple quotas David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aab56bfb675a0ce87e9d4b4d18b354880262f139.1695836680.git.boris@bur.io \
--to=boris@bur.io \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).