aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 6aad98cb343f..b01fb6c527e3 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -32,7 +32,6 @@
32#include <linux/writeback.h> 32#include <linux/writeback.h>
33#include <linux/bit_spinlock.h> 33#include <linux/bit_spinlock.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include "compat.h"
36#include "ctree.h" 35#include "ctree.h"
37#include "disk-io.h" 36#include "disk-io.h"
38#include "transaction.h" 37#include "transaction.h"
@@ -129,11 +128,10 @@ static int check_compressed_csum(struct inode *inode,
129 kunmap_atomic(kaddr); 128 kunmap_atomic(kaddr);
130 129
131 if (csum != *cb_sum) { 130 if (csum != *cb_sum) {
132 printk(KERN_INFO "btrfs csum failed ino %llu " 131 btrfs_info(BTRFS_I(inode)->root->fs_info,
133 "extent %llu csum %u " 132 "csum failed ino %llu extent %llu csum %u wanted %u mirror %d",
134 "wanted %u mirror %d\n", 133 btrfs_ino(inode), disk_start, csum, *cb_sum,
135 btrfs_ino(inode), disk_start, csum, *cb_sum, 134 cb->mirror_num);
136 cb->mirror_num);
137 ret = -EIO; 135 ret = -EIO;
138 goto fail; 136 goto fail;
139 } 137 }
@@ -173,7 +171,8 @@ static void end_compressed_bio_read(struct bio *bio, int err)
173 goto out; 171 goto out;
174 172
175 inode = cb->inode; 173 inode = cb->inode;
176 ret = check_compressed_csum(inode, cb, (u64)bio->bi_sector << 9); 174 ret = check_compressed_csum(inode, cb,
175 (u64)bio->bi_iter.bi_sector << 9);
177 if (ret) 176 if (ret)
178 goto csum_failed; 177 goto csum_failed;
179 178
@@ -202,18 +201,16 @@ csum_failed:
202 if (cb->errors) { 201 if (cb->errors) {
203 bio_io_error(cb->orig_bio); 202 bio_io_error(cb->orig_bio);
204 } else { 203 } else {
205 int bio_index = 0; 204 int i;
206 struct bio_vec *bvec = cb->orig_bio->bi_io_vec; 205 struct bio_vec *bvec;
207 206
208 /* 207 /*
209 * we have verified the checksum already, set page 208 * we have verified the checksum already, set page
210 * checked so the end_io handlers know about it 209 * checked so the end_io handlers know about it
211 */ 210 */
212 while (bio_index < cb->orig_bio->bi_vcnt) { 211 bio_for_each_segment_all(bvec, cb->orig_bio, i)
213 SetPageChecked(bvec->bv_page); 212 SetPageChecked(bvec->bv_page);
214 bvec++; 213
215 bio_index++;
216 }
217 bio_endio(cb->orig_bio, 0); 214 bio_endio(cb->orig_bio, 0);
218 } 215 }
219 216
@@ -360,7 +357,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
360 bdev = BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev; 357 bdev = BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev;
361 358
362 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS); 359 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS);
363 if(!bio) { 360 if (!bio) {
364 kfree(cb); 361 kfree(cb);
365 return -ENOMEM; 362 return -ENOMEM;
366 } 363 }
@@ -373,7 +370,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
373 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) { 370 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) {
374 page = compressed_pages[pg_index]; 371 page = compressed_pages[pg_index];
375 page->mapping = inode->i_mapping; 372 page->mapping = inode->i_mapping;
376 if (bio->bi_size) 373 if (bio->bi_iter.bi_size)
377 ret = io_tree->ops->merge_bio_hook(WRITE, page, 0, 374 ret = io_tree->ops->merge_bio_hook(WRITE, page, 0,
378 PAGE_CACHE_SIZE, 375 PAGE_CACHE_SIZE,
379 bio, 0); 376 bio, 0);
@@ -413,7 +410,8 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
413 bio_add_page(bio, page, PAGE_CACHE_SIZE, 0); 410 bio_add_page(bio, page, PAGE_CACHE_SIZE, 0);
414 } 411 }
415 if (bytes_left < PAGE_CACHE_SIZE) { 412 if (bytes_left < PAGE_CACHE_SIZE) {
416 printk("bytes left %lu compress len %lu nr %lu\n", 413 btrfs_info(BTRFS_I(inode)->root->fs_info,
414 "bytes left %lu compress len %lu nr %lu",
417 bytes_left, cb->compressed_len, cb->nr_pages); 415 bytes_left, cb->compressed_len, cb->nr_pages);
418 } 416 }
419 bytes_left -= PAGE_CACHE_SIZE; 417 bytes_left -= PAGE_CACHE_SIZE;
@@ -507,7 +505,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
507 505
508 if (!em || last_offset < em->start || 506 if (!em || last_offset < em->start ||
509 (last_offset + PAGE_CACHE_SIZE > extent_map_end(em)) || 507 (last_offset + PAGE_CACHE_SIZE > extent_map_end(em)) ||
510 (em->block_start >> 9) != cb->orig_bio->bi_sector) { 508 (em->block_start >> 9) != cb->orig_bio->bi_iter.bi_sector) {
511 free_extent_map(em); 509 free_extent_map(em);
512 unlock_extent(tree, last_offset, end); 510 unlock_extent(tree, last_offset, end);
513 unlock_page(page); 511 unlock_page(page);
@@ -553,7 +551,7 @@ next:
553 * in it. We don't actually do IO on those pages but allocate new ones 551 * in it. We don't actually do IO on those pages but allocate new ones
554 * to hold the compressed pages on disk. 552 * to hold the compressed pages on disk.
555 * 553 *
556 * bio->bi_sector points to the compressed extent on disk 554 * bio->bi_iter.bi_sector points to the compressed extent on disk
557 * bio->bi_io_vec points to all of the inode pages 555 * bio->bi_io_vec points to all of the inode pages
558 * bio->bi_vcnt is a count of pages 556 * bio->bi_vcnt is a count of pages
559 * 557 *
@@ -574,7 +572,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
574 struct page *page; 572 struct page *page;
575 struct block_device *bdev; 573 struct block_device *bdev;
576 struct bio *comp_bio; 574 struct bio *comp_bio;
577 u64 cur_disk_byte = (u64)bio->bi_sector << 9; 575 u64 cur_disk_byte = (u64)bio->bi_iter.bi_sector << 9;
578 u64 em_len; 576 u64 em_len;
579 u64 em_start; 577 u64 em_start;
580 struct extent_map *em; 578 struct extent_map *em;
@@ -660,7 +658,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
660 page->mapping = inode->i_mapping; 658 page->mapping = inode->i_mapping;
661 page->index = em_start >> PAGE_CACHE_SHIFT; 659 page->index = em_start >> PAGE_CACHE_SHIFT;
662 660
663 if (comp_bio->bi_size) 661 if (comp_bio->bi_iter.bi_size)
664 ret = tree->ops->merge_bio_hook(READ, page, 0, 662 ret = tree->ops->merge_bio_hook(READ, page, 0,
665 PAGE_CACHE_SIZE, 663 PAGE_CACHE_SIZE,
666 comp_bio, 0); 664 comp_bio, 0);
@@ -688,8 +686,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
688 comp_bio, sums); 686 comp_bio, sums);
689 BUG_ON(ret); /* -ENOMEM */ 687 BUG_ON(ret); /* -ENOMEM */
690 } 688 }
691 sums += (comp_bio->bi_size + root->sectorsize - 1) / 689 sums += (comp_bio->bi_iter.bi_size +
692 root->sectorsize; 690 root->sectorsize - 1) / root->sectorsize;
693 691
694 ret = btrfs_map_bio(root, READ, comp_bio, 692 ret = btrfs_map_bio(root, READ, comp_bio,
695 mirror_num, 0); 693 mirror_num, 0);
@@ -1012,6 +1010,8 @@ int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
1012 bytes = min(bytes, working_bytes); 1010 bytes = min(bytes, working_bytes);
1013 kaddr = kmap_atomic(page_out); 1011 kaddr = kmap_atomic(page_out);
1014 memcpy(kaddr + *pg_offset, buf + buf_offset, bytes); 1012 memcpy(kaddr + *pg_offset, buf + buf_offset, bytes);
1013 if (*pg_index == (vcnt - 1) && *pg_offset == 0)
1014 memset(kaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1015 kunmap_atomic(kaddr); 1015 kunmap_atomic(kaddr);
1016 flush_dcache_page(page_out); 1016 flush_dcache_page(page_out);
1017 1017