summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2008-11-10 13:34:43 +0100
committerChris Mason <chris.mason@oracle.com>2008-11-10 13:34:43 +0100
commitff5b7ee33d82414bf4baf299c21fb703bcc89629 (patch)
tree926786cf57b375e5ef1f865427c910c3d4bdfc7a /fs/btrfs/compression.c
parentBtrfs: Make sure pages are dirty before doing delalloc for them (diff)
downloadlinux-ff5b7ee33d82414bf4baf299c21fb703bcc89629.tar.xz
linux-ff5b7ee33d82414bf4baf299c21fb703bcc89629.zip
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 <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 7397c622fb6a..8e7a78acf81a 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)) {