Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5034282ybv; Mon, 17 Feb 2020 10:50:56 -0800 (PST) X-Google-Smtp-Source: APXvYqy8sSkd4Hv+UYKs8JdVD5zoePaHi1GH4EWkFLoRLjMRMH+EPpHyGs4oIGZcH43PS9O0ZjwW X-Received: by 2002:a9d:620c:: with SMTP id g12mr981203otj.111.1581965455906; Mon, 17 Feb 2020 10:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581965455; cv=none; d=google.com; s=arc-20160816; b=C5PCPoaxYKtXQ9IEnaCPG/v0ncDbqVXHxUPe/wSc2iicFGx9FoE2rasVOw0shUBic5 KqXBMgkFgrJ/mtq/n8v9Rv10Jl8dQH3zG+YQHZrKZo67rS5L/o33PB/FmP7xDlAd/59o 4gPDgcgvURjE3VhVWV3lfFlPHtxdaVl5RKZkLKE7Wq5T1qRqBRowEfcuIp849i53UNfG sreyQdfsyOIemAgTsCrVmmpENRqZex5WzWRSAJ+ecZfHGmoHTOQz7VUHYavhg4Tq9o4x ZXMT/7Xnmr87ZeuBU/QaAV0medZ+Aztbv/lmWhkqsQxcInBsavqNfxjzjPy/y8aZXwu6 HoyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SByyiFZxo6mKeGfmmPSPoRTX+MwXpUXrSbQ1yx7hUZg=; b=I6YQsCohnMMFwFsZtwL/DsGE5eDDtUAbmmRx2PfRjwFox2NSUQMW44qHC7hiNdjZxO OtYIhHo56KzcMrWDFngImnejpdFkL1DFO67eUht1Kxac6+wA4CLM+8u97Zw0+3XDns3s d8VitZDDccnOgqHobhPCG0VgadQzCK+3FrppE/LNbqNVT9LDs0LA6bEbgeSpjrVnrpHA 9JpTnBIhoxawQt1l/Dgr2tWndKbLwedBhtNPU94ijpefrbDsPXWfwqynwxfKp5lrxe/X 73IbfgcCx9tvwbkHjM3I0+C4lavVvaHxqdqHxSwRCizrEvRXAiOsBOcMgysPfl5ZxB2G ni5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OMvAvn22; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18si6294244oic.188.2020.02.17.10.50.43; Mon, 17 Feb 2020 10:50:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OMvAvn22; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730261AbgBQStL (ORCPT + 99 others); Mon, 17 Feb 2020 13:49:11 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48068 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729794AbgBQSqT (ORCPT ); Mon, 17 Feb 2020 13:46:19 -0500 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=SByyiFZxo6mKeGfmmPSPoRTX+MwXpUXrSbQ1yx7hUZg=; b=OMvAvn22Mp1T9c9Y5Yp+PUl3ZQ 5EU8aXEaJPdrfwLqmmxku3auxQmO5ZgHofDPmcLQACF3x/rwgZhuhtgV0hkBrCwZOeFiRseyv0k+4 YMQpE4ACpmPAOCEcwah0fo+TKg6A5yP98qtQdsxU8rnLiMbcx6g1incwzk94lWHK3RUiW9jjSlG9Z W7/BTyFVuElbyQIbdCfuMEXGI4NquDy7djRt3+axU4bi1dHWHGTuBnoc0MxLZHirFbXLJq7hTn1wE 1pG8j4AG3sA9Lcmk4xyBIuoHBYwc/E7VQzijTfSDZSch+RMRmcCrxcKmI3cp+eAspwqiuOgLhRdPK M4+xPdNg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j3lPM-0005BU-33; Mon, 17 Feb 2020 18:46:16 +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 v6 12/16] ext4: Convert from readpages to readahead Date: Mon, 17 Feb 2020 10:46:02 -0800 Message-Id: <20200217184613.19668-22-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200217184613.19668-1-willy@infradead.org> References: <20200217184613.19668-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 23 ++++++++++------------- fs/ext4/readpage.c | 22 ++++++++-------------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 9a2ee2428ecc..3af755da101d 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3276,8 +3276,7 @@ static inline void ext4_set_de_type(struct super_block *sb, /* 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); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 1305b810c44a..7770e38e17e7 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3218,7 +3218,7 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block) static int ext4_readpage(struct file *file, struct page *page) { int ret = -EAGAIN; - struct inode *inode = page->mapping->host; + struct inode *inode = file_inode(file); trace_ext4_readpage(page); @@ -3226,23 +3226,20 @@ static int ext4_readpage(struct file *file, struct page *page) ret = ext4_readpage_inline(inode, page); if (ret == -EAGAIN) - return ext4_mpage_readpages(page->mapping, NULL, page, 1, - false); + return ext4_mpage_readpages(page->mapping, NULL, page); return ret; } -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 = mapping->host; + struct inode *inode = rac->mapping->host; - /* 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; - return ext4_mpage_readpages(mapping, pages, NULL, nr_pages, true); + ext4_mpage_readpages(rac->mapping, rac, NULL); } static void ext4_invalidatepage(struct page *page, unsigned int offset, @@ -3587,7 +3584,7 @@ static int ext4_set_page_dirty(struct page *page) static const struct address_space_operations ext4_aops = { .readpage = ext4_readpage, - .readpages = ext4_readpages, + .readahead = ext4_readahead, .writepage = ext4_writepage, .writepages = ext4_writepages, .write_begin = ext4_write_begin, @@ -3604,7 +3601,7 @@ static const struct address_space_operations ext4_aops = { static const struct address_space_operations ext4_journalled_aops = { .readpage = ext4_readpage, - .readpages = ext4_readpages, + .readahead = ext4_readahead, .writepage = ext4_writepage, .writepages = ext4_writepages, .write_begin = ext4_write_begin, @@ -3620,7 +3617,7 @@ static const struct address_space_operations ext4_journalled_aops = { static const struct address_space_operations ext4_da_aops = { .readpage = ext4_readpage, - .readpages = ext4_readpages, + .readahead = ext4_readahead, .writepage = ext4_writepage, .writepages = ext4_writepages, .write_begin = ext4_da_write_begin, diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index c1769afbf799..e14841ade612 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_readahead() 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 != block_size. @@ -222,8 +222,7 @@ static inline loff_t ext4_readpage_limit(struct inode *inode) } 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 = NULL; sector_t last_block_in_bio = 0; @@ -241,6 +240,7 @@ int ext4_mpage_readpages(struct address_space *mapping, int length; unsigned relative_block = 0; struct ext4_map_blocks map; + unsigned int nr_pages = rac ? readahead_count(rac) : 1; map.m_pblk = 0; map.m_lblk = 0; @@ -251,14 +251,9 @@ int ext4_mpage_readpages(struct address_space *mapping, int fully_mapped = 1; unsigned first_hole = blocks_per_page; - if (pages) { - page = lru_to_page(pages); - + if (rac) { + page = 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; } if (page_has_buffers(page)) @@ -381,7 +376,7 @@ int ext4_mpage_readpages(struct address_space *mapping, bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9); bio->bi_end_io = mpage_end_io; bio_set_op_attrs(bio, REQ_OP_READ, - is_readahead ? REQ_RAHEAD : 0); + rac ? REQ_RAHEAD : 0); } length = first_hole << blkbits; @@ -406,10 +401,9 @@ int ext4_mpage_readpages(struct address_space *mapping, 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; -- 2.25.0