* [PATCH] block: fix mp_bvec_for_each_page
@ 2019-02-28 12:29 Ming Lei
2019-02-28 12:56 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2019-02-28 12:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei
mp_bvec_for_each_page() may miss the 1st page in case that the bvec
ends before last byte of the 1st PAGE.
So fix it by checking against the last page.
Fixes: 05d5585e42a399700 ("block: introduce mp_bvec_for_each_page() for iterating over page")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
include/linux/bvec.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 98a140fa4dac..85894d5000a1 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -197,7 +197,7 @@ 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) / 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 */
--
2.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-28 12:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-28 12:29 [PATCH] block: fix mp_bvec_for_each_page Ming Lei
2019-02-28 12:56 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox