From patchwork Fri Jan 22 16:01:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12039919 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 ADBADC433E0 for ; Fri, 22 Jan 2021 16:12:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5DCE7206F6 for ; Fri, 22 Jan 2021 16:12:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DCE7206F6 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 F028B6B0022; Fri, 22 Jan 2021 11:12:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB2136B0024; Fri, 22 Jan 2021 11:12:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA1D36B0025; Fri, 22 Jan 2021 11:12:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id C363E6B0022 for ; Fri, 22 Jan 2021 11:12:43 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9182C180238C6 for ; Fri, 22 Jan 2021 16:12:43 +0000 (UTC) X-FDA: 77733904206.16.title33_390d5602756d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 6AB2E100E6912 for ; Fri, 22 Jan 2021 16:12:43 +0000 (UTC) X-HE-Tag: title33_390d5602756d X-Filterd-Recvd-Size: 3301 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Jan 2021 16:12:42 +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=H2OcqOIMq0mcv5yQgY/W8VUwwxU4vHAWx5dRYzYPb2U=; b=I0D4E/EtTL95duVjzt01mHGoVU foiuIH3AEhr3uDWLJmuJHac2e2oZAohCznE89JQCJXdmISMqKDTKQsNRvC0kMldRfoXOX+CKdcYwj kX1ofuUXbyQyIEkuIXg2DqP5Ll1ctUNv/w1wcqT5wiYIRc7NLlmHVLn7oIEXsEVOybqe7H1l1f7Jw 6vJEyFckzSICuwnvXwCTtx4pzsFG1Kvxl+yeiW3NOQhGB+uqYPvdHYOa+TSItOHy7MbYrALr156BM hmZ5/npfFDHzzqq8wepllJFFO3ThmrtsNUwmmeLww0BHorc4E9JH0d+RqtJhuIbAp080PficLddlt cSIJSvtw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l2z20-000weN-6H; Fri, 22 Jan 2021 16:11:43 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kent Overstreet , Christoph Hellwig Subject: [PATCH v5 14/18] mm/filemap: Split filemap_readahead out of filemap_get_pages Date: Fri, 22 Jan 2021 16:01:36 +0000 Message-Id: <20210122160140.223228-15-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122160140.223228-1-willy@infradead.org> References: <20210122160140.223228-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 simplifies the error handling. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Kent Overstreet Reviewed-by: Christoph Hellwig --- mm/filemap.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index a3ebc6082022e..ba20baef9056c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2342,6 +2342,17 @@ static int filemap_create_page(struct file *file, return error; } +static int filemap_readahead(struct kiocb *iocb, struct file *file, + struct address_space *mapping, struct page *page, + pgoff_t last_index) +{ + if (iocb->ki_flags & IOCB_NOIO) + return -EAGAIN; + page_cache_async_readahead(mapping, &file->f_ra, file, page, + page->index, last_index - page->index); + return 0; +} + static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, struct pagevec *pvec) { @@ -2379,17 +2390,15 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, got_pages: { struct page *page = pvec->pages[pvec->nr - 1]; - pgoff_t pg_index = page->index; if (PageReadahead(page)) { - if (iocb->ki_flags & IOCB_NOIO) { + err = filemap_readahead(iocb, filp, mapping, page, + last_index); + if (err) { put_page(page); pvec->nr--; - err = -EAGAIN; goto err; } - page_cache_async_readahead(mapping, ra, filp, page, - pg_index, last_index - pg_index); } if (!PageUptodate(page)) {