Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1976351imm; Sat, 9 Jun 2018 05:34:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJXWNbkchGIwgV0NyFZKJP+7+CWsmHcctnQddwoMbETfQHagpOAclmlNUU2piudcE8umVij X-Received: by 2002:a62:119d:: with SMTP id 29-v6mr10094274pfr.102.1528547667026; Sat, 09 Jun 2018 05:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528547667; cv=none; d=google.com; s=arc-20160816; b=j0N4k/pYiRx8Au70qLrour5wpOFTqEhahMf5xIdqpknGypmx6w7LOJUPxDLhxqKy9p eDvmAMlY/9yQ95UFTXR/SP2AY5STfzJtWOsIuT8n6dY7iJKU94l+fV3nkdl3+jWifTai Wl/ieMqCUSR0DDJdDyw8sVHr+RUF5HdkBQcnR1GR5XgRcC0ccAJJkem1aBFtUIYidc8/ B9zbixGoF0ijttCB6bIByekGI9vFpVYEQlFQ4Fq4ZRz/f46rkONlbW6YyyzQLOVba2lP KB11ARAYg/c/H525is63A1p1SguCbVc7Cj5tO/zHJ62CUpN1PTqG/oQHyeMSPnMjZubl TFpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=QnymLwdG7ovrTOVELMTlHpWEzuGZyOESpKC4mPgtjHU=; b=jxeKPFahgNhT0eJ1DbeuRuUrnxCq4RSq46tuRqMlD4mTYHKuM3Fp3sQnJeLUolR3od k+r6WBCn55Mge50P7pDdDuNXqEoo02vj7y5yQap0iOfPjx6+f2AxSqaV+8dUlshehpAA A0C4hxrqUumDeQyECcTOcIITSloPWtnqDY7eMlOdyNZFOKFURi6em9qHPjZqfNu2M2gB lkgE4lU4XmxBt3AYyK0AXulyY0/VNn9SCGDK0A+MGOJsWvP5cciUiiHfS+xBWpl2qKnN kTYwbs7Qy/Nvf8yk+7oWUp7pPzr7VY4nazeuk2reLHkXS3xQaJWS79yRD2FehNnwBhL0 QQiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be3-v6si17003795plb.67.2018.06.09.05.34.12; Sat, 09 Jun 2018 05:34:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753421AbeFIMc3 (ORCPT + 99 others); Sat, 9 Jun 2018 08:32:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42080 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753211AbeFIMc1 (ORCPT ); Sat, 9 Jun 2018 08:32:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5E68BB42D; Sat, 9 Jun 2018 12:32:26 +0000 (UTC) Received: from localhost (ovpn-12-40.pek2.redhat.com [10.72.12.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17F1342236; Sat, 9 Jun 2018 12:32:15 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet Cc: David Sterba , Huang Ying , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Randy Dunlap , Ming Lei Subject: [PATCH V6 09/30] fs/buffer.c: use bvec iterator to truncate the bio Date: Sat, 9 Jun 2018 20:29:53 +0800 Message-Id: <20180609123014.8861-10-ming.lei@redhat.com> In-Reply-To: <20180609123014.8861-1-ming.lei@redhat.com> References: <20180609123014.8861-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 09 Jun 2018 12:32:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 09 Jun 2018 12:32:26 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Once multipage bvec is enabled, the last bvec may include more than one page, this patch use chunk_last_segment() to truncate the bio. 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 cabc045f483d..630ae3e0238b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3021,7 +3021,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; + + chunk_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } } -- 2.9.5