Skip to content

Commit 1072c12

Browse files
osandovkdave
authored andcommitted
block: add bio_for_each_bvec_all()
An upcoming Btrfs fix needs to know the original size of a non-cloned bios. Rather than accessing the bvec table directly, let's add a bio_for_each_bvec_all() accessor. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Omar Sandoval <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 534cf53 commit 1072c12

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ ForEachMacros:
8080
- 'ax25_uid_for_each'
8181
- '__bio_for_each_bvec'
8282
- 'bio_for_each_bvec'
83+
- 'bio_for_each_bvec_all'
8384
- 'bio_for_each_integrity_vec'
8485
- '__bio_for_each_segment'
8586
- 'bio_for_each_segment'

Documentation/block/biovecs.rst

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Usage of helpers:
129129
::
130130

131131
bio_for_each_segment_all()
132+
bio_for_each_bvec_all()
132133
bio_first_bvec_all()
133134
bio_first_page_all()
134135
bio_last_bvec_all()
@@ -143,4 +144,5 @@ Usage of helpers:
143144
bio_vec' will contain a multi-page IO vector during the iteration::
144145

145146
bio_for_each_bvec()
147+
bio_for_each_bvec_all()
146148
rq_for_each_bvec()

include/linux/bio.h

+8
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
169169
#define bio_for_each_bvec(bvl, bio, iter) \
170170
__bio_for_each_bvec(bvl, bio, iter, (bio)->bi_iter)
171171

172+
/*
173+
* Iterate over all multi-page bvecs. Drivers shouldn't use this version for the
174+
* same reasons as bio_for_each_segment_all().
175+
*/
176+
#define bio_for_each_bvec_all(bvl, bio, i) \
177+
for (i = 0, bvl = bio_first_bvec_all(bio); \
178+
i < (bio)->bi_vcnt; i++, bvl++) \
179+
172180
#define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len)
173181

174182
static inline unsigned bio_segments(struct bio *bio)

0 commit comments

Comments
 (0)