From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Josef Bacik <josef@toxicpanda.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: Josef Bacik <jbacik@fb.com>
Subject: Re: [PATCH 1/2] btrfs: catch cow on deleting snapshots
Date: Sat, 1 Dec 2018 08:19:40 +0800 [thread overview]
Message-ID: <4a9577f2-9c3b-eb9e-a6a5-b3878769cd2e@gmx.com> (raw)
In-Reply-To: <20181130165214.17883-2-josef@toxicpanda.com>
[-- Attachment #1.1: Type: text/plain, Size: 2651 bytes --]
On 2018/12/1 上午12:52, Josef Bacik wrote:
> From: Josef Bacik <jbacik@fb.com>
>
> When debugging some weird extent reference bug I suspected that we were
> changing a snapshot while we were deleting it, which could explain my
> bug.
May I ask under which case we're going to modify an unlinked snapshot?
Maybe metadata relocation?
Thanks,
Qu
> This was indeed what was happening, and this patch helped me
> verify my theory. It is never correct to modify the snapshot once it's
> being deleted, so mark the root when we are deleting it and make sure we
> complain about it when it happens.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/ctree.c | 3 +++
> fs/btrfs/ctree.h | 1 +
> fs/btrfs/extent-tree.c | 9 +++++++++
> 3 files changed, 13 insertions(+)
>
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 5912a97b07a6..5f82f86085e8 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -1440,6 +1440,9 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans,
> u64 search_start;
> int ret;
>
> + if (test_bit(BTRFS_ROOT_DELETING, &root->state))
> + WARN(1, KERN_CRIT "cow'ing blocks on a fs root thats being dropped\n");
> +
> if (trans->transaction != fs_info->running_transaction)
> WARN(1, KERN_CRIT "trans %llu running %llu\n",
> trans->transid,
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index facde70c15ed..5a3a94ccb65c 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1199,6 +1199,7 @@ enum {
> BTRFS_ROOT_FORCE_COW,
> BTRFS_ROOT_MULTI_LOG_TASKS,
> BTRFS_ROOT_DIRTY,
> + BTRFS_ROOT_DELETING,
> };
>
> /*
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 581c2a0b2945..dcb699dd57f3 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -9333,6 +9333,15 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
> if (block_rsv)
> trans->block_rsv = block_rsv;
>
> + /*
> + * This will help us catch people modifying the fs tree while we're
> + * dropping it. It is unsafe to mess with the fs tree while it's being
> + * dropped as we unlock the root node and parent nodes as we walk down
> + * the tree, assuming nothing will change. If something does change
> + * then we'll have stale information and drop references to blocks we've
> + * already dropped.
> + */
> + set_bit(BTRFS_ROOT_DELETING, &root->state);
> if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) {
> level = btrfs_header_level(root->node);
> path->nodes[level] = btrfs_lock_root_node(root);
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2018-12-01 0:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-30 16:52 [PATCH 0/2] Fix aborts when dropping snapshots Josef Bacik
2018-11-30 16:52 ` [PATCH 1/2] btrfs: catch cow on deleting snapshots Josef Bacik
2018-11-30 17:14 ` Filipe Manana
2018-11-30 17:19 ` Josef Bacik
2018-12-06 18:05 ` David Sterba
2018-12-01 0:19 ` Qu Wenruo [this message]
2018-12-01 3:02 ` Hans van Kranenburg
2018-11-30 16:52 ` [PATCH 2/2] btrfs: run delayed items before dropping the snapshot Josef Bacik
2018-11-30 17:12 ` Filipe Manana
2018-11-30 21:15 ` Filipe Manana
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=4a9577f2-9c3b-eb9e-a6a5-b3878769cd2e@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=jbacik@fb.com \
--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;
as well as URLs for NNTP newsgroup(s).