]> git.hungrycats.org Git - linux/commitdiff
btrfs: get rid of maximum dedupe length
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 12 Nov 2024 01:32:54 +0000 (20:32 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Thu, 14 Nov 2024 22:33:45 +0000 (17:33 -0500)
Since v4.20, the dedupe compare function allocates memory one page at
a time, removing the need to limit the length of any stage of a dedupe
operation.  So let's remove the limit too, since it forces the creation
of short extents.

Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
(cherry picked from commit 6d1620667f1f4072faf405fe1cb97cfbcffc7d85)

fs/btrfs/reflink.c

index 4b3ae0faf548e5df94ff2e38b3d483fd42b2d106..98d6421bc00c48ffb9af713253179ec686e535b4 100644 (file)
@@ -8,8 +8,6 @@
 #include "reflink.h"
 #include "transaction.h"
 
-#define BTRFS_MAX_DEDUPE_LEN   SZ_16M
-
 static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
                                     struct inode *inode,
                                     u64 endoff,
@@ -638,7 +636,6 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
                             struct inode *dst, u64 dst_loff)
 {
        int ret = 0;
-       u64 i, tail_len, chunk_count;
        struct btrfs_root *root_dst = BTRFS_I(dst)->root;
 
        spin_lock(&root_dst->root_item_lock);
@@ -653,22 +650,8 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
        root_dst->dedupe_in_progress++;
        spin_unlock(&root_dst->root_item_lock);
 
-       tail_len = olen % BTRFS_MAX_DEDUPE_LEN;
-       chunk_count = div_u64(olen, BTRFS_MAX_DEDUPE_LEN);
-
-       for (i = 0; i < chunk_count; i++) {
-               ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN,
-                                             dst, dst_loff);
-               if (ret)
-                       goto out;
-
-               loff += BTRFS_MAX_DEDUPE_LEN;
-               dst_loff += BTRFS_MAX_DEDUPE_LEN;
-       }
-
-       if (tail_len > 0)
-               ret = btrfs_extent_same_range(src, loff, tail_len, dst, dst_loff);
-out:
+       if (olen > 0)
+               ret = btrfs_extent_same_range(src, loff, olen, dst, dst_loff);
        spin_lock(&root_dst->root_item_lock);
        root_dst->dedupe_in_progress--;
        spin_unlock(&root_dst->root_item_lock);