Skip to content

Commit 86292ab

Browse files
Ming Leiaxboe
authored andcommitted
block: introduce bio helpers for converting to multipage bvec
The following helpers are introduced for converting current users of direct access to bvec table, and prepares for supporting multipage bvec: bio_pages_all() bio_first_bvec_all() bio_first_page_all() bio_last_bvec_all() All are named as bio_*_all() to following bio_for_each_segment_all(), they can only be used on bio of !bio_flagged(bio, BIO_CLONED), that means the whole bvec table is covered. Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9b25bd0 commit 86292ab

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎include/linux/bio.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,29 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
300300
bv->bv_len = iter.bi_bvec_done;
301301
}
302302

303+
static inline unsigned bio_pages_all(struct bio *bio)
304+
{
305+
WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
306+
return bio->bi_vcnt;
307+
}
308+
309+
static inline struct bio_vec *bio_first_bvec_all(struct bio *bio)
310+
{
311+
WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
312+
return bio->bi_io_vec;
313+
}
314+
315+
static inline struct page *bio_first_page_all(struct bio *bio)
316+
{
317+
return bio_first_bvec_all(bio)->bv_page;
318+
}
319+
320+
static inline struct bio_vec *bio_last_bvec_all(struct bio *bio)
321+
{
322+
WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
323+
return &bio->bi_io_vec[bio->bi_vcnt - 1];
324+
}
325+
303326
enum bip_flags {
304327
BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */
305328
BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */

0 commit comments

Comments
 (0)