From patchwork Fri Jan 11 11:01:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 483C41515 for ; Fri, 11 Jan 2019 11:04:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A82C29AF7 for ; Fri, 11 Jan 2019 11:04:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E6F029B7F; Fri, 11 Jan 2019 11:04:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE90829AF7 for ; Fri, 11 Jan 2019 11:04:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD4158E000C; Fri, 11 Jan 2019 06:04:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D83EB8E0001; Fri, 11 Jan 2019 06:04:21 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4E438E000C; Fri, 11 Jan 2019 06:04:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 9CE7A8E0001 for ; Fri, 11 Jan 2019 06:04:21 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id q3so16261481qtq.15 for ; Fri, 11 Jan 2019 03:04:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=KDOxgUQA1eq12LTIJGFOvJl6oox1oM46t4Al3oSWylY=; b=Ssb6gYGSWaPGeJBzzJRZyD57Wj2duO6eMcYMsdx9JKiJo0xlMS3bSfAAvvJ+4TCpbn Th28dnA2Vdx/pryHup0uXebyDsuMxUdOYrgMNriY2/dPTizlHp+R/Dmb9igWdU/o4IJh WbHcCFCE+NslC3XMzawYZejfz9TRUkjlpJu/yjaW9eIPaVNoWdj+36D7buN8Xp//xq0I 3910bqXovY10QwoE4U6jM0la9Nqx6u7K+0c3SpeAbafFdbny3fmHROTqP7nyJaotrkzk zsMUHmRmW4U6QuC3XVjlE9T7VGJR8hTFUq7eHArrAszCgs+f1fzXRpccrF7S9sDmGN61 oF/g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukfFu4To513X4MsHVtAgAqBAEiQHk6lZhvPGAsmrkZjIZ2zRhQQb HYHtBDku6Nbz6wZCTjAEXPSGNmQs9pF/BP27OKs2Td9gLXWpmhUTJATTjhnjmqv3644QtKcuSRc 3Czl6YDYsG9cY1WXp2miHFp5IIqFJ3OVymm9X3PX+uCoK65f9dut6pqa0f7wKSeFjdQ== X-Received: by 2002:ac8:60cb:: with SMTP id i11mr13517361qtm.360.1547204661439; Fri, 11 Jan 2019 03:04:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mRHLSSOHzOQ7w4jvajnfzyKCoD+eRV7KsFkU/zj3fZcuCWeF8FYYx467/OUlUR/GvATVg X-Received: by 2002:ac8:60cb:: with SMTP id i11mr13517331qtm.360.1547204660910; Fri, 11 Jan 2019 03:04:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204660; cv=none; d=google.com; s=arc-20160816; b=ZEwBhIG8Y+yOGxCjcgYuG6jusaxRHVZEUvm2myC7XA8NGAGTTR403xSdDDvcxM96jj Rsah4sK0hrvo04HVlE9/yA0WLKzB7Ta3ZwQcUCP/r+aZHUC2C/bEBe16RQvXXrISbnJX Icr5Hpr1CgovVDsrk2JcrQF4o8boFMalAGmC11DP5BMMVzkzMSV9YV+HTaZAYjjk/vV+ g8Ir8zxQjdBh/FQET3Fm1fWuPdUzjsLqlTE4YkaAIEhcyFg+qJCANSFW0BfXzwN8S5ZM R4oCA0BfoqyOOqEivFXHfwu740B9fGZgNYa+WnzuLss9XK4y5FGTr9S0Q5E5umjZVqQc /4ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=KDOxgUQA1eq12LTIJGFOvJl6oox1oM46t4Al3oSWylY=; b=iY8VLhhIy87HPLjKob94UV1f1RHvMa6AsJkKP7NzC8RkTOhMy4l1EdPwFHhw6Qy72f S98vGiBGCc/ljKsQT2X42+nIPOhtnUnqx3l3RT9vXPKoD/sU6vPiYsBQH5M3PRiV+DhC 62wXZf2PYT9BczR0NYsEohk3NqZvALn0djr86B479O1Dq0fl73sg6eSfK2C32clK36P+ lDD9WtmNKR8aDkm77uK2Y8vJD6p4J4NF4tg8dqxIzZu3GYVijbxLZDRItGDYtedxmNHz nm6XSo4WJHkY550n836aXO4GILhLmnmX/ca9lxL1zIRMQxcuRLguwo920GrNSEngRawz plWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l28si1244811qtb.119.2019.01.11.03.04.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF9EE12F8F9; Fri, 11 Jan 2019 11:04:19 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22A2B605C8; Fri, 11 Jan 2019 11:04:06 +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, 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 V13 10/19] fs/buffer.c: use bvec iterator to truncate the bio Date: Fri, 11 Jan 2019 19:01:18 +0800 Message-Id: <20190111110127.21664-11-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 11 Jan 2019 11:04:20 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 52d024bfdbc1..fb72ac21f2b1 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); } }