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,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 B86A5C4BA07 for ; Tue, 25 Feb 2020 21:49:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 642E024650 for ; Tue, 25 Feb 2020 21:49:19 +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="V2XShZXm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 642E024650 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 A4CA26B0037; Tue, 25 Feb 2020 16:48:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CE056B0073; Tue, 25 Feb 2020 16:48:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C29B6B0010; Tue, 25 Feb 2020 16:48:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id DEE8B6B0071 for ; Tue, 25 Feb 2020 16:48:46 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8CD1D40EE for ; Tue, 25 Feb 2020 21:48:46 +0000 (UTC) X-FDA: 76529989452.18.cover30_2f78852e17a21 X-HE-Tag: cover30_2f78852e17a21 X-Filterd-Recvd-Size: 7284 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Feb 2020 21:48:46 +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=Cq11a3Et0pjl7ytuFO9ggJAHwiQeJdhfAdDYVeF6iqQ=; b=V2XShZXmVEahpdhQ2uSPQLy4yn S13y7Jad027u3yqrWPK9zPSIFwCP1u300B/STCsft9KboF9Quy6XOmAUyNrMUIa990dmC4BS8rdoJ zVTIijo5JBrEhvOoIonzysi/T5TNdtyVuS4OIQdhjJZn/qCXG9PQIdBn5DH/kZhJev95EJmCNDpf9 EJIKhJeuJ7rKcVRlkcKws08HV+GijuxFgmtbxexEnGY96LZeMxahX/7B1h2ew1ItlfU3wjbhNekh8 tPLkTZYaBvq8yGceIlmEMdvGPgWnfUxRXFem0AwOvUYnypRPOW6Z7MtuOyP2QcZKt69BN1GYVrLuK ukd6h59g==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6i4H-0007r2-Ki; Tue, 25 Feb 2020 21:48:41 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , 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 Subject: [PATCH v8 20/25] ext4: Convert from readpages to readahead Date: Tue, 25 Feb 2020 13:48:33 -0800 Message-Id: <20200225214838.30017-21-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200225214838.30017-1-willy@infradead.org> References: <20200225214838.30017-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) --- 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 4441331d06cc..1570a0b51b73 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3279,8 +3279,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 e60aca791d3f..d674c5f9066c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3226,23 +3226,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, @@ -3587,7 +3584,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, @@ -3604,7 +3601,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, @@ -3620,7 +3617,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.0