erofs: enable iomap for file-backed mounts on unencoded inodes
Gao Xiang
maintainerPATCH 1/1 erofs: enable iomap for file-backed mounts on unencoded inodes
Iomap supports non-bdev I/O through fs-provided callbacks since commit b2f35ac4146d ("iomap: add caller-provided callbacks for read and readahead"), making it suitable for file-backed mounts on unencoded inodes.
Enable iomap for this case to support sub-folio buffered I/Os on file-backed mounts and simplify the codebase.
--- fs/erofs/data.c | 23 ++++--- fs/erofs/fileio.c | 144 ++++++++++++-------------------------------- fs/erofs/internal.h | 5 +- 3 files changed, 53 insertions(+), 119 deletions(-)
fs/erofs/data.c +14 -9
@@ -308,6 +308,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->length = map.m_llen; iomap->flags =0 ; iomap->addr =IOMAP_NULL_ADDR ; + iomap->private =NULL ;if (!(map.m_flags &EROFS_MAP_MAPPED )) { iomap->type =IOMAP_HOLE ;return 0 ;
@@ -322,6 +323,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (ret)return ret; + iomap->private = mdev.m_dif;if (flags &IOMAP_DAX ) iomap->dax_dev = mdev.m_dif->dax_dev;else
@@ -396,14 +398,16 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,*/ static int erofs_read_folio (struct file *file,struct folio *folio) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .cur_folio = folio, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (folio_inode (folio), &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .cur_folio = folio, + };trace_erofs_read_folio (iter_ctx.realinode, folio, true);iomap_read_folio (&erofs_iomap_ops, &read_ctx, &iter_ctx);
@@ -414,14 +418,16 @@ static int erofs_read_folio(struct file *file, struct folio *folio)static void erofs_readahead (struct readahead_control *rac) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .rac = rac, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (rac->mapping->host, &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .rac = rac, + };trace_erofs_readahead (iter_ctx.realinode,readahead_index (rac),readahead_count (rac), true);
@@ -457,7 +463,6 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)return filemap_read (iocb, to,0 ); } -/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_aops = { .read_folio = erofs_read_folio, .readahead = erofs_readahead,
fs/erofs/fileio.c +38 -106
186 lines not on this page · raw message
fs/erofs/internal.h +1 -4
@@ -380,7 +380,6 @@ struct erofs_map_dev {extern const struct super_operations erofs_sops;extern const struct address_space_operations erofs_aops; -extern const struct address_space_operations erofs_fileio_aops;extern const struct address_space_operations z_erofs_aops;extern const struct inode_operations erofs_generic_iops;
@@ -393,6 +392,7 @@ extern const struct file_operations erofs_dir_fops;extern const struct file_operations erofs_ishare_fops;extern const struct iomap_ops z_erofs_iomap_report_ops; +extern const struct iomap_read_ops erofs_fileio_iomap_read_ops;int erofs_setup_managed_cache (struct super_block *sb);#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
@@ -450,9 +450,6 @@ erofs_get_aops(struct inode *realinode) "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");return &z_erofs_aops; } -if (IS_ENABLED (CONFIG_EROFS_FS_BACKED_BY_FILE ) && -erofs_is_fileio_mode (EROFS_SB (realinode->i_sb))) -return &erofs_fileio_aops;return &erofs_aops; }
Signature · 1 line
2.47.3
Gao Xiang
maintainerPATCH v2 1/1 erofs: enable iomap for file-backed mounts on unencoded inodes
Iomap supports non-bdev I/O through fs-provided callbacks since commit b2f35ac4146d ("iomap: add caller-provided callbacks for read and readahead"), making it suitable for file-backed mounts on unencoded inodes.
Enable iomap for this case to support sub-folio buffered I/Os on file-backed mounts and simplify the codebase.
---
v2:
- fix sashiko's reports.
fs/erofs/data.c | 29 +++++---- fs/erofs/fileio.c | 148 ++++++++++++-------------------------------- fs/erofs/internal.h | 11 ++-- 3 files changed, 61 insertions(+), 127 deletions(-)
fs/erofs/data.c +14 -15
@@ -281,12 +281,6 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)folio_end_read (folio, !(v &BIT (EROFS_ONLINEFOLIO_EIO ))); } -struct erofs_iomap_iter_ctx { -struct page *page; -void *base; -struct inode *realinode; -}; -static int erofs_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned int flags,struct iomap *iomap,struct iomap *srcmap) {
@@ -308,6 +302,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->length = map.m_llen; iomap->flags =0 ; iomap->addr =IOMAP_NULL_ADDR ; + iomap->private =NULL ;if (!(map.m_flags &EROFS_MAP_MAPPED )) { iomap->type =IOMAP_HOLE ;return 0 ;
@@ -322,6 +317,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (ret)return ret; + iomap->private = mdev.m_dif;if (flags &IOMAP_DAX ) iomap->dax_dev = mdev.m_dif->dax_dev;else
@@ -396,14 +392,16 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,*/ static int erofs_read_folio (struct file *file,struct folio *folio) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .cur_folio = folio, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (folio_inode (folio), &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .cur_folio = folio, + };trace_erofs_read_folio (iter_ctx.realinode, folio, true);iomap_read_folio (&erofs_iomap_ops, &read_ctx, &iter_ctx);
@@ -414,14 +412,16 @@ static int erofs_read_folio(struct file *file, struct folio *folio)static void erofs_readahead (struct readahead_control *rac) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .rac = rac, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (rac->mapping->host, &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .rac = rac, + };trace_erofs_readahead (iter_ctx.realinode,readahead_index (rac),readahead_count (rac), true);
@@ -457,7 +457,6 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)return filemap_read (iocb, to,0 ); } -/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_aops = { .read_folio = erofs_read_folio, .readahead = erofs_readahead,
fs/erofs/fileio.c +40 -108
195 lines not on this page · raw message
fs/erofs/internal.h +7 -4
@@ -380,7 +380,6 @@ struct erofs_map_dev {extern const struct super_operations erofs_sops;extern const struct address_space_operations erofs_aops; -extern const struct address_space_operations erofs_fileio_aops;extern const struct address_space_operations z_erofs_aops;extern const struct inode_operations erofs_generic_iops;
@@ -392,7 +391,14 @@ extern const struct file_operations erofs_file_fops;extern const struct file_operations erofs_dir_fops;extern const struct file_operations erofs_ishare_fops; +struct erofs_iomap_iter_ctx { +struct page *page; +void *base; +struct inode *realinode; +}; +extern const struct iomap_ops z_erofs_iomap_report_ops; +extern const struct iomap_read_ops erofs_fileio_iomap_read_ops;int erofs_setup_managed_cache (struct super_block *sb);#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
@@ -450,9 +456,6 @@ erofs_get_aops(struct inode *realinode) "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");return &z_erofs_aops; } -if (IS_ENABLED (CONFIG_EROFS_FS_BACKED_BY_FILE ) && -erofs_is_fileio_mode (EROFS_SB (realinode->i_sb))) -return &erofs_fileio_aops;return &erofs_aops; }
Signature · 1 line
2.47.3
Gao Xiang
maintainerPATCH v3 1/1 erofs: enable iomap for file-backed mounts on unencoded inodes
In reply to Gao XiangIomap supports non-bdev I/O through fs-provided callbacks since commit b2f35ac4146d ("iomap: add caller-provided callbacks for read and readahead"), making it suitable for file-backed mounts on unencoded inodes.
Enable iomap for this case to support sub-folio buffered I/Os on file-backed mounts and simplify the codebase.
---
v3:
- meta fileIOs shouldn't go into iomap for now.
fs/erofs/data.c | 29 ++++---- fs/erofs/fileio.c | 157 ++++++++++++++------------------------------ fs/erofs/internal.h | 11 ++-- 3 files changed, 70 insertions(+), 127 deletions(-)
fs/erofs/data.c +14 -15
@@ -281,12 +281,6 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)folio_end_read (folio, !(v &BIT (EROFS_ONLINEFOLIO_EIO ))); } -struct erofs_iomap_iter_ctx { -struct page *page; -void *base; -struct inode *realinode; -}; -static int erofs_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned int flags,struct iomap *iomap,struct iomap *srcmap) {
@@ -308,6 +302,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->length = map.m_llen; iomap->flags =0 ; iomap->addr =IOMAP_NULL_ADDR ; + iomap->private =NULL ;if (!(map.m_flags &EROFS_MAP_MAPPED )) { iomap->type =IOMAP_HOLE ;return 0 ;
@@ -322,6 +317,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (ret)return ret; + iomap->private = mdev.m_dif;if (flags &IOMAP_DAX ) iomap->dax_dev = mdev.m_dif->dax_dev;else
@@ -396,14 +392,16 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,*/ static int erofs_read_folio (struct file *file,struct folio *folio) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .cur_folio = folio, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (folio_inode (folio), &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .cur_folio = folio, + };trace_erofs_read_folio (iter_ctx.realinode, folio, true);iomap_read_folio (&erofs_iomap_ops, &read_ctx, &iter_ctx);
@@ -414,14 +412,16 @@ static int erofs_read_folio(struct file *file, struct folio *folio)static void erofs_readahead (struct readahead_control *rac) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .rac = rac, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (rac->mapping->host, &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .rac = rac, + };trace_erofs_readahead (iter_ctx.realinode,readahead_index (rac),readahead_count (rac), true);
@@ -457,7 +457,6 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)return filemap_read (iocb, to,0 ); } -/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_aops = { .read_folio = erofs_read_folio, .readahead = erofs_readahead,
fs/erofs/fileio.c +49 -108
209 lines not on this page · raw message
fs/erofs/internal.h +7 -4
@@ -380,7 +380,6 @@ struct erofs_map_dev {extern const struct super_operations erofs_sops;extern const struct address_space_operations erofs_aops; -extern const struct address_space_operations erofs_fileio_aops;extern const struct address_space_operations z_erofs_aops;extern const struct inode_operations erofs_generic_iops;
@@ -392,7 +391,14 @@ extern const struct file_operations erofs_file_fops;extern const struct file_operations erofs_dir_fops;extern const struct file_operations erofs_ishare_fops; +struct erofs_iomap_iter_ctx { +struct page *page; +void *base; +struct inode *realinode; +}; +extern const struct iomap_ops z_erofs_iomap_report_ops; +extern const struct iomap_read_ops erofs_fileio_iomap_read_ops;int erofs_setup_managed_cache (struct super_block *sb);#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
@@ -450,9 +456,6 @@ erofs_get_aops(struct inode *realinode) "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");return &z_erofs_aops; } -if (IS_ENABLED (CONFIG_EROFS_FS_BACKED_BY_FILE ) && -erofs_is_fileio_mode (EROFS_SB (realinode->i_sb))) -return &erofs_fileio_aops;return &erofs_aops; }
Signature · 1 line
2.47.3
Gao Xiang
maintainerPATCH v4 1/1 erofs: enable iomap for file-backed mounts on unencoded inodes
In reply to Gao XiangIomap supports non-bdev I/O through fs-provided callbacks since commit b2f35ac4146d ("iomap: add caller-provided callbacks for read and readahead"), making it suitable for file-backed mounts on unencoded inodes.
Enable iomap for this case to support sub-folio buffered I/Os on file-backed mounts and simplify the codebase.
---
v4:
- update i_blkbits of ishare inodes for sub-page block sizes found by sashiko.
fs/erofs/data.c | 29 ++++---- fs/erofs/fileio.c | 157 ++++++++++++++------------------------------ fs/erofs/internal.h | 11 ++-- fs/erofs/ishare.c | 1 + 4 files changed, 71 insertions(+), 127 deletions(-)
fs/erofs/data.c +14 -15
@@ -281,12 +281,6 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)folio_end_read (folio, !(v &BIT (EROFS_ONLINEFOLIO_EIO ))); } -struct erofs_iomap_iter_ctx { -struct page *page; -void *base; -struct inode *realinode; -}; -static int erofs_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned int flags,struct iomap *iomap,struct iomap *srcmap) {
@@ -308,6 +302,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->length = map.m_llen; iomap->flags =0 ; iomap->addr =IOMAP_NULL_ADDR ; + iomap->private =NULL ;if (!(map.m_flags &EROFS_MAP_MAPPED )) { iomap->type =IOMAP_HOLE ;return 0 ;
@@ -322,6 +317,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (ret)return ret; + iomap->private = mdev.m_dif;if (flags &IOMAP_DAX ) iomap->dax_dev = mdev.m_dif->dax_dev;else
@@ -396,14 +392,16 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,*/ static int erofs_read_folio (struct file *file,struct folio *folio) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .cur_folio = folio, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (folio_inode (folio), &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .cur_folio = folio, + };trace_erofs_read_folio (iter_ctx.realinode, folio, true);iomap_read_folio (&erofs_iomap_ops, &read_ctx, &iter_ctx);
@@ -414,14 +412,16 @@ static int erofs_read_folio(struct file *file, struct folio *folio)static void erofs_readahead (struct readahead_control *rac) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .rac = rac, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (rac->mapping->host, &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .rac = rac, + };trace_erofs_readahead (iter_ctx.realinode,readahead_index (rac),readahead_count (rac), true);
@@ -457,7 +457,6 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)return filemap_read (iocb, to,0 ); } -/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_aops = { .read_folio = erofs_read_folio, .readahead = erofs_readahead,
fs/erofs/fileio.c +49 -108
209 lines not on this page · raw message
fs/erofs/internal.h +7 -4
@@ -380,7 +380,6 @@ struct erofs_map_dev {extern const struct super_operations erofs_sops;extern const struct address_space_operations erofs_aops; -extern const struct address_space_operations erofs_fileio_aops;extern const struct address_space_operations z_erofs_aops;extern const struct inode_operations erofs_generic_iops;
@@ -392,7 +391,14 @@ extern const struct file_operations erofs_file_fops;extern const struct file_operations erofs_dir_fops;extern const struct file_operations erofs_ishare_fops; +struct erofs_iomap_iter_ctx { +struct page *page; +void *base; +struct inode *realinode; +}; +extern const struct iomap_ops z_erofs_iomap_report_ops; +extern const struct iomap_read_ops erofs_fileio_iomap_read_ops;int erofs_setup_managed_cache (struct super_block *sb);#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
@@ -450,9 +456,6 @@ erofs_get_aops(struct inode *realinode) "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");return &z_erofs_aops; } -if (IS_ENABLED (CONFIG_EROFS_FS_BACKED_BY_FILE ) && -erofs_is_fileio_mode (EROFS_SB (realinode->i_sb))) -return &erofs_fileio_aops;return &erofs_aops; }
fs/erofs/ishare.c +1 -0
@@ -54,6 +54,7 @@ bool erofs_ishare_fill_inode(struct inode *inode) si->i_mapping->a_ops = aops; si->i_mode =0444 |S_IFREG ; si->i_size = inode->i_size; + si->i_blkbits = inode->i_blkbits;mapping_set_large_folios (si->i_mapping);unlock_new_inode (si); }else {
Signature · 1 line
2.47.3
Gao Xiang
maintainerPATCH RESEND v4 1/1 erofs: enable iomap for file-backed mounts on unencoded inodes
In reply to Gao XiangIomap supports non-bdev I/O through fs-provided callbacks since commit b2f35ac4146d ("iomap: add caller-provided callbacks for read and readahead"), making it suitable for file-backed mounts on unencoded inodes.
Enable iomap for this case to support sub-folio buffered I/Os on file-backed mounts and simplify the codebase.
---
v4 RESEND:
- consider i_blkbits of ishare inodes for sub-page block sizes found by sashiko.
fs/erofs/data.c | 29 ++++---- fs/erofs/fileio.c | 157 ++++++++++++++------------------------------ fs/erofs/internal.h | 11 ++-- fs/erofs/ishare.c | 4 +- 4 files changed, 73 insertions(+), 128 deletions(-)
fs/erofs/data.c +14 -15
@@ -281,12 +281,6 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)folio_end_read (folio, !(v &BIT (EROFS_ONLINEFOLIO_EIO ))); } -struct erofs_iomap_iter_ctx { -struct page *page; -void *base; -struct inode *realinode; -}; -static int erofs_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned int flags,struct iomap *iomap,struct iomap *srcmap) {
@@ -308,6 +302,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->length = map.m_llen; iomap->flags =0 ; iomap->addr =IOMAP_NULL_ADDR ; + iomap->private =NULL ;if (!(map.m_flags &EROFS_MAP_MAPPED )) { iomap->type =IOMAP_HOLE ;return 0 ;
@@ -322,6 +317,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (ret)return ret; + iomap->private = mdev.m_dif;if (flags &IOMAP_DAX ) iomap->dax_dev = mdev.m_dif->dax_dev;else
@@ -396,14 +392,16 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,*/ static int erofs_read_folio (struct file *file,struct folio *folio) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .cur_folio = folio, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (folio_inode (folio), &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .cur_folio = folio, + };trace_erofs_read_folio (iter_ctx.realinode, folio, true);iomap_read_folio (&erofs_iomap_ops, &read_ctx, &iter_ctx);
@@ -414,14 +412,16 @@ static int erofs_read_folio(struct file *file, struct folio *folio)static void erofs_readahead (struct readahead_control *rac) { -struct iomap_read_folio_ctx read_ctx = { - .ops = &iomap_bio_read_ops, - .rac = rac, - };bool need_iput;struct erofs_iomap_iter_ctx iter_ctx = { .realinode =erofs_real_inode (rac->mapping->host, &need_iput), }; +struct erofs_sb_info *sbi =EROFS_I_SB (iter_ctx.realinode); +struct iomap_read_folio_ctx read_ctx = { + .ops =erofs_is_fileio_mode (sbi) ? + &erofs_fileio_iomap_read_ops : &iomap_bio_read_ops, + .rac = rac, + };trace_erofs_readahead (iter_ctx.realinode,readahead_index (rac),readahead_count (rac), true);
@@ -457,7 +457,6 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)return filemap_read (iocb, to,0 ); } -/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_aops = { .read_folio = erofs_read_folio, .readahead = erofs_readahead,
fs/erofs/fileio.c +49 -108
209 lines not on this page · raw message
fs/erofs/internal.h +7 -4
@@ -380,7 +380,6 @@ struct erofs_map_dev {extern const struct super_operations erofs_sops;extern const struct address_space_operations erofs_aops; -extern const struct address_space_operations erofs_fileio_aops;extern const struct address_space_operations z_erofs_aops;extern const struct inode_operations erofs_generic_iops;
@@ -392,7 +391,14 @@ extern const struct file_operations erofs_file_fops;extern const struct file_operations erofs_dir_fops;extern const struct file_operations erofs_ishare_fops; +struct erofs_iomap_iter_ctx { +struct page *page; +void *base; +struct inode *realinode; +}; +extern const struct iomap_ops z_erofs_iomap_report_ops; +extern const struct iomap_read_ops erofs_fileio_iomap_read_ops;int erofs_setup_managed_cache (struct super_block *sb);#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
@@ -450,9 +456,6 @@ erofs_get_aops(struct inode *realinode) "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");return &z_erofs_aops; } -if (IS_ENABLED (CONFIG_EROFS_FS_BACKED_BY_FILE ) && -erofs_is_fileio_mode (EROFS_SB (realinode->i_sb))) -return &erofs_fileio_aops;return &erofs_aops; }
fs/erofs/ishare.c +3 -1
@@ -54,11 +54,13 @@ bool erofs_ishare_fill_inode(struct inode *inode) si->i_mapping->a_ops = aops; si->i_mode =0444 |S_IFREG ; si->i_size = inode->i_size; + si->i_blkbits = inode->i_blkbits;mapping_set_large_folios (si->i_mapping);unlock_new_inode (si); }else {kfree (fp.opaque); -if (!si || aops != si->i_mapping->a_ops) { +if (!si || aops != si->i_mapping->a_ops || + si->i_blkbits != inode->i_blkbits) {iput (si);return false; }
Signature · 1 line
2.47.3
Quoted 9 lines · Gao Xiang
Iomap supports non-bdev I/O through fs-provided callbacks since commit
b2f35ac4146d("iomap: add caller-provided callbacks for read and readahead"), making it suitable for file-backed mounts on unencoded inodes.Enable iomap for this case to support sub-folio buffered I/Os on file-backed mounts and simplify the codebase.
Signed-off-by Gao Xiang (Docker) <[email protected]>
Thanks,