ext4: convert from readpages to readahead
Use the new readahead operation in ext4 Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: William Kucharski <william.kucharski@oracle.com> Reviewed-by: Eric Biggers <ebiggers@google.com> Cc: Chao Yu <yuchao0@huawei.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Darrick J. Wong <darrick.wong@oracle.com> Cc: Dave Chinner <dchinner@redhat.com> Cc: Gao Xiang <gaoxiang25@huawei.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-21-willy@infradead.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0615090c50
commit
6311f91f76
|
@ -3318,8 +3318,7 @@ static inline void ext4_set_de_type(struct super_block *sb,
|
||||||
|
|
||||||
/* readpages.c */
|
/* readpages.c */
|
||||||
extern int ext4_mpage_readpages(struct address_space *mapping,
|
extern int ext4_mpage_readpages(struct address_space *mapping,
|
||||||
struct list_head *pages, struct page *page,
|
struct readahead_control *rac, struct page *page);
|
||||||
unsigned nr_pages, bool is_readahead);
|
|
||||||
extern int __init ext4_init_post_read_processing(void);
|
extern int __init ext4_init_post_read_processing(void);
|
||||||
extern void ext4_exit_post_read_processing(void);
|
extern void ext4_exit_post_read_processing(void);
|
||||||
|
|
||||||
|
|
|
@ -3224,23 +3224,20 @@ static int ext4_readpage(struct file *file, struct page *page)
|
||||||
ret = ext4_readpage_inline(inode, page);
|
ret = ext4_readpage_inline(inode, page);
|
||||||
|
|
||||||
if (ret == -EAGAIN)
|
if (ret == -EAGAIN)
|
||||||
return ext4_mpage_readpages(page->mapping, NULL, page, 1,
|
return ext4_mpage_readpages(page->mapping, NULL, page);
|
||||||
false);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void ext4_readahead(struct readahead_control *rac)
|
||||||
ext4_readpages(struct file *file, struct address_space *mapping,
|
|
||||||
struct list_head *pages, unsigned nr_pages)
|
|
||||||
{
|
{
|
||||||
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))
|
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,
|
static void ext4_invalidatepage(struct page *page, unsigned int offset,
|
||||||
|
@ -3605,7 +3602,7 @@ static int ext4_set_page_dirty(struct page *page)
|
||||||
|
|
||||||
static const struct address_space_operations ext4_aops = {
|
static const struct address_space_operations ext4_aops = {
|
||||||
.readpage = ext4_readpage,
|
.readpage = ext4_readpage,
|
||||||
.readpages = ext4_readpages,
|
.readahead = ext4_readahead,
|
||||||
.writepage = ext4_writepage,
|
.writepage = ext4_writepage,
|
||||||
.writepages = ext4_writepages,
|
.writepages = ext4_writepages,
|
||||||
.write_begin = ext4_write_begin,
|
.write_begin = ext4_write_begin,
|
||||||
|
@ -3622,7 +3619,7 @@ static const struct address_space_operations ext4_aops = {
|
||||||
|
|
||||||
static const struct address_space_operations ext4_journalled_aops = {
|
static const struct address_space_operations ext4_journalled_aops = {
|
||||||
.readpage = ext4_readpage,
|
.readpage = ext4_readpage,
|
||||||
.readpages = ext4_readpages,
|
.readahead = ext4_readahead,
|
||||||
.writepage = ext4_writepage,
|
.writepage = ext4_writepage,
|
||||||
.writepages = ext4_writepages,
|
.writepages = ext4_writepages,
|
||||||
.write_begin = ext4_write_begin,
|
.write_begin = ext4_write_begin,
|
||||||
|
@ -3638,7 +3635,7 @@ static const struct address_space_operations ext4_journalled_aops = {
|
||||||
|
|
||||||
static const struct address_space_operations ext4_da_aops = {
|
static const struct address_space_operations ext4_da_aops = {
|
||||||
.readpage = ext4_readpage,
|
.readpage = ext4_readpage,
|
||||||
.readpages = ext4_readpages,
|
.readahead = ext4_readahead,
|
||||||
.writepage = ext4_writepage,
|
.writepage = ext4_writepage,
|
||||||
.writepages = ext4_writepages,
|
.writepages = ext4_writepages,
|
||||||
.write_begin = ext4_da_write_begin,
|
.write_begin = ext4_da_write_begin,
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
*
|
*
|
||||||
* This was originally taken from fs/mpage.c
|
* This was originally taken from fs/mpage.c
|
||||||
*
|
*
|
||||||
* The intent is the ext4_mpage_readpages() function here is intended
|
* The ext4_mpage_readpages() function here is intended to
|
||||||
* to replace mpage_readpages() in the general case, not just for
|
* replace mpage_readahead() in the general case, not just for
|
||||||
* encrypted files. It has some limitations (see below), where it
|
* encrypted files. It has some limitations (see below), where it
|
||||||
* will fall back to read_block_full_page(), but these limitations
|
* will fall back to read_block_full_page(), but these limitations
|
||||||
* should only be hit when page_size != block_size.
|
* 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,
|
int ext4_mpage_readpages(struct address_space *mapping,
|
||||||
struct list_head *pages, struct page *page,
|
struct readahead_control *rac, struct page *page)
|
||||||
unsigned nr_pages, bool is_readahead)
|
|
||||||
{
|
{
|
||||||
struct bio *bio = NULL;
|
struct bio *bio = NULL;
|
||||||
sector_t last_block_in_bio = 0;
|
sector_t last_block_in_bio = 0;
|
||||||
|
@ -241,6 +240,7 @@ int ext4_mpage_readpages(struct address_space *mapping,
|
||||||
int length;
|
int length;
|
||||||
unsigned relative_block = 0;
|
unsigned relative_block = 0;
|
||||||
struct ext4_map_blocks map;
|
struct ext4_map_blocks map;
|
||||||
|
unsigned int nr_pages = rac ? readahead_count(rac) : 1;
|
||||||
|
|
||||||
map.m_pblk = 0;
|
map.m_pblk = 0;
|
||||||
map.m_lblk = 0;
|
map.m_lblk = 0;
|
||||||
|
@ -251,14 +251,9 @@ int ext4_mpage_readpages(struct address_space *mapping,
|
||||||
int fully_mapped = 1;
|
int fully_mapped = 1;
|
||||||
unsigned first_hole = blocks_per_page;
|
unsigned first_hole = blocks_per_page;
|
||||||
|
|
||||||
if (pages) {
|
if (rac) {
|
||||||
page = lru_to_page(pages);
|
page = readahead_page(rac);
|
||||||
|
|
||||||
prefetchw(&page->flags);
|
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))
|
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_iter.bi_sector = blocks[0] << (blkbits - 9);
|
||||||
bio->bi_end_io = mpage_end_io;
|
bio->bi_end_io = mpage_end_io;
|
||||||
bio_set_op_attrs(bio, REQ_OP_READ,
|
bio_set_op_attrs(bio, REQ_OP_READ,
|
||||||
is_readahead ? REQ_RAHEAD : 0);
|
rac ? REQ_RAHEAD : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
length = first_hole << blkbits;
|
length = first_hole << blkbits;
|
||||||
|
@ -406,10 +401,9 @@ int ext4_mpage_readpages(struct address_space *mapping,
|
||||||
else
|
else
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
next_page:
|
next_page:
|
||||||
if (pages)
|
if (rac)
|
||||||
put_page(page);
|
put_page(page);
|
||||||
}
|
}
|
||||||
BUG_ON(pages && !list_empty(pages));
|
|
||||||
if (bio)
|
if (bio)
|
||||||
submit_bio(bio);
|
submit_bio(bio);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue