]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
block: introduce mp_bvec_for_each_page() for iterating over page
authorMing Lei <ming.lei@redhat.com>
Wed, 27 Feb 2019 12:40:13 +0000 (20:40 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 28 Feb 2019 12:56:03 +0000 (05:56 -0700)
mp_bvec_for_each_segment() is a bit big for the iteration, so introduce
a light-weight helper for iterating over pages, then 32bytes stack
space can be saved.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/bvec.h

index 4376f683c08aedaccb477fe950fe297d0e361867..87e82e503a52fbd55ac184656950c0511237c94d 100644 (file)
@@ -188,4 +188,9 @@ static inline void mp_bvec_last_segment(const struct bio_vec *bvec,
        }
 }
 
+#define mp_bvec_for_each_page(pg, bv, i)                               \
+       for (i = (bv)->bv_offset / PAGE_SIZE;                           \
+               (i <= (((bv)->bv_offset + (bv)->bv_len - 1) / PAGE_SIZE)) && \
+               (pg = bvec_nth_page((bv)->bv_page, i)); i += 1)
+
 #endif /* __LINUX_BVEC_ITER_H */