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.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 41d1d7c70e29..bfe42b03eaf9 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -125,9 +125,10 @@ static int check_compressed_csum(struct inode *inode,
125 kunmap_atomic(kaddr, KM_USER0); 125 kunmap_atomic(kaddr, KM_USER0);
126 126
127 if (csum != *cb_sum) { 127 if (csum != *cb_sum) {
128 printk(KERN_INFO "btrfs csum failed ino %lu " 128 printk(KERN_INFO "btrfs csum failed ino %llu "
129 "extent %llu csum %u " 129 "extent %llu csum %u "
130 "wanted %u mirror %d\n", inode->i_ino, 130 "wanted %u mirror %d\n",
131 (unsigned long long)btrfs_ino(inode),
131 (unsigned long long)disk_start, 132 (unsigned long long)disk_start,
132 csum, *cb_sum, cb->mirror_num); 133 csum, *cb_sum, cb->mirror_num);
133 ret = -EIO; 134 ret = -EIO;
@@ -332,7 +333,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
332 struct compressed_bio *cb; 333 struct compressed_bio *cb;
333 unsigned long bytes_left; 334 unsigned long bytes_left;
334 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; 335 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
335 int page_index = 0; 336 int pg_index = 0;
336 struct page *page; 337 struct page *page;
337 u64 first_byte = disk_start; 338 u64 first_byte = disk_start;
338 struct block_device *bdev; 339 struct block_device *bdev;
@@ -366,8 +367,8 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
366 367
367 /* create and submit bios for the compressed pages */ 368 /* create and submit bios for the compressed pages */
368 bytes_left = compressed_len; 369 bytes_left = compressed_len;
369 for (page_index = 0; page_index < cb->nr_pages; page_index++) { 370 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) {
370 page = compressed_pages[page_index]; 371 page = compressed_pages[pg_index];
371 page->mapping = inode->i_mapping; 372 page->mapping = inode->i_mapping;
372 if (bio->bi_size) 373 if (bio->bi_size)
373 ret = io_tree->ops->merge_bio_hook(page, 0, 374 ret = io_tree->ops->merge_bio_hook(page, 0,
@@ -432,7 +433,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
432 struct compressed_bio *cb) 433 struct compressed_bio *cb)
433{ 434{
434 unsigned long end_index; 435 unsigned long end_index;
435 unsigned long page_index; 436 unsigned long pg_index;
436 u64 last_offset; 437 u64 last_offset;
437 u64 isize = i_size_read(inode); 438 u64 isize = i_size_read(inode);
438 int ret; 439 int ret;
@@ -456,13 +457,13 @@ static noinline int add_ra_bio_pages(struct inode *inode,
456 end_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT; 457 end_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;
457 458
458 while (last_offset < compressed_end) { 459 while (last_offset < compressed_end) {
459 page_index = last_offset >> PAGE_CACHE_SHIFT; 460 pg_index = last_offset >> PAGE_CACHE_SHIFT;
460 461
461 if (page_index > end_index) 462 if (pg_index > end_index)
462 break; 463 break;
463 464
464 rcu_read_lock(); 465 rcu_read_lock();
465 page = radix_tree_lookup(&mapping->page_tree, page_index); 466 page = radix_tree_lookup(&mapping->page_tree, pg_index);
466 rcu_read_unlock(); 467 rcu_read_unlock();
467 if (page) { 468 if (page) {
468 misses++; 469 misses++;
@@ -476,7 +477,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
476 if (!page) 477 if (!page)
477 break; 478 break;
478 479
479 if (add_to_page_cache_lru(page, mapping, page_index, 480 if (add_to_page_cache_lru(page, mapping, pg_index,
480 GFP_NOFS)) { 481 GFP_NOFS)) {
481 page_cache_release(page); 482 page_cache_release(page);
482 goto next; 483 goto next;
@@ -560,7 +561,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
560 unsigned long uncompressed_len = bio->bi_vcnt * PAGE_CACHE_SIZE; 561 unsigned long uncompressed_len = bio->bi_vcnt * PAGE_CACHE_SIZE;
561 unsigned long compressed_len; 562 unsigned long compressed_len;
562 unsigned long nr_pages; 563 unsigned long nr_pages;
563 unsigned long page_index; 564 unsigned long pg_index;
564 struct page *page; 565 struct page *page;
565 struct block_device *bdev; 566 struct block_device *bdev;
566 struct bio *comp_bio; 567 struct bio *comp_bio;
@@ -613,10 +614,10 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
613 614
614 bdev = BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev; 615 bdev = BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev;
615 616
616 for (page_index = 0; page_index < nr_pages; page_index++) { 617 for (pg_index = 0; pg_index < nr_pages; pg_index++) {
617 cb->compressed_pages[page_index] = alloc_page(GFP_NOFS | 618 cb->compressed_pages[pg_index] = alloc_page(GFP_NOFS |
618 __GFP_HIGHMEM); 619 __GFP_HIGHMEM);
619 if (!cb->compressed_pages[page_index]) 620 if (!cb->compressed_pages[pg_index])
620 goto fail2; 621 goto fail2;
621 } 622 }
622 cb->nr_pages = nr_pages; 623 cb->nr_pages = nr_pages;
@@ -634,8 +635,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
634 comp_bio->bi_end_io = end_compressed_bio_read; 635 comp_bio->bi_end_io = end_compressed_bio_read;
635 atomic_inc(&cb->pending_bios); 636 atomic_inc(&cb->pending_bios);
636 637
637 for (page_index = 0; page_index < nr_pages; page_index++) { 638 for (pg_index = 0; pg_index < nr_pages; pg_index++) {
638 page = cb->compressed_pages[page_index]; 639 page = cb->compressed_pages[pg_index];
639 page->mapping = inode->i_mapping; 640 page->mapping = inode->i_mapping;
640 page->index = em_start >> PAGE_CACHE_SHIFT; 641 page->index = em_start >> PAGE_CACHE_SHIFT;
641 642
@@ -702,8 +703,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
702 return 0; 703 return 0;
703 704
704fail2: 705fail2:
705 for (page_index = 0; page_index < nr_pages; page_index++) 706 for (pg_index = 0; pg_index < nr_pages; pg_index++)
706 free_page((unsigned long)cb->compressed_pages[page_index]); 707 free_page((unsigned long)cb->compressed_pages[pg_index]);
707 708
708 kfree(cb->compressed_pages); 709 kfree(cb->compressed_pages);
709fail1: 710fail1:
@@ -945,7 +946,7 @@ void btrfs_exit_compress(void)
945int btrfs_decompress_buf2page(char *buf, unsigned long buf_start, 946int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
946 unsigned long total_out, u64 disk_start, 947 unsigned long total_out, u64 disk_start,
947 struct bio_vec *bvec, int vcnt, 948 struct bio_vec *bvec, int vcnt,
948 unsigned long *page_index, 949 unsigned long *pg_index,
949 unsigned long *pg_offset) 950 unsigned long *pg_offset)
950{ 951{
951 unsigned long buf_offset; 952 unsigned long buf_offset;
@@ -954,7 +955,7 @@ int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
954 unsigned long working_bytes = total_out - buf_start; 955 unsigned long working_bytes = total_out - buf_start;
955 unsigned long bytes; 956 unsigned long bytes;
956 char *kaddr; 957 char *kaddr;
957 struct page *page_out = bvec[*page_index].bv_page; 958 struct page *page_out = bvec[*pg_index].bv_page;
958 959
959 /* 960 /*
960 * start byte is the first byte of the page we're currently 961 * start byte is the first byte of the page we're currently
@@ -995,11 +996,11 @@ int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
995 996
996 /* check if we need to pick another page */ 997 /* check if we need to pick another page */
997 if (*pg_offset == PAGE_CACHE_SIZE) { 998 if (*pg_offset == PAGE_CACHE_SIZE) {
998 (*page_index)++; 999 (*pg_index)++;
999 if (*page_index >= vcnt) 1000 if (*pg_index >= vcnt)
1000 return 0; 1001 return 0;
1001 1002
1002 page_out = bvec[*page_index].bv_page; 1003 page_out = bvec[*pg_index].bv_page;
1003 *pg_offset = 0; 1004 *pg_offset = 0;
1004 start_byte = page_offset(page_out) - disk_start; 1005 start_byte = page_offset(page_out) - disk_start;
1005 1006