aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2017-12-13 03:25:37 -0500
committerDavid Sterba <dsterba@suse.com>2018-01-22 10:08:19 -0500
commit32506af595dcaa8b71b7858bb54ccaa310d274fb (patch)
treed52cb516e7cb6d17228872e6e7f3c3b690b5fef0 /fs/btrfs/compression.c
parent4271ecea64f40683d28d83ad433ddc43e5ca2ee9 (diff)
btrfs: Remove redundant bio_get/set calls in compressed read/write paths
bio_get/set is necessary only if the bio is going to be referenced following submissions. In the code paths where such calls are made we don't really need them since the bio is referenced only if btrfs_map_bio returns an error. And this function can return an error prior to submission only. So referencing the bio is safe. Furthermore we do call bio_endio which will consume the last reference. So let's remove the redundant calls. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 208334aa6c6e..5abcc0461ee1 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -362,8 +362,6 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
362 page->mapping = NULL; 362 page->mapping = NULL;
363 if (submit || bio_add_page(bio, page, PAGE_SIZE, 0) < 363 if (submit || bio_add_page(bio, page, PAGE_SIZE, 0) <
364 PAGE_SIZE) { 364 PAGE_SIZE) {
365 bio_get(bio);
366
367 /* 365 /*
368 * inc the count before we submit the bio so 366 * inc the count before we submit the bio so
369 * we know the end IO handler won't happen before 367 * we know the end IO handler won't happen before
@@ -386,8 +384,6 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
386 bio_endio(bio); 384 bio_endio(bio);
387 } 385 }
388 386
389 bio_put(bio);
390
391 bio = btrfs_bio_alloc(bdev, first_byte); 387 bio = btrfs_bio_alloc(bdev, first_byte);
392 bio->bi_opf = REQ_OP_WRITE | write_flags; 388 bio->bi_opf = REQ_OP_WRITE | write_flags;
393 bio->bi_private = cb; 389 bio->bi_private = cb;
@@ -403,7 +399,6 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
403 first_byte += PAGE_SIZE; 399 first_byte += PAGE_SIZE;
404 cond_resched(); 400 cond_resched();
405 } 401 }
406 bio_get(bio);
407 402
408 ret = btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA); 403 ret = btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA);
409 BUG_ON(ret); /* -ENOMEM */ 404 BUG_ON(ret); /* -ENOMEM */
@@ -419,7 +414,6 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
419 bio_endio(bio); 414 bio_endio(bio);
420 } 415 }
421 416
422 bio_put(bio);
423 return 0; 417 return 0;
424} 418}
425 419
@@ -652,8 +646,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
652 page->mapping = NULL; 646 page->mapping = NULL;
653 if (submit || bio_add_page(comp_bio, page, PAGE_SIZE, 0) < 647 if (submit || bio_add_page(comp_bio, page, PAGE_SIZE, 0) <
654 PAGE_SIZE) { 648 PAGE_SIZE) {
655 bio_get(comp_bio);
656
657 ret = btrfs_bio_wq_end_io(fs_info, comp_bio, 649 ret = btrfs_bio_wq_end_io(fs_info, comp_bio,
658 BTRFS_WQ_ENDIO_DATA); 650 BTRFS_WQ_ENDIO_DATA);
659 BUG_ON(ret); /* -ENOMEM */ 651 BUG_ON(ret); /* -ENOMEM */
@@ -680,8 +672,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
680 bio_endio(comp_bio); 672 bio_endio(comp_bio);
681 } 673 }
682 674
683 bio_put(comp_bio);
684
685 comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte); 675 comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte);
686 bio_set_op_attrs(comp_bio, REQ_OP_READ, 0); 676 bio_set_op_attrs(comp_bio, REQ_OP_READ, 0);
687 comp_bio->bi_private = cb; 677 comp_bio->bi_private = cb;
@@ -691,7 +681,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
691 } 681 }
692 cur_disk_byte += PAGE_SIZE; 682 cur_disk_byte += PAGE_SIZE;
693 } 683 }
694 bio_get(comp_bio);
695 684
696 ret = btrfs_bio_wq_end_io(fs_info, comp_bio, BTRFS_WQ_ENDIO_DATA); 685 ret = btrfs_bio_wq_end_io(fs_info, comp_bio, BTRFS_WQ_ENDIO_DATA);
697 BUG_ON(ret); /* -ENOMEM */ 686 BUG_ON(ret); /* -ENOMEM */
@@ -707,7 +696,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
707 bio_endio(comp_bio); 696 bio_endio(comp_bio);
708 } 697 }
709 698
710 bio_put(comp_bio);
711 return 0; 699 return 0;
712 700
713fail2: 701fail2: