Skip to content

Commit 0615090

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
erofs: convert compressed files from readpages to readahead
Use the new readahead operation in erofs. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: William Kucharski <william.kucharski@oracle.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Acked-by: Gao Xiang <gaoxiang25@huawei.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Darrick J. Wong <darrick.wong@oracle.com> Cc: Eric Biggers <ebiggers@google.com> Cc: Jaegeuk Kim <jaegeuk@kernel.org> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Zi Yan <ziy@nvidia.com> Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com> Cc: Miklos Szeredi <mszeredi@redhat.com> Link: http://lkml.kernel.org/r/20200414150233.24495-20-willy@infradead.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0c07a9f commit 0615090

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

‎fs/erofs/zdata.c‎

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,28 +1305,23 @@ static bool should_decompress_synchronously(struct erofs_sb_info *sbi,
13051305
return nr <= sbi->max_sync_decompress_pages;
13061306
}
13071307

1308-
static int z_erofs_readpages(struct file *filp, struct address_space *mapping,
1309-
struct list_head *pages, unsigned int nr_pages)
1308+
static void z_erofs_readahead(struct readahead_control *rac)
13101309
{
1311-
struct inode *const inode = mapping->host;
1310+
struct inode *const inode = rac->mapping->host;
13121311
struct erofs_sb_info *const sbi = EROFS_I_SB(inode);
13131312

1314-
bool sync = should_decompress_synchronously(sbi, nr_pages);
1313+
bool sync = should_decompress_synchronously(sbi, readahead_count(rac));
13151314
struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode);
1316-
gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL);
1317-
struct page *head = NULL;
1315+
struct page *page, *head = NULL;
13181316
LIST_HEAD(pagepool);
13191317

1320-
trace_erofs_readpages(mapping->host, lru_to_page(pages)->index,
1321-
nr_pages, false);
1318+
trace_erofs_readpages(inode, readahead_index(rac),
1319+
readahead_count(rac), false);
13221320

1323-
f.headoffset = (erofs_off_t)lru_to_page(pages)->index << PAGE_SHIFT;
1324-
1325-
for (; nr_pages; --nr_pages) {
1326-
struct page *page = lru_to_page(pages);
1321+
f.headoffset = readahead_pos(rac);
13271322

1323+
while ((page = readahead_page(rac))) {
13281324
prefetchw(&page->flags);
1329-
list_del(&page->lru);
13301325

13311326
/*
13321327
* A pure asynchronous readahead is indicated if
@@ -1335,11 +1330,6 @@ static int z_erofs_readpages(struct file *filp, struct address_space *mapping,
13351330
*/
13361331
sync &= !(PageReadahead(page) && !head);
13371332

1338-
if (add_to_page_cache_lru(page, mapping, page->index, gfp)) {
1339-
list_add(&page->lru, &pagepool);
1340-
continue;
1341-
}
1342-
13431333
set_page_private(page, (unsigned long)head);
13441334
head = page;
13451335
}
@@ -1368,11 +1358,10 @@ static int z_erofs_readpages(struct file *filp, struct address_space *mapping,
13681358

13691359
/* clean up the remaining free pages */
13701360
put_pages_list(&pagepool);
1371-
return 0;
13721361
}
13731362

13741363
const struct address_space_operations z_erofs_aops = {
13751364
.readpage = z_erofs_readpage,
1376-
.readpages = z_erofs_readpages,
1365+
.readahead = z_erofs_readahead,
13771366
};
13781367

0 commit comments

Comments
 (0)