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 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 C89BCC433B4 for ; Wed, 5 May 2021 17:20:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 15A3861185 for ; Wed, 5 May 2021 17:20:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15A3861185 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 7A6656B006C; Wed, 5 May 2021 13:20:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77D7C6B006E; Wed, 5 May 2021 13:20:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6456C6B0070; Wed, 5 May 2021 13:20:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id 4C4006B006C for ; Wed, 5 May 2021 13:20:43 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0E72852B0 for ; Wed, 5 May 2021 17:20:43 +0000 (UTC) X-FDA: 78107841966.11.29D19B3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 41A8DC000C72 for ; Wed, 5 May 2021 17:20:44 +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=3oul7NQQ/uE+srpwctZ89k99gmcgVzJVHJCnnkiuaMk=; b=iAX7sPAQm9wyCQagLFCssgPtRz 0W1Qo9ESTuRbTUcdZhOBFlryC/+oGX9wddBfq7URIzysA+/kjjk5PCbrKmjImgkPkeZXAa0e1XleI xy+L+xWbEkDmEPtuYcDqtrk+gWBujNM5r/t6gi/klQjzG2PYW8FYuoQxfTZhNM/S5wWCV23/i+82a xfTsgUDy8yqafl9ysJITYlxPvq6+uNH+pQ+p/pZ4C5WnhufZJBSzL1npFdT74MoHZKo7ehKHuRvWq EC1s9nAswdBBee+Y0OhQX4vK7kTUcWTsl5SUom9y1CiLjhevGRd1ygogFhybRWN/yi9zMg4dYp0mK /2MGRV6Q==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1leL00-000cla-ER; Wed, 05 May 2021 17:08:43 +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 v9 81/96] mm/filemap: Add filemap_get_stable_folio Date: Wed, 5 May 2021 16:06:13 +0100 Message-Id: <20210505150628.111735-82-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210505150628.111735-1-willy@infradead.org> References: <20210505150628.111735-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 41A8DC000C72 X-Stat-Signature: qepcqo8oj61k8zo73ggxscjg87nzjbj6 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iAX7sPAQ; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620235244-456502 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: This is the folio equivalent of grab_cache_page_write_begin(), which is reimplemented as a wrapper around it. Kernel grows by 88 bytes. filemap_get_stable_folio() is the same size as the old grab_cache_page_write_begin(), but the wrapper is 80 bytes, plus the 8 bytes for the EXPORT_SYMBOL. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 20 ++++++++++---------- mm/folio-compat.c | 9 +++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 03125035077c..726cfc61b9e5 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -589,6 +589,8 @@ static inline unsigned find_get_pages_tag(struct addr= ess_space *mapping, nr_pages, pages); } =20 +struct folio *filemap_get_stable_folio(struct address_space *mapping, + pgoff_t index, unsigned flags); struct page *grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index, unsigned flags); =20 diff --git a/mm/filemap.c b/mm/filemap.c index 3d8715a6dd08..8399deb678f6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3574,26 +3574,26 @@ generic_file_direct_write(struct kiocb *iocb, str= uct iov_iter *from) EXPORT_SYMBOL(generic_file_direct_write); =20 /* - * Find or create a page at the given pagecache position. Return the loc= ked - * page. This function is specifically for buffered writes. + * Find or create a folio at the given pagecache position. Return the lo= cked + * folio once there are no pending writes. */ -struct page *grab_cache_page_write_begin(struct address_space *mapping, +struct folio *filemap_get_stable_folio(struct address_space *mapping, pgoff_t index, unsigned flags) { - struct page *page; - int fgp_flags =3D FGP_LOCK|FGP_WRITE|FGP_CREAT; + struct folio *folio; + int fgp_flags =3D FGP_LOCK | FGP_WRITE | FGP_CREAT; =20 if (flags & AOP_FLAG_NOFS) fgp_flags |=3D FGP_NOFS; =20 - page =3D pagecache_get_page(mapping, index, fgp_flags, + folio =3D filemap_get_folio(mapping, index, fgp_flags, mapping_gfp_mask(mapping)); - if (page) - wait_for_stable_page(page); + if (folio) + folio_wait_stable(folio); =20 - return page; + return folio; } -EXPORT_SYMBOL(grab_cache_page_write_begin); +EXPORT_SYMBOL(filemap_get_stable_folio); =20 ssize_t generic_perform_write(struct file *file, struct iov_iter *i, loff_t pos) diff --git a/mm/folio-compat.c b/mm/folio-compat.c index df0038c65da9..940fe515a3a2 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -96,3 +96,12 @@ struct page *pagecache_get_page(struct address_space *= mapping, pgoff_t index, return folio_file_page(folio, index); } EXPORT_SYMBOL(pagecache_get_page); + +struct page *grab_cache_page_write_begin(struct address_space *mapping, + pgoff_t index, unsigned flags) +{ + struct folio *folio =3D filemap_get_stable_folio(mapping, index, flags)= ; + + return folio ? folio_file_page(folio, index) : NULL; +} +EXPORT_SYMBOL(grab_cache_page_write_begin); --=20 2.30.2