diff options
author | Christoph Hellwig <hch@lst.de> | 2019-06-28 22:30:22 -0400 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-28 22:30:22 -0400 |
commit | a247373596677bd38a88fcaf1606be51a44c614d (patch) | |
tree | c54bbe5c2ce2c77286886068dba6d75b5a9f279f | |
parent | f327a00745fffd9159d54b442cb75c0266fb89d6 (diff) |
xfs: simplify xfs_chain_bio
Move setting up operation and write hint to xfs_alloc_ioend, and
then just copy over all needed information from the previous bio
in xfs_chain_bio and stop passing various parameters to it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r-- | fs/xfs/xfs_aops.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index a6f0f4761a37..9cceb90e77c5 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
@@ -665,7 +665,6 @@ xfs_submit_ioend( | |||
665 | 665 | ||
666 | ioend->io_bio->bi_private = ioend; | 666 | ioend->io_bio->bi_private = ioend; |
667 | ioend->io_bio->bi_end_io = xfs_end_bio; | 667 | ioend->io_bio->bi_end_io = xfs_end_bio; |
668 | ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc); | ||
669 | 668 | ||
670 | /* | 669 | /* |
671 | * If we are failing the IO now, just mark the ioend with an | 670 | * If we are failing the IO now, just mark the ioend with an |
@@ -679,7 +678,6 @@ xfs_submit_ioend( | |||
679 | return status; | 678 | return status; |
680 | } | 679 | } |
681 | 680 | ||
682 | ioend->io_bio->bi_write_hint = ioend->io_inode->i_write_hint; | ||
683 | submit_bio(ioend->io_bio); | 681 | submit_bio(ioend->io_bio); |
684 | return 0; | 682 | return 0; |
685 | } | 683 | } |
@@ -691,7 +689,8 @@ xfs_alloc_ioend( | |||
691 | xfs_exntst_t state, | 689 | xfs_exntst_t state, |
692 | xfs_off_t offset, | 690 | xfs_off_t offset, |
693 | struct block_device *bdev, | 691 | struct block_device *bdev, |
694 | sector_t sector) | 692 | sector_t sector, |
693 | struct writeback_control *wbc) | ||
695 | { | 694 | { |
696 | struct xfs_ioend *ioend; | 695 | struct xfs_ioend *ioend; |
697 | struct bio *bio; | 696 | struct bio *bio; |
@@ -699,6 +698,8 @@ xfs_alloc_ioend( | |||
699 | bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, &xfs_ioend_bioset); | 698 | bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, &xfs_ioend_bioset); |
700 | bio_set_dev(bio, bdev); | 699 | bio_set_dev(bio, bdev); |
701 | bio->bi_iter.bi_sector = sector; | 700 | bio->bi_iter.bi_sector = sector; |
701 | bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc); | ||
702 | bio->bi_write_hint = inode->i_write_hint; | ||
702 | 703 | ||
703 | ioend = container_of(bio, struct xfs_ioend, io_inline_bio); | 704 | ioend = container_of(bio, struct xfs_ioend, io_inline_bio); |
704 | INIT_LIST_HEAD(&ioend->io_list); | 705 | INIT_LIST_HEAD(&ioend->io_list); |
@@ -719,24 +720,22 @@ xfs_alloc_ioend( | |||
719 | * so that the bi_private linkage is set up in the right direction for the | 720 | * so that the bi_private linkage is set up in the right direction for the |
720 | * traversal in xfs_destroy_ioend(). | 721 | * traversal in xfs_destroy_ioend(). |
721 | */ | 722 | */ |
722 | static void | 723 | static struct bio * |
723 | xfs_chain_bio( | 724 | xfs_chain_bio( |
724 | struct xfs_ioend *ioend, | 725 | struct bio *prev) |
725 | struct writeback_control *wbc, | ||
726 | struct block_device *bdev, | ||
727 | sector_t sector) | ||
728 | { | 726 | { |
729 | struct bio *new; | 727 | struct bio *new; |
730 | 728 | ||
731 | new = bio_alloc(GFP_NOFS, BIO_MAX_PAGES); | 729 | new = bio_alloc(GFP_NOFS, BIO_MAX_PAGES); |
732 | bio_set_dev(new, bdev); | 730 | bio_copy_dev(new, prev); |
733 | new->bi_iter.bi_sector = sector; | 731 | new->bi_iter.bi_sector = bio_end_sector(prev); |
734 | bio_chain(ioend->io_bio, new); | 732 | new->bi_opf = prev->bi_opf; |
735 | bio_get(ioend->io_bio); /* for xfs_destroy_ioend */ | 733 | new->bi_write_hint = prev->bi_write_hint; |
736 | ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc); | 734 | |
737 | ioend->io_bio->bi_write_hint = ioend->io_inode->i_write_hint; | 735 | bio_chain(prev, new); |
738 | submit_bio(ioend->io_bio); | 736 | bio_get(prev); /* for xfs_destroy_ioend */ |
739 | ioend->io_bio = new; | 737 | submit_bio(prev); |
738 | return new; | ||
740 | } | 739 | } |
741 | 740 | ||
742 | /* | 741 | /* |
@@ -771,14 +770,14 @@ xfs_add_to_ioend( | |||
771 | if (wpc->ioend) | 770 | if (wpc->ioend) |
772 | list_add(&wpc->ioend->io_list, iolist); | 771 | list_add(&wpc->ioend->io_list, iolist); |
773 | wpc->ioend = xfs_alloc_ioend(inode, wpc->fork, | 772 | wpc->ioend = xfs_alloc_ioend(inode, wpc->fork, |
774 | wpc->imap.br_state, offset, bdev, sector); | 773 | wpc->imap.br_state, offset, bdev, sector, wbc); |
775 | } | 774 | } |
776 | 775 | ||
777 | if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff, true)) { | 776 | if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff, true)) { |
778 | if (iop) | 777 | if (iop) |
779 | atomic_inc(&iop->write_count); | 778 | atomic_inc(&iop->write_count); |
780 | if (bio_full(wpc->ioend->io_bio)) | 779 | if (bio_full(wpc->ioend->io_bio)) |
781 | xfs_chain_bio(wpc->ioend, wbc, bdev, sector); | 780 | wpc->ioend->io_bio = xfs_chain_bio(wpc->ioend->io_bio); |
782 | bio_add_page(wpc->ioend->io_bio, page, len, poff); | 781 | bio_add_page(wpc->ioend->io_bio, page, len, poff); |
783 | } | 782 | } |
784 | 783 | ||