From: Josef Bacik <josef@toxicpanda.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: qgroup: Mark qgroup inconsistent if we're inherting snapshot to a new qgroup
Date: Fri, 10 Apr 2020 15:19:27 -0400 [thread overview]
Message-ID: <ecc9ec25-e8ca-a288-bc56-aa962c01e02c@toxicpanda.com> (raw)
In-Reply-To: <20200402063735.32808-1-wqu@suse.com>
On 4/2/20 2:37 AM, Qu Wenruo wrote:
> [BUG]
> For the following operation, qgroup is guaranteed to be screwed up due
> to snapshot adding to a new qgroup:
>
> # mkfs.btrfs -f $dev
> # mount $dev $mnt
> # btrfs qgroup en $mnt
> # btrfs subv create $mnt/src
> # xfs_io -f -c "pwrite 0 1m" $mnt/src/file
> # sync
> # btrfs qgroup create 1/0 $mnt/src
> # btrfs subv snapshot -i 1/0 $mnt/src $mnt/snapshot
> # btrfs qgroup show -prce $mnt/src
> qgroupid rfer excl max_rfer max_excl parent child
> -------- ---- ---- -------- -------- ------ -----
> 0/5 16.00KiB 16.00KiB none none --- ---
> 0/257 1.02MiB 16.00KiB none none --- ---
> 0/258 1.02MiB 16.00KiB none none 1/0 ---
> 1/0 0.00B 0.00B none none --- 0/258
> ^^^^^^^^^^^^^^^^^^^^
>
Can we get an xfstest for this? When I go through qgroups in a few months I
want to have as many regression tests as possible to rely on.
> [CAUSE]
> The problem is in btrfs_qgroup_inherit(), we don't have good enough
> check to determine if the new relation ship would break the existing
> accounting.
>
> Unlike btrfs_add_qgroup_relation(), which has proper check to determine
> if we can do quick update without a rescan, in btrfs_qgroup_inherit() we
> can even assign a snapshot to multiple qgroups.
>
> [FIX]
> Fix the problem by manually marking qgroup inconsistent for snapshot
> inheritance.
>
> For subvolume creation, since all its extents are exclusively owned by
> itself, we don't need to rescan.
>
> In theory, we should call relationship check like quick_update_accounting()
> when doing qgroup inheritance and inform user about qgroup inconsistent.
>
> But we don't have good enough mechanism to inform user in the snapshot
> creation context, thus we can only silently mark the qgroup
> inconsistent.
>
> Anyway, user shouldn't use qgroup inheritance during snapshot creation,
> and should add qgroup relationship after snapshot creation by 'btrfs
> qgroup assign', which has a much better UI to inform user about qgroup
> inconsistent and kick in rescan automatically.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
next prev parent reply other threads:[~2020-04-10 19:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-02 6:37 [PATCH] btrfs: qgroup: Mark qgroup inconsistent if we're inherting snapshot to a new qgroup Qu Wenruo
2020-04-08 12:36 ` Qu Wenruo
2020-05-06 15:04 ` David Sterba
2020-05-06 22:48 ` Qu Wenruo
2020-05-07 20:51 ` David Sterba
2020-05-08 0:08 ` Qu Wenruo
2020-04-10 19:19 ` Josef Bacik [this message]
2020-05-07 20:57 ` 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=ecc9ec25-e8ca-a288-bc56-aa962c01e02c@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.