Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5175567imu; Sun, 25 Nov 2018 18:21:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/VfohED+BUzc8rcgTcK4hPticY2o3ysStzHAxXsU43Yw09sM2y9NY+r6PVN9iqtK7fsW+5/ X-Received: by 2002:a63:b105:: with SMTP id r5mr23170788pgf.442.1543198910135; Sun, 25 Nov 2018 18:21:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198910; cv=none; d=google.com; s=arc-20160816; b=gDuMYRCYhMWC7Uu87tTNN/M9zz6nnTbr01ZZ+Pu4eiybHBnQk51A+pjQLYrZ2D/+MI 7PE0VgWog4D/Ce9BPVRg0Kn2nZCGTHcNuGfI8m+8aSwNX7pyl3bB6iAjU4glD4nRZP7A FfaCT/klRtrzjbV39y0M8d6jLuelINpQOYGP4e+h96nB/Bi6bgJmLQ6E6tk1MIfN+NLk gd8lfQYIyj0IC1PmwAR52RHqmpaBgRn0yCGi7tff8bTmSE0ooRctuTw1cmBWdS2QrP5M XaxxU3JTk0sH/di9vhOB3lbw9Fdp+GFMHdx5SDqO/W50NQtAf7NwNyeca5/wOZMR6HVu Za0Q== 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=0iB3prQUZRKK2nPzac3Xqe7BDn/y9dLXfxQ66sZQHUrIK0Npvp0te8KUJvjsquhFsj Hqpk84C9+lrQfNhNi44h/9loh3cq4X3Fy0RNZEF5m+jypLJOK6CgLkBNe4wz/4TRLLE9 3Lr12kQOaATtYq7G8vum5Sc6ItQrABD5U3oLgQCYS5wjNVxS7FlrTQinYs+8emXM6ZRC yBrSxwERs4cpF5wfHujoiV6UD5q39pD8xW7VJ/5SCb9fgaF/W6y30XGNh+wc8BDRzPkU 58FtTRgND9tZ/TtBvM8scRpqA7bTYEm5myDgugNmp+kFjr4iXAuLtd7Onwe4TVK3ylkk IlHg== 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 h19si60011979pgb.231.2018.11.25.18.21.35; Sun, 25 Nov 2018 18:21:50 -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 S1726705AbeKZNMt (ORCPT + 99 others); Mon, 26 Nov 2018 08:12:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45050 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbeKZNMt (ORCPT ); Mon, 26 Nov 2018 08:12:49 -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 4191888308; Mon, 26 Nov 2018 02:20:13 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id A53F65DD64; Mon, 26 Nov 2018 02:19:59 +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 V12 12/20] fs/buffer.c: use bvec iterator to truncate the bio Date: Mon, 26 Nov 2018 10:17:12 +0800 Message-Id: <20181126021720.19471-13-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.28]); Mon, 26 Nov 2018 02:20:13 +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