From patchwork Fri May 25 03:45:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10426045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1F11B602D8 for ; Fri, 25 May 2018 03:48:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0895C28DB7 for ; Fri, 25 May 2018 03:48:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1CF228DBF; Fri, 25 May 2018 03:48:38 +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 91EB228DB7 for ; Fri, 25 May 2018 03:48:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AC846B029C; Thu, 24 May 2018 23:48:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 45C366B029E; Thu, 24 May 2018 23:48:37 -0400 (EDT) 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 34A756B029F; Thu, 24 May 2018 23:48:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id 0A8956B029C for ; Thu, 24 May 2018 23:48:37 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id i64-v6so3001151qkh.14 for ; Thu, 24 May 2018 20:48:37 -0700 (PDT) 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=03dDLi5iyfvB8jXKN6mINd7a1RQadP/VKvx195QbTWQ=; b=INxEBkH0mokYmEWZVqsJ/rf5P/UaDdrGWS1g2gEJBVD/Ud717tBix7PhR7EnvOQaIA gYssKCyGhVC1QW9ZAksQOrNQaqxnU1U+iCquWyjKYSVSSciTbJs8xdUGeDIar64JCBOe EOzp5c2m7Ju/m+ak6BGSbzPFT6/IRf7GAB9wwlkAaxAZCanTwGvKbkJYhDY3xJohM/3r +Jw8F7slExNEBS4KEZMPG9XS3YIGYZUD7N1n3bjVGkMN8KmnN2JT/9FOnrd1ZKuNP6Qm aqA78ncQuHwj7+Go9HPexxE5D389jgJYoXCWdlnBmEYckNbP+BJTJ2ndokJ19rY05Rol 8n8w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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: ALKqPweHIMSIr5dzZz1xvri9P2wvqreFIe17u9Xd1T5Bw1WErcG2aFgX LqXq/5qKy9+eNweCwmzBhKJKJwKtfWD75wxOEkqwpTLjeW6Kby3pUFN2FS5AVVcAPhky2fMS0Pp CfudFJMZYRVbJXjnRzbATzu6VW+rY5ZoGHQLRSocIC/t2lmlRo9RznLMfoUakOC3XTQ== X-Received: by 2002:a0c:bd04:: with SMTP id m4-v6mr620673qvg.140.1527220116854; Thu, 24 May 2018 20:48:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJeZKEg5/glSmi9iiTeEGUMjNRMMsNomgRc7qK5/x+vez8cI1apdVOpTbJn8PaPlgPJjaQY X-Received: by 2002:a0c:bd04:: with SMTP id m4-v6mr620660qvg.140.1527220116369; Thu, 24 May 2018 20:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527220116; cv=none; d=google.com; s=arc-20160816; b=BgFRH+coXQht9lmydUV3Zi9EhVitrB08uF/JO1otXJsVll2L7nm8oOlVXIrlYVX/jF cpJQWLu8Ne2799I6O7mHzAcpkgPBszWOP7NC18S6U03b2byk9ApAu0fMx7c7ZJQ0dnqr iwqeySTMGHdA/nML0lFs5HW89O0OjEYE2cQriquUkohJ9RXzIK1t+Dlo15IoSmPtPcWm q9UbeSnCbvtiHZX1YzoNWuzZbS2p5vtq/KPszsBRbUvFgs4Ws8L9vJDrDxRX8nRhwOPI 9PVBoildeaG4Sx3/Pk3V/o79nyt+YEnDJXvvQDE1NxP9vWFMx4K25rs9wnR7M9X2C+Io u4sw== 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 :arc-authentication-results; bh=03dDLi5iyfvB8jXKN6mINd7a1RQadP/VKvx195QbTWQ=; b=XSoQTIx6UprZSOBloE/OYbcuhEOeQWO+PXo6e5JIAjCHKNl/gifdLwzuBAFIKO++Ap oOcQKexg7x5PFSXFofPdejvFwfEGGxzUWzFrMKu3yFhzB7FA3uXnze5nyqDEHGIYAsNZ utIps+YzacTzC7dr3NaFOVKhnyWCXeZI+hJaznLaCunYvEEl4d6XDFrXW+QTRFyURgnu 1adjJMEPkMiwnWFAF9Yq7rheFi/50jndSMLT4JPkfcBDoAQzNuEBuGpIJtbPRLVMMnvo OKb37Slz1u5sqprmtwOy6LgY/oMw1xmqy47vgu0iJJWHwAJhzQq7x7cQ+E84vAbj/+oV ZG/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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 (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id b18-v6si10316522qtp.303.2018.05.24.20.48.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 20:48:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04187402290A; Fri, 25 May 2018 03:48:36 +0000 (UTC) Received: from localhost (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 016AD2026980; Fri, 25 May 2018 03:48:27 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet Cc: David Sterba , Huang Ying , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Ming Lei Subject: [RESEND PATCH V5 09/33] fs/buffer.c: use bvec iterator to truncate the bio Date: Fri, 25 May 2018 11:45:57 +0800 Message-Id: <20180525034621.31147-10-ming.lei@redhat.com> In-Reply-To: <20180525034621.31147-1-ming.lei@redhat.com> References: <20180525034621.31147-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 25 May 2018 03:48:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 25 May 2018 03:48:36 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' 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 multipage bvec is enabled, the last bvec may include more than one page, this patch use segment_last_page() to truncate the bio. 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 249b83fafe48..da4b19f7b67b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3021,7 +3021,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; + + segment_last_page(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } }