From patchwork Mon Oct 26 18:31:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11858217 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73CCC92C for ; Mon, 26 Oct 2020 18:32:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 169872087C for ; Mon, 26 Oct 2020 18:31:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AvQOhwnb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 169872087C 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 C117F6B0062; Mon, 26 Oct 2020 14:31:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A8D2A6B006E; Mon, 26 Oct 2020 14:31:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9265E6B0068; Mon, 26 Oct 2020 14:31:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 56D806B0068 for ; Mon, 26 Oct 2020 14:31:45 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D1C83181AC9CC for ; Mon, 26 Oct 2020 18:31:44 +0000 (UTC) X-FDA: 77414920128.07.sheet38_461554827275 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id A7CBD1803F9A1 for ; Mon, 26 Oct 2020 18:31:44 +0000 (UTC) X-Spam-Summary: 1,0,0,fc01475d54d20a34,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3867:3870:3871:4250:4321:4605:5007:6261:6653:7875:7903:8660:8957:10004:11026:11473:11658:11914:12043:12114:12296:12297:12438:12555:12895:13069:13148:13230:13311:13357:13894:14096:14181:14384:14394:14721:21080:21324:21451:21627:21740:21939:21990:30003:30054,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.15.100;04yricnbokkhukqkeq73bo3dqg7eiypfsg19ku8pqb358tbtkwuo7ta8syp5e1h.neozh3ukdd8jpoug3db6gswyoabwieeygayin7hi7rw4mgi5ac89e9krtkaz5p5.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: sheet38_461554827275 X-Filterd-Recvd-Size: 3555 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Mon, 26 Oct 2020 18:31:43 +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=Nxr3mPTUTpTqNHQZgTOz1Cs76dGKRGwiKCi73s14jS4=; b=AvQOhwnb29KFpHetuF8xRT99VV i8gl5AB+jf/uhEqufUz88wxjT/paeS3Rh1DaYQ9NbhHEN+5ZFXil+zW0/etcNn5VlB3/gXu3w9gv5 PJfCafIsc2b7mqgQAl4g79A+WThihEMzUiceLq3ejap/cq/xJ+sUlWzx2um7dJfp12yIOodh7sdYV j4CrWK15YfOYhy0gk92KD//1A16vxbBk04zZPVZGgCYaS85dj5OPTzGt6Lwy8Jse+bYYYEDGUrmj+ jO1TD9NSXQBtno+1QwKSgRkRtrEZqMogO+18xAHjt1uZ0cdvUNZhdXLTftkC5VruphqUw3L6Ki/8c na6JiiGQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX7HS-0002jU-94; Mon, 26 Oct 2020 18:31:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org Subject: [PATCH 3/9] mm: Return head pages from grab_cache_page_write_begin Date: Mon, 26 Oct 2020 18:31:30 +0000 Message-Id: <20201026183136.10404-4-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026183136.10404-1-willy@infradead.org> References: <20201026183136.10404-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: This function is only called from filesystems on their own mapping, so no caller will be surprised by getting back a head page when they were expecting a tail page. This lets us remove a call to thp_head() in wait_for_stable_page(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 12 ++++++++++-- mm/page-writeback.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 2214a2c48dd1..62bc6affeb70 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3327,15 +3327,23 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from) } EXPORT_SYMBOL(generic_file_direct_write); -/* +/** + * grab_cache_page_write_begin - Find or create a page for buffered writes. + * @mapping: The address space we're writing to. + * @index: The index we're writing to. + * @flags: %AOP_FLAG_NOFS to prevent memory reclaim calling the filesystem. + * * Find or create a page at the given pagecache position. Return the locked * page. This function is specifically for buffered writes. + * + * Return: The head page found in the cache, or NULL if no page could be + * created (due to lack of memory). */ struct page *grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index, unsigned flags) { struct page *page; - int fgp_flags = FGP_LOCK|FGP_WRITE|FGP_CREAT; + int fgp_flags = FGP_LOCK|FGP_WRITE|FGP_CREAT|FGP_HEAD; if (flags & AOP_FLAG_NOFS) fgp_flags |= FGP_NOFS; diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7709f0e223f5..3671568d433f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2849,7 +2849,7 @@ EXPORT_SYMBOL_GPL(wait_on_page_writeback); */ void wait_for_stable_page(struct page *page) { - page = thp_head(page); + VM_BUG_ON_PGFLAGS(PageTail(page), page); if (page->mapping->host->i_sb->s_iflags & SB_I_STABLE_WRITES) wait_on_page_writeback(page); }