aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2008-11-10 07:34:43 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-10 07:34:43 -0500
commitff5b7ee33d82414bf4baf299c21fb703bcc89629 (patch)
tree926786cf57b375e5ef1f865427c910c3d4bdfc7a /fs/btrfs/compression.c
parentf2b1c41cf94d7f839fe9ede5f3ead92698a93fb3 (diff)
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,
505 struct block_device *bdev; 505 struct block_device *bdev;
506 struct bio *comp_bio; 506 struct bio *comp_bio;
507 u64 cur_disk_byte = (u64)bio->bi_sector << 9; 507 u64 cur_disk_byte = (u64)bio->bi_sector << 9;
508 u64 em_len;
509 struct extent_map *em; 508 struct extent_map *em;
510 int ret; 509 int ret;
511 510
@@ -524,9 +523,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
524 cb->errors = 0; 523 cb->errors = 0;
525 cb->inode = inode; 524 cb->inode = inode;
526 525
527 cb->start = em->start; 526 cb->start = em->orig_start;
528 compressed_len = em->block_len; 527 compressed_len = em->block_len;
529 em_len = em->len;
530 free_extent_map(em); 528 free_extent_map(em);
531 529
532 cb->len = uncompressed_len; 530 cb->len = uncompressed_len;
@@ -545,7 +543,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
545 } 543 }
546 cb->nr_pages = nr_pages; 544 cb->nr_pages = nr_pages;
547 545
548 add_ra_bio_pages(inode, cb->start + em_len, cb); 546 add_ra_bio_pages(inode, em->start + em->len, cb);
549 547
550 if (!btrfs_test_opt(root, NODATASUM) && 548 if (!btrfs_test_opt(root, NODATASUM) &&
551 !btrfs_test_flag(inode, NODATASUM)) { 549 !btrfs_test_flag(inode, NODATASUM)) {