From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH] block: fix mp_bvec_for_each_page
Date: Thu, 28 Feb 2019 20:29:27 +0800 [thread overview]
Message-ID: <20190228122927.3495-1-ming.lei@redhat.com> (raw)
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
next reply other threads:[~2019-02-28 12:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 12:29 Ming Lei [this message]
2019-02-28 12:56 ` [PATCH] block: fix mp_bvec_for_each_page Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190228122927.3495-1-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox