]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/linux/bio.h
block: allow bio_for_each_segment_all() to iterate over multi-page bvec
[linux.git] / include / linux / bio.h
index 7ef8a7505c0a221f2d9b05fa92dc6a6fb0895f1c..089370eb84d97bd1b471d5789bc0010d6adbe911 100644 (file)
@@ -128,12 +128,19 @@ static inline bool bio_full(struct bio *bio)
        return bio->bi_vcnt >= bio->bi_max_vecs;
 }
 
+#define mp_bvec_for_each_segment(bv, bvl, i, iter_all)                 \
+       for (bv = bvec_init_iter_all(&iter_all);                        \
+               (iter_all.done < (bvl)->bv_len) &&                      \
+               (mp_bvec_next_segment((bvl), &iter_all), 1);            \
+               iter_all.done += bv->bv_len, i += 1)
+
 /*
  * drivers should _never_ use the all version - the bio may have been split
  * before it got to the driver and the driver won't own all of it
  */
-#define bio_for_each_segment_all(bvl, bio, i)                          \
-       for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++)
+#define bio_for_each_segment_all(bvl, bio, i, iter_all)                \
+       for (i = 0, iter_all.idx = 0; iter_all.idx < (bio)->bi_vcnt; iter_all.idx++)    \
+               mp_bvec_for_each_segment(bvl, &((bio)->bi_io_vec[iter_all.idx]), i, iter_all)
 
 static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
                                    unsigned bytes)