From patchwork Wed Dec 16 18:23:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11978385 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 D7913C4361B for ; Wed, 16 Dec 2020 18:46:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6ED1F233F6 for ; Wed, 16 Dec 2020 18:46:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ED1F233F6 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 0059A6B0070; Wed, 16 Dec 2020 13:46:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF6828D0001; Wed, 16 Dec 2020 13:46:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E34C76B0073; Wed, 16 Dec 2020 13:46:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id CC6FE6B0070 for ; Wed, 16 Dec 2020 13:46:49 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 94E331EE6 for ; Wed, 16 Dec 2020 18:46:49 +0000 (UTC) X-FDA: 77600026938.18.sign63_5e01c002742e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 6BB69100ED3A2 for ; Wed, 16 Dec 2020 18:46:49 +0000 (UTC) X-HE-Tag: sign63_5e01c002742e X-Filterd-Recvd-Size: 4111 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 18:46:48 +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=Z2WxcQe4oqvmu0Mp0Iq/n1ReJp9tHHAOahV82RnR75I=; b=UfIFz383k7RGHSLOtIF8vJza9v 6WhQD3hj+MX3bWM8l3uqi2D0jl1Grxe7mWEBT2Om9yUWzgoUYaIV1bG4BW7nj0GSbOEvJT6kb94Nf qWJ9AO+o9LwmNeeza9Eawa2nyLyiLLkpkMQH1FbzsO4A76foLDCoPRSTXINUefBiJoZj+T6uj/lXb 8uiCM1tFYSg1bxZje7HbSj2+Lkm9uFhXbxH7NVDQnJJzOi781EroVvE+peMZxk7EoFYBGvkZ9tN4F uiIatA6ZLRgwQCh/mE6FpZD7ZvO/7//aFcCmYNPgHFUUj5SlnrpiDe3foFxI0U4we6YKeejaCcEAK ffam0Z0g==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpbSe-000771-9K; Wed, 16 Dec 2020 18:23:40 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH 11/25] mm: Convert mapping_get_entry to return a folio Date: Wed, 16 Dec 2020 18:23:21 +0000 Message-Id: <20201216182335.27227-12-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201216182335.27227-1-willy@infradead.org> References: <20201216182335.27227-1-willy@infradead.org> MIME-Version: 1.0 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: The pagecache only contains folios, so this is the right thing to do. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 654bba53442a..b9f25a2d8312 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1673,33 +1673,33 @@ EXPORT_SYMBOL(page_cache_prev_miss); * @index: The page cache index. * * Looks up the page cache slot at @mapping & @offset. If there is a - * page cache page, the head page is returned with an increased refcount. + * page cache page, the folio is returned with an increased refcount. * * If the slot holds a shadow entry of a previously evicted page, or a * swap entry from shmem/tmpfs, it is returned. * - * Return: The head page or shadow entry, %NULL if nothing is found. + * Return: The folio or shadow entry, %NULL if nothing is found. */ -static struct page *mapping_get_entry(struct address_space *mapping, +static struct folio *mapping_get_entry(struct address_space *mapping, pgoff_t index) { XA_STATE(xas, &mapping->i_pages, index); - struct page *page; + struct folio *folio; rcu_read_lock(); repeat: xas_reset(&xas); - page = xas_load(&xas); - if (xas_retry(&xas, page)) + folio = xas_load(&xas); + if (xas_retry(&xas, folio)) goto repeat; /* * A shadow entry of a recently evicted page, or a swap entry from * shmem/tmpfs. Return it without attempting to raise page count. */ - if (!page || xa_is_value(page)) + if (!folio || xa_is_value(folio)) goto out; - if (!page_cache_get_speculative(page)) + if (!page_cache_get_speculative(&folio->page)) goto repeat; /* @@ -1707,14 +1707,14 @@ static struct page *mapping_get_entry(struct address_space *mapping, * This is part of the lockless pagecache protocol. See * include/linux/pagemap.h for details. */ - if (unlikely(page != xas_reload(&xas))) { - put_page(page); + if (unlikely(folio != xas_reload(&xas))) { + put_folio(folio); goto repeat; } out: rcu_read_unlock(); - return page; + return folio; } /** @@ -1757,7 +1757,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, struct page *page; repeat: - page = mapping_get_entry(mapping, index); + page = &mapping_get_entry(mapping, index)->page; if (xa_is_value(page)) { if (fgp_flags & FGP_ENTRY) return page;