From: Josef Bacik <josef@toxicpanda.com>
To: Boris Burkov <boris@bur.io>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 04/18] btrfs: add new quota mode for simple quotas
Date: Thu, 13 Jul 2023 10:07:55 -0400 [thread overview]
Message-ID: <20230713140755.GD207541@perftesting> (raw)
In-Reply-To: <668b2472739b712195d9520fdaed205ec7e4ee15.1688597211.git.boris@bur.io>
On Wed, Jul 05, 2023 at 04:20:41PM -0700, Boris Burkov wrote:
> Add a new quota mode called "simple quotas". It can be enabled by the
> existing quota enable ioctl via an unused field, and sets an incompat
> bit, as the implementation of simple quotas will make backwards
> incompatible changes to the disk format of the extent tree.
>
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
> fs/btrfs/delayed-ref.c | 4 +-
> fs/btrfs/fs.h | 5 +--
> fs/btrfs/ioctl.c | 2 +-
> fs/btrfs/qgroup.c | 88 ++++++++++++++++++++++++++------------
> fs/btrfs/qgroup.h | 4 +-
> fs/btrfs/root-tree.c | 2 +-
> fs/btrfs/transaction.c | 4 +-
> include/uapi/linux/btrfs.h | 2 +
> 8 files changed, 74 insertions(+), 37 deletions(-)
>
> diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
> index 6a13cf00218b..a9b938d3a531 100644
> --- a/fs/btrfs/delayed-ref.c
> +++ b/fs/btrfs/delayed-ref.c
> @@ -898,7 +898,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
> return -ENOMEM;
> }
>
> - if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
> + if (btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_DISABLED &&
> !generic_ref->skip_qgroup) {
> record = kzalloc(sizeof(*record), GFP_NOFS);
> if (!record) {
> @@ -1002,7 +1002,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
> return -ENOMEM;
> }
>
> - if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
> + if (btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_DISABLED &&
> !generic_ref->skip_qgroup) {
> record = kzalloc(sizeof(*record), GFP_NOFS);
> if (!record) {
> diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
> index 203d2a267828..f76f450c2abf 100644
> --- a/fs/btrfs/fs.h
> +++ b/fs/btrfs/fs.h
> @@ -218,7 +218,8 @@ enum {
> BTRFS_FEATURE_INCOMPAT_NO_HOLES | \
> BTRFS_FEATURE_INCOMPAT_METADATA_UUID | \
> BTRFS_FEATURE_INCOMPAT_RAID1C34 | \
> - BTRFS_FEATURE_INCOMPAT_ZONED)
> + BTRFS_FEATURE_INCOMPAT_ZONED | \
> + BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA)
>
> #ifdef CONFIG_BTRFS_DEBUG
> /*
> @@ -233,7 +234,6 @@ enum {
>
> #define BTRFS_FEATURE_INCOMPAT_SUPP \
> (BTRFS_FEATURE_INCOMPAT_SUPP_STABLE)
> -
> #endif
>
> #define BTRFS_FEATURE_INCOMPAT_SAFE_SET \
> @@ -790,7 +790,6 @@ struct btrfs_fs_info {
> struct lockdep_map btrfs_state_change_map[4];
> struct lockdep_map btrfs_trans_pending_ordered_map;
> struct lockdep_map btrfs_ordered_extent_map;
> -
> #ifdef CONFIG_BTRFS_FS_REF_VERIFY
> spinlock_t ref_verify_lock;
> struct rb_root block_tree;
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index edbbd5cf23fc..63c1a9258a1b 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3691,7 +3691,7 @@ static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg)
>
> switch (sa->cmd) {
> case BTRFS_QUOTA_CTL_ENABLE:
> - ret = btrfs_quota_enable(fs_info);
> + ret = btrfs_quota_enable(fs_info, sa);
> break;
> case BTRFS_QUOTA_CTL_DISABLE:
> ret = btrfs_quota_disable(fs_info);
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 2b4473cb77d6..80c1f500b6cc 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -3,6 +3,8 @@
> * Copyright (C) 2011 STRATO. All rights reserved.
> */
>
> +#include "linux/btrfs.h"
> +#include <linux/btrfs.h>
> #include <linux/sched.h>
> #include <linux/pagemap.h>
> #include <linux/writeback.h>
> @@ -10,7 +12,6 @@
> #include <linux/rbtree.h>
> #include <linux/slab.h>
> #include <linux/workqueue.h>
> -#include <linux/btrfs.h>
> #include <linux/sched/mm.h>
>
Something wonky happened here.
<snip>
> #include "ctree.h"
> @@ -34,6 +35,8 @@ enum btrfs_qgroup_mode btrfs_qgroup_mode(struct btrfs_fs_info *fs_info)
> {
> if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
> return BTRFS_QGROUP_MODE_DISABLED;
> + if (btrfs_fs_incompat(fs_info, SIMPLE_QUOTA))
> + return BTRFS_QGROUP_MODE_SIMPLE;
> return BTRFS_QGROUP_MODE_FULL;
> }
>
> @@ -347,6 +350,8 @@ int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
>
> static void qgroup_mark_inconsistent(struct btrfs_fs_info *fs_info)
> {
> + if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_SIMPLE)
> + return;
> fs_info->qgroup_flags |= (BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT |
> BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN |
> BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING);
> @@ -368,7 +373,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
> u64 flags = 0;
> u64 rescan_progress = 0;
>
> - if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
> + if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED)
> return 0;
>
> fs_info->qgroup_ulist = ulist_alloc(GFP_KERNEL);
> @@ -419,7 +424,8 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
> goto out;
> }
> if (btrfs_qgroup_status_generation(l, ptr) !=
> - fs_info->generation) {
> + fs_info->generation &&
> + btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_SIMPLE) {
> qgroup_mark_inconsistent(fs_info);
> btrfs_err(fs_info,
> "qgroup generation mismatch, marked as inconsistent");
> @@ -557,7 +563,7 @@ bool btrfs_check_quota_leak(struct btrfs_fs_info *fs_info)
> struct rb_node *node;
> bool ret = false;
>
> - if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
> + if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED)
> return ret;
> /*
> * Since we're unmounting, there is no race and no need to grab qgroup
> @@ -956,7 +962,8 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans,
> return ret;
> }
>
> -int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
> +int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
> + struct btrfs_ioctl_quota_ctl_args *quota_ctl_args)
> {
> struct btrfs_root *quota_root;
> struct btrfs_root *tree_root = fs_info->tree_root;
> @@ -968,6 +975,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
> struct btrfs_qgroup *qgroup = NULL;
> struct btrfs_trans_handle *trans = NULL;
> struct ulist *ulist = NULL;
> + bool simple = quota_ctl_args->status == BTRFS_QUOTA_CTL_ENABLE_SIMPLE_QUOTA;
Why are you using status here? Just use it as a different command.
<snip>
> @@ -3010,11 +3033,10 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
> qgroup_dirty(fs_info, dstgroup);
> }
>
> - if (srcid) {
> + if (srcid && btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_FULL) {
> srcgroup = find_qgroup_rb(fs_info, srcid);
> if (!srcgroup)
> goto unlock;
> -
Errant change.
<snip>
> diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
> index dbb8b96da50d..1cdabdd92338 100644
> --- a/include/uapi/linux/btrfs.h
> +++ b/include/uapi/linux/btrfs.h
> @@ -333,6 +333,7 @@ struct btrfs_ioctl_fs_info_args {
> #define BTRFS_FEATURE_INCOMPAT_RAID1C34 (1ULL << 11)
> #define BTRFS_FEATURE_INCOMPAT_ZONED (1ULL << 12)
> #define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 (1ULL << 13)
> +#define BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA (1ULL << 14)
>
> struct btrfs_ioctl_feature_flags {
> __u64 compat_flags;
> @@ -753,6 +754,7 @@ struct btrfs_ioctl_get_dev_stats {
> #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 (1UL)
> struct btrfs_ioctl_quota_ctl_args {
> __u64 cmd;
> __u64 status;
Yeah this just has cmd and status, and cmd can be whatever we want, so just make
ENABLE_SIMPLE_QUOTA 4 and use it in cmd. Thanks,
Josef
next prev parent reply other threads:[~2023-07-13 14:08 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 23:20 [PATCH 00/18] btrfs: simple quotas Boris Burkov
2023-07-05 23:20 ` [PATCH 01/18] btrfs: free qgroup rsv on io failure Boris Burkov
2023-07-13 14:01 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 02/18] btrfs: fix start transaction qgroup rsv double free Boris Burkov
2023-07-13 14:02 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 03/18] btrfs: introduce quota mode Boris Burkov
2023-07-13 14:02 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 04/18] btrfs: add new quota mode for simple quotas Boris Burkov
2023-07-13 14:07 ` Josef Bacik [this message]
2023-07-05 23:20 ` [PATCH 05/18] btrfs: expose quota mode via sysfs Boris Burkov
2023-07-13 14:11 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 06/18] btrfs: flush reservations during quota disable Boris Burkov
2023-07-13 14:20 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 07/18] btrfs: create qgroup earlier in snapshot creation Boris Burkov
2023-07-13 14:26 ` Josef Bacik
2023-07-13 19:00 ` Boris Burkov
2023-07-13 20:37 ` Josef Bacik
2023-07-13 23:13 ` Boris Burkov
2023-07-05 23:20 ` [PATCH 08/18] btrfs: function for recording simple quota deltas Boris Burkov
2023-07-13 14:34 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 09/18] btrfs: rename tree_ref and data_ref owning_root Boris Burkov
2023-07-13 16:33 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 10/18] btrfs: track owning root in btrfs_ref Boris Burkov
2023-07-13 16:58 ` Josef Bacik
2023-07-13 21:21 ` Boris Burkov
2023-07-05 23:20 ` [PATCH 11/18] btrfs: track original extent owner in head_ref Boris Burkov
2023-07-13 17:09 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 12/18] btrfs: new inline ref storing owning subvol of data extents Boris Burkov
2023-07-13 17:16 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 13/18] btrfs: inline owner ref lookup helper Boris Burkov
2023-07-13 17:18 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 14/18] btrfs: record simple quota deltas Boris Burkov
2023-07-13 17:23 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 15/18] btrfs: simple quota auto hierarchy for nested subvols Boris Burkov
2023-07-13 17:28 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 16/18] btrfs: check generation when recording simple quota delta Boris Burkov
2023-07-13 17:29 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 17/18] btrfs: track metadata relocation cow with simple quota Boris Burkov
2023-07-13 17:31 ` Josef Bacik
2023-07-05 23:20 ` [PATCH 18/18] btrfs: track data relocation " Boris Burkov
2023-07-13 17:37 ` Josef Bacik
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=20230713140755.GD207541@perftesting \
--to=josef@toxicpanda.com \
--cc=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