On Mon, May 13, 2019 at 05:56:07PM +0200, David Sterba wrote:
> On Mon, Apr 22, 2019 at 04:43:42PM +0100, fdman...@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);
 }

Reply via email to