Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1491304imu; Tue, 20 Nov 2018 19:27:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/XeKnotGMgReqPVv/OiZT2xkLWSZ9BqHbizgv8VKBijBCF2/gawjmQWX1f9eGv6nIjANgVC X-Received: by 2002:a63:a16:: with SMTP id 22mr4427337pgk.318.1542770873038; Tue, 20 Nov 2018 19:27:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542770873; cv=none; d=google.com; s=arc-20160816; b=qaBkvq3SFfQePjVTYMEIbSm1103JLONjQ5ABPm6lt0hSsuTyqENAh937uQSzZng4rO fagT5cSzXmuCcKP07RPIU6THuetHyivUmRksYXihmzdeP2rte9R2Ofh5npkFS91TFgkA Wnzvx841ZX4Lj+p0dTsOyuPZFy8xg1Ivyx4vbTv+EbZx4+NxwfgyjqLELjLYhPeeHPMk 4CvoJkPS+BTRdOLUgocJOqr6n9QbYFEiO+YksRXoyLA8C5p3raDwAts815j9Ex0KLyH4 xUvAwzs2oaXz27X5ZBVTp7VfdcP5OQzo/gGPnyQpf4UoJEH48HsuQN70onXzvtGwY0d5 QW8Q== 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=c2SF5KIPKkkjYa6soG59vjMHK08LElFkLaPhpIbMqOY=; b=oVJDu0rQG8clvxlPj1wZTVNOTPsBvQ+Nfa0LiMGneWrNMhYkETDYr6Xm7wtLAWrvHa U4+1yjDnpjsJNA3uOHsMAMM5sKRmnXFbFINiSeNBTm/IPkVjR505rNO7rhuyEoVM4oV8 qYPaKrdxaAzWpfzoHXt/d/WC5UiT9cI+GT0dehWGKcrRv0pX6bptTUcq3KkbYXMlXI/x c3FpgwKBqpy3PpTH99qHPithMpyY7N5MPnGWtN1N7bC22An8ffGP/3e1TrxtF4tO3uoi 8NItBA9mFdMPJxm/G9G9HBIz1+NfgLUF0pqWMEvi422RiWEGx9aoGONtSW6ig/wDbUkt bkIQ== 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 t2si1001545pfd.236.2018.11.20.19.27.38; Tue, 20 Nov 2018 19:27:53 -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 S1727815AbeKUN7H (ORCPT + 99 others); Wed, 21 Nov 2018 08:59:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38294 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbeKUN7G (ORCPT ); Wed, 21 Nov 2018 08:59:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C75B7F6A8; Wed, 21 Nov 2018 03:26:35 +0000 (UTC) Received: from localhost (ovpn-8-21.pek2.redhat.com [10.72.8.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17CC25DD86; Wed, 21 Nov 2018 03:26:22 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com, Ming Lei Subject: [PATCH V11 07/19] fs/buffer.c: use bvec iterator to truncate the bio Date: Wed, 21 Nov 2018 11:23:15 +0800 Message-Id: <20181121032327.8434-8-ming.lei@redhat.com> In-Reply-To: <20181121032327.8434-1-ming.lei@redhat.com> References: <20181121032327.8434-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Nov 2018 03:26:35 +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. Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig 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