Hi, On Mon, 15 Feb 2016 10:19:49 +0200 Sagi Grimberg <sagig@xxxxxxxxxxxxxxxxxx> wrote: > > > +/* > > + * bio_get_last_bvec() is introduced to get the last bvec of one > > + * bio for bio_will_gap(). > > + * > > + * TODO: make it more efficient. > > + */ > > +static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) > > +{ > > + struct bvec_iter iter; > > + > > + bio_for_each_segment(*bv, bio, iter) > > + if (bv->bv_len == iter.bi_size) > > + break; > > +} > > This helper is used for each req/bio once or more. I'd say No, the helper is only used for the non-splitted BIO, and all splitted BIO is marked as non-merge. > it's critical to make it efficient and not settle for > a quick bail for drivers that don't have a virt_boundary > like you did in patch #2. Cc Kent and Keith. Follows another version which should be more efficient. Kent and Keith, I appreciate much if you may give a review on it. diff --git a/include/linux/bio.h b/include/linux/bio.h index 56d2db8..ef45fec 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -278,11 +278,21 @@ static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv) */ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) { - struct bvec_iter iter; + struct bvec_iter iter = bio->bi_iter; + int idx; + + bio_advance_iter(bio, &iter, iter.bi_size); + + WARN_ON(!iter.bi_idx && !iter.bi_bvec_done); + + if (!iter.bi_bvec_done) + idx = iter.bi_idx - 1; + else /* in the middle of bvec */ + idx = iter.bi_idx; - bio_for_each_segment(*bv, bio, iter) - if (bv->bv_len == iter.bi_size) - break; + *bv = bio->bi_io_vec[idx]; + if (iter.bi_bvec_done) + bv->bv_len = iter.bi_bvec_done; } /* > > However, given that it's a regression bug fix I'm not sure it's the best > idea to add logic here. But the issue is obviously in bio_will_gap(), isn't it? Simply reverting 52cc6eead9095(block: blk-merge: fast-clone bio when splitting rw bios) still might cause performance regression too. > -- > To unsubscribe from this list: send the line "unsubscribe linux-block" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html