erofs: promote erofs from staging
Subsystems (4)
PATCH v2 10/25 erofs: update erofs_fs.h comments
In reply to Gao XiangAs Christoph said [1] [2], update it now.
[1] https://lore.kernel.org/r/[email protected]/
[2] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/erofs_fs.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/erofs/erofs_fs.h +5 -4
@@ -1,5 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */ /* +* EROFS (Enhanced ROM File System) on-disk format definition +* * Copyright (C) 2017-2018 HUAWEI, Inc. * http://www.huawei.com/ * Created by Gao Xiang <[email protected]>
@@ -7,7 +9,6 @@#ifndef __EROFS_FS_H#define __EROFS_FS_H -/* Enhanced(Extended) ROM File System */ #define EROFS_SUPER_OFFSET 1024/*
@@ -41,7 +42,7 @@ struct erofs_super_block { };/* -* erofs inode datalayout: +* erofs inode datalayout (i_format in on-disk inode): * 0 - inode plain without inline data A: * inode, [xattrs], ... | ... | no-holed data * 1 - inode VLE compression B (legacy):
@@ -187,7 +188,7 @@ static inline unsigned int erofs_xattr_entry_size(struct erofs_xattr_entry *e) e->e_name_len + le16_to_cpu(e->e_value_size)); } -/* available compression algorithm types */ +/* available compression algorithm types (for h_algorithmtype) */ enum {Z_EROFS_COMPRESSION_LZ4 =0 ,Z_EROFS_COMPRESSION_MAX
@@ -222,7 +223,7 @@ struct z_erofs_map_header {#define Z_EROFS_VLE_LEGACY_HEADER_PADDING 8/* -* Z_EROFS Variable-sized Logical Extent cluster type: +* Fixed-sized output compression ondisk Logical Extent cluster type: * 0 - literal (uncompressed) cluster * 1 - compressed cluster (for the head logical cluster) * 2 - compressed cluster (for the other logical clusters)
Signature · 1 line
2.17.1
PATCH v2 11/25 erofs: update comments in inode.c
In reply to Gao XiangAs Christoph suggested [1], update them all.
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/inode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/erofs/inode.c +2 -3
@@ -147,7 +147,7 @@ static int fill_inline_data(struct inode *inode, void *data,if (vi->datalayout !=EROFS_INODE_FLAT_INLINE )return 0 ; -/* fast symlink (following ext4) */ +/* fast symlink */ if (S_ISLNK (inode->i_mode) && inode->i_size <PAGE_SIZE ) {char *lnk =erofs_kmalloc (sbi, inode->i_size +1 ,GFP_KERNEL );
@@ -156,7 +156,7 @@ static int fill_inline_data(struct inode *inode, void *data, m_pofs += vi->inode_isize + vi->xattr_isize; -/* inline symlink data shouldn't across page boundary as well */ +/* inline symlink data shouldn't cross page boundary as well */ if (m_pofs + inode->i_size >PAGE_SIZE ) {kfree (lnk); errln("inline data cross block boundary @ nid %llu",
@@ -165,7 +165,6 @@ static int fill_inline_data(struct inode *inode, void *data,return -EFSCORRUPTED ; } -/* get in-page inline data */ memcpy (lnk, data + m_pofs, inode->i_size); lnk[inode->i_size] ='\0' ;
Signature · 1 line
2.17.1
PATCH v2 12/25 erofs: better erofs symlink stuffs
In reply to Gao XiangFix as Christoph suggested [1] [2], "remove is_inode_fast_symlink and just opencode it in the few places using it"
and
"Please just set the ops directly instead of obsfucating that in a single caller, single line inline function. And please set it instead of the normal symlink iops in the same place where you also set those."
[1] https://lore.kernel.org/r/[email protected]/
[2] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/inode.c | 68 ++++++++++++++++++--------------------------- fs/erofs/internal.h | 10 ------- fs/erofs/super.c | 5 ++-- 3 files changed, 29 insertions(+), 54 deletions(-)
fs/erofs/inode.c +27 -41
@@ -127,50 +127,39 @@ static int read_inode(struct inode *inode, void *data)return -EFSCORRUPTED ; } -/* -* try_lock can be required since locking order is: -* file data(fs_inode) -* meta(bd_inode) -* but the majority of the callers is "iget", -* in that case we are pretty sure no deadlock since -* no data operations exist. However I tend to -* try_lock since it takes no much overhead and -* will success immediately. -*/ -static int fill_inline_data (struct inode *inode,void *data, -unsigned int m_pofs) +static int erofs_fill_symlink (struct inode *inode,void *data, +unsigned int m_pofs) {struct erofs_inode *vi =EROFS_I (inode);struct erofs_sb_info *sbi =EROFS_I_SB (inode); +char *lnk; -/* should be tail-packing data inline */ -if (vi->datalayout !=EROFS_INODE_FLAT_INLINE ) +/* if it cannot be handled with fast symlink scheme */ +if (vi->datalayout !=EROFS_INODE_FLAT_INLINE || + inode->i_size >=PAGE_SIZE ) { + inode->i_op = &erofs_symlink_iops;return 0 ; + } -/* fast symlink */ -if (S_ISLNK (inode->i_mode) && inode->i_size <PAGE_SIZE ) { -char *lnk =erofs_kmalloc (sbi, inode->i_size +1 ,GFP_KERNEL ); - -if (!lnk) -return -ENOMEM ; - - m_pofs += vi->inode_isize + vi->xattr_isize; + lnk =erofs_kmalloc (sbi, inode->i_size +1 ,GFP_KERNEL ); +if (!lnk) +return -ENOMEM ; -/* inline symlink data shouldn't cross page boundary as well */ -if (m_pofs + inode->i_size >PAGE_SIZE ) { -kfree (lnk); -errln ("inline data cross block boundary @ nid %llu" , - vi->nid); -DBG_BUGON (1 ); -return -EFSCORRUPTED ; - } + m_pofs += vi->inode_isize + vi->xattr_isize; +/* inline symlink data shouldn't cross page boundary as well */ +if (m_pofs + inode->i_size >PAGE_SIZE ) { +kfree (lnk); +errln ("inline data cross block boundary @ nid %llu" , + vi->nid); +DBG_BUGON (1 ); +return -EFSCORRUPTED ; + } -memcpy (lnk, data + m_pofs, inode->i_size); - lnk[inode->i_size] ='\0' ; +memcpy (lnk, data + m_pofs, inode->i_size); + lnk[inode->i_size] ='\0' ; - inode->i_link = lnk; -set_inode_fast_symlink (inode); - } + inode->i_link = lnk; + inode->i_op = &erofs_fast_symlink_iops;return 0 ; }
@@ -217,8 +206,9 @@ static int fill_inode(struct inode *inode, int isdir) inode->i_fop = &erofs_dir_fops;break ;case S_IFLNK : -/* by default, page_get_link is used for symlink */ - inode->i_op = &erofs_symlink_iops; + err =erofs_fill_symlink (inode, data, ofs); +if (err) + goto out_unlock;inode_nohighmem (inode);break ;case S_IFCHR :
@@ -237,11 +227,7 @@ static int fill_inode(struct inode *inode, int isdir) err =z_erofs_fill_inode (inode); goto out_unlock; } - inode->i_mapping->a_ops = &erofs_raw_access_aops; - -/* fill last page if inline data is available */ - err =fill_inline_data (inode, data, ofs); } out_unlock:
fs/erofs/internal.h +0 -10
@@ -479,16 +479,6 @@ extern const struct inode_operations erofs_generic_iops;extern const struct inode_operations erofs_symlink_iops;extern const struct inode_operations erofs_fast_symlink_iops; -static inline void set_inode_fast_symlink (struct inode *inode) -{ - inode->i_op = &erofs_fast_symlink_iops; -} - -static inline bool is_inode_fast_symlink (struct inode *inode) -{ -return inode->i_op == &erofs_fast_symlink_iops; -} -struct inode *erofs_iget (struct super_block *sb,erofs_nid_t nid,bool dir);int erofs_getattr (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags);
fs/erofs/super.c +2 -3
@@ -40,10 +40,9 @@ static void free_inode(struct inode *inode) {struct erofs_inode *vi =EROFS_I (inode); -/* be careful RCU symlink path (see ext4_inode_info->i_data)! */ -if (is_inode_fast_symlink (inode)) +/* be careful of RCU symlink path */ +if (inode->i_op == &erofs_fast_symlink_iops)kfree (inode->i_link); -kfree (vi->xattr_shared_xattrs);kmem_cache_free (erofs_inode_cachep, vi);
Signature · 1 line
2.17.1
PATCH v2 13/25 erofs: use dsb instead of layout for ondisk super_block
In reply to Gao XiangAs Christoph pointed out [1], "Why is the variable name for the on-disk subperblock layout? We usually still calls this something with sb in the name, e.g. dsb. for disksuper block. " Let's fix it.
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/super.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
fs/erofs/super.c +17 -18
@@ -49,9 +49,9 @@ static void free_inode(struct inode *inode) }static bool check_layout_compatibility (struct super_block *sb, -struct erofs_super_block *layout) +struct erofs_super_block *dsb) { -const unsigned int feature =le32_to_cpu (layout->feature_incompat); +const unsigned int feature =le32_to_cpu (dsb->feature_incompat);EROFS_SB (sb)->feature_incompat = feature;
@@ -68,7 +68,7 @@ static int superblock_read(struct super_block *sb) {struct erofs_sb_info *sbi;struct buffer_head *bh; -struct erofs_super_block *layout; +struct erofs_super_block *dsb;unsigned int blkszbits;int ret;
@@ -80,16 +80,15 @@ static int superblock_read(struct super_block *sb) } sbi =EROFS_SB (sb); - layout = (struct erofs_super_block *)((u8 *)bh->b_data - +EROFS_SUPER_OFFSET ); + dsb = (struct erofs_super_block *)(bh->b_data +EROFS_SUPER_OFFSET ); ret = -EINVAL ; -if (le32_to_cpu (layout->magic) !=EROFS_SUPER_MAGIC_V1 ) { +if (le32_to_cpu (dsb->magic) !=EROFS_SUPER_MAGIC_V1 ) {errln ("cannot find valid erofs superblock" ); goto out; } - blkszbits = layout->blkszbits; + blkszbits = dsb->blkszbits;/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ if (blkszbits !=LOG_BLOCK_SIZE ) { errln("blksize %u isn't supported on this platform",
@@ -97,25 +96,25 @@ static int superblock_read(struct super_block *sb) goto out; } -if (!check_layout_compatibility (sb, layout)) +if (!check_layout_compatibility (sb, dsb)) goto out; - sbi->blocks =le32_to_cpu (layout->blocks); - sbi->meta_blkaddr =le32_to_cpu (layout->meta_blkaddr); + sbi->blocks =le32_to_cpu (dsb->blocks); + sbi->meta_blkaddr =le32_to_cpu (dsb->meta_blkaddr);#ifdef CONFIG_EROFS_FS_XATTR - sbi->xattr_blkaddr =le32_to_cpu (layout->xattr_blkaddr); + sbi->xattr_blkaddr =le32_to_cpu (dsb->xattr_blkaddr);#endif sbi->islotbits =ilog2 (sizeof (struct erofs_inode_compact )); - sbi->root_nid =le16_to_cpu (layout->root_nid); - sbi->inos =le64_to_cpu (layout->inos); + sbi->root_nid =le16_to_cpu (dsb->root_nid); + sbi->inos =le64_to_cpu (dsb->inos); - sbi->build_time =le64_to_cpu (layout->build_time); - sbi->build_time_nsec =le32_to_cpu (layout->build_time_nsec); + sbi->build_time =le64_to_cpu (dsb->build_time); + sbi->build_time_nsec =le32_to_cpu (dsb->build_time_nsec); -memcpy (&sb->s_uuid, layout->uuid,sizeof (layout->uuid)); +memcpy (&sb->s_uuid, dsb->uuid,sizeof (dsb->uuid)); - ret =strscpy (sbi->volume_name, layout->volume_name, -sizeof (layout->volume_name)); + ret =strscpy (sbi->volume_name, dsb->volume_name, +sizeof (dsb->volume_name));if (ret <0 ) {/* -E2BIG */ errln ("bad volume name without NIL terminator" ); ret = -EFSCORRUPTED ;
Signature · 1 line
2.17.1
PATCH v2 14/25 erofs: kill verbose debug info in erofs_fill_super
In reply to Gao XiangAs Christoph said [1], "That is some very verbose debug info. We usually don't add that and let people trace the function instead. "
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/super.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/erofs/super.c +2 -7
@@ -384,9 +384,6 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)struct erofs_sb_info *sbi;int err; -infoln ("fill_super, device -> %s" , sb->s_id); -infoln ("options -> %s" , (char *)data); - sb->s_magic =EROFS_SUPER_MAGIC ;if (!sb_set_blocksize (sb,EROFS_BLKSIZ )) {
@@ -419,9 +416,6 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)if (err)return err; -if (!silent) -infoln ("root inode @ nid %llu" ,ROOT_NID (sbi)); -if (test_opt (sbi,POSIX_ACL )) sb->s_flags |=SB_POSIXACL ;else
@@ -454,7 +448,8 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)return err;if (!silent) -infoln ("mounted on %s with opts: %s." , sb->s_id, (char *)data); +infoln ("mounted on %s with opts: %s, root inode @ nid %llu." , + sb->s_id, (char *)data,ROOT_NID (sbi));return 0 ; }
Signature · 1 line
2.17.1
PATCH v2 15/25 erofs: localize erofs_grab_bio()
In reply to Gao XiangAs Christoph pointed out [1], "erofs_grab_bio tries to handle a bio_alloc failure, except that the function will not actually fail due the mempool backing it."
Sorry about useless code, fix it now and
localize erofs_grab_bio [2].
[1] https://lore.kernel.org/r/[email protected]/
[2] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/data.c | 28 +++++++++++++++------------- fs/erofs/internal.h | 29 ----------------------------- fs/erofs/zdata.c | 10 +++++++--- 3 files changed, 22 insertions(+), 45 deletions(-)
fs/erofs/data.c +15 -13
@@ -38,6 +38,19 @@ static inline void read_endio(struct bio *bio)bio_put (bio); } +static struct bio *erofs_grab_raw_bio (struct super_block *sb, +erofs_blk_t blkaddr, +unsigned int nr_pages) +{ +struct bio *bio =bio_alloc (GFP_NOIO , nr_pages); + + bio->bi_end_io = read_endio; +bio_set_dev (bio, sb->s_bdev); + bio->bi_iter.bi_sector = (sector_t )blkaddr <<LOG_SECTORS_PER_BLOCK ; + bio->bi_private = sb; +return bio; +} +/* prio -- true is used for dir */ struct page *__erofs_get_meta_page (struct super_block *sb,erofs_blk_t blkaddr,bool prio,bool nofail)
@@ -62,12 +75,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,if (!PageUptodate (page)) {struct bio *bio; - bio =erofs_grab_bio (sb, blkaddr,1 , sb, read_endio, nofail); -if (IS_ERR (bio)) { -DBG_BUGON (nofail); - err =PTR_ERR (bio); - goto err_out; - } + bio =erofs_grab_raw_bio (sb, blkaddr,1 );if (bio_add_page (bio, page,PAGE_SIZE ,0 ) !=PAGE_SIZE ) { err = -EFAULT ;
@@ -276,13 +284,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,if (nblocks >BIO_MAX_PAGES ) nblocks =BIO_MAX_PAGES ; - bio =erofs_grab_bio (sb, blknr, nblocks, sb, - read_endio, false); -if (IS_ERR (bio)) { - err =PTR_ERR (bio); - bio =NULL ; - goto err_out; - } + bio =erofs_grab_raw_bio (sb, blknr, nblocks); } err =bio_add_page (bio, page,PAGE_SIZE ,0 );
fs/erofs/internal.h +0 -29
@@ -411,35 +411,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,#endif /* !CONFIG_EROFS_FS_ZIP */ /* data.c */ -static inline struct bio *erofs_grab_bio (struct super_block *sb, -erofs_blk_t blkaddr, -unsigned int nr_pages, -void *bi_private,bio_end_io_t endio, -bool nofail) -{ -const gfp_t gfp =GFP_NOIO ; -struct bio *bio; - -do { -if (nr_pages ==1 ) { - bio =bio_alloc (gfp | (nofail ? __GFP_NOFAIL :0 ),1 ); -if (!bio) { -DBG_BUGON (nofail); -return ERR_PTR (-ENOMEM ); - } -break ; - } - bio =bio_alloc (gfp, nr_pages); - nr_pages /=2 ; - }while (!bio); - - bio->bi_end_io = endio; -bio_set_dev (bio, sb->s_bdev); - bio->bi_iter.bi_sector = (sector_t )blkaddr <<LOG_SECTORS_PER_BLOCK ; - bio->bi_private = bi_private; -return bio; -} -static inline void __submit_bio (struct bio *bio,unsigned int op,unsigned int op_flags) {
fs/erofs/zdata.c +7 -3
@@ -1263,9 +1263,13 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, }if (!bio) { - bio =erofs_grab_bio (sb, first_index + i, -BIO_MAX_PAGES , bi_private, - z_erofs_vle_read_endio, true); + bio =bio_alloc (GFP_NOIO ,BIO_MAX_PAGES ); + + bio->bi_end_io = z_erofs_vle_read_endio; +bio_set_dev (bio, sb->s_bdev); + bio->bi_iter.bi_sector = (sector_t)(first_index + i) << +LOG_SECTORS_PER_BLOCK ; + bio->bi_private = bi_private; ++nr_bios; }
Signature · 1 line
2.17.1
PATCH v2 16/25 erofs: kill prio and nofail of erofs_get_meta_page()
In reply to Gao XiangAs Christoph pointed out [1],
"Why is there __erofs_get_meta_page with the two weird booleans instead of a single erofs_get_meta_page that gets and gfp_t for additional flags and an unsigned int for additional bio op flags."
And since all callers can handle errors, let's kill prio and nofail and erofs_get_inline_page() now.
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/data.c | 25 ++++++------------------- fs/erofs/inode.c | 2 +- fs/erofs/internal.h | 18 +----------------- fs/erofs/xattr.c | 13 ++++++------- fs/erofs/zmap.c | 4 ++-- 5 files changed, 16 insertions(+), 46 deletions(-)
fs/erofs/data.c +6 -19
@@ -51,25 +51,19 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb,return bio; } -/* prio -- true is used for dir */ -struct page *__erofs_get_meta_page (struct super_block *sb, -erofs_blk_t blkaddr,bool prio,bool nofail) +struct page *erofs_get_meta_page (struct super_block *sb,erofs_blk_t blkaddr) {struct inode *const bd_inode = sb->s_bdev->bd_inode;struct address_space *const mapping = bd_inode->i_mapping; -/* prefer retrying in the allocator to blindly looping below */ -const gfp_t gfp =mapping_gfp_constraint (mapping, ~__GFP_FS) | - (nofail ? __GFP_NOFAIL :0 ); -unsigned int io_retries = nofail ?EROFS_IO_MAX_RETRIES_NOFAIL :0 ; +const gfp_t gfp =mapping_gfp_constraint (mapping, ~__GFP_FS);struct page *page;int err; repeat: page =find_or_create_page (mapping, blkaddr, gfp); -if (!page) { -DBG_BUGON (nofail); +if (!page)return ERR_PTR (-ENOMEM ); - } +DBG_BUGON (!PageLocked (page));if (!PageUptodate (page)) {
@@ -82,14 +76,11 @@ struct page *__erofs_get_meta_page(struct super_block *sb, goto err_out; } -__submit_bio (bio,REQ_OP_READ , -REQ_META | (prio ?REQ_PRIO :0 )); - +__submit_bio (bio,REQ_OP_READ ,REQ_META );lock_page (page);/* this page has been truncated by others */ if (page->mapping != mapping) { -unlock_repeat:unlock_page (page);put_page (page); goto repeat;
@@ -97,10 +88,6 @@ struct page *__erofs_get_meta_page(struct super_block *sb,/* more likely a read error */ if (!PageUptodate (page)) { -if (io_retries) { - --io_retries; - goto unlock_repeat; - } err = -EIO ; goto err_out; }
@@ -251,7 +238,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,DBG_BUGON (map.m_plen >PAGE_SIZE ); - ipage =erofs_get_meta_page (inode->i_sb, blknr,0 ); + ipage =erofs_get_meta_page (inode->i_sb, blknr);if (IS_ERR (ipage)) { err =PTR_ERR (ipage);
fs/erofs/inode.c +1 -1
@@ -182,7 +182,7 @@ static int fill_inode(struct inode *inode, int isdir)debugln ("%s, reading inode nid %llu at %u of blkaddr %u" , __func__, vi->nid, ofs, blkaddr); - page =erofs_get_meta_page (inode->i_sb, blkaddr, isdir); + page =erofs_get_meta_page (inode->i_sb, blkaddr);if (IS_ERR (page)) { errln("failed to get inode (nid: %llu) page, err %ld",
fs/erofs/internal.h +1 -17
@@ -258,8 +258,6 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)#error erofs cannot be used in this platform#endif -#define EROFS_IO_MAX_RETRIES_NOFAIL 5 -#define ROOT_NID (sb) ((sb)->root_nid)#define erofs_blknr (addr) ((addr) / EROFS_BLKSIZ)
@@ -418,24 +416,10 @@ static inline void __submit_bio(struct bio *bio, unsigned int op,submit_bio (bio); } -struct page *__erofs_get_meta_page (struct super_block *sb,erofs_blk_t blkaddr, -bool prio,bool nofail); - -static inline struct page *erofs_get_meta_page (struct super_block *sb, -erofs_blk_t blkaddr,bool prio) -{ -return __erofs_get_meta_page (sb, blkaddr, prio, false); -} +struct page *erofs_get_meta_page (struct super_block *sb,erofs_blk_t blkaddr);int erofs_map_blocks (struct inode *,struct erofs_map_blocks *,int ); -static inline struct page *erofs_get_inline_page (struct inode *inode, -erofs_blk_t blkaddr) -{ -return erofs_get_meta_page (inode->i_sb, blkaddr, -S_ISDIR (inode->i_mode)); -} -/* inode.c */ static inline unsigned long erofs_inode_hash (erofs_nid_t nid) {
fs/erofs/xattr.c +6 -7
@@ -87,7 +87,7 @@ static int init_inode_xattrs(struct inode *inode) it.blkaddr =erofs_blknr (iloc (sbi, vi->nid) + vi->inode_isize); it.ofs =erofs_blkoff (iloc (sbi, vi->nid) + vi->inode_isize); - it.page =erofs_get_inline_page (inode, it.blkaddr); + it.page =erofs_get_meta_page (sb, it.blkaddr);if (IS_ERR (it.page)) { ret =PTR_ERR (it.page); goto out_unlock;
@@ -117,8 +117,7 @@ static int init_inode_xattrs(struct inode *inode)DBG_BUGON (it.ofs !=EROFS_BLKSIZ );xattr_iter_end (&it, atomic_map); - it.page =erofs_get_meta_page (sb, ++it.blkaddr, -S_ISDIR (inode->i_mode)); + it.page =erofs_get_meta_page (sb, ++it.blkaddr);if (IS_ERR (it.page)) {kfree (vi->xattr_shared_xattrs); vi->xattr_shared_xattrs =NULL ;
@@ -168,7 +167,7 @@ static inline int xattr_iter_fixup(struct xattr_iter *it) it->blkaddr +=erofs_blknr (it->ofs); - it->page =erofs_get_meta_page (it->sb, it->blkaddr, false); + it->page =erofs_get_meta_page (it->sb, it->blkaddr);if (IS_ERR (it->page)) {int err =PTR_ERR (it->page);
@@ -199,7 +198,7 @@ static int inline_xattr_iter_begin(struct xattr_iter *it, it->blkaddr =erofs_blknr (iloc (sbi, vi->nid) + inline_xattr_ofs); it->ofs =erofs_blkoff (iloc (sbi, vi->nid) + inline_xattr_ofs); - it->page =erofs_get_inline_page (inode, it->blkaddr); + it->page =erofs_get_meta_page (inode->i_sb, it->blkaddr);if (IS_ERR (it->page))return PTR_ERR (it->page);
@@ -401,7 +400,7 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)if (i)xattr_iter_end (&it->it, true); - it->it.page =erofs_get_meta_page (sb, blkaddr, false); + it->it.page =erofs_get_meta_page (sb, blkaddr);if (IS_ERR (it->it.page))return PTR_ERR (it->it.page);
@@ -623,7 +622,7 @@ static int shared_listxattr(struct listxattr_iter *it)if (i)xattr_iter_end (&it->it, true); - it->it.page =erofs_get_meta_page (sb, blkaddr, false); + it->it.page =erofs_get_meta_page (sb, blkaddr);if (IS_ERR (it->it.page))return PTR_ERR (it->it.page);
fs/erofs/zmap.c +2 -2
@@ -50,7 +50,7 @@ static int fill_inode_lazy(struct inode *inode) pos =ALIGN (iloc (EROFS_SB (sb), vi->nid) + vi->inode_isize + vi->xattr_isize,8 ); - page =erofs_get_meta_page (sb,erofs_blknr (pos), false); + page =erofs_get_meta_page (sb,erofs_blknr (pos));if (IS_ERR (page)) { err =PTR_ERR (page); goto out_unlock;
@@ -127,7 +127,7 @@ static int z_erofs_reload_indexes(struct z_erofs_maprecorder *m,put_page (mpage); } - mpage =erofs_get_meta_page (sb, eblk, false); + mpage =erofs_get_meta_page (sb, eblk);if (IS_ERR (mpage)) { map->mpage =NULL ;return PTR_ERR (mpage);
Signature · 1 line
2.17.1
PATCH v2 17/25 erofs: kill __submit_bio()
In reply to Gao XiangAs Christoph pointed out [1], "
Why is there __submit_bio which really just obsfucates what is going on? Also why is __submit_bio using bio_set_op_attrs instead of opencode it as the comment right next to it asks you to? "
Let's use submit_bio directly instead.
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/data.c | 21 +++++++++++++-------- fs/erofs/internal.h | 7 ------- fs/erofs/zdata.c | 6 ++++-- 3 files changed, 17 insertions(+), 17 deletions(-)
fs/erofs/data.c +13 -8
@@ -40,7 +40,8 @@ static inline void read_endio(struct bio *bio)static struct bio *erofs_grab_raw_bio (struct super_block *sb,erofs_blk_t blkaddr, -unsigned int nr_pages) +unsigned int nr_pages, +bool ismeta) {struct bio *bio =bio_alloc (GFP_NOIO , nr_pages);
@@ -48,6 +49,11 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb,bio_set_dev (bio, sb->s_bdev); bio->bi_iter.bi_sector = (sector_t )blkaddr <<LOG_SECTORS_PER_BLOCK ; bio->bi_private = sb; +if (ismeta) + bio->bi_opf =REQ_OP_READ |REQ_META ; +else + bio->bi_opf =REQ_OP_READ ; +return bio; }
@@ -69,14 +75,14 @@ struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)if (!PageUptodate (page)) {struct bio *bio; - bio =erofs_grab_raw_bio (sb, blkaddr,1 ); + bio =erofs_grab_raw_bio (sb, blkaddr,1 , true);if (bio_add_page (bio, page,PAGE_SIZE ,0 ) !=PAGE_SIZE ) { err = -EFAULT ; goto err_out; } -__submit_bio (bio,REQ_OP_READ ,REQ_META ); +submit_bio (bio);lock_page (page);/* this page has been truncated by others */
@@ -201,7 +207,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,/* not continuous */ *last_block + 1 != current_block) { submit_bio_retry: -__submit_bio (bio,REQ_OP_READ ,0 ); +submit_bio (bio); bio =NULL ; }
@@ -271,7 +277,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,if (nblocks >BIO_MAX_PAGES ) nblocks =BIO_MAX_PAGES ; - bio =erofs_grab_raw_bio (sb, blknr, nblocks); + bio =erofs_grab_raw_bio (sb, blknr, nblocks, false); } err =bio_add_page (bio, page,PAGE_SIZE ,0 );
@@ -302,8 +308,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,/* if updated manually, continuous pages has a gap */ if (bio) submit_bio_out: -__submit_bio (bio,REQ_OP_READ ,0 ); - +submit_bio (bio);return err ?ERR_PTR (err) :NULL ; }
@@ -367,7 +372,7 @@ static int erofs_raw_access_readpages(struct file *filp,/* the rare case (end in gaps) */ if (bio) -__submit_bio (bio,REQ_OP_READ ,0 ); +submit_bio (bio);return 0 ; }
fs/erofs/internal.h +0 -7
@@ -409,13 +409,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,#endif /* !CONFIG_EROFS_FS_ZIP */ /* data.c */ -static inline void __submit_bio (struct bio *bio,unsigned int op, -unsigned int op_flags) -{ -bio_set_op_attrs (bio, op, op_flags); -submit_bio (bio); -} -struct page *erofs_get_meta_page (struct super_block *sb,erofs_blk_t blkaddr);int erofs_map_blocks (struct inode *,struct erofs_map_blocks *,int );
fs/erofs/zdata.c +4 -2
@@ -1258,7 +1258,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,if (bio && force_submit) { submit_bio_retry: -__submit_bio (bio,REQ_OP_READ ,0 ); +submit_bio (bio); bio =NULL ; }
@@ -1270,6 +1270,8 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, bio->bi_iter.bi_sector = (sector_t)(first_index + i) <<LOG_SECTORS_PER_BLOCK ; bio->bi_private = bi_private; + bio->bi_opf =REQ_OP_READ ; + ++nr_bios; }
@@ -1290,7 +1292,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, }while (owned_head !=Z_EROFS_PCLUSTER_TAIL );if (bio) -__submit_bio (bio,REQ_OP_READ ,0 ); +submit_bio (bio);if (postsubmit_is_all_bypassed (q, nr_bios, force_fg))return true;
Signature · 1 line
2.17.1
PATCH v2 18/25 erofs: add "erofs_" prefix for common and short functions
In reply to Gao XiangAdd erofs_ prefix to free_inode, alloc_inode, ...
--- fs/erofs/data.c | 4 ++-- fs/erofs/decompressor.c | 22 +++++++++++----------- fs/erofs/inode.c | 8 ++++---- fs/erofs/internal.h | 2 +- fs/erofs/namei.c | 12 ++++++------ fs/erofs/super.c | 40 ++++++++++++++++++++-------------------- fs/erofs/zdata.c | 19 ++++++++++--------- 7 files changed, 54 insertions(+), 53 deletions(-)
fs/erofs/data.c +2 -2
@@ -9,7 +9,7 @@#include <trace/events/erofs.h> -static inline void read_endio (struct bio *bio) +static void erofs_readendio (struct bio *bio) {struct super_block *const sb = bio->bi_private;struct bio_vec *bvec;
@@ -45,7 +45,7 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb, {struct bio *bio =bio_alloc (GFP_NOIO , nr_pages); - bio->bi_end_io = read_endio; + bio->bi_end_io = erofs_readendio;bio_set_dev (bio, sb->s_bdev); bio->bi_iter.bi_sector = (sector_t )blkaddr <<LOG_SECTORS_PER_BLOCK ; bio->bi_private = sb;
fs/erofs/decompressor.c +11 -11
@@ -32,8 +32,8 @@ static bool use_vmap;module_param (use_vmap, bool,0444 );MODULE_PARM_DESC (use_vmap,"Use vmap() instead of vm_map_ram() (default 0)" ); -static int lz4_prepare_destpages (struct z_erofs_decompress_req *rq, -struct list_head *pagepool) +static int z_erofs_lz4_prepare_destpages (struct z_erofs_decompress_req *rq, +struct list_head *pagepool) {const unsigned int nr =PAGE_ALIGN (rq->pageofs_out + rq->outputsize) >>PAGE_SHIFT ;
@@ -114,7 +114,7 @@ static void *generic_copy_inplace_data(struct z_erofs_decompress_req *rq,return tmp; } -static int lz4_decompress (struct z_erofs_decompress_req *rq,u8 *out) +static int z_erofs_lz4_decompress (struct z_erofs_decompress_req *rq,u8 *out) {unsigned int inputmargin, inlen;u8 *src;
@@ -188,8 +188,8 @@ static struct z_erofs_decompressor decompressors[] = { .name = "shifted" }, [Z_EROFS_COMPRESSION_LZ4] = { - .prepare_destpages = lz4_prepare_destpages, - .decompress = lz4_decompress, + .prepare_destpages = z_erofs_lz4_prepare_destpages, + .decompress = z_erofs_lz4_decompress, .name ="lz4" }, };
@@ -247,8 +247,8 @@ static void erofs_vunmap(const void *mem, unsigned int count)vunmap (mem); } -static int decompress_generic (struct z_erofs_decompress_req *rq, -struct list_head *pagepool) +static int z_erofs_decompress_generic (struct z_erofs_decompress_req *rq, +struct list_head *pagepool) {const unsigned int nrpages_out =PAGE_ALIGN (rq->pageofs_out + rq->outputsize) >>PAGE_SHIFT ;
@@ -308,8 +308,8 @@ static int decompress_generic(struct z_erofs_decompress_req *rq,return ret; } -static int shifted_decompress (const struct z_erofs_decompress_req *rq, -struct list_head *pagepool) +static int z_erofs_shifted_transform (const struct z_erofs_decompress_req *rq, +struct list_head *pagepool) {const unsigned int nrpages_out =PAGE_ALIGN (rq->pageofs_out + rq->outputsize) >>PAGE_SHIFT ;
@@ -353,7 +353,7 @@ int z_erofs_decompress(struct z_erofs_decompress_req *rq, struct list_head *pagepool) {if (rq->alg ==Z_EROFS_COMPRESSION_SHIFTED ) -return shifted_decompress (rq, pagepool); -return decompress_generic (rq, pagepool); +return z_erofs_shifted_transform (rq, pagepool); +return z_erofs_decompress_generic (rq, pagepool); }
fs/erofs/inode.c +4 -4
@@ -9,7 +9,7 @@#include <trace/events/erofs.h> /* no locking */ -static int read_inode (struct inode *inode,void *data) +static int erofs_read_inode (struct inode *inode,void *data) {struct erofs_inode *vi =EROFS_I (inode);struct erofs_inode_compact *dic = data;
@@ -163,7 +163,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,return 0 ; } -static int fill_inode (struct inode *inode,int isdir) +static int erofs_fill_inode (struct inode *inode,int isdir) {struct erofs_sb_info *sbi =EROFS_SB (inode->i_sb);struct erofs_inode *vi =EROFS_I (inode);
@@ -193,7 +193,7 @@ static int fill_inode(struct inode *inode, int isdir)DBG_BUGON (!PageUptodate (page)); data =page_address (page); - err =read_inode (inode, data + ofs); + err =erofs_read_inode (inode, data + ofs);if (!err) {/* setup the new inode */ switch (inode->i_mode &S_IFMT ) {
@@ -286,7 +286,7 @@ struct inode *erofs_iget(struct super_block *sb, vi->nid = nid; - err =fill_inode (inode, isdir); + err =erofs_fill_inode (inode, isdir);if (!err)unlock_new_inode (inode);else {
fs/erofs/internal.h +1 -1
@@ -308,7 +308,7 @@ struct erofs_inode {#define EROFS_I (ptr) \ container_of(ptr, struct erofs_inode, vfs_inode) -static inline unsigned long inode_datablocks (struct inode *inode) +static inline unsigned long erofs_inode_datablocks (struct inode *inode) {/* since i_size cannot be changed */ return DIV_ROUND_UP (inode->i_size,EROFS_BLKSIZ );
fs/erofs/namei.c +6 -6
@@ -14,9 +14,9 @@ struct erofs_qstr { };/* based on the end of qn is accurate and it must have the trailing '\0' */ -static inline int dirnamecmp (const struct erofs_qstr *qn, -const struct erofs_qstr *qd, -unsigned int *matched) +static inline int erofs_dirnamecmp (const struct erofs_qstr *qn, +const struct erofs_qstr *qd, +unsigned int *matched) {unsigned int i = *matched;
@@ -71,7 +71,7 @@ static struct erofs_dirent *find_target_dirent(struct erofs_qstr *name, };/* string comparison without already matched prefix */ -int ret =dirnamecmp (name, &dname, &matched); +int ret =erofs_dirnamecmp (name, &dname, &matched);if (!ret) {return de + mid;
@@ -98,7 +98,7 @@ static struct page *find_target_block_classic(struct inode *dir, startprfx = endprfx =0 ; head =0 ; - back =inode_datablocks (dir) -1 ; + back =erofs_inode_datablocks (dir) -1 ;while (head <= back) {const int mid = head + (back - head) /2 ;
@@ -134,7 +134,7 @@ static struct page *find_target_block_classic(struct inode *dir, EROFS_BLKSIZ);/* string comparison without already matched prefix */ - diff =dirnamecmp (name, &dname, &matched); + diff =erofs_dirnamecmp (name, &dname, &matched);kunmap_atomic (de);if (!diff) {
fs/erofs/super.c +20 -20
@@ -16,14 +16,14 @@static struct kmem_cache *erofs_inode_cachep__read_mostly ; -static void init_once (void *ptr) +static void erofs_inode_init_once (void *ptr) {struct erofs_inode *vi = ptr;inode_init_once (&vi->vfs_inode); } -static struct inode *alloc_inode (struct super_block *sb) +static struct inode *erofs_alloc_inode (struct super_block *sb) {struct erofs_inode *vi =kmem_cache_alloc (erofs_inode_cachep,GFP_KERNEL );
@@ -36,7 +36,7 @@ static struct inode *alloc_inode(struct super_block *sb)return &vi->vfs_inode; } -static void free_inode (struct inode *inode) +static void erofs_free_inode (struct inode *inode) {struct erofs_inode *vi =EROFS_I (inode);
@@ -64,7 +64,7 @@ static bool check_layout_compatibility(struct super_block *sb,return true; } -static int superblock_read (struct super_block *sb) +static int erofs_read_superblock (struct super_block *sb) {struct erofs_sb_info *sbi;struct buffer_head *bh;
@@ -218,7 +218,7 @@ static int erofs_build_cache_strategy(struct erofs_sb_info *sbi,#endif /* set up default EROFS parameters */ -static void default_options (struct erofs_sb_info *sbi) +static void erofs_default_options (struct erofs_sb_info *sbi) {#ifdef CONFIG_EROFS_FS_ZIP sbi->cache_strategy =EROFS_ZIP_CACHE_READAROUND ;
@@ -252,7 +252,7 @@ static match_table_t erofs_tokens = { {Opt_err, NULL} }; -static int parse_options (struct super_block *sb,char *options) +static int erofs_parse_options (struct super_block *sb,char *options) {substring_t args[MAX_OPT_ARGS ];char *p;
@@ -322,7 +322,7 @@ static int parse_options(struct super_block *sb, char *options)#ifdef CONFIG_EROFS_FS_ZIP static const struct address_space_operations managed_cache_aops; -static int managed_cache_releasepage (struct page *page,gfp_t gfp_mask) +static int erofs_managed_cache_releasepage (struct page *page,gfp_t gfp_mask) {int ret =1 ;/* 0 - busy */ struct address_space *const mapping = page->mapping;
@@ -336,9 +336,9 @@ static int managed_cache_releasepage(struct page *page, gfp_t gfp_mask)return ret; } -static void managed_cache_invalidatepage (struct page *page, -unsigned int offset, -unsigned int length) +static void erofs_managed_cache_invalidatepage (struct page *page, +unsigned int offset, +unsigned int length) {const unsigned int stop = length + offset;
@@ -348,13 +348,13 @@ static void managed_cache_invalidatepage(struct page *page,DBG_BUGON (stop >PAGE_SIZE || stop < length);if (offset ==0 && stop ==PAGE_SIZE ) -while (!managed_cache_releasepage (page,GFP_NOFS )) +while (!erofs_managed_cache_releasepage (page,GFP_NOFS ))cond_resched (); }static const struct address_space_operations managed_cache_aops = { - .releasepage = managed_cache_releasepage, - .invalidatepage = managed_cache_invalidatepage, + .releasepage = erofs_managed_cache_releasepage, + .invalidatepage = erofs_managed_cache_invalidatepage, };static int erofs_init_managed_cache (struct super_block *sb)
@@ -396,7 +396,7 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)return -ENOMEM ; sb->s_fs_info = sbi; - err =superblock_read (sb); + err =erofs_read_superblock (sb);if (err)return err;
@@ -410,9 +410,9 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent) sb->s_xattr = erofs_xattr_handlers;#endif /* set erofs default mount options */ -default_options (sbi); +erofs_default_options (sbi); - err =parse_options (sb, data); + err =erofs_parse_options (sb, data);if (err)return err;
@@ -512,7 +512,7 @@ static int __init erofs_module_init(void) erofs_inode_cachep =kmem_cache_create ("erofs_inode" ,sizeof (struct erofs_inode ),0 ,SLAB_RECLAIM_ACCOUNT , - init_once); + erofs_inode_init_once);if (!erofs_inode_cachep) { err = -ENOMEM ; goto icache_err;
@@ -619,7 +619,7 @@ static int erofs_remount(struct super_block *sb, int *flags, char *data)int err;DBG_BUGON (!sb_rdonly (sb)); - err =parse_options (sb, data); + err =erofs_parse_options (sb, data);if (err) goto out;
@@ -639,8 +639,8 @@ static int erofs_remount(struct super_block *sb, int *flags, char *data)const struct super_operations erofs_sops = { .put_super = erofs_put_super, - .alloc_inode = alloc_inode, - .free_inode = free_inode, + .alloc_inode = erofs_alloc_inode, + .free_inode = erofs_free_inode, .statfs = erofs_statfs, .show_options = erofs_show_options, .remount_fs = erofs_remount,
fs/erofs/zdata.c +10 -9
@@ -40,7 +40,7 @@ void z_erofs_exit_zip_subsystem(void)kmem_cache_destroy (pcluster_cachep); } -static inline int init_unzip_workqueue (void ) +static inline int z_erofs_init_workqueue (void ) {const unsigned int onlinecpus =num_possible_cpus ();const unsigned int flags =WQ_UNBOUND |WQ_HIGHPRI |WQ_CPU_INTENSIVE ;
@@ -54,7 +54,7 @@ static inline int init_unzip_workqueue(void)return z_erofs_workqueue ?0 : -ENOMEM ; } -static void init_once (void *ptr) +static void z_erofs_pcluster_init_once (void *ptr) {struct z_erofs_pcluster *pcl = ptr;struct z_erofs_collection *cl =z_erofs_primarycollection (pcl);
@@ -67,7 +67,7 @@ static void init_once(void *ptr) pcl->compressed_pages[i] =NULL ; } -static void init_always (struct z_erofs_pcluster *pcl) +static void z_erofs_pcluster_init_always (struct z_erofs_pcluster *pcl) {struct z_erofs_collection *cl =z_erofs_primarycollection (pcl);
@@ -81,9 +81,10 @@ int __init z_erofs_init_zip_subsystem(void) { pcluster_cachep =kmem_cache_create ("erofs_compress" ,Z_EROFS_WORKGROUP_SIZE ,0 , -SLAB_RECLAIM_ACCOUNT , init_once); +SLAB_RECLAIM_ACCOUNT , + z_erofs_pcluster_init_once);if (pcluster_cachep) { -if (!init_unzip_workqueue ()) +if (!z_erofs_init_workqueue ())return 0 ;kmem_cache_destroy (pcluster_cachep);
@@ -272,8 +273,8 @@ int erofs_try_to_free_cached_page(struct address_space *mapping, }/* page_type must be Z_EROFS_PAGE_TYPE_EXCLUSIVE */ -static inline bool try_inplace_io (struct z_erofs_collector *clt, -struct page *page) +static inline bool z_erofs_try_inplace_io (struct z_erofs_collector *clt, +struct page *page) {struct z_erofs_pcluster *const pcl = clt->pcl;const unsigned int clusterpages =BIT (pcl->clusterbits);
@@ -296,7 +297,7 @@ static int z_erofs_attach_page(struct z_erofs_collector *clt,/* give priority for inplaceio */ if (clt->mode >=COLLECT_PRIMARY && type ==Z_EROFS_PAGE_TYPE_EXCLUSIVE && -try_inplace_io (clt, page)) +z_erofs_try_inplace_io (clt, page))return 0 ; ret = z_erofs_pagevec_enqueue(&clt->vector,
@@ -409,7 +410,7 @@ static struct z_erofs_collection *clregister(struct z_erofs_collector *clt,if (!pcl)return ERR_PTR (-ENOMEM ); -init_always (pcl); +z_erofs_pcluster_init_always (pcl); pcl->obj.index = map->m_pa >>PAGE_SHIFT ; pcl->length = (map->m_llen << Z_EROFS_PCLUSTER_LENGTH_BIT) |
Signature · 1 line
2.17.1
PATCH v2 19/25 erofs: kill all erofs specific fault injection
In reply to Gao XiangAs Christoph suggested [1], "Please just use plain kmalloc everywhere and let the normal kernel error injection code take care of injeting any errors."
[1] https://lore.kernel.org/r/[email protected]/
--- Documentation/filesystems/erofs.txt | 5 --- fs/erofs/Kconfig | 7 --- fs/erofs/data.c | 7 --- fs/erofs/inode.c | 3 +- fs/erofs/internal.h | 65 --------------------------- fs/erofs/super.c | 70 ----------------------------- fs/erofs/zdata.c | 8 +--- 7 files changed, 2 insertions(+), 163 deletions(-)
Documentation/filesystems/erofs.txt +0 -5
@@ -52,11 +52,6 @@ linux-erofs mailing list: Mount options ============= -fault_injection=%d Enable fault injection in all supported types with - specified injection rate. Supported injection type: - Type_Name Type_Value - FAULT_KMALLOC 0x000000001 - FAULT_READ_IO 0x000000002 (no)user_xattr Setup Extended User Attributes. Note: xattr is enabled by default if CONFIG_EROFS_FS_XATTR is selected. (no)acl Setup POSIX Access Control List. Note: acl is enabled
fs/erofs/Kconfig +0 -7
@@ -27,13 +27,6 @@ config EROFS_FS_DEBUG For daily use, say N. -config EROFS_FAULT_INJECTION - bool "EROFS fault injection facility" - depends on EROFS_FS - help - Test EROFS to inject faults such as ENOMEM, EIO, and so on. - If unsure, say N. - config EROFS_FS_XATTR bool "EROFS extended attributes" depends on EROFS_FS
fs/erofs/data.c +0 -7
@@ -11,16 +11,10 @@static void erofs_readendio (struct bio *bio) { -struct super_block *const sb = bio->bi_private;struct bio_vec *bvec;blk_status_t err = bio->bi_status;struct bvec_iter_all iter_all; -if (time_to_inject (EROFS_SB (sb),FAULT_READ_IO )) { -erofs_show_injection_info (FAULT_READ_IO ); - err =BLK_STS_IOERR ; - } -bio_for_each_segment_all (bvec, bio, iter_all) {struct page *page = bvec->bv_page;
@@ -48,7 +42,6 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb, bio->bi_end_io = erofs_readendio;bio_set_dev (bio, sb->s_bdev); bio->bi_iter.bi_sector = (sector_t )blkaddr <<LOG_SECTORS_PER_BLOCK ; - bio->bi_private = sb;if (ismeta) bio->bi_opf =REQ_OP_READ |REQ_META ;else
fs/erofs/inode.c +1 -2
@@ -131,7 +131,6 @@ static int erofs_fill_symlink(struct inode *inode, void *data, unsigned int m_pofs) {struct erofs_inode *vi =EROFS_I (inode); -struct erofs_sb_info *sbi =EROFS_I_SB (inode);char *lnk;/* if it cannot be handled with fast symlink scheme */
@@ -141,7 +140,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,return 0 ; } - lnk =erofs_kmalloc (sbi, inode->i_size +1 ,GFP_KERNEL ); + lnk =kmalloc (inode->i_size +1 ,GFP_KERNEL );if (!lnk)return -ENOMEM ;
fs/erofs/internal.h +0 -65
85 lines not on this page · raw message
fs/erofs/super.c +0 -70
113 lines not on this page · raw message
fs/erofs/zdata.c +1 -7
@@ -724,15 +724,9 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)DBG_BUGON (PageUptodate (page));DBG_BUGON (!page->mapping); -if (!sbi && !z_erofs_page_is_staging (page)) { +if (!sbi && !z_erofs_page_is_staging (page)) sbi =EROFS_SB (page->mapping->host->i_sb); -if (time_to_inject (sbi,FAULT_READ_IO )) { -erofs_show_injection_info (FAULT_READ_IO ); - err =BLK_STS_IOERR ; - } - } -/* sbi should already be gotten if the page is managed */ if (sbi) cachemngd =erofs_page_is_managed (sbi, page);
Signature · 1 line
2.17.1
PATCH v2 20/25 erofs: kill use_vmap module parameter
In reply to Gao XiangAs Christoph said [1],
"vm_map_ram is supposed to generally behave better. So if it doesn't please report that that to the arch maintainer and linux-mm so that they can look into the issue. Having user make choices of deep down kernel internals is just a horrible interface.
Please talk to maintainers of other bits of the kernel if you see issues and / or need enhancements. "
Let's redo the previous conclusion and kill the vmap approach.
[1] https://lore.kernel.org/r/[email protected]/
--- Documentation/filesystems/erofs.txt | 4 --- fs/erofs/decompressor.c | 46 ++++++++--------------------- 2 files changed, 13 insertions(+), 37 deletions(-)
Documentation/filesystems/erofs.txt +0 -4
@@ -67,10 +67,6 @@ cache_strategy=%s Select a strategy for cached decompression from now on: It still does in-place I/O decompression for the rest compressed physical clusters. -Module parameters -================= -use_vmap=[0|1] Use vmap() instead of vm_map_ram() (default 0). - On-disk details ===============
fs/erofs/decompressor.c +13 -33
78 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 21/25 erofs: save one level of indentation
In reply to Gao XiangAs Christoph said [1], ".. and save one
level of indentation."
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/inode.c | 65 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 32 deletions(-)
fs/erofs/inode.c +33 -32
@@ -193,41 +193,42 @@ static int erofs_fill_inode(struct inode *inode, int isdir) data =page_address (page); err =erofs_read_inode (inode, data + ofs); -if (!err) { -/* setup the new inode */ -switch (inode->i_mode &S_IFMT ) { -case S_IFREG : - inode->i_op = &erofs_generic_iops; - inode->i_fop = &generic_ro_fops; -break ; -case S_IFDIR : - inode->i_op = &erofs_dir_iops; - inode->i_fop = &erofs_dir_fops; -break ; -case S_IFLNK : - err =erofs_fill_symlink (inode, data, ofs); -if (err) - goto out_unlock; -inode_nohighmem (inode); -break ; -case S_IFCHR : -case S_IFBLK : -case S_IFIFO : -case S_IFSOCK : - inode->i_op = &erofs_generic_iops; -init_special_inode (inode, inode->i_mode, inode->i_rdev); - goto out_unlock; -default : - err = -EFSCORRUPTED ; +if (err) + goto out_unlock; + +/* setup the new inode */ +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &erofs_generic_iops; + inode->i_fop = &generic_ro_fops; +break ; +case S_IFDIR : + inode->i_op = &erofs_dir_iops; + inode->i_fop = &erofs_dir_fops; +break ; +case S_IFLNK : + err =erofs_fill_symlink (inode, data, ofs); +if (err) goto out_unlock; - } +inode_nohighmem (inode); +break ; +case S_IFCHR : +case S_IFBLK : +case S_IFIFO : +case S_IFSOCK : + inode->i_op = &erofs_generic_iops; +init_special_inode (inode, inode->i_mode, inode->i_rdev); + goto out_unlock; +default : + err = -EFSCORRUPTED ; + goto out_unlock; + } -if (erofs_inode_is_data_compressed (vi->datalayout)) { - err =z_erofs_fill_inode (inode); - goto out_unlock; - } - inode->i_mapping->a_ops = &erofs_raw_access_aops; +if (erofs_inode_is_data_compressed (vi->datalayout)) { + err =z_erofs_fill_inode (inode); + goto out_unlock; } + inode->i_mapping->a_ops = &erofs_raw_access_aops; out_unlock:unlock_page (page);
Signature · 1 line
2.17.1
PATCH v2 22/25 erofs: rename errln/infoln/debugln to erofs_{err,info,dbg}
In reply to Gao XiangAdd prefix "erofs_" to these functions and print sb->s_id as a prefix to erofs_{err, info} so that the user knows which file system is affected.
--- fs/erofs/data.c | 10 +++-- fs/erofs/decompressor.c | 5 +-- fs/erofs/dir.c | 17 +++++---- fs/erofs/inode.c | 31 ++++++++------- fs/erofs/internal.h | 14 +++++-- fs/erofs/namei.c | 9 +++-- fs/erofs/super.c | 83 +++++++++++++++++++++++++++-------------- fs/erofs/xattr.c | 8 ++-- fs/erofs/zdata.c | 13 ++++--- fs/erofs/zdata.h | 2 +- fs/erofs/zmap.c | 37 ++++++++++-------- 11 files changed, 139 insertions(+), 90 deletions(-)
fs/erofs/data.c +6 -4
@@ -137,8 +137,9 @@ static int erofs_map_blocks_flatmode(struct inode *inode,/* inline data should be located in one meta block */ if (erofs_blkoff (map->m_pa) + map->m_plen >PAGE_SIZE ) { -errln ("inline data cross block boundary @ nid %llu" , - vi->nid); +erofs_err (inode->i_sb, +"inline data cross block boundary @ nid %llu" , + vi->nid);DBG_BUGON (1 ); err = -EFSCORRUPTED ; goto err_out;
@@ -146,8 +147,9 @@ static int erofs_map_blocks_flatmode(struct inode *inode, map->m_flags |=EROFS_MAP_META ; }else { -errln ("internal error @ nid: %llu (size %llu), m_la 0x%llx" , - vi->nid, inode->i_size, map->m_la); +erofs_err (inode->i_sb, +"internal error @ nid: %llu (size %llu), m_la 0x%llx" , + vi->nid, inode->i_size, map->m_la);DBG_BUGON (1 ); err = -EIO ; goto err_out;
fs/erofs/decompressor.c +2 -3
@@ -161,9 +161,8 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) inlen, rq->outputsize, rq->outputsize);if (ret <0 ) { -errln ("%s, failed to decompress, in[%p, %u, %u] out[%p, %u]" , - __func__, src + inputmargin, inlen, inputmargin, - out, rq->outputsize); +erofs_err (rq->sb,"failed to decompress, in[%u, %u] out[%u]" , + inlen, inputmargin, rq->outputsize);WARN_ON (1 );print_hex_dump (KERN_DEBUG ,"[ in]: " ,DUMP_PREFIX_OFFSET ,16 ,1 , src + inputmargin, inlen, true);
fs/erofs/dir.c +10 -7
@@ -16,8 +16,8 @@ static void debug_one_dentry(unsigned char d_type, const char *de_name,memcpy (dbg_namebuf, de_name, de_namelen); dbg_namebuf[de_namelen] ='\0' ; -debugln ("found dirent %s de_len %u d_type %d" , dbg_namebuf, - de_namelen, d_type); +erofs_dbg ("found dirent %s de_len %u d_type %d" , dbg_namebuf, + de_namelen, d_type);#endif }
@@ -47,7 +47,8 @@ static int erofs_fill_dentries(struct inode *dir, struct dir_context *ctx,/* a corrupted entry is found */ if (nameoff + de_namelen > maxsize || de_namelen >EROFS_NAME_LEN ) { -errln ("bogus dirent @ nid %llu" ,EROFS_I (dir)->nid); +erofs_err (dir->i_sb,"bogus dirent @ nid %llu" , +EROFS_I (dir)->nid);DBG_BUGON (1 );return -EFSCORRUPTED ; }
@@ -84,8 +85,9 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx) err = -ENOMEM ;break ; }else if (IS_ERR (dentry_page)) { -errln ("fail to readdir of logical block %u of nid %llu" , - i,EROFS_I (dir)->nid); +erofs_err (dir->i_sb, +"fail to readdir of logical block %u of nid %llu" , + i,EROFS_I (dir)->nid); err = -EFSCORRUPTED ;break ; }
@@ -96,8 +98,9 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)if (nameoff <sizeof (struct erofs_dirent ) || nameoff >=PAGE_SIZE ) { -errln ("%s, invalid de[0].nameoff %u @ nid %llu" , - __func__, nameoff,EROFS_I (dir)->nid); +erofs_err (dir->i_sb, +"invalid de[0].nameoff %u @ nid %llu" , + nameoff,EROFS_I (dir)->nid); err = -EFSCORRUPTED ; goto skip_this; }
fs/erofs/inode.c +17 -14
@@ -22,8 +22,8 @@ static int erofs_read_inode(struct inode *inode, void *data) vi->datalayout =erofs_inode_datalayout (ifmt);if (vi->datalayout >=EROFS_INODE_DATALAYOUT_MAX ) { -errln ("unsupported datalayout %u of nid %llu" , - vi->datalayout, vi->nid); +erofs_err (inode->i_sb,"unsupported datalayout %u of nid %llu" , + vi->datalayout, vi->nid);DBG_BUGON (1 );return -EOPNOTSUPP ; }
@@ -108,8 +108,9 @@ static int erofs_read_inode(struct inode *inode, void *data) nblks =le32_to_cpu (dic->i_u.compressed_blocks);break ;default : -errln ("unsupported on-disk inode version %u of nid %llu" , -erofs_inode_version (ifmt), vi->nid); +erofs_err (inode->i_sb, +"unsupported on-disk inode version %u of nid %llu" , +erofs_inode_version (ifmt), vi->nid);DBG_BUGON (1 );return -EOPNOTSUPP ; }
@@ -122,7 +123,8 @@ static int erofs_read_inode(struct inode *inode, void *data)return 0 ; bogusimode: -errln ("bogus i_mode (%o) @ nid %llu" , inode->i_mode, vi->nid); +erofs_err (inode->i_sb,"bogus i_mode (%o) @ nid %llu" , + inode->i_mode, vi->nid);DBG_BUGON (1 );return -EFSCORRUPTED ; }
@@ -148,8 +150,9 @@ static int erofs_fill_symlink(struct inode *inode, void *data,/* inline symlink data shouldn't cross page boundary as well */ if (m_pofs + inode->i_size >PAGE_SIZE ) {kfree (lnk); -errln ("inline data cross block boundary @ nid %llu" , - vi->nid); +erofs_err (inode->i_sb, +"inline data cross block boundary @ nid %llu" , + vi->nid);DBG_BUGON (1 );return -EFSCORRUPTED ; }
@@ -164,7 +167,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,static int erofs_fill_inode (struct inode *inode,int isdir) { -struct erofs_sb_info *sbi =EROFS_SB (inode->i_sb); +struct super_block *sb = inode->i_sb;struct erofs_inode *vi =EROFS_I (inode);struct page *page;void *data;
@@ -174,18 +177,18 @@ static int erofs_fill_inode(struct inode *inode, int isdir)erofs_off_t inode_loc;trace_erofs_fill_inode (inode, isdir); - inode_loc =iloc (sbi, vi->nid); + inode_loc =iloc (EROFS_SB (sb), vi->nid); blkaddr =erofs_blknr (inode_loc); ofs =erofs_blkoff (inode_loc); -debugln ("%s, reading inode nid %llu at %u of blkaddr %u" , - __func__, vi->nid, ofs, blkaddr); +erofs_dbg ("%s, reading inode nid %llu at %u of blkaddr %u" , + __func__, vi->nid, ofs, blkaddr); - page =erofs_get_meta_page (inode->i_sb, blkaddr); + page =erofs_get_meta_page (sb, blkaddr);if (IS_ERR (page)) { -errln ("failed to get inode (nid: %llu) page, err %ld" , - vi->nid,PTR_ERR (page)); +erofs_err (sb,"failed to get inode (nid: %llu) page, err %ld" , + vi->nid,PTR_ERR (page));return PTR_ERR (page); }
fs/erofs/internal.h +10 -4
@@ -22,13 +22,19 @@#undef pr_fmt#define pr_fmt (fmt) "erofs: " fmt -#define errln (x, ...) pr_err(x "\n", ##__VA_ARGS__) -#define infoln (x, ...) pr_info(x "\n", ##__VA_ARGS__) +__printf(3, 4) void _erofs_err(struct super_block *sb, +const char *function,const char *fmt, ...); +#define erofs_err (sb, fmt, ...) \ + _erofs_err(sb, __func__, fmt "\n", ##__VA_ARGS__) +__printf(3, 4) void _erofs_info(struct super_block *sb, +const char *function,const char *fmt, ...); +#define erofs_info (sb, fmt, ...) \ + _erofs_info(sb, __func__, fmt "\n", ##__VA_ARGS__)#ifdef CONFIG_EROFS_FS_DEBUG -#define debugln (x, ...) pr_debug(x "\n", ##__VA_ARGS__) +#define erofs_dbg (x, ...) pr_debug(x "\n", ##__VA_ARGS__)#define DBG_BUGON BUG_ON#else -#define debugln (x, ...) ((void)0) +#define erofs_dbg (x, ...) ((void)0)#define DBG_BUGON (x) ((void)(x))#endif /* !CONFIG_EROFS_FS_DEBUG */
fs/erofs/namei.c +5 -4
@@ -116,8 +116,9 @@ static struct page *find_target_block_classic(struct inode *dir,if (!ndirents) {kunmap_atomic (de);put_page (page); -errln ("corrupted dir block %d @ nid %llu" , - mid,EROFS_I (dir)->nid); +erofs_err (dir->i_sb, +"corrupted dir block %d @ nid %llu" , + mid,EROFS_I (dir)->nid);DBG_BUGON (1 ); page =ERR_PTR (-EFSCORRUPTED ); goto out;
@@ -233,8 +234,8 @@ static struct dentry *erofs_lookup(struct inode *dir, }else if (err) { inode =ERR_PTR (err); }else { -debugln ("%s, %s (nid %llu) found, d_type %u" , __func__, - dentry->d_name.name, nid, d_type); +erofs_dbg ("%s, %s (nid %llu) found, d_type %u" , __func__, + dentry->d_name.name, nid, d_type); inode =erofs_iget (dir->i_sb, nid, d_type ==FT_DIR ); }return d_splice_alias (inode, dentry);
fs/erofs/super.c +55 -28
210 lines not on this page · raw message
fs/erofs/xattr.c +5 -3
@@ -67,13 +67,15 @@ static int init_inode_xattrs(struct inode *inode)* undefined right now (maybe use later with some new sb feature). */ if (vi->xattr_isize ==sizeof (struct erofs_xattr_ibody_header )) { -errln ("xattr_isize %d of nid %llu is not supported yet" , - vi->xattr_isize, vi->nid); +erofs_err (inode->i_sb, +"xattr_isize %d of nid %llu is not supported yet" , + vi->xattr_isize, vi->nid); ret = -EOPNOTSUPP ; goto out_unlock; }else if (vi->xattr_isize <sizeof (struct erofs_xattr_ibody_header )) {if (vi->xattr_isize) { -errln ("bogus xattr ibody @ nid %llu" , vi->nid); +erofs_err (inode->i_sb, +"bogus xattr ibody @ nid %llu" , vi->nid);DBG_BUGON (1 ); ret = -EFSCORRUPTED ; goto out_unlock;/* xattr ondisk layout error */
fs/erofs/zdata.c +7 -6
@@ -600,7 +600,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, }/* go ahead the next map_blocks */ -debugln ("%s: [out-of-range] pos %llu" , __func__, offset + cur); +erofs_dbg ("%s: [out-of-range] pos %llu" , __func__, offset + cur);if (z_erofs_collector_end (clt)) fe->backmost = false;
@@ -680,8 +680,8 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, out:z_erofs_onlinepage_endio (page); -debugln ("%s, finish page: %pK spiltted: %u map->m_llen %llu" , - __func__, page, spiltted, map->m_llen); +erofs_dbg ("%s, finish page: %pK spiltted: %u map->m_llen %llu" , + __func__, page, spiltted, map->m_llen);return err;/* if some error occurred while processing this page */
@@ -1340,7 +1340,7 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file,z_erofs_submit_and_unzip (inode->i_sb, &f.clt, &pagepool, true);if (err) -errln ("%s, failed to read, err [%d]" , __func__, err); +erofs_err (inode->i_sb,"failed to read, err [%d]" , err);if (f.map.mpage)put_page (f.map.mpage);
@@ -1406,8 +1406,9 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp, err =z_erofs_do_read_page (&f, page, &pagepool);if (err) -errln ("%s, readahead error at page %lu of nid %llu" , - __func__, page->index,EROFS_I (inode)->nid); +erofs_err (inode->i_sb, +"readahead error at page %lu @ nid %llu" , + page->index,EROFS_I (inode)->nid);put_page (page); }
fs/erofs/zdata.h +1 -1
@@ -182,7 +182,7 @@ static inline void z_erofs_onlinepage_endio(struct page *page)SetPageUptodate (page);unlock_page (page); } -debugln ("%s, page %p value %x" , __func__, page,atomic_read (u.o)); +erofs_dbg ("%s, page %p value %x" , __func__, page,atomic_read (u.o)); }#define Z_EROFS_VMAP_ONSTACK_PAGES \
fs/erofs/zmap.c +21 -16
@@ -64,8 +64,8 @@ static int fill_inode_lazy(struct inode *inode) vi->z_algorithmtype[1 ] = h->h_algorithmtype >>4 ;if (vi->z_algorithmtype[0 ] >=Z_EROFS_COMPRESSION_MAX ) { -errln ("unknown compression format %u for nid %llu, please upgrade kernel" , - vi->z_algorithmtype[0 ], vi->nid); +erofs_err (sb,"unknown compression format %u for nid %llu, please upgrade kernel" , + vi->z_algorithmtype[0 ], vi->nid); err = -EOPNOTSUPP ; goto unmap_done; }
@@ -75,8 +75,8 @@ static int fill_inode_lazy(struct inode *inode) ((h->h_clusterbits >>3 ) &3 );if (vi->z_physical_clusterbits[0 ] !=LOG_BLOCK_SIZE ) { -errln ("unsupported physical clusterbits %u for nid %llu, please upgrade kernel" , - vi->z_physical_clusterbits[0 ], vi->nid); +erofs_err (sb,"unsupported physical clusterbits %u for nid %llu, please upgrade kernel" , + vi->z_physical_clusterbits[0 ], vi->nid); err = -EOPNOTSUPP ; goto unmap_done; }
@@ -335,7 +335,8 @@ static int vle_extent_lookback(struct z_erofs_maprecorder *m,int err;if (lcn < lookback_distance) { -errln ("bogus lookback distance @ nid %llu" , vi->nid); +erofs_err (m->inode->i_sb, +"bogus lookback distance @ nid %llu" , vi->nid);DBG_BUGON (1 );return -EFSCORRUPTED ; }
@@ -349,8 +350,9 @@ static int vle_extent_lookback(struct z_erofs_maprecorder *m,switch (m->type) {case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD :if (!m->delta[0 ]) { -errln ("invalid lookback distance 0 at nid %llu" , - vi->nid); +erofs_err (m->inode->i_sb, +"invalid lookback distance 0 @ nid %llu" , + vi->nid);DBG_BUGON (1 );return -EFSCORRUPTED ; }
@@ -362,8 +364,9 @@ static int vle_extent_lookback(struct z_erofs_maprecorder *m, map->m_la = (lcn << lclusterbits) | m->clusterofs;break ;default : -errln ("unknown type %u at lcn %lu of nid %llu" , - m->type, lcn, vi->nid); +erofs_err (m->inode->i_sb, +"unknown type %u @ lcn %lu of nid %llu" , + m->type, lcn, vi->nid);DBG_BUGON (1 );return -EOPNOTSUPP ; }
@@ -421,8 +424,9 @@ int z_erofs_map_blocks_iter(struct inode *inode, }/* m.lcn should be >= 1 if endoff < m.clusterofs */ if (!m.lcn) { -errln ("invalid logical cluster 0 at nid %llu" , - vi->nid); +erofs_err (inode->i_sb, +"invalid logical cluster 0 at nid %llu" , + vi->nid); err = -EFSCORRUPTED ; goto unmap_out; }
@@ -437,8 +441,9 @@ int z_erofs_map_blocks_iter(struct inode *inode, goto unmap_out;break ;default : -errln ("unknown type %u at offset %llu of nid %llu" , - m.type, ofs, vi->nid); +erofs_err (inode->i_sb, +"unknown type %u @ offset %llu of nid %llu" , + m.type, ofs, vi->nid); err = -EOPNOTSUPP ; goto unmap_out; }
@@ -453,9 +458,9 @@ int z_erofs_map_blocks_iter(struct inode *inode,kunmap_atomic (m.kaddr); out: -debugln ("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o" , - __func__, map->m_la, map->m_pa, - map->m_llen, map->m_plen, map->m_flags); +erofs_dbg ("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o" , + __func__, map->m_la, map->m_pa, + map->m_llen, map->m_plen, map->m_flags);trace_z_erofs_map_blocks_iter_exit (inode, map, flags, err);
Signature · 1 line
2.17.1
PATCH v2 23/25 erofs: use read_mapping_page instead of sb_bread
In reply to Gao XiangAs Christoph said [1], "This seems to be your only direct use of buffer heads, which while not deprecated are a bit of an ugly step child. So if you can easily avoid creating a buffer_head dependency in a new filesystem I think you should avoid it. "
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/super.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
fs/erofs/super.c +9 -6
@@ -98,20 +98,22 @@ static bool check_layout_compatibility(struct super_block *sb,static int erofs_read_superblock (struct super_block *sb) {struct erofs_sb_info *sbi; -struct buffer_head *bh; +struct page *page;struct erofs_super_block *dsb;unsigned int blkszbits; +void *data;int ret; - bh =sb_bread (sb,0 ); - -if (!bh) { + page =read_mapping_page (sb->s_bdev->bd_inode->i_mapping,0 ,NULL ); +if (!page) {erofs_err (sb,"cannot read erofs superblock" );return -EIO ; } sbi =EROFS_SB (sb); - dsb = (struct erofs_super_block *)(bh->b_data +EROFS_SUPER_OFFSET ); + + data =kmap_atomic (page); + dsb = (struct erofs_super_block *)(data +EROFS_SUPER_OFFSET ); ret = -EINVAL ;if (le32_to_cpu (dsb->magic) !=EROFS_SUPER_MAGIC_V1 ) {
@@ -153,7 +155,8 @@ static int erofs_read_superblock(struct super_block *sb) } ret =0 ; out: -brelse (bh); +kunmap_atomic (data); +put_page (page);return ret; }
Signature · 1 line
2.17.1
PATCH v2 24/25 erofs: always use iget5_locked
In reply to Gao XiangAs Christoph said [1] [2], "Just use the slightly more complicated 32-bit version everywhere so that you have a single actually tested code path. And then remove this helper. "
[1] https://lore.kernel.org/r/[email protected]/
[2] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/inode.c | 7 ------- 1 file changed, 7 deletions(-)
fs/erofs/inode.c +0 -7
@@ -243,7 +243,6 @@ static int erofs_fill_inode(struct inode *inode, int isdir)* erofs nid is 64bits, but i_ino is 'unsigned long', therefore * we should do more for 32-bit platform to find the right inode. */ -#if BITS_PER_LONG ==32 static int erofs_ilookup_test_actor (struct inode *inode,void *opaque) {const erofs_nid_t nid = *(erofs_nid_t *)opaque;
@@ -258,20 +257,14 @@ static int erofs_iget_set_actor(struct inode *inode, void *opaque) inode->i_ino =erofs_inode_hash (nid);return 0 ; } -#endif static inline struct inode *erofs_iget_locked (struct super_block *sb,erofs_nid_t nid) {const unsigned long hashval =erofs_inode_hash (nid); -#if BITS_PER_LONG >=64 -/* it is safe to use iget_locked for >= 64-bit platform */ -return iget_locked (sb, hashval); -#else return iget5_locked (sb, hashval, erofs_ilookup_test_actor, erofs_iget_set_actor, &nid); -#endif } struct inode *erofs_iget(struct super_block *sb,
Signature · 1 line
2.17.1
PATCH v2 25/25 erofs: use read_cache_page_gfp for erofs_get_meta_page
In reply to Gao XiangAs Christoph said [1], "I'd much prefer to just use read_cache_page_gfp, and live with the fact that this allocates bufferheads behind you for now. I'll try to speed up my attempts to get rid of the buffer heads on the block device mapping instead. "
This simplifies the code a lot and a minor thing is "no REQ_META (e.g. for blktrace) on metadata at all..."
[1] https://lore.kernel.org/r/[email protected]/
--- fs/erofs/data.c | 70 +++++++------------------------------------------ 1 file changed, 9 insertions(+), 61 deletions(-)
fs/erofs/data.c +9 -61
@@ -32,71 +32,13 @@ static void erofs_readendio(struct bio *bio)bio_put (bio); } -static struct bio *erofs_grab_raw_bio (struct super_block *sb, -erofs_blk_t blkaddr, -unsigned int nr_pages, -bool ismeta) -{ -struct bio *bio =bio_alloc (GFP_NOIO , nr_pages); - - bio->bi_end_io = erofs_readendio; -bio_set_dev (bio, sb->s_bdev); - bio->bi_iter.bi_sector = (sector_t )blkaddr <<LOG_SECTORS_PER_BLOCK ; -if (ismeta) - bio->bi_opf =REQ_OP_READ |REQ_META ; -else - bio->bi_opf =REQ_OP_READ ; - -return bio; -} -struct page *erofs_get_meta_page (struct super_block *sb,erofs_blk_t blkaddr) {struct inode *const bd_inode = sb->s_bdev->bd_inode;struct address_space *const mapping = bd_inode->i_mapping; -const gfp_t gfp =mapping_gfp_constraint (mapping, ~__GFP_FS); -struct page *page; -int err; - -repeat: - page =find_or_create_page (mapping, blkaddr, gfp); -if (!page) -return ERR_PTR (-ENOMEM ); - -DBG_BUGON (!PageLocked (page)); - -if (!PageUptodate (page)) { -struct bio *bio; - - bio =erofs_grab_raw_bio (sb, blkaddr,1 , true); - -if (bio_add_page (bio, page,PAGE_SIZE ,0 ) !=PAGE_SIZE ) { - err = -EFAULT ; - goto err_out; - } - -submit_bio (bio); -lock_page (page); -/* this page has been truncated by others */ -if (page->mapping != mapping) { -unlock_page (page); -put_page (page); - goto repeat; - } - -/* more likely a read error */ -if (!PageUptodate (page)) { - err = -EIO ; - goto err_out; - } - } -return page; - -err_out: -unlock_page (page); -put_page (page); -return ERR_PTR (err); +return read_cache_page_gfp (mapping, blkaddr, +mapping_gfp_constraint (mapping, ~__GFP_FS)); } static int erofs_map_blocks_flatmode(struct inode *inode,
@@ -272,7 +214,13 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,if (nblocks >BIO_MAX_PAGES ) nblocks =BIO_MAX_PAGES ; - bio =erofs_grab_raw_bio (sb, blknr, nblocks, false); + bio =bio_alloc (GFP_NOIO , nblocks); + + bio->bi_end_io = erofs_readendio; +bio_set_dev (bio, sb->s_bdev); + bio->bi_iter.bi_sector = (sector_t )blknr << +LOG_SECTORS_PER_BLOCK ; + bio->bi_opf =REQ_OP_READ ; } err =bio_add_page (bio, page,PAGE_SIZE ,0 );
Signature · 1 line
2.17.1
Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments
In reply to Gao XiangQuoted 9 lines · Gao Xiang
Hi,
This patchset is based on the following patch by Pratik Shinde,
https://lore.kernel.org/linux-erofs/[email protected]/All patches addressing Christoph's comments on v6, which are trivial, most deleted code are from erofs specific fault injection, which was followed f2fs and previously discussed in earlier topic [1], but let's follow what Christoph's said now.
Thanks,
Quoted 65 lines
Comments and suggestions are welcome...
[1] https://lore.kernel.org/r/[email protected]/
changes since v1:
- leave some comments near the numbers to indicate where they are stored;
- avoid a u8 cast;
- use erofs_{err,info,dbg} and printsb->s_idas a prefix before the actual message;
- add a on-disk title inerofs_fs.h
- use feature_{compat,incompat} rather than features and requirements;
- suggestions onerofs_grab_bio:https://lore.kernel.org/r/[email protected]/- use compact/extended instead of erofs_inode_v1/v2 and
i_formatinstead ofi_advise;
- avoid chained if/else if/else if statements inerofs_read_inode;
- avoid erofs_vmap/vunmap wrappers;
- useread_cache_page_gfpforerofs_get_meta_page;Gao Xiang (25):
erofs: remove all the byte offset comments
erofs: on-disk format should have explicitly assigned numbers
erofs: some macros are much more readable as a function
erofs: kill__packedfor on-disk structures
erofs: updateerofs_inode_is_data_compressedhelper
erofs: usefeature_incompatrather than requirements
erofs: better naming for erofs inode related stuffs
erofs: kill erofs_{init,exit}_inode_cache
erofs: useerofs_inodenaming
erofs: updateerofs_fs.hcomments
erofs: update comments ininode.c
erofs: better erofs symlink stuffs
erofs: use dsb instead of layout for ondisksuper_block
erofs: kill verbose debug info inerofs_fill_super
erofs: localizeerofs_grab_bio()
erofs: kill prio and nofail oferofs_get_meta_page()
erofs: kill__submit_bio()
erofs: add "erofs_" prefix for common and short functions
erofs: kill all erofs specific fault injection
erofs: killuse_vmapmodule parameter
erofs: save one level of indentation
erofs: rename errln/infoln/debugln to erofs_{err,info,dbg}
erofs: useread_mapping_pageinstead ofsb_bread
erofs: always useiget5_locked
erofs: useread_cache_page_gfpforerofs_get_meta_pageDocumentation/filesystems/erofs.txt | 9 - fs/erofs/Kconfig | 7 - fs/erofs/data.c | 118 +++-------- fs/erofs/decompressor.c | 76 +++---- fs/erofs/dir.c | 17 +- fs/erofs/erofs_fs.h | 197 +++++++++--------- fs/erofs/inode.c | 297 ++++++++++++++-------------- fs/erofs/internal.h | 192 ++++-------------- fs/erofs/namei.c | 21 +- fs/erofs/super.c | 282 +++++++++++--------------- fs/erofs/xattr.c | 41 ++-- fs/erofs/xattr.h | 4 +- fs/erofs/zdata.c | 63 +++--- fs/erofs/zdata.h | 2 +- fs/erofs/zmap.c | 73 +++---- include/trace/events/erofs.h | 14 +- 16 files changed, 578 insertions(+), 835 deletions(-)
Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments
Hi Christoph,
Quoted 6 lines · Chao Yu
Quoted 5 lines · Gao Xiang
Hi,
This patchset is based on the following patch by Pratik Shinde,
https://lore.kernel.org/linux-erofs/[email protected]/
Quoted 8 lines
Quoted 4 lines
All patches addressing Christoph's comments on v6, which are trivial, most deleted code are from erofs specific fault injection, which was followed f2fs and previously discussed in earlier topic [1], but let's follow what Christoph's said now.
Reviewed-by Chao Yu <[email protected]>Thanks,
Could we submit these patches if these patches look good... Since I'd like to work based on these patches, it makes a difference to the current code though...
Thanks a lot!
Thanks,
Gao Xiang
Quoted 70 lines
Quoted 57 lines
Comments and suggestions are welcome...
[1] https://lore.kernel.org/r/[email protected]/
changes since v1:
- leave some comments near the numbers to indicate where they are stored;
- avoid a u8 cast;
- use erofs_{err,info,dbg} and printsb->s_idas a prefix before the actual message;
- add a on-disk title inerofs_fs.h
- use feature_{compat,incompat} rather than features and requirements;
- suggestions onerofs_grab_bio:https://lore.kernel.org/r/[email protected]/- use compact/extended instead of erofs_inode_v1/v2 and
i_formatinstead ofi_advise;
- avoid chained if/else if/else if statements inerofs_read_inode;
- avoid erofs_vmap/vunmap wrappers;
- useread_cache_page_gfpforerofs_get_meta_page;Gao Xiang (25):
erofs: remove all the byte offset comments
erofs: on-disk format should have explicitly assigned numbers
erofs: some macros are much more readable as a function
erofs: kill__packedfor on-disk structures
erofs: updateerofs_inode_is_data_compressedhelper
erofs: usefeature_incompatrather than requirements
erofs: better naming for erofs inode related stuffs
erofs: kill erofs_{init,exit}_inode_cache
erofs: useerofs_inodenaming
erofs: updateerofs_fs.hcomments
erofs: update comments ininode.c
erofs: better erofs symlink stuffs
erofs: use dsb instead of layout for ondisksuper_block
erofs: kill verbose debug info inerofs_fill_super
erofs: localizeerofs_grab_bio()
erofs: kill prio and nofail oferofs_get_meta_page()
erofs: kill__submit_bio()
erofs: add "erofs_" prefix for common and short functions
erofs: kill all erofs specific fault injection
erofs: killuse_vmapmodule parameter
erofs: save one level of indentation
erofs: rename errln/infoln/debugln to erofs_{err,info,dbg}
erofs: useread_mapping_pageinstead ofsb_bread
erofs: always useiget5_locked
erofs: useread_cache_page_gfpforerofs_get_meta_pageDocumentation/filesystems/erofs.txt | 9 - fs/erofs/Kconfig | 7 - fs/erofs/data.c | 118 +++-------- fs/erofs/decompressor.c | 76 +++---- fs/erofs/dir.c | 17 +- fs/erofs/erofs_fs.h | 197 +++++++++--------- fs/erofs/inode.c | 297 ++++++++++++++-------------- fs/erofs/internal.h | 192 ++++-------------- fs/erofs/namei.c | 21 +-Quoted 9 lines
fs/erofs/super.c | 282 +++++++++++--------------- fs/erofs/xattr.c | 41 ++-- fs/erofs/xattr.h | 4 +- fs/erofs/zdata.c | 63 +++--- fs/erofs/zdata.h | 2 +- fs/erofs/zmap.c | 73 +++---- include/trace/events/erofs.h | 14 +- 16 files changed, 578 insertions(+), 835 deletions(-)_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments
Quoted 3 lines · Gao Xiang
Could we submit these patches if these patches look good... Since I'd like to work based on these patches, it makes a difference to the current code though...
Yes, I'm fine with these patches.
Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments
In reply to Gao XiangQuoted 11 lines · Gao Xiang
Hi,
This patchset is based on the following patch by Pratik Shinde,
https://lore.kernel.org/linux-erofs/[email protected]/All patches addressing Christoph's comments on v6, which are trivial, most deleted code are from erofs specific fault injection, which was followed f2fs and previously discussed in earlier topic [1], but let's follow what Christoph's said now.
Comments and suggestions are welcome...
Do you have a git branch available somewhere containing the state with all these patches applied?
Re: [PATCH v2 00/25] erofs: patchset addressing Christoph's comments
Hi Christoph,
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Gao Xiang
Hi,
This patchset is based on the following patch by Pratik Shinde,
https://lore.kernel.org/linux-erofs/[email protected]/All patches addressing Christoph's comments on v6, which are trivial, most deleted code are from erofs specific fault injection, which was followed f2fs and previously discussed in earlier topic [1], but let's follow what Christoph's said now.
Quoted 4 lines
Quoted 1 line
Comments and suggestions are welcome...
Do you have a git branch available somewhere containing the state with all these patches applied?
here you are...git://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git -b erofs-experimental
Thanks,
Gao Xiang