From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:51776 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731502AbeKNBOf (ORCPT ); Tue, 13 Nov 2018 20:14:35 -0500 From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Ming Lei , Christoph Hellwig , linux-fsdevel@vger.kernel.org Subject: [PATCH V9 06/19] fs/buffer.c: use bvec iterator to truncate the bio Date: Tue, 13 Nov 2018 23:14:52 +0800 Message-Id: <20181113151505.15498-7-ming.lei@redhat.com> In-Reply-To: <20181113151505.15498-1-ming.lei@redhat.com> References: <20181113151505.15498-1-ming.lei@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Ming Lei --- 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