From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDCD4C433F5 for ; Mon, 14 Feb 2022 20:00:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DECA6B0082; Mon, 14 Feb 2022 15:00:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 495356B0080; Mon, 14 Feb 2022 15:00:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E9916B008A; Mon, 14 Feb 2022 15:00:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id C13C36B0080 for ; Mon, 14 Feb 2022 15:00:23 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 78A3E181B5EB2 for ; Mon, 14 Feb 2022 20:00:23 +0000 (UTC) X-FDA: 79142452326.21.23BD49E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 042D014000D for ; Mon, 14 Feb 2022 20:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=rLkp+NVco19SWWCWG6ARM6GyjcMhE2nofxKuhunYvDE=; b=TSySHaxSmHclYNTQQpXJR/Z55u P4BXbH/qp3OgHkvU7CT47LGPeraYuezmJp/Wo/kIpij91nZpnHSOWb8e/tBuWdtTFtPCyHv4T6KBL 1VxNiTXAUA23N2ppqCeWF+BvEEJU5Za9l9TXdKWOTS/42DhYOrLGujgUmSF3VnVjjDxPY+JzvsnzE UUJaZgP11K3AoADu7xYJlbBUVfY4Zfi0tVxAGcUo9DCdKVvK7l5yyI623m18weM4EkpnMZqFpEgR8 4EnEzioxIp1iC1wZkX0W8PGe5iWBvk5Wci21Ih46xxYFPohHi/sLI1ijgowOvz1rejsB5kFBX/hmA ibxx+q6w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJhWF-00DDdW-HO; Mon, 14 Feb 2022 20:00:19 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 02/10] mm/truncate: Inline invalidate_complete_page() into its one caller Date: Mon, 14 Feb 2022 20:00:09 +0000 Message-Id: <20220214200017.3150590-3-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220214200017.3150590-1-willy@infradead.org> References: <20220214200017.3150590-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 042D014000D X-Stat-Signature: 7ueczaswqec4ccb1pquz7bxweo6nf3f1 X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TSySHaxS; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1644868822-800015 Content-Transfer-Encoding: quoted-printable 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: invalidate_inode_page() is the only caller of invalidate_complete_page() and inlining it reveals that the first check is unnecessary (because we hold the page locked, and we just retrieved the mapping from the page). Actually, it does make a difference, in that tail pages no longer fail at this check, so it's now possible to remove a tail page from a mapping. Signed-off-by: Matthew Wilcox (Oracle) --- mm/truncate.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index 9dbf0b75da5d..e5e2edaa0b76 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -193,27 +193,6 @@ static void truncate_cleanup_folio(struct folio *fol= io) folio_clear_mappedtodisk(folio); } =20 -/* - * This is for invalidate_mapping_pages(). That function can be called = at - * any time, and is not supposed to throw away dirty pages. But pages c= an - * be marked dirty at any time too, so use remove_mapping which safely - * discards clean, unused pages. - * - * Returns non-zero if the page was successfully invalidated. - */ -static int -invalidate_complete_page(struct address_space *mapping, struct page *pag= e) -{ - - if (page->mapping !=3D mapping) - return 0; - - if (page_has_private(page) && !try_to_release_page(page, 0)) - return 0; - - return remove_mapping(mapping, page); -} - int truncate_inode_folio(struct address_space *mapping, struct folio *fo= lio) { if (folio->mapping !=3D mapping) @@ -309,7 +288,10 @@ int invalidate_inode_page(struct page *page) return 0; if (page_mapped(page)) return 0; - return invalidate_complete_page(mapping, page); + if (page_has_private(page) && !try_to_release_page(page, 0)) + return 0; + + return remove_mapping(mapping, page); } =20 /** @@ -584,7 +566,7 @@ void invalidate_mapping_pagevec(struct address_space = *mapping, } =20 /* - * This is like invalidate_complete_page(), except it ignores the page's + * This is like invalidate_inode_page(), except it ignores the page's * refcount. We do this because invalidate_inode_pages2() needs stronge= r * invalidation guarantees, and cannot afford to leave pages behind beca= use * shrink_page_list() has a temp ref on them, or because they're transie= ntly --=20 2.34.1