]> git.hungrycats.org Git - linux/commitdiff
btrfs: get rid of maximum dedupe length 6.18/topics/dedupe-fixes
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 12 Nov 2024 01:32:54 +0000 (20:32 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 16 Sep 2026 21:39:57 +0000 (17:39 -0400)
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.

Remove the limit too, since it forces the creation of short extent
references.

Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
fs/btrfs/reflink.c

index 8356e3b74cd37a5216e2065f8a2603394349b017..316d11b22a87e854cc72ab5c4bc99931a9a67cdf 100644 (file)
@@ -16,8 +16,6 @@
 #include "file.h"
 #include "super.h"
 
-#define BTRFS_MAX_DEDUPE_LEN   SZ_16M
-
 static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
                                     struct inode *inode,
                                     u64 endoff,
@@ -716,7 +714,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);
@@ -731,23 +728,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(BTRFS_I(src), loff, BTRFS_MAX_DEDUPE_LEN,
-                                             BTRFS_I(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(BTRFS_I(src), loff, tail_len,
-                                             BTRFS_I(dst), dst_loff);
-out:
+       if (olen > 0)
+               ret = btrfs_extent_same_range(BTRFS_I(src), loff, olen, BTRFS_I(dst), dst_loff);
        spin_lock(&root_dst->root_item_lock);
        root_dst->dedupe_in_progress--;
        spin_unlock(&root_dst->root_item_lock);