Once multi-page bvec is enabled, the last bvec may include more than one page, this patch use bvec_last_segment() to truncate the bio.
Cc: Dave Chinner <dchin...@redhat.com> Cc: Kent Overstreet <kent.overstr...@gmail.com> Cc: Mike Snitzer <snit...@redhat.com> Cc: dm-devel@redhat.com Cc: Alexander Viro <v...@zeniv.linux.org.uk> Cc: linux-fsde...@vger.kernel.org Cc: Shaohua Li <s...@kernel.org> Cc: linux-r...@vger.kernel.org Cc: linux-er...@lists.ozlabs.org Cc: David Sterba <dste...@suse.com> Cc: linux-bt...@vger.kernel.org Cc: Darrick J. Wong <darrick.w...@oracle.com> Cc: linux-...@vger.kernel.org Cc: Gao Xiang <gaoxian...@huawei.com> Cc: Christoph Hellwig <h...@lst.de> Cc: Theodore Ts'o <ty...@mit.edu> Cc: linux-e...@vger.kernel.org Cc: Coly Li <col...@suse.de> Cc: linux-bca...@vger.kernel.org Cc: Boaz Harrosh <o...@electrozaur.com> Cc: Bob Peterson <rpete...@redhat.com> Cc: cluster-de...@redhat.com Signed-off-by: Ming Lei <ming....@redhat.com> --- fs/buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 1286c2b95498..fa37ad52e962 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3032,7 +3032,10 @@ void guard_bio_eod(int op, struct bio *bio) /* ..and clear the end of the buffer for reads */ if (op == REQ_OP_READ) { - zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len, + struct bio_vec bv; + + bvec_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } } -- 2.9.5 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel