diff options
author | Jens Axboe <axboe@fb.com> | 2015-09-03 19:28:20 +0300 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-09-03 10:33:09 -0600 |
commit | 5e7c4274a70aa2d6f485996d0ca1dad52d0039ca (patch) | |
tree | dce51421028d162af78514b631dc75a6be92cf11 /include | |
parent | 5fdb7e1b976dc9d18aff8c711e51d17c4c324a0e (diff) | |
download | linux-5e7c4274a70aa2d6f485996d0ca1dad52d0039ca.tar.gz linux-5e7c4274a70aa2d6f485996d0ca1dad52d0039ca.tar.bz2 linux-5e7c4274a70aa2d6f485996d0ca1dad52d0039ca.zip |
block: Check for gaps on front and back merges
We are checking for gaps to previous bio_vec, which can
only detect back merges gaps. Moreover, at the point where
we check for a gap, we don't know if we will attempt a back
or a front merge. Thus, check for gap to prev in a back merge
attempt and check for a gap to next in a front merge attempt.
Signed-off-by: Jens Axboe <axboe@fb.com>
[sagig: Minor rename change]
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/blkdev.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a622f270f09e..2ff94def041e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1368,6 +1368,26 @@ static inline bool bvec_gap_to_prev(struct request_queue *q, ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q)); } +static inline bool bio_will_gap(struct request_queue *q, struct bio *prev, + struct bio *next) +{ + if (!bio_has_data(prev)) + return false; + + return bvec_gap_to_prev(q, &prev->bi_io_vec[prev->bi_vcnt - 1], + next->bi_io_vec[0].bv_offset); +} + +static inline bool req_gap_back_merge(struct request *req, struct bio *bio) +{ + return bio_will_gap(req->q, req->biotail, bio); +} + +static inline bool req_gap_front_merge(struct request *req, struct bio *bio) +{ + return bio_will_gap(req->q, bio, req->bio); +} + struct work_struct; int kblockd_schedule_work(struct work_struct *work); int kblockd_schedule_delayed_work(struct delayed_work *dwork, unsigned long delay); |