Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp945277imu; Fri, 9 Nov 2018 08:29:56 -0800 (PST) X-Google-Smtp-Source: AJdET5ebvjawEzdjE0Y/7FNh/97tuslVIG6Hfrg4bReQYTJaB5yNjax9knVIn0Ayu2Jqc7QPJvNt X-Received: by 2002:a17:902:20c5:: with SMTP id v5-v6mr9662730plg.156.1541780996896; Fri, 09 Nov 2018 08:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541780996; cv=none; d=google.com; s=arc-20160816; b=laQhrrRsnO4IhjxUdrrX2uDdribiL82YSxRnBMK1yoHImrqKLW+b6DEW3oTxA+J1Yz Gi8BNTNjEmOLbf2jCGbD813l4JmkNN2AQ7jwB7X291qRdZ5XnW9zcDNEAD0mXtY9JWKP m8sUOZuoJnaEbqpBRlxmQ2r77SXAWk0Wjp9TxkmsLGUPIUeCyb7Snyf5kEWrFMfj1unZ JI3BuJkGLZXoWKNa7rlRFuESPTH1X1TDwSQRvRAY0iSXVjTes8mf67pXl6lufXZFdkJ3 UE9OxGg8UC1XFyyntKgiB1mpp4hcKDeN+fdGhO3vGLd9qEGXMhhmA6LnfE3LCD9TN16r Ay9g== 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; bh=7lDwtrstD69pWac14ncJsY4csIjwk+WkJC/QHIoU0ns=; b=cB7RioJ5ZoBpqUa6FhsEoudZICdP9ggBRslHjp/rvC47UFc/NFL0c4W2ihAsQKu4aY 01PyIN9tABOcAtEBEABZR6wGi5Wgjv8LyXvPc4yW9j9/cEvXmuDPzfE0cqYrJO7gz5AA S6NVqcYmGxGo6TAohV1IuFbxs44vLYVHm1+RfThvOKzRUAHnBgNbU8YIvStOWj2ARWpK pTcEZeZA0hQcF/2RyESnduWh+NlFa4CD2e4DDeZlC/K3cO5yLPLzCqdLAkR6RG2Jqp3e x6vm4giBgWAYPXqJPcyHXiQaVggy4xKEogX0HwsjXb+5Nm9+lcIFqtmohop//nYyaYGi C1hg== 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 j24si1287736pgn.149.2018.11.09.08.29.33; Fri, 09 Nov 2018 08:29:56 -0800 (PST) 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 S1728647AbeKJCIT (ORCPT + 99 others); Fri, 9 Nov 2018 21:08:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19053 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbeKJCIT (ORCPT ); Fri, 9 Nov 2018 21:08:19 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55B0381E05; Fri, 9 Nov 2018 16:27:02 +0000 (UTC) Received: from localhost (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F02B5C229; Fri, 9 Nov 2018 16:27:01 +0000 (UTC) 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 V8 06/18] fs/buffer.c: use bvec iterator to truncate the bio Date: Sat, 10 Nov 2018 00:25:58 +0800 Message-Id: <20181109162610.18981-7-ming.lei@redhat.com> In-Reply-To: <20181109162610.18981-1-ming.lei@redhat.com> References: <20181109162610.18981-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 09 Nov 2018 16:27:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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