From: Christoph Hellwig Date: Mon, 2 Feb 2026 06:06:32 +0000 (+0100) Subject: ext4: move ->read_folio and ->readahead to readpage.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=314b652b7e7ad335fa20b693c8878a4850dae098;p=thirdparty%2Fkernel%2Flinux.git ext4: move ->read_folio and ->readahead to readpage.c Keep all the read into pagecache code in a single file. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Theodore Ts'o Link: https://lore.kernel.org/r/20260202060754.270269-4-hch@lst.de Signed-off-by: Eric Biggers --- diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 56112f201cace..a8a448e20ef88 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3735,8 +3735,8 @@ static inline void ext4_set_de_type(struct super_block *sb, } /* readpages.c */ -extern int ext4_mpage_readpages(struct inode *inode, - struct readahead_control *rac, struct folio *folio); +int ext4_read_folio(struct file *file, struct folio *folio); +void ext4_readahead(struct readahead_control *rac); 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 8c2ef98fa5304..e98954e7d0b39 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3380,33 +3380,6 @@ out: return ret; } -static int ext4_read_folio(struct file *file, struct folio *folio) -{ - int ret = -EAGAIN; - struct inode *inode = folio->mapping->host; - - trace_ext4_read_folio(inode, folio); - - if (ext4_has_inline_data(inode)) - ret = ext4_readpage_inline(inode, folio); - - if (ret == -EAGAIN) - return ext4_mpage_readpages(inode, NULL, folio); - - return ret; -} - -static void ext4_readahead(struct readahead_control *rac) -{ - struct inode *inode = rac->mapping->host; - - /* If the file has inline data, no need to do readahead. */ - if (ext4_has_inline_data(inode)) - return; - - ext4_mpage_readpages(inode, rac, NULL); -} - static void ext4_invalidate_folio(struct folio *folio, size_t offset, size_t length) { diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index 267594ef0b2ca..5a7774f089e81 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -45,6 +45,7 @@ #include #include "ext4.h" +#include #define NUM_PREALLOC_POST_READ_CTXS 128 @@ -209,7 +210,7 @@ static inline loff_t ext4_readpage_limit(struct inode *inode) return i_size_read(inode); } -int ext4_mpage_readpages(struct inode *inode, +static int ext4_mpage_readpages(struct inode *inode, struct readahead_control *rac, struct folio *folio) { struct bio *bio = NULL; @@ -394,6 +395,33 @@ next_page: return 0; } +int ext4_read_folio(struct file *file, struct folio *folio) +{ + int ret = -EAGAIN; + struct inode *inode = folio->mapping->host; + + trace_ext4_read_folio(inode, folio); + + if (ext4_has_inline_data(inode)) + ret = ext4_readpage_inline(inode, folio); + + if (ret == -EAGAIN) + return ext4_mpage_readpages(inode, NULL, folio); + + return ret; +} + +void ext4_readahead(struct readahead_control *rac) +{ + struct inode *inode = rac->mapping->host; + + /* If the file has inline data, no need to do readahead. */ + if (ext4_has_inline_data(inode)) + return; + + ext4_mpage_readpages(inode, rac, NULL); +} + int __init ext4_init_post_read_processing(void) { bio_post_read_ctx_cache = KMEM_CACHE(bio_post_read_ctx, SLAB_RECLAIM_ACCOUNT);