From patchwork Mon Jul 12 03:06:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12370121 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,URIBL_BLOCKED,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 85B11C07E99 for ; Mon, 12 Jul 2021 04:16:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A01B610FB for ; Mon, 12 Jul 2021 04:16:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A01B610FB 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 59E226B0070; Mon, 12 Jul 2021 00:16:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 574E36B009B; Mon, 12 Jul 2021 00:16:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 464476B009F; Mon, 12 Jul 2021 00:16:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 1E06F6B0070 for ; Mon, 12 Jul 2021 00:16:56 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 413D3183C8CD7 for ; Mon, 12 Jul 2021 04:16:55 +0000 (UTC) X-FDA: 78352625190.08.291F1C4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id D7A5A10000A6 for ; Mon, 12 Jul 2021 04:16:54 +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=afpe9MgEq6p1fMK6Y/D/Lr2EVdIHLoiu+PRgXveJNJA=; b=g1axzEAW/gsANmxA4iPiXtm6z0 RHVYRgd8wLpVwRzAGppfJdDqHtcZpE1U10e3KKQDbx0C8Qbgtqo80quUgN7D308rCpMPg2+2RB0NW PWG8AThdoP5l739Jj8R3X7SqXDNuxP2BuGStoSO/N+QJodwCBs6J+okMa9XhUv2dBWVSWQzZMFZ3V 6FvY7kAQw+QTJci5G5WY+MVZ9nWErw0CfGmFMa1EBI5r/DYcV1v7JCo7A1uukDN8XUfj/e06OUzya 7NfpZ+EBfP4NcoNO2ANqoVtGaxYNGj/na+TjybIpHmK1or729pI0dcd71MUF4mTVDsa1K2zDhdFdv bKiIvz4A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2nMR-00GrcV-Dz; Mon, 12 Jul 2021 04:16:15 +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 v13 130/137] mm/truncate: Fix invalidate_complete_page2 for THPs Date: Mon, 12 Jul 2021 04:06:54 +0100 Message-Id: <20210712030701.4000097-131-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712030701.4000097-1-willy@infradead.org> References: <20210712030701.4000097-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=g1axzEAW; spf=none (imf12.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: rspam03 X-Rspamd-Queue-Id: D7A5A10000A6 X-Stat-Signature: xai66x9r8ehgu7be7gr4pus8mh381x8j X-HE-Tag: 1626063414-472769 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 ab3503493975..c8fc0d07fa92 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 65314d4380d0..d3958ef40d8b 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 cc849e2b080b..b2c4d2bcf970 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);