@@ -391,6 +391,27 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
bv->bv_len = iter.bi_bvec_done;
}
+/*
+ * Return how many singlepage bvecs included in this bio,
+ * and this helper is only used for some fs to replace
+ * bio->bi_vcnt.
+ */
+static inline unsigned bio_segments_all(struct bio *bio)
+{
+ unsigned segs = 0;
+ int i;
+ struct bio_vec *bv;
+ struct bvec_iter_all bia;
+
+ WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
+
+ bio_for_each_segment_all_sp(bv, bio, i, bia)
+ segs++;
+
+ return segs;
+}
+
+
enum bip_flags {
BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */
BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */
There are still several direct access to .bi_vcnt, so introduce this helper to replace that usage for supporting multipage bvec. Signed-off-by: Ming Lei <tom.leiming@gmail.com> --- include/linux/bio.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)