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 08/18] btrfs: function for recording simple quota deltas
Date: Thu, 13 Jul 2023 10:34:54 -0400 [thread overview]
Message-ID: <20230713143454.GH207541@perftesting> (raw)
In-Reply-To: <17e93036e598545781cb13376abb868dc22d51b2.1688597211.git.boris@bur.io>
On Wed, Jul 05, 2023 at 04:20:45PM -0700, Boris Burkov wrote:
> Rather than re-computing shared/exclusive ownership based on backrefs
> and walking roots for implicit backrefs, simple quotas does an increment
> when creating an extent and a decrement when deleting it. Add the API
> for the extent item code to use to track those events.
>
> Also add a helper function to make collecting parent qgroups in a ulist
> easier for functions like this.
>
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
> fs/btrfs/qgroup.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++
> fs/btrfs/qgroup.h | 11 ++++++-
> 2 files changed, 92 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 8419270f7417..97c00697b475 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -333,6 +333,44 @@ static int del_relation_rb(struct btrfs_fs_info *fs_info,
> return -ENOENT;
> }
>
> +static int qgroup_collect_parents(struct btrfs_qgroup *qgroup,
> + struct ulist *ul)
> +{
> + struct ulist_iterator uiter;
> + struct ulist_node *unode;
> + struct btrfs_qgroup_list *glist;
> + struct btrfs_qgroup *qg;
> + bool err_free = false;
> + int ret = 0;
> +
> + if (!ul) {
> + ul = ulist_alloc(GFP_KERNEL);
> + err_free = true;
> + } else {
> + ulist_reinit(ul);
> + }
You're calling this under a spin_lock, so GFP_KERNEL isn't allowed here.
Additionally it doesn't seem like you ever call it with a NULL ulist, so
probably just get rid of the above.
> +
> + ret = ulist_add(ul, qgroup->qgroupid,
> + qgroup_to_aux(qgroup), GFP_ATOMIC);
We're going to hit ENOMEM in production here, we used to hit it all the time
with the extent state stuff. How will this affect us? Will it screw up
accounting? If so we need to figure out a way to back up out of the lock and
pre-allocate a node to use in this case.
> + if (ret < 0)
> + goto out;
> + ULIST_ITER_INIT(&uiter);
> + while ((unode = ulist_next(ul, &uiter))) {
> + qg = unode_aux_to_qgroup(unode);
> + list_for_each_entry(glist, &qg->groups, next_group) {
> + ret = ulist_add(ul, glist->group->qgroupid,
> + qgroup_to_aux(glist->group), GFP_ATOMIC);
> + if (ret < 0)
> + goto out;
> + }
> + }
> + ret = 0;
> +out:
> + if (ret && err_free)
> + ulist_free(ul);
> + return ret;
> +}
> +
> #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
> int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
> u64 rfer, u64 excl)
> @@ -4531,3 +4569,47 @@ void btrfs_qgroup_destroy_extent_records(struct btrfs_transaction *trans)
> kfree(entry);
> }
> }
> +
> +int btrfs_record_simple_quota_delta(struct btrfs_fs_info *fs_info,
> + struct btrfs_simple_quota_delta *delta)
> +{
> + int ret;
> + struct ulist *ul = fs_info->qgroup_ulist;
This isn't NULL if we're enabled right? Thanks,
Josef
next prev parent reply other threads:[~2023-07-13 14:35 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
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 [this message]
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=20230713143454.GH207541@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