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.6 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,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 869B8C38A29 for ; Tue, 14 Apr 2020 15:03:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3D23720787 for ; Tue, 14 Apr 2020 15:03:44 +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="O1GTXnG4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D23720787 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 9EA748E000B; Tue, 14 Apr 2020 11:02:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 716268E001D; Tue, 14 Apr 2020 11:02:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE6828E000F; Tue, 14 Apr 2020 11:02:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id 51A5B8E001A for ; Tue, 14 Apr 2020 11:02:43 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 11884801B7EC for ; Tue, 14 Apr 2020 15:02:43 +0000 (UTC) X-FDA: 76706777406.12.note05_51e5ffa560f28 X-HE-Tag: note05_51e5ffa560f28 X-Filterd-Recvd-Size: 7532 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 15:02:42 +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=vVZzy/wo5GT119Pk8wsTZ72fWKLWcOEqAlTxnpE9eWc=; b=O1GTXnG4tewdn3Zh9gA6VrsxNz HwDx/AO8L9v+LjoGZSHL79ov8Vt634A42qvZorLmlG9OpkgqBT8F7Wp7Cmx/gTg5wydmJurkXkGBs XeMGxj9a30kwN7b4/vtULNq5MxDpL0h/edUGZBahgcd4nhNVozYXNEDC1nxwRMc7NLX46Nw4lU2Sn M+VqsGWYeq03qtrZRYNL8gLsYV69OtXKlhBWbx+XbPB7KS/aSSrOvGp9RZ8YdI2WNvHmcujOx8AWd 9zPSP/lnxPn8FT9IuKnj9k5UxbYgYnmnP0zvizdGWAJj75I9icH6U3vWA/E6ZPug3P7CpCRz3Spph KbjOkFMA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jON5A-0006PO-EO; Tue, 14 Apr 2020 15:02:36 +0000 From: Matthew Wilcox To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, ocfs2-devel@oss.oracle.com, linux-xfs@vger.kernel.org, William Kucharski , Eric Biggers Subject: [PATCH v11 20/25] ext4: Convert from readpages to readahead Date: Tue, 14 Apr 2020 08:02:28 -0700 Message-Id: <20200414150233.24495-21-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200414150233.24495-1-willy@infradead.org> References: <20200414150233.24495-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: From: "Matthew Wilcox (Oracle)" Use the new readahead operation in ext4 Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: William Kucharski Reviewed-by: Eric Biggers --- fs/ext4/ext4.h | 3 +-- fs/ext4/inode.c | 21 +++++++++------------ fs/ext4/readpage.c | 22 ++++++++-------------- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 91eb4381cae5..9f2d3cd1df81 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3317,8 +3317,7 @@ static inline void ext4_set_de_type(struct super_bl= ock *sb, =20 /* readpages.c */ extern int ext4_mpage_readpages(struct address_space *mapping, - struct list_head *pages, struct page *page, - unsigned nr_pages, bool is_readahead); + struct readahead_control *rac, struct page *page); extern int __init ext4_init_post_read_processing(void); extern void ext4_exit_post_read_processing(void); =20 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e416096fc081..fafd2862d7cd 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3224,23 +3224,20 @@ static int ext4_readpage(struct file *file, struc= t page *page) ret =3D ext4_readpage_inline(inode, page); =20 if (ret =3D=3D -EAGAIN) - return ext4_mpage_readpages(page->mapping, NULL, page, 1, - false); + return ext4_mpage_readpages(page->mapping, NULL, page); =20 return ret; } =20 -static int -ext4_readpages(struct file *file, struct address_space *mapping, - struct list_head *pages, unsigned nr_pages) +static void ext4_readahead(struct readahead_control *rac) { - struct inode *inode =3D mapping->host; + struct inode *inode =3D rac->mapping->host; =20 - /* If the file has inline data, no need to do readpages. */ + /* If the file has inline data, no need to do readahead. */ if (ext4_has_inline_data(inode)) - return 0; + return; =20 - return ext4_mpage_readpages(mapping, pages, NULL, nr_pages, true); + ext4_mpage_readpages(rac->mapping, rac, NULL); } =20 static void ext4_invalidatepage(struct page *page, unsigned int offset, @@ -3605,7 +3602,7 @@ static int ext4_set_page_dirty(struct page *page) =20 static const struct address_space_operations ext4_aops =3D { .readpage =3D ext4_readpage, - .readpages =3D ext4_readpages, + .readahead =3D ext4_readahead, .writepage =3D ext4_writepage, .writepages =3D ext4_writepages, .write_begin =3D ext4_write_begin, @@ -3622,7 +3619,7 @@ static const struct address_space_operations ext4_a= ops =3D { =20 static const struct address_space_operations ext4_journalled_aops =3D { .readpage =3D ext4_readpage, - .readpages =3D ext4_readpages, + .readahead =3D ext4_readahead, .writepage =3D ext4_writepage, .writepages =3D ext4_writepages, .write_begin =3D ext4_write_begin, @@ -3638,7 +3635,7 @@ static const struct address_space_operations ext4_j= ournalled_aops =3D { =20 static const struct address_space_operations ext4_da_aops =3D { .readpage =3D ext4_readpage, - .readpages =3D ext4_readpages, + .readahead =3D ext4_readahead, .writepage =3D ext4_writepage, .writepages =3D ext4_writepages, .write_begin =3D ext4_da_write_begin, diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index c1769afbf799..66275f25235d 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -7,8 +7,8 @@ * * This was originally taken from fs/mpage.c * - * The intent is the ext4_mpage_readpages() function here is intended - * to replace mpage_readpages() in the general case, not just for + * The ext4_mpage_readpages() function here is intended to + * replace mpage_readahead() in the general case, not just for * encrypted files. It has some limitations (see below), where it * will fall back to read_block_full_page(), but these limitations * should only be hit when page_size !=3D block_size. @@ -222,8 +222,7 @@ static inline loff_t ext4_readpage_limit(struct inode= *inode) } =20 int ext4_mpage_readpages(struct address_space *mapping, - struct list_head *pages, struct page *page, - unsigned nr_pages, bool is_readahead) + struct readahead_control *rac, struct page *page) { struct bio *bio =3D NULL; sector_t last_block_in_bio =3D 0; @@ -241,6 +240,7 @@ int ext4_mpage_readpages(struct address_space *mappin= g, int length; unsigned relative_block =3D 0; struct ext4_map_blocks map; + unsigned int nr_pages =3D rac ? readahead_count(rac) : 1; =20 map.m_pblk =3D 0; map.m_lblk =3D 0; @@ -251,14 +251,9 @@ int ext4_mpage_readpages(struct address_space *mappi= ng, int fully_mapped =3D 1; unsigned first_hole =3D blocks_per_page; =20 - if (pages) { - page =3D lru_to_page(pages); - + if (rac) { + page =3D readahead_page(rac); prefetchw(&page->flags); - list_del(&page->lru); - if (add_to_page_cache_lru(page, mapping, page->index, - readahead_gfp_mask(mapping))) - goto next_page; } =20 if (page_has_buffers(page)) @@ -381,7 +376,7 @@ int ext4_mpage_readpages(struct address_space *mappin= g, bio->bi_iter.bi_sector =3D blocks[0] << (blkbits - 9); bio->bi_end_io =3D mpage_end_io; bio_set_op_attrs(bio, REQ_OP_READ, - is_readahead ? REQ_RAHEAD : 0); + rac ? REQ_RAHEAD : 0); } =20 length =3D first_hole << blkbits; @@ -406,10 +401,9 @@ int ext4_mpage_readpages(struct address_space *mappi= ng, else unlock_page(page); next_page: - if (pages) + if (rac) put_page(page); } - BUG_ON(pages && !list_empty(pages)); if (bio) submit_bio(bio); return 0; --=20 2.25.1