public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 07/18] btrfs: create qgroup earlier in snapshot creation
Date: Thu, 13 Jul 2023 16:13:57 -0700	[thread overview]
Message-ID: <20230713231357.GA2710302@zen> (raw)
In-Reply-To: <20230713203704.GB338010@perftesting>

On Thu, Jul 13, 2023 at 04:37:04PM -0400, Josef Bacik wrote:
> On Thu, Jul 13, 2023 at 12:00:42PM -0700, Boris Burkov wrote:
> > On Thu, Jul 13, 2023 at 10:26:00AM -0400, Josef Bacik wrote:
> > > On Wed, Jul 05, 2023 at 04:20:44PM -0700, Boris Burkov wrote:
> > > > Pull creating the qgroup earlier in the snapshot. This allows simple
> > > > quotas qgroups to see all the metadata writes related to the snapshot
> > > > being created and to be born with the root node accounted.
> > > > 
> > > > Signed-off-by: Boris Burkov <boris@bur.io>
> > > > ---
> > > >  fs/btrfs/qgroup.c      | 3 +++
> > > >  fs/btrfs/transaction.c | 5 +++++
> > > >  2 files changed, 8 insertions(+)
> > > > 
> > > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> > > > index 75afd8212bc0..8419270f7417 100644
> > > > --- a/fs/btrfs/qgroup.c
> > > > +++ b/fs/btrfs/qgroup.c
> > > > @@ -1670,6 +1670,9 @@ int btrfs_create_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
> > > >  	struct btrfs_qgroup *qgroup;
> > > >  	int ret = 0;
> > > >  
> > > > +	if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED)
> > > > +		return 0;
> > > > +
> > > >  	mutex_lock(&fs_info->qgroup_ioctl_lock);
> > > >  	if (!fs_info->quota_root) {
> > > >  		ret = -ENOTCONN;
> > > > diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> > > > index f644c7c04d53..2bb5a64f6d84 100644
> > > > --- a/fs/btrfs/transaction.c
> > > > +++ b/fs/btrfs/transaction.c
> > > > @@ -1716,6 +1716,11 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
> > > >  	}
> > > >  	btrfs_release_path(path);
> > > >  
> > > > +	ret = btrfs_create_qgroup(trans, objectid);
> > > > +	if (ret) {
> > > > +		btrfs_abort_transaction(trans, ret);
> > > > +		goto fail;
> > > > +	}
> > > 
> > > Newline please.
> > > 
> > > How is this ok with normal qgroups?  We weren't creating a qgroup at snapshot
> > > creation time at all it seems, so I don't understand how this is ok for qgroups.
> > 
> > qgroup_account_snapshot calls btrfs_qgroup_inherit which contains a
> > separate implementation of qgroup creation.
> 
> Which it still does, so I'm confused as to how this is ok.  How do we not get an
> EEXIST when we do the btrfs_qgroup_inherit?  Thanks,
> 
> Josef

add_qgroup_item ignores EEXIST. I believe this should be exercised by
a user intentionally creating a qgroup for a subvolume before
creating the subvolume (I believe that is explicitly supported, though
it does seem to rely on guessing the subvol ID?!)

from man btrfs-qgroup:
"For the 0/<subvolume id> qgroup, a qgroup can be created even before
the subvolume is created."

  reply	other threads:[~2023-07-13 23:15 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 [this message]
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=20230713231357.GA2710302@zen \
    --to=boris@bur.io \
    --cc=josef@toxicpanda.com \
    --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