Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752128AbdFZMNL (ORCPT ); Mon, 26 Jun 2017 08:13:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56534 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751440AbdFZMNE (ORCPT ); Mon, 26 Jun 2017 08:13:04 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 591E84E4C6 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ming.lei@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 591E84E4C6 From: Ming Lei To: Jens Axboe , Christoph Hellwig , Huang Ying , Andrew Morton , Alexander Viro Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Ming Lei Subject: [PATCH v2 05/51] fs/buffer: comment on direct access to bvec table Date: Mon, 26 Jun 2017 20:09:48 +0800 Message-Id: <20170626121034.3051-6-ming.lei@redhat.com> In-Reply-To: <20170626121034.3051-1-ming.lei@redhat.com> References: <20170626121034.3051-1-ming.lei@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 26 Jun 2017 12:12:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 796 Lines: 26 Signed-off-by: Ming Lei --- fs/buffer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 4d5d03b42e11..1910f539770b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3052,8 +3052,13 @@ static void end_bio_bh_io_sync(struct bio *bio) void guard_bio_eod(int op, struct bio *bio) { sector_t maxsector; - struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1]; unsigned truncated_bytes; + /* + * It is safe to truncate the last bvec in the following way + * even though multipage bvec is supported, but we need to + * fix the parameters passed to zero_user(). + */ + struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1]; maxsector = i_size_read(bio->bi_bdev->bd_inode) >> 9; if (!maxsector) -- 2.9.4