fs/buffer.c: use bvec iterator to truncate the bio
authorMing Lei <ming.lei@redhat.com>
Fri, 15 Feb 2019 11:13:15 +0000 (19:13 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 15 Feb 2019 15:40:11 +0000 (08:40 -0700)
Once multi-page bvec is enabled, the last bvec may include more than one
page, this patch use mp_bvec_last_segment() to truncate the bio.

Reviewed-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/buffer.c

index 52d024bfdbc12142a97ff8ec204ce4b658df6fe6..817871274c77682d180261bcdffcd0e76ab7dcb6 100644 (file)
@@ -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;
+
+               mp_bvec_last_segment(bvec, &bv);
+               zero_user(bv.bv_page, bv.bv_offset + bv.bv_len,
                                truncated_bytes);
        }
 }