From: Josef Bacik <[email protected]>

Patch "Btrfs: remove btrfs_sector_sum structure" introduced a problem
that we copied the checksum value to the wrong address when doing
relocation.

The reason is:
It is very likely that one ordered extent has two or more checksum
structures to keep the relative checksum value, and ->bytenr in each
checksum structure should point to the start of its extent, not the
start of the ordered extent. Fix it.

Signed-off-by: Josef Bacik <[email protected]>
Signed-off-by: Miao Xie <[email protected]>
---
 fs/btrfs/relocation.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 35c0cf7..e3108e5 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4410,11 +4410,13 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 
file_pos, u64 len)
        if (ret)
                goto out;
 
+       disk_bytenr = ordered->start;
        while (!list_empty(&list)) {
                sums = list_entry(list.next, struct btrfs_ordered_sum, list);
                list_del_init(&sums->list);
 
-               sums->bytenr = ordered->start;
+               sums->bytenr = disk_bytenr;
+               disk_bytenr += sums->len;
 
                btrfs_add_ordered_sum(inode, ordered, sums);
        }
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to