From patchwork Thu Jul 15 03:36:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12378997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC453C07E96 for ; Thu, 15 Jul 2021 05:24:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B0C26100A for ; Thu, 15 Jul 2021 05:24:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B0C26100A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CEE9C8D008A; Thu, 15 Jul 2021 01:24:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC52A8D0065; Thu, 15 Jul 2021 01:24:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3F318D008A; Thu, 15 Jul 2021 01:24:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id 91E638D0065 for ; Thu, 15 Jul 2021 01:24:04 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 88ABD1649B for ; Thu, 15 Jul 2021 05:24:03 +0000 (UTC) X-FDA: 78363680766.38.E6419A4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id 3D4C46001A85 for ; Thu, 15 Jul 2021 05:24:03 +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=VtHfn0sslcY9O2vVH0P420AejCUsoqkaY5BNLZez8k8=; b=cbDjLajck0dFxp0HsF6cDTnbFH bPgp1bEhoEnt6ZaucvI8tj0gt2Dtn5gVzaJYBqj/CkhPFyZKtbaiLrrYYf+pHN6BN8Xi91drlggG5 5l8ZHwmveva9ORl4BE3kkqKerSSUT8MHJfSitvGJlWOdKa7vYz++QjYFhXZsnSKsEHECPMoJvnukr G/k7xk4lkIT0UqPXWtgvjRAfg2xPBV2rpYVYX3lCvWk4Rxc1WXd1NNfFBMLCfOEt3xVoqrQaP1P53 SyGMEMVgBePp2HWBtgAN5uPX4Sdw6Md6Fyp1jH7nmg4yIIkf/P0/m3shRTiBn0eM3kBwS9U0Syvqh mMklttNg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3tpJ-0030xF-0t; Thu, 15 Jul 2021 05:22:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v14 131/138] mm/truncate: Fix invalidate_complete_page2 for THPs Date: Thu, 15 Jul 2021 04:36:57 +0100 Message-Id: <20210715033704.692967-132-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cbDjLajc; spf=none (imf10.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-Rspamd-Server: rspam05 X-Stat-Signature: qjr688p6sdxasch7h5x4t1eiqdd1mn7f X-Rspamd-Queue-Id: 3D4C46001A85 X-HE-Tag: 1626326643-258443 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_complete_page2() currently open-codes filemap_free_folio(), except for the part where it handles THP. Rather than adding that, call page_cache_free_page() from invalidate_complete_page2(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 3 +-- mm/internal.h | 1 + mm/truncate.c | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 97d17e8c76aa..d5787502c3be 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -228,8 +228,7 @@ void __filemap_remove_folio(struct folio *folio, void *shadow) page_cache_delete(mapping, folio, shadow); } -static void filemap_free_folio(struct address_space *mapping, - struct folio *folio) +void filemap_free_folio(struct address_space *mapping, struct folio *folio) { void (*freepage)(struct page *); diff --git a/mm/internal.h b/mm/internal.h index 3e32064df18d..d63ef2595eff 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -73,6 +73,7 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start, unsigned find_get_entries(struct address_space *mapping, pgoff_t start, pgoff_t end, struct pagevec *pvec, pgoff_t *indices); bool truncate_inode_partial_page(struct page *page, loff_t start, loff_t end); +void filemap_free_folio(struct address_space *mapping, struct folio *folio); /** * folio_evictable - Test whether a folio is evictable. diff --git a/mm/truncate.c b/mm/truncate.c index d068f22fe422..e000402e817b 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -619,10 +619,7 @@ static int invalidate_complete_folio2(struct address_space *mapping, __filemap_remove_folio(folio, NULL); xa_unlock_irqrestore(&mapping->i_pages, flags); - if (mapping->a_ops->freepage) - mapping->a_ops->freepage(&folio->page); - - folio_ref_sub(folio, folio_nr_pages(folio)); /* pagecache ref */ + filemap_free_folio(mapping, folio); return 1; failed: xa_unlock_irqrestore(&mapping->i_pages, flags);