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=-9.5 required=3.0 tests=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 F09AAC433E1 for ; Fri, 29 May 2020 02:59:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A870F2075F for ; Fri, 29 May 2020 02:59:14 +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="MJ3CZ22E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A870F2075F 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 A6F6A800C3; Thu, 28 May 2020 22:58:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBED7800CA; Thu, 28 May 2020 22:58:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDB91800CA; Thu, 28 May 2020 22:58:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id E1143800CB for ; Thu, 28 May 2020 22:58:30 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A05792C78 for ; Fri, 29 May 2020 02:58:30 +0000 (UTC) X-FDA: 76868248380.22.owl69_100c54397034e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 8453918038E60 for ; Fri, 29 May 2020 02:58:30 +0000 (UTC) X-HE-Tag: owl69_100c54397034e X-Filterd-Recvd-Size: 8038 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 May 2020 02:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=Ysignvay07aGV2g+2ppaOJhhO1uLO2KHfF9elCeY6Tg=; b=MJ3CZ22Eu+TMwB6eWCRzY6+ukn crO4Zwnq0jhofpneDKmHpRfbLlGGSi6cwMDzpmW4P4o9egsID0MUjZrYn5tff6zbd0EsRG3I/268c iDUWlHOCfXsuyb1e0zL7WEpGAdGGVwFSIY98Ul/nGF1xUltlMBSVKUAssQFlWnTrhLYUuxVC1S147 U9EFwhGlcYqA4Ki5ZczsvMw8bN9rhoJcxjC0KGhYVremKxnv4xibJ4fcAFge4Wh+g2dOAMLg4K/RO irzk/N20qkU2reKBVQmk1hJ95GmzO6ZNPbvMSrsPh8tkHBruB+4fYx1YT9jMvc8PE3FRDtpCv/a/I WYw+4Tmg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jeVE3-0008Tk-Uc; Fri, 29 May 2020 02:58:27 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 35/39] mm: Make page_cache_readahead_unbounded take a readahead_control Date: Thu, 28 May 2020 19:58:20 -0700 Message-Id: <20200529025824.32296-36-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200529025824.32296-1-willy@infradead.org> References: <20200529025824.32296-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8453918038E60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: "Matthew Wilcox (Oracle)" Define it in the callers instead of in page_cache_readahead_unbounded(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ext4/verity.c | 4 ++-- fs/f2fs/verity.c | 4 ++-- include/linux/pagemap.h | 5 ++--- mm/readahead.c | 26 ++++++++++++-------------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index dec1244dd062..fe2e541543da 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -346,6 +346,7 @@ static struct page *ext4_read_merkle_tree_page(struct= inode *inode, pgoff_t index, unsigned long num_ra_pages) { + DEFINE_READAHEAD(rac, NULL, inode->i_mapping, index); struct page *page; =20 index +=3D ext4_verity_metadata_pos(inode) >> PAGE_SHIFT; @@ -355,8 +356,7 @@ static struct page *ext4_read_merkle_tree_page(struct= inode *inode, if (page) put_page(page); else if (num_ra_pages > 1) - page_cache_readahead_unbounded(inode->i_mapping, NULL, - index, num_ra_pages, 0); + page_cache_readahead_unbounded(&rac, num_ra_pages, 0); page =3D read_mapping_page(inode->i_mapping, index, NULL); } return page; diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c index 865c9fb774fb..707a94745472 100644 --- a/fs/f2fs/verity.c +++ b/fs/f2fs/verity.c @@ -226,6 +226,7 @@ static struct page *f2fs_read_merkle_tree_page(struct= inode *inode, pgoff_t index, unsigned long num_ra_pages) { + DEFINE_READAHEAD(rac, NULL, inode->i_mapping, index); struct page *page; =20 index +=3D f2fs_verity_metadata_pos(inode) >> PAGE_SHIFT; @@ -235,8 +236,7 @@ static struct page *f2fs_read_merkle_tree_page(struct= inode *inode, if (page) put_page(page); else if (num_ra_pages > 1) - page_cache_readahead_unbounded(inode->i_mapping, NULL, - index, num_ra_pages, 0); + page_cache_readahead_unbounded(&rac, num_ra_pages, 0); page =3D read_mapping_page(inode->i_mapping, index, NULL); } return page; diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 84ba69477e3b..725940563c8b 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -675,9 +675,8 @@ void page_cache_sync_readahead(struct address_space *= , struct file_ra_state *, void page_cache_async_readahead(struct address_space *, struct file_ra_s= tate *, struct file *, struct page *, pgoff_t index, unsigned long req_count); -void page_cache_readahead_unbounded(struct address_space *, struct file = *, - pgoff_t index, unsigned long nr_to_read, - unsigned long lookahead_count); +void page_cache_readahead_unbounded(struct readahead_control *, + unsigned long nr_to_read, unsigned long lookahead_count); =20 /* * Like add_to_page_cache_locked, but used to add newly allocated pages: diff --git a/mm/readahead.c b/mm/readahead.c index 2126a2754e22..62da2d4beed1 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -159,9 +159,7 @@ static void read_pages(struct readahead_control *rac,= struct list_head *pages, =20 /** * page_cache_readahead_unbounded - Start unchecked readahead. - * @mapping: File address space. - * @file: This instance of the open file; used for authentication. - * @index: First page index to read. + * @rac: Readahead control. * @nr_to_read: The number of pages to read. * @lookahead_size: Where to start the next readahead. * @@ -173,13 +171,13 @@ static void read_pages(struct readahead_control *ra= c, struct list_head *pages, * Context: File is referenced by caller. Mutexes may be held by caller= . * May sleep, but will not reenter filesystem to reclaim memory. */ -void page_cache_readahead_unbounded(struct address_space *mapping, - struct file *file, pgoff_t index, unsigned long nr_to_read, - unsigned long lookahead_size) +void page_cache_readahead_unbounded(struct readahead_control *rac, + unsigned long nr_to_read, unsigned long lookahead_size) { + struct address_space *mapping =3D rac->mapping; + unsigned long index =3D readahead_index(rac); LIST_HEAD(page_pool); gfp_t gfp_mask =3D readahead_gfp_mask(mapping); - DEFINE_READAHEAD(rac, file, mapping, index); unsigned long i; =20 /* @@ -200,7 +198,7 @@ void page_cache_readahead_unbounded(struct address_sp= ace *mapping, for (i =3D 0; i < nr_to_read; i++) { struct page *page =3D xa_load(&mapping->i_pages, index + i); =20 - BUG_ON(index + i !=3D rac._index + rac._nr_pages); + BUG_ON(index + i !=3D rac->_index + rac->_nr_pages); =20 if (page && !xa_is_value(page)) { /* @@ -211,7 +209,7 @@ void page_cache_readahead_unbounded(struct address_sp= ace *mapping, * have a stable reference to this page, and it's * not worth getting one just for that. */ - read_pages(&rac, &page_pool, true); + read_pages(rac, &page_pool, true); continue; } =20 @@ -224,12 +222,12 @@ void page_cache_readahead_unbounded(struct address_= space *mapping, } else if (add_to_page_cache_lru(page, mapping, index + i, gfp_mask) < 0) { put_page(page); - read_pages(&rac, &page_pool, true); + read_pages(rac, &page_pool, true); continue; } if (i =3D=3D nr_to_read - lookahead_size) SetPageReadahead(page); - rac._nr_pages++; + rac->_nr_pages++; } =20 /* @@ -237,7 +235,7 @@ void page_cache_readahead_unbounded(struct address_sp= ace *mapping, * uptodate then the caller will launch readpage again, and * will then handle the error. */ - read_pages(&rac, &page_pool, false); + read_pages(rac, &page_pool, false); memalloc_nofs_restore(nofs); } EXPORT_SYMBOL_GPL(page_cache_readahead_unbounded); @@ -252,6 +250,7 @@ void __do_page_cache_readahead(struct address_space *= mapping, struct file *file, pgoff_t index, unsigned long nr_to_read, unsigned long lookahead_size) { + DEFINE_READAHEAD(rac, file, mapping, index); struct inode *inode =3D mapping->host; loff_t isize =3D i_size_read(inode); pgoff_t end_index; /* The last page we want to read */ @@ -266,8 +265,7 @@ void __do_page_cache_readahead(struct address_space *= mapping, if (nr_to_read > end_index - index) nr_to_read =3D end_index - index + 1; =20 - page_cache_readahead_unbounded(mapping, file, index, nr_to_read, - lookahead_size); + page_cache_readahead_unbounded(&rac, nr_to_read, lookahead_size); } =20 /* --=20 2.26.2