From 452a928ab0da163fbd2f82d63851539f907b1633 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 11 Nov 2024 20:32:54 -0500 Subject: [PATCH] btrfs: get rid of maximum dedupe length 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 (cherry picked from commit 6d1620667f1f4072faf405fe1cb97cfbcffc7d85) --- fs/btrfs/reflink.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c index 4b3ae0faf548..98d6421bc00c 100644 --- a/fs/btrfs/reflink.c +++ b/fs/btrfs/reflink.c @@ -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); -- 2.39.5