On Mon, Aug 10, 2020 at 04:33:09AM +0100, Matthew Wilcox wrote:
On Mon, Aug 10, 2020 at 11:19:15AM +0800, Ming Lei wrote:
+++ b/include/linux/bvec.h @@ -117,11 +117,18 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, return true; } +static inline void bvec_iter_skip_zero_bvec(struct bvec_iter *iter) +{
- iter->bi_bvec_done = 0;
- iter->bi_idx++;
+}
#define for_each_bvec(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \ ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
(bvl).bv_len ? bvec_iter_advance((bio_vec), &(iter), \
(bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter)))
What if you have two zero-length bvecs in a row? Won't this just skip the first one?
The 2nd one will be skipped too when it is observed in next loop.
It would seem better to me to put the bv_len test in bvec_iter_advance() instead of making the macro more complicated.
The reason is that block layer won't support zero length bvec, and I'd not bother bvec_iter_advance() for adding this check.
Thanks, Ming