@@ -300,6 +300,30 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
bv->bv_len = iter.bi_bvec_done;
}
+static inline unsigned bio_nr_pages(struct bio *bio)
+{
+ WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
+
+ return bio->bi_vcnt;
+}
+
+static inline struct bio_vec *bio_first_bvec(struct bio *bio)
+{
+ WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
+ return bio->bi_io_vec;
+}
+
+static inline struct page *bio_first_page(struct bio *bio)
+{
+ return bio_first_bvec(bio)->bv_page;
+}
+
+static inline struct bio_vec *bio_last_bvec(struct bio *bio)
+{
+ WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
+ return &bio->bi_io_vec[bio->bi_vcnt - 1];
+}
+
enum bip_flags {
BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */
BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */
These helpers are introduced for converting current users of direct access to bvec table, and prepares for supporting multipage bvec. Signed-off-by: Ming Lei <ming.lei@redhat.com> --- include/linux/bio.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)