diff mbox

Btrfs: fix wrong csum clone when doing relocation

Message ID 51BFD061.4070404@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Miao Xie June 18, 2013, 3:13 a.m. UTC
From: Josef Bacik <jbacik@fusionio.com>

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 <jbacik@fusionio.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/relocation.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Josef Bacik June 18, 2013, 12:23 p.m. UTC | #1
On Tue, Jun 18, 2013 at 11:13:37AM +0800, Miao Xie wrote:
> From: Josef Bacik <jbacik@fusionio.com>
> 
> 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.
> 

Just fold it into the original patch, since it corrupts the file system I'd
rather people not be able to bisect across them.  Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);
 	}