From patchwork Mon Jan 21 08:17:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773211 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 19E8E1390 for ; Mon, 21 Jan 2019 08:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BB6629B02 for ; Mon, 21 Jan 2019 08:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F423229EEA; Mon, 21 Jan 2019 08:20:56 +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 4937529B02 for ; Mon, 21 Jan 2019 08:20:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D2508E002E; Mon, 21 Jan 2019 03:20:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 75A3A8E0025; Mon, 21 Jan 2019 03:20:55 -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 624828E002E; Mon, 21 Jan 2019 03:20:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 350AE8E0025 for ; Mon, 21 Jan 2019 03:20:55 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id 80so18730970qkd.0 for ; Mon, 21 Jan 2019 00:20:55 -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=l7lN66KMtANDHHviPGwNxorL5gsXHpR77t2q1BoYAso=; b=Om3h+rqKO9EbYBX4dwZarahYiPh/FIj6iVXSlJGXSxfKx5Mt6pYgClTBjX+S8P0HAR P3NWmZqu1RhLudwNhVigVBW8hxvirJ89QUnsBpYHOuMRP7ju3qJsLgMSk5GXF7qxtWeY sTsB4kMktt+avLTedCf4Vn4e8t/EKAUCuFRMa8vCQdY0FVGkKfwh6KHM4I6aolv8xzdn VuEcyQ9xdg5wxOQP1fZMPlP+JBIxV1/Gql0L/PIOmaPRY3JQydGHbIKxKDi+yPVNr27Z hJeA30U9HQN4nW1u6MorpS9bu6AbugkGA+KIqd6z9QRIPGwcuRywHp3FFhkBQurstW+5 BgFQ== 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: AJcUukcfEyqtkJuOwGfibd8I6KkkW/BE+he96OxwVb1xDvAymo3pB7G4 DwbUqMq0hT5pQaGD2rrSVOxBXu0UCxS0pzaILJA4dJGzVf7Tcul0nsdhlSF+frk6xRBEq3MVQAW Xj0aZ849zAcQRRDeEY3W+i+bD9l1NPBWIPscIOI9U7bOxG6RQcltenkSd33pO+qJDGA== X-Received: by 2002:a37:310e:: with SMTP id x14mr24537307qkx.78.1548058854988; Mon, 21 Jan 2019 00:20:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7P3nMRUJ9ke53YV43gPojpOwaT0hHQe52eXs6Y7VdMcbooV71e3IpTiG2iVfHCQf8lNxWl X-Received: by 2002:a37:310e:: with SMTP id x14mr24537291qkx.78.1548058854549; Mon, 21 Jan 2019 00:20:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058854; cv=none; d=google.com; s=arc-20160816; b=BIM1pVZ+U3SaqVxO1THptTwfdkttYz/zAf77JKzfPIM6Sx4rb3lAQnbSIvKlBUE18X 3nh1+kgipaLq/J+RS6atjwBh8Xpl79qyjEoIZREtY3FziKmRYwyBrfpBwps4riNuHQ5g qgzuVIoXDQW/x1yXdJShYwqGz3y2QvwBw0qcpKNVsuTuL6Gtw/fdLubZ0JiOFyB8HlU0 DdUgcLAIMyq7VgV70kj234RCe4/DOIDId3KPcdk7r7mMdHQPNYQ6PTvVSrGqWOCQNK0F DDioizx9601Z5o0e+sqhiBGvHJvgD+pJ/yd65IH9H9nOzDfxeFFQ2e5NWtUaUgAEPOB2 pp1A== 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=l7lN66KMtANDHHviPGwNxorL5gsXHpR77t2q1BoYAso=; b=B0XDWhO22xkkFDbLq1un4cx289O2jBz+FMJAj2emimdDN/dmmnex3x4+GV3wG+EcHT jVFqgfczLJeFKbFtEvyC9WgZZQeglSLGmk0OU/N9MVGZzlcXOyF2RQ4BJwYNpTCCOd9E v3pcbcFfB0Lisy2TbjfzCFJ0zYCj7IVgZ7Mf3l1UqQWWzbQYuhaMYFhsdCBdG6CxMeP8 4DfW9aOUjUHGiX/tgjRnqU4sGN+m3zQ5kwefkmJxHvxZ2POKPv7DVEsdKiWa6KCg23LC 8f6yWR7oe5d34aiNtaGykyq9Hgcb7zBfipz6st9XDWUnY5WtMz1FE0gtypyyaY5bXQyd Cugg== 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 l2si4203998qtf.302.2019.01.21.00.20.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:20:54 -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-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C9BC5F797; Mon, 21 Jan 2019 08:20:53 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C63F5D756; Mon, 21 Jan 2019 08:20:38 +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 V14 09/18] fs/buffer.c: use bvec iterator to truncate the bio Date: Mon, 21 Jan 2019 16:17:56 +0800 Message-Id: <20190121081805.32727-10-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 21 Jan 2019 08:20:53 +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 mp_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..817871274c77 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; + + mp_bvec_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } }