aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-06-03 03:38:06 -0400
committerJens Axboe <axboe@fb.com>2017-06-09 11:27:32 -0400
commit4e4cbee93d56137ebff722be022cae5f70ef84fb (patch)
tree4fa7345155599fc6bdd653fca8c5224ddf90a5be /fs/btrfs/compression.c
parentfc17b6534eb8395f0b3133eb31d87deec32c642b (diff)
block: switch bios to blk_status_t
Replace bi_error with a new bi_status to allow for a clear conversion. Note that device mapper overloaded bi_error with a private value, which we'll have to keep arround at least for now and thus propagate to a proper blk_status_t value. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
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 10e6b282d09d..9ac55b266e78 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -155,7 +155,7 @@ static void end_compressed_bio_read(struct bio *bio)
155 unsigned long index; 155 unsigned long index;
156 int ret; 156 int ret;
157 157
158 if (bio->bi_error) 158 if (bio->bi_status)
159 cb->errors = 1; 159 cb->errors = 1;
160 160
161 /* if there are more bios still pending for this compressed 161 /* if there are more bios still pending for this compressed
@@ -268,7 +268,7 @@ static void end_compressed_bio_write(struct bio *bio)
268 struct page *page; 268 struct page *page;
269 unsigned long index; 269 unsigned long index;
270 270
271 if (bio->bi_error) 271 if (bio->bi_status)
272 cb->errors = 1; 272 cb->errors = 1;
273 273
274 /* if there are more bios still pending for this compressed 274 /* if there are more bios still pending for this compressed
@@ -287,7 +287,7 @@ static void end_compressed_bio_write(struct bio *bio)
287 cb->start, 287 cb->start,
288 cb->start + cb->len - 1, 288 cb->start + cb->len - 1,
289 NULL, 289 NULL,
290 bio->bi_error ? 0 : 1); 290 bio->bi_status ? 0 : 1);
291 cb->compressed_pages[0]->mapping = NULL; 291 cb->compressed_pages[0]->mapping = NULL;
292 292
293 end_compressed_writeback(inode, cb); 293 end_compressed_writeback(inode, cb);
@@ -320,7 +320,7 @@ out:
320 * This also checksums the file bytes and gets things ready for 320 * This also checksums the file bytes and gets things ready for
321 * the end io hooks. 321 * the end io hooks.
322 */ 322 */
323int btrfs_submit_compressed_write(struct inode *inode, u64 start, 323blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
324 unsigned long len, u64 disk_start, 324 unsigned long len, u64 disk_start,
325 unsigned long compressed_len, 325 unsigned long compressed_len,
326 struct page **compressed_pages, 326 struct page **compressed_pages,
@@ -335,13 +335,13 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
335 struct page *page; 335 struct page *page;
336 u64 first_byte = disk_start; 336 u64 first_byte = disk_start;
337 struct block_device *bdev; 337 struct block_device *bdev;
338 int ret; 338 blk_status_t ret;
339 int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; 339 int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
340 340
341 WARN_ON(start & ((u64)PAGE_SIZE - 1)); 341 WARN_ON(start & ((u64)PAGE_SIZE - 1));
342 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS); 342 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
343 if (!cb) 343 if (!cb)
344 return -ENOMEM; 344 return BLK_STS_RESOURCE;
345 refcount_set(&cb->pending_bios, 0); 345 refcount_set(&cb->pending_bios, 0);
346 cb->errors = 0; 346 cb->errors = 0;
347 cb->inode = inode; 347 cb->inode = inode;
@@ -358,7 +358,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
358 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS); 358 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS);
359 if (!bio) { 359 if (!bio) {
360 kfree(cb); 360 kfree(cb);
361 return -ENOMEM; 361 return BLK_STS_RESOURCE;
362 } 362 }
363 bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 363 bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
364 bio->bi_private = cb; 364 bio->bi_private = cb;
@@ -368,17 +368,17 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
368 /* create and submit bios for the compressed pages */ 368 /* create and submit bios for the compressed pages */
369 bytes_left = compressed_len; 369 bytes_left = compressed_len;
370 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) { 370 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) {
371 int submit = 0;
372
371 page = compressed_pages[pg_index]; 373 page = compressed_pages[pg_index];
372 page->mapping = inode->i_mapping; 374 page->mapping = inode->i_mapping;
373 if (bio->bi_iter.bi_size) 375 if (bio->bi_iter.bi_size)
374 ret = io_tree->ops->merge_bio_hook(page, 0, 376 submit = io_tree->ops->merge_bio_hook(page, 0,
375 PAGE_SIZE, 377 PAGE_SIZE,
376 bio, 0); 378 bio, 0);
377 else
378 ret = 0;
379 379
380 page->mapping = NULL; 380 page->mapping = NULL;
381 if (ret || bio_add_page(bio, page, PAGE_SIZE, 0) < 381 if (submit || bio_add_page(bio, page, PAGE_SIZE, 0) <
382 PAGE_SIZE) { 382 PAGE_SIZE) {
383 bio_get(bio); 383 bio_get(bio);
384 384
@@ -400,7 +400,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
400 400
401 ret = btrfs_map_bio(fs_info, bio, 0, 1); 401 ret = btrfs_map_bio(fs_info, bio, 0, 1);
402 if (ret) { 402 if (ret) {
403 bio->bi_error = ret; 403 bio->bi_status = ret;
404 bio_endio(bio); 404 bio_endio(bio);
405 } 405 }
406 406
@@ -434,7 +434,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
434 434
435 ret = btrfs_map_bio(fs_info, bio, 0, 1); 435 ret = btrfs_map_bio(fs_info, bio, 0, 1);
436 if (ret) { 436 if (ret) {
437 bio->bi_error = ret; 437 bio->bi_status = ret;
438 bio_endio(bio); 438 bio_endio(bio);
439 } 439 }
440 440
@@ -569,7 +569,7 @@ next:
569 * After the compressed pages are read, we copy the bytes into the 569 * After the compressed pages are read, we copy the bytes into the
570 * bio we were passed and then call the bio end_io calls 570 * bio we were passed and then call the bio end_io calls
571 */ 571 */
572int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, 572blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
573 int mirror_num, unsigned long bio_flags) 573 int mirror_num, unsigned long bio_flags)
574{ 574{
575 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 575 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -586,7 +586,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
586 u64 em_len; 586 u64 em_len;
587 u64 em_start; 587 u64 em_start;
588 struct extent_map *em; 588 struct extent_map *em;
589 int ret = -ENOMEM; 589 blk_status_t ret = BLK_STS_RESOURCE;
590 int faili = 0; 590 int faili = 0;
591 u32 *sums; 591 u32 *sums;
592 592
@@ -600,7 +600,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
600 PAGE_SIZE); 600 PAGE_SIZE);
601 read_unlock(&em_tree->lock); 601 read_unlock(&em_tree->lock);
602 if (!em) 602 if (!em)
603 return -EIO; 603 return BLK_STS_IOERR;
604 604
605 compressed_len = em->block_len; 605 compressed_len = em->block_len;
606 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS); 606 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
@@ -659,19 +659,19 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
659 refcount_set(&cb->pending_bios, 1); 659 refcount_set(&cb->pending_bios, 1);
660 660
661 for (pg_index = 0; pg_index < nr_pages; pg_index++) { 661 for (pg_index = 0; pg_index < nr_pages; pg_index++) {
662 int submit = 0;
663
662 page = cb->compressed_pages[pg_index]; 664 page = cb->compressed_pages[pg_index];
663 page->mapping = inode->i_mapping; 665 page->mapping = inode->i_mapping;
664 page->index = em_start >> PAGE_SHIFT; 666 page->index = em_start >> PAGE_SHIFT;
665 667
666 if (comp_bio->bi_iter.bi_size) 668 if (comp_bio->bi_iter.bi_size)
667 ret = tree->ops->merge_bio_hook(page, 0, 669 submit = tree->ops->merge_bio_hook(page, 0,
668 PAGE_SIZE, 670 PAGE_SIZE,
669 comp_bio, 0); 671 comp_bio, 0);
670 else
671 ret = 0;
672 672
673 page->mapping = NULL; 673 page->mapping = NULL;
674 if (ret || bio_add_page(comp_bio, page, PAGE_SIZE, 0) < 674 if (submit || bio_add_page(comp_bio, page, PAGE_SIZE, 0) <
675 PAGE_SIZE) { 675 PAGE_SIZE) {
676 bio_get(comp_bio); 676 bio_get(comp_bio);
677 677
@@ -697,7 +697,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
697 697
698 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0); 698 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
699 if (ret) { 699 if (ret) {
700 comp_bio->bi_error = ret; 700 comp_bio->bi_status = ret;
701 bio_endio(comp_bio); 701 bio_endio(comp_bio);
702 } 702 }
703 703
@@ -726,7 +726,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
726 726
727 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0); 727 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
728 if (ret) { 728 if (ret) {
729 comp_bio->bi_error = ret; 729 comp_bio->bi_status = ret;
730 bio_endio(comp_bio); 730 bio_endio(comp_bio);
731 } 731 }
732 732