summaryrefslogtreecommitdiffstats
path: root/include/linux/bvec.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bvec.h')
-rw-r--r--include/linux/bvec.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 21f76bad7be2..30a57b68d017 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -45,6 +45,12 @@ struct bvec_iter {
45 current bvec */ 45 current bvec */
46}; 46};
47 47
48struct bvec_iter_all {
49 struct bio_vec bv;
50 int idx;
51 unsigned done;
52};
53
48/* 54/*
49 * various member access, note that bio_data should of course not be used 55 * various member access, note that bio_data should of course not be used
50 * on highmem page vectors 56 * on highmem page vectors
@@ -131,6 +137,30 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
131 .bi_bvec_done = 0, \ 137 .bi_bvec_done = 0, \
132} 138}
133 139
140static inline struct bio_vec *bvec_init_iter_all(struct bvec_iter_all *iter_all)
141{
142 iter_all->bv.bv_page = NULL;
143 iter_all->done = 0;
144
145 return &iter_all->bv;
146}
147
148static inline void mp_bvec_next_segment(const struct bio_vec *bvec,
149 struct bvec_iter_all *iter_all)
150{
151 struct bio_vec *bv = &iter_all->bv;
152
153 if (bv->bv_page) {
154 bv->bv_page = nth_page(bv->bv_page, 1);
155 bv->bv_offset = 0;
156 } else {
157 bv->bv_page = bvec->bv_page;
158 bv->bv_offset = bvec->bv_offset;
159 }
160 bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset,
161 bvec->bv_len - iter_all->done);
162}
163
134/* 164/*
135 * Get the last single-page segment from the multi-page bvec and store it 165 * Get the last single-page segment from the multi-page bvec and store it
136 * in @seg 166 * in @seg