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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 6BAB6C4742C for ; Mon, 2 Nov 2020 18:43:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EE9072225E for ; Mon, 2 Nov 2020 18:43:33 +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="DCaCsr2S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE9072225E 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 1DC226B0072; Mon, 2 Nov 2020 13:43:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1C176B006E; Mon, 2 Nov 2020 13:43:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 977116B0072; Mon, 2 Nov 2020 13:43:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 510696B0074 for ; Mon, 2 Nov 2020 13:43:25 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EC79E3630 for ; Mon, 2 Nov 2020 18:43:24 +0000 (UTC) X-FDA: 77440351128.15.stone27_1316a74272b2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id CD9AA1814B0C1 for ; Mon, 2 Nov 2020 18:43:24 +0000 (UTC) X-HE-Tag: stone27_1316a74272b2 X-Filterd-Recvd-Size: 4080 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Nov 2020 18:43:24 +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=73msYa311R11WAkHAc3cSVAXeaQOWUerwPhWbLhOqVE=; b=DCaCsr2SioJGpGQUS75coYTkcw Y/6SR4iAb+jkb4MUbGIwu34RdotOOrFJF1qe4BfRZFdx0PAAgsoq8kUR6zEoI6DA2PlBhm4DI5z1B yM+cFtXZJsWF6VC0rmq0yOCewwamZMJZJI38bKB30+evYQWty+SVd5Lhq8r9rJMIDkg80rdRxj6hx w3NUzDOrWRJ3RptaiI3JFB7tk/ReLEsEHSV5qBwQJT/bTbw4G76eRiYfvLNigrh2Q0CthVui19zEx 2KgL/d82nyEnDIOKApXYd5YJCkIy9ZWVHg6w1vwX/BsjDNNq1Y2+HFTkpbESF6+2K59vYPcTyAjsL 7BfvRwpw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZenZ-0006n8-S2; Mon, 02 Nov 2020 18:43:21 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , hch@lst.de, kent.overstreet@gmail.com Subject: [PATCH 08/17] mm/filemap: Change filemap_create_page arguments Date: Mon, 2 Nov 2020 18:43:03 +0000 Message-Id: <20201102184312.25926-9-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201102184312.25926-1-willy@infradead.org> References: <20201102184312.25926-1-willy@infradead.org> MIME-Version: 1.0 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: filemap_create_page() doesn't need the iocb or the iter. It just needs the file and the index. Move the iocb flag checks to the caller. We can skip checking GFP_NOIO as that's checked a few lines earlier. There's no need to fall through to filemap_update_page() -- if filemap_create_page couldn't update it, filemap_update_page will not be able to. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 171da5c592fa..5527b239771c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2285,26 +2285,20 @@ static struct page *filemap_update_page(struct ki= ocb *iocb, struct file *filp, return NULL; } =20 -static struct page *filemap_create_page(struct kiocb *iocb, - struct iov_iter *iter) +static struct page *filemap_create_page(struct file *file, + struct address_space *mapping, pgoff_t index) { - struct file *filp =3D iocb->ki_filp; - struct address_space *mapping =3D filp->f_mapping; - pgoff_t index =3D iocb->ki_pos >> PAGE_SHIFT; struct page *page; int error; =20 - if (iocb->ki_flags & (IOCB_NOIO | IOCB_NOWAIT | IOCB_WAITQ)) - return ERR_PTR(-EAGAIN); - page =3D page_cache_alloc(mapping); if (!page) return ERR_PTR(-ENOMEM); =20 error =3D add_to_page_cache_lru(page, mapping, index, - mapping_gfp_constraint(mapping, GFP_KERNEL)); + mapping_gfp_constraint(mapping, GFP_KERNEL)); if (!error) - error =3D filemap_read_page(iocb->ki_filp, mapping, page); + error =3D filemap_read_page(file, mapping, page); if (!error) return page; put_page(page); @@ -2338,13 +2332,17 @@ static int filemap_get_pages(struct kiocb *iocb, = struct iov_iter *iter, page_cache_sync_readahead(mapping, ra, filp, index, last_index - index)= ; =20 nr_got =3D mapping_get_read_thps(mapping, index, nr, pages); - if (nr_got) - goto got_pages; - - pages[0] =3D filemap_create_page(iocb, iter); - err =3D PTR_ERR_OR_ZERO(pages[0]); - if (!IS_ERR_OR_NULL(pages[0])) - nr_got =3D 1; + if (!nr_got) { + if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) + return -EAGAIN; + pages[0] =3D filemap_create_page(filp, mapping, + iocb->ki_pos >> PAGE_SHIFT); + if (!pages[0]) + goto find_page; + if (IS_ERR(pages[0])) + return PTR_ERR(pages[0]); + return 1; + } got_pages: if (nr_got > 0) { struct page *page =3D pages[nr_got - 1]; --=20 2.28.0