From: David Sterba <dsterba@suse.cz>
To: dsterba@suse.cz, fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] Btrfs: fix race between send and deduplication that lead to failures and crashes
Date: Mon, 13 May 2019 18:07:04 +0200 [thread overview]
Message-ID: <20190513160704.GE3138@twin.jikos.cz> (raw)
In-Reply-To: <20190513155607.GD3138@twin.jikos.cz>
On Mon, May 13, 2019 at 05:56:07PM +0200, David Sterba wrote:
> On Mon, Apr 22, 2019 at 04:43:42PM +0100, fdmanana@kernel.org wrote:
> > + btrfs_warn_rl(root_dst->fs_info,
> > +"Can not deduplicate to root %llu while send operations are using it (%d in progress)",
> > + root_dst->root_key.objectid,
> > + root_dst->send_in_progress);
>
> The test btrfs/187 stresses this code and the logs are flooded by the
> messages, even ratelimited.
>
> I wonder if the test is rather artificail (and that's fine for the testing
> purposes) or if the number of messages would repeat under normal conditions.
>
> We don't need to print the message each time the dedup tries to acces a
> snapshot under send, so keeping track if the message has been sent already
> would be less intrusive and still provide the information.
Untested:
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1205,6 +1205,8 @@ enum {
BTRFS_ROOT_DEAD_RELOC_TREE,
/* Mark dead root stored on device whose cleanup needs to be resumed */
BTRFS_ROOT_DEAD_TREE,
+ /* Track if dedupe was attempted under a current send */
+ BTRFS_ROOT_NOTIFIED_DEDUPE_DURING_SEND,
};
/*
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6dafa857bbb9..23677cf12afc 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3263,7 +3263,9 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
spin_lock(&root_dst->root_item_lock);
if (root_dst->send_in_progress) {
- btrfs_warn_rl(root_dst->fs_info,
+ if (!test_and_set_bit(BTRFS_ROOT_NOTIFIED_DEDUPE_DURING_SEND,
+ &root_dst->state))
+ btrfs_warn(root_dst->fs_info,
"cannot deduplicate to root %llu while send operations are using it (%d in progress)",
root_dst->root_key.objectid,
root_dst->send_in_progress);
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index dd38dfe174df..cc85ae903368 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -6637,6 +6637,8 @@ static void btrfs_root_dec_send_in_progress(struct btrfs_root* root)
btrfs_err(root->fs_info,
"send_in_progress unbalanced %d root %llu",
root->send_in_progress, root->root_key.objectid);
+ if (root->send_in_progress == 0)
+ clear_bit(BTRFS_ROOT_NOTIFIED_DEDUPE_DURING_SEND, &root->state);
spin_unlock(&root->root_item_lock);
}
next prev parent reply other threads:[~2019-05-13 16:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-15 8:30 [PATCH] Btrfs: fix race between send and deduplication that lead to failures and crashes fdmanana
2019-04-17 14:11 ` David Sterba
2019-04-22 15:43 ` [PATCH v2] " fdmanana
2019-04-24 16:26 ` David Sterba
2019-05-13 15:56 ` David Sterba
2019-05-13 16:07 ` David Sterba [this message]
2019-05-13 16:18 ` Filipe Manana
2019-05-13 16:58 ` David Sterba
2019-05-13 17:05 ` Filipe Manana
2019-05-13 19:10 ` David Sterba
2019-05-13 22:06 ` 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=20190513160704.GE3138@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=fdmanana@kernel.org \
--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).