From ff5b7ee33d82414bf4baf299c21fb703bcc89629 Mon Sep 17 00:00:00 2001 From: Yan Zheng Date: Mon, 10 Nov 2008 07:34:43 -0500 Subject: Btrfs: Fix csum error for compressed data The decompress code doesn't take the logical offset in extent pointer into account. If the logical offset isn't zero, data will be decompressed into wrong pages. The solution used here is to record the starting offset of the extent in the file separately from the logical start of the extent_map struct. This allows us to avoid problems inserting overlapping extents. Signed-off-by: Yan Zheng --- fs/btrfs/compression.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'fs/btrfs/compression.c') diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 7397c62..8e7a78a 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -505,7 +505,6 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, struct block_device *bdev; struct bio *comp_bio; u64 cur_disk_byte = (u64)bio->bi_sector << 9; - u64 em_len; struct extent_map *em; int ret; @@ -524,9 +523,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, cb->errors = 0; cb->inode = inode; - cb->start = em->start; + cb->start = em->orig_start; compressed_len = em->block_len; - em_len = em->len; free_extent_map(em); cb->len = uncompressed_len; @@ -545,7 +543,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, } cb->nr_pages = nr_pages; - add_ra_bio_pages(inode, cb->start + em_len, cb); + add_ra_bio_pages(inode, em->start + em->len, cb); if (!btrfs_test_opt(root, NODATASUM) && !btrfs_test_flag(inode, NODATASUM)) { -- cgit v1.1