aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-09-24 03:43:48 -0400
committerJens Axboe <axboe@kernel.dk>2018-09-24 14:33:51 -0400
commite9907009cbfc0c93d987d5a8fdf3d6c3c7b89717 (patch)
tree5157c60b845699e33f7035dc283d0575c9522e5b /include/linux/blkdev.h
parent43b729bfe9cf30ad11499a66e3b7bd300c716d44 (diff)
block: move req_gap_{back,front}_merge to blk-merge.c
Keep it close to the actual users instead of exposing the function to all drivers. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h69
1 files changed, 0 insertions, 69 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bc534c857344..b7e676bb01bc 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1695,75 +1695,6 @@ static inline bool bvec_gap_to_prev(struct request_queue *q,
1695 return __bvec_gap_to_prev(q, bprv, offset); 1695 return __bvec_gap_to_prev(q, bprv, offset);
1696} 1696}
1697 1697
1698/*
1699 * Check if the two bvecs from two bios can be merged to one segment.
1700 * If yes, no need to check gap between the two bios since the 1st bio
1701 * and the 1st bvec in the 2nd bio can be handled in one segment.
1702 */
1703static inline bool bios_segs_mergeable(struct request_queue *q,
1704 struct bio *prev, struct bio_vec *prev_last_bv,
1705 struct bio_vec *next_first_bv)
1706{
1707 if (!BIOVEC_PHYS_MERGEABLE(prev_last_bv, next_first_bv))
1708 return false;
1709 if (!BIOVEC_SEG_BOUNDARY(q, prev_last_bv, next_first_bv))
1710 return false;
1711 if (prev->bi_seg_back_size + next_first_bv->bv_len >
1712 queue_max_segment_size(q))
1713 return false;
1714 return true;
1715}
1716
1717static inline bool bio_will_gap(struct request_queue *q,
1718 struct request *prev_rq,
1719 struct bio *prev,
1720 struct bio *next)
1721{
1722 if (bio_has_data(prev) && queue_virt_boundary(q)) {
1723 struct bio_vec pb, nb;
1724
1725 /*
1726 * don't merge if the 1st bio starts with non-zero
1727 * offset, otherwise it is quite difficult to respect
1728 * sg gap limit. We work hard to merge a huge number of small
1729 * single bios in case of mkfs.
1730 */
1731 if (prev_rq)
1732 bio_get_first_bvec(prev_rq->bio, &pb);
1733 else
1734 bio_get_first_bvec(prev, &pb);
1735 if (pb.bv_offset)
1736 return true;
1737
1738 /*
1739 * We don't need to worry about the situation that the
1740 * merged segment ends in unaligned virt boundary:
1741 *
1742 * - if 'pb' ends aligned, the merged segment ends aligned
1743 * - if 'pb' ends unaligned, the next bio must include
1744 * one single bvec of 'nb', otherwise the 'nb' can't
1745 * merge with 'pb'
1746 */
1747 bio_get_last_bvec(prev, &pb);
1748 bio_get_first_bvec(next, &nb);
1749
1750 if (!bios_segs_mergeable(q, prev, &pb, &nb))
1751 return __bvec_gap_to_prev(q, &pb, nb.bv_offset);
1752 }
1753
1754 return false;
1755}
1756
1757static inline bool req_gap_back_merge(struct request *req, struct bio *bio)
1758{
1759 return bio_will_gap(req->q, req, req->biotail, bio);
1760}
1761
1762static inline bool req_gap_front_merge(struct request *req, struct bio *bio)
1763{
1764 return bio_will_gap(req->q, NULL, bio, req->bio);
1765}
1766
1767int kblockd_schedule_work(struct work_struct *work); 1698int kblockd_schedule_work(struct work_struct *work);
1768int kblockd_schedule_work_on(int cpu, struct work_struct *work); 1699int kblockd_schedule_work_on(int cpu, struct work_struct *work);
1769int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); 1700int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);