lkml.org 
[lkml]   [2017]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 26/49] block: introduce bvec_for_each_sp_bvec()
Date
This helper can be used to iterate each singlepage bvec
from one multipage bvec.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
include/linux/bvec.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index c1ec0945451a..23d3abdf057c 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -224,4 +224,18 @@ static inline bool bvec_iter_advance_mp(const struct bio_vec *bv,
.bi_bvec_done = 0, \
}

+/*
+ * This helper iterates over the multipage bvec of @mp_bvec and
+ * returns each singlepage bvec via @sp_bvl.
+ */
+#define __bvec_for_each_sp_bvec(sp_bvl, mp_bvec, iter, start) \
+ for (iter = start, \
+ (iter).bi_size = (mp_bvec)->bv_len - (iter).bi_bvec_done; \
+ (iter).bi_size && \
+ ((sp_bvl = bvec_iter_bvec((mp_bvec), (iter))), 1); \
+ bvec_iter_advance((mp_bvec), &(iter), (sp_bvl).bv_len))
+
+#define bvec_for_each_sp_bvec(sp_bvl, mp_bvec, iter) \
+ __bvec_for_each_sp_bvec(sp_bvl, mp_bvec, iter, BVEC_ITER_ALL_INIT)
+
#endif /* __LINUX_BVEC_ITER_H */
--
2.9.4
\
 
 \ /
  Last update: 2017-08-08 10:58    [W:0.217 / U:0.624 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site