staging: erofs: support statx
PATCH 1/2 staging: erofs: support statx
statx() has already been supported in commit a528d35e8bfc ("statx: Add a system call to make enhanced file info available"), user programs can get more useful attributes.
--- drivers/staging/erofs/inode.c | 18 ++++++++++++++++++ drivers/staging/erofs/internal.h | 2 ++ drivers/staging/erofs/namei.c | 1 + 3 files changed, 21 insertions(+)
drivers/staging/erofs/inode.c +18 -0
@@ -285,7 +285,23 @@ struct inode *erofs_iget(struct super_block *sb,return inode; } +int erofs_getattr (const struct path *path,struct kstat *stat, +u32 request_mask,unsigned int query_flags) +{ +struct inode *const inode =d_inode (path->dentry); +struct erofs_vnode *const vi =EROFS_V (inode); + +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + stat->attributes |=STATX_ATTR_COMPRESSED ; + + stat->attributes |=STATX_ATTR_IMMUTABLE ; + +generic_fillattr (inode, stat); +return 0 ; +} +const struct inode_operations erofs_generic_iops = { + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
@@ -294,6 +310,7 @@ const struct inode_operations erofs_generic_iops = {const struct inode_operations erofs_symlink_iops = { .get_link = page_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
@@ -302,6 +319,7 @@ const struct inode_operations erofs_symlink_iops = {const struct inode_operations erofs_fast_symlink_iops = { .get_link = simple_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
drivers/staging/erofs/internal.h +2 -0
@@ -556,6 +556,8 @@ static inline bool is_inode_fast_symlink(struct inode *inode) }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);/* namei.c */ extern const struct inode_operations erofs_dir_iops;
drivers/staging/erofs/namei.c +1 -0
@@ -247,6 +247,7 @@ static struct dentry *erofs_lookup(struct inode *dir,const struct inode_operations erofs_dir_iops = { .lookup = erofs_lookup, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
Signature · 1 line
2.17.1
PATCH 2/2 staging: erofs: fix i_blocks calculation
For compressed files, i_blocks should not be calculated by using i_size. i_u.compressed_blocks is used instead.
In addition, i_blocks is miscalculated for non-compressed files previously, fix it as well.
--- drivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/staging/erofs/inode.c +12 -2
@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);
@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v2->i_u.compressed_blocks; }else if (__inode_version (advise) ==EROFS_INODE_LAYOUT_V1 ) {struct erofs_sb_info *sbi =EROFS_SB (inode->i_sb);
@@ -90,6 +95,8 @@ static int read_inode(struct inode *inode, void *data) sbi->build_time_nsec; inode->i_size =le32_to_cpu (v1->i_size); +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v1->i_u.compressed_blocks; }else {errln ("unsupported on-disk inode version %u of nid %llu" ,__inode_version (advise), vi->nid);
@@ -97,8 +104,11 @@ static int read_inode(struct inode *inode, void *data)return -EIO ; } -/* measure inode.i_blocks as the generic filesystem */ - inode->i_blocks = ((inode->i_size -1 ) >>9 ) +1 ; +if (!nblks) +/* measure inode.i_blocks as generic filesystems */ + inode->i_blocks =roundup (inode->i_size,EROFS_BLKSIZ ) >>9 ; +else + inode->i_blocks = nblks >>LOG_SECTORS_PER_BLOCK ;return 0 ; }
Signature · 1 line
2.17.1
PATCH v2 2/2 staging: erofs: fix i_blocks calculation
For compressed files, i_blocks should not be calculated by using i_size. i_u.compressed_blocks is used instead.
In addition, i_blocks was miscalculated for non-compressed files previously, fix it as well.
---
change log v2:
- fix description in commit message
- fix to 'inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK'
Thanks,
Gao Xiang
drivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/staging/erofs/inode.c +12 -2
@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);
@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v2->i_u.compressed_blocks; }else if (__inode_version (advise) ==EROFS_INODE_LAYOUT_V1 ) {struct erofs_sb_info *sbi =EROFS_SB (inode->i_sb);
@@ -90,6 +95,8 @@ static int read_inode(struct inode *inode, void *data) sbi->build_time_nsec; inode->i_size =le32_to_cpu (v1->i_size); +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v1->i_u.compressed_blocks; }else {errln ("unsupported on-disk inode version %u of nid %llu" ,__inode_version (advise), vi->nid);
@@ -97,8 +104,11 @@ static int read_inode(struct inode *inode, void *data)return -EIO ; } -/* measure inode.i_blocks as the generic filesystem */ - inode->i_blocks = ((inode->i_size -1 ) >>9 ) +1 ; +if (!nblks) +/* measure inode.i_blocks as generic filesystems */ + inode->i_blocks =roundup (inode->i_size,EROFS_BLKSIZ ) >>9 ; +else + inode->i_blocks = nblks <<LOG_SECTORS_PER_BLOCK ;return 0 ; }
Signature · 1 line
2.17.1
Re: [PATCH v2 2/2] staging: erofs: fix i_blocks calculation
Quoted 31 lines · Gao Xiang
For compressed files,
i_blocksshould not be calculated by usingi_size. i_u.compressed_blocks is used instead.In addition,
i_blockswas miscalculated for non-compressed files previously, fix it as well.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>---
change log v2:
- fix description in commit message
- fix to 'inode->i_blocks= nblks <<LOG_SECTORS_PER_BLOCK'Thanks,
Gao Xiangdrivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/staging/erofs/inode.c +1
-0@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);
drivers/staging/erofs/inode.c static int read_inode(struct inode *inode, void *data) · line 67
Quoted 7 lines
drivers/staging/erofs/inode.c +4
-0@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v2->i_u.compressed_blocks;
Xiang,
It needs to use le32_to_cpu(). ;)
drivers/staging/erofs/inode.c static int read_inode(struct inode *inode, void *data) · line 99
Quoted 9 lines
drivers/staging/erofs/inode.c +2
-0}else if (__inode_version (advise) ==EROFS_INODE_LAYOUT_V1 ) {struct erofs_sb_info *sbi =EROFS_SB (inode->i_sb);@@ -90,6 +95,8 @@ static int read_inode(struct inode *inode, void *data) sbi->build_time_nsec; inode->i_size =le32_to_cpu (v1->i_size); +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v1->i_u.compressed_blocks;
Ditto.
Thanks,
Quoted 18 lines
drivers/staging/erofs/inode.c +5
-2}else {errln ("unsupported on-disk inode version %u of nid %llu" ,__inode_version (advise), vi->nid);@@ -97,8 +104,11 @@ static int read_inode(struct inode *inode, void *data)return -EIO ; } -/* measure inode.i_blocks as the generic filesystem */ - inode->i_blocks = ((inode->i_size -1 ) >>9 ) +1 ; +if (!nblks) +/* measure inode.i_blocks as generic filesystems */ + inode->i_blocks =roundup (inode->i_size,EROFS_BLKSIZ ) >>9 ; +else + inode->i_blocks = nblks <<LOG_SECTORS_PER_BLOCK ;return 0 ; }
Re: [PATCH v2 2/2] staging: erofs: fix i_blocks calculation
Quoted 42 lines · Chao Yu
Quoted 31 lines · Gao Xiang
For compressed files,
i_blocksshould not be calculated by usingi_size. i_u.compressed_blocks is used instead.In addition,
i_blockswas miscalculated for non-compressed files previously, fix it as well.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>---
change log v2:
- fix description in commit message
- fix to 'inode->i_blocks= nblks <<LOG_SECTORS_PER_BLOCK'Thanks,
Gao Xiangdrivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/staging/erofs/inode.c +1
-0@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);drivers/staging/erofs/inode.c static int read_inode(struct inode *inode, void *data) · line 67
Quoted 7 lines
drivers/staging/erofs/inode.c +4
-0@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v2->i_u.compressed_blocks;Xiang,
Quoted 1 line
It needs to use
le32_to_cpu(). ;)
Already fixed in v3... Sorry about that...
Thanks,
Gao Xiang
Quoted 33 lines
drivers/staging/erofs/inode.c static int read_inode(struct inode *inode, void *data) · line 99
Quoted 10 lines
drivers/staging/erofs/inode.c +2
-0}else if (__inode_version (advise) ==EROFS_INODE_LAYOUT_V1 ) {struct erofs_sb_info *sbi =EROFS_SB (inode->i_sb);@@ -90,6 +95,8 @@ static int read_inode(struct inode *inode, void *data) sbi->build_time_nsec; inode->i_size =le32_to_cpu (v1->i_size); +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v1->i_u.compressed_blocks;Ditto.
Thanks,
Quoted 18 lines
drivers/staging/erofs/inode.c +5
-2}else {errln ("unsupported on-disk inode version %u of nid %llu" ,__inode_version (advise), vi->nid);@@ -97,8 +104,11 @@ static int read_inode(struct inode *inode, void *data)return -EIO ; } -/* measure inode.i_blocks as the generic filesystem */ - inode->i_blocks = ((inode->i_size -1 ) >>9 ) +1 ; +if (!nblks) +/* measure inode.i_blocks as generic filesystems */ + inode->i_blocks =roundup (inode->i_size,EROFS_BLKSIZ ) >>9 ; +else + inode->i_blocks = nblks <<LOG_SECTORS_PER_BLOCK ;return 0 ; }
Re: [PATCH v2 2/2] staging: erofs: fix i_blocks calculation
In reply to Chao YuQuoted 42 lines · Chao Yu
Quoted 31 lines · Gao Xiang
For compressed files,
i_blocksshould not be calculated by usingi_size. i_u.compressed_blocks is used instead.In addition,
i_blockswas miscalculated for non-compressed files previously, fix it as well.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>---
change log v2:
- fix description in commit message
- fix to 'inode->i_blocks= nblks <<LOG_SECTORS_PER_BLOCK'Thanks,
Gao Xiangdrivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/staging/erofs/inode.c +1
-0@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);drivers/staging/erofs/inode.c static int read_inode(struct inode *inode, void *data) · line 67
Quoted 7 lines
drivers/staging/erofs/inode.c +4
-0@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v2->i_u.compressed_blocks;Xiang,
Quoted 2 lines
It needs to use
le32_to_cpu(). ;)
I wonder it the kbuild bot is going to send an email about that... Hopefully these sorts of bugs get detected with Sparse CF=-D__CHECK_ENDIAN__
regards,
dan carpenter
Re: [PATCH v2 2/2] staging: erofs: fix i_blocks calculation
Hi Dan,
Quoted 43 lines · Dan Carpenter
Quoted 42 lines · Chao Yu
Quoted 31 lines · Gao Xiang
For compressed files,
i_blocksshould not be calculated by usingi_size. i_u.compressed_blocks is used instead.In addition,
i_blockswas miscalculated for non-compressed files previously, fix it as well.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>---
change log v2:
- fix description in commit message
- fix to 'inode->i_blocks= nblks <<LOG_SECTORS_PER_BLOCK'Thanks,
Gao Xiangdrivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/staging/erofs/inode.c +1
-0@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);drivers/staging/erofs/inode.c static int read_inode(struct inode *inode, void *data) · line 67
Quoted 7 lines
drivers/staging/erofs/inode.c +4
-0@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v2->i_u.compressed_blocks;Xiang,
Quoted 4 lines
Quoted 2 lines
It needs to use
le32_to_cpu(). ;)I wonder it the kbuild bot is going to send an email about that...
Not yet, and v3 fixes it. I have no idea whether kbuild checks all version or just the latest version...
Quoted 1 line
Hopefully these sorts of bugs get detected with Sparse CF=-D__CHECK_ENDIAN__
Yes, I missed this case by mistake.
These two patches are small, I didn't do too many static checking expect for checkpatch.pl. v3 seems fine and I will take care later, Thanks for kindly suggestion. :)
Thanks,
Gao Xiang
Quoted 4 lines
regards,
dan carpenter
Re: [PATCH v2 2/2] staging: erofs: fix i_blocks calculation
In reply to Dan CarpenterQuoted 43 lines · Dan Carpenter
Quoted 42 lines · Chao Yu
Quoted 31 lines · Gao Xiang
For compressed files,
i_blocksshould not be calculated by usingi_size. i_u.compressed_blocks is used instead.In addition,
i_blockswas miscalculated for non-compressed files previously, fix it as well.Signed-off-by Gao Xiang <[email protected]>---
change log v2:
- fix description in commit message
- fix to 'inode->i_blocks= nblks <<LOG_SECTORS_PER_BLOCK'Thanks,
Gao Xiangdrivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/staging/erofs/inode.c +1
-0@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);drivers/staging/erofs/inode.c static int read_inode(struct inode *inode, void *data) · line 67
Quoted 7 lines
drivers/staging/erofs/inode.c +4
-0@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks = v2->i_u.compressed_blocks;Xiang,
Quoted 4 lines
Quoted 2 lines
It needs to use
le32_to_cpu(). ;)I wonder it the kbuild bot is going to send an email about that...
0-day may do this a little later.
Quoted 1 line
Hopefully these sorts of bugs get detected with Sparse CF=-D__CHECK_ENDIAN__
Thanks, Dan, let's use this sparse flag more frequently to avoid such issue.
Thanks,
Quoted 6 lines
regards,
dan carpenter.
PATCH v3 1/2 staging: erofs: support statx
In reply to Gao Xiangstatx() has already been supported in commit a528d35e8bfc ("statx: Add a system call to make enhanced file info available"), user programs can get more useful attributes.
---
change log v3:
- update attributes_mask to indicate bits which erofs support as Chao pointed out;
- already tested with samples/vfs/test-statx.c;
Thanks,
Gao Xiang
drivers/staging/erofs/inode.c | 20 ++++++++++++++++++++ drivers/staging/erofs/internal.h | 2 ++ drivers/staging/erofs/namei.c | 1 + 3 files changed, 23 insertions(+)
drivers/staging/erofs/inode.c +20 -0
@@ -285,7 +285,25 @@ struct inode *erofs_iget(struct super_block *sb,return inode; } +int erofs_getattr (const struct path *path,struct kstat *stat, +u32 request_mask,unsigned int query_flags) +{ +struct inode *const inode =d_inode (path->dentry); +struct erofs_vnode *const vi =EROFS_V (inode); + +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + stat->attributes |=STATX_ATTR_COMPRESSED ; + + stat->attributes |=STATX_ATTR_IMMUTABLE ; + stat->attributes_mask |= (STATX_ATTR_COMPRESSED | +STATX_ATTR_IMMUTABLE ); + +generic_fillattr (inode, stat); +return 0 ; +} +const struct inode_operations erofs_generic_iops = { + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
@@ -294,6 +312,7 @@ const struct inode_operations erofs_generic_iops = {const struct inode_operations erofs_symlink_iops = { .get_link = page_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
@@ -302,6 +321,7 @@ const struct inode_operations erofs_symlink_iops = {const struct inode_operations erofs_fast_symlink_iops = { .get_link = simple_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
drivers/staging/erofs/internal.h +2 -0
@@ -556,6 +556,8 @@ static inline bool is_inode_fast_symlink(struct inode *inode) }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);/* namei.c */ extern const struct inode_operations erofs_dir_iops;
drivers/staging/erofs/namei.c +1 -0
@@ -247,6 +247,7 @@ static struct dentry *erofs_lookup(struct inode *dir,const struct inode_operations erofs_dir_iops = { .lookup = erofs_lookup, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
Signature · 1 line
2.17.1
PATCH v3 2/2 staging: erofs: fix i_blocks calculation
For compressed files, i_blocks should not be calculated by using i_size. use i_u.compressed_blocks instead.
In addition, i_blocks was miscalculated for non-compressed files previously, fix it as well.
---
change log v3:
- wrap i.u.compressed_blocks with le32_to_cpu() as Chao pointed out;
change log v2:
- fix description in commit message;
- fix to 'inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK'.
Thanks,
Gao Xiang
drivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/staging/erofs/inode.c +12 -2
@@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data)struct erofs_vnode *vi =EROFS_V (inode);struct erofs_inode_v1 *v1 = data;const unsigned int advise =le16_to_cpu (v1->i_advise); +erofs_blk_t nblks =0 ; vi->data_mapping_mode =__inode_data_mapping (advise);
@@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data)le32_to_cpu (v2->i_ctime_nsec); inode->i_size =le64_to_cpu (v2->i_size); + +/* total blocks for compressed files */ +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks =le32_to_cpu (v2->i_u.compressed_blocks); }else if (__inode_version (advise) ==EROFS_INODE_LAYOUT_V1 ) {struct erofs_sb_info *sbi =EROFS_SB (inode->i_sb);
@@ -90,6 +95,8 @@ static int read_inode(struct inode *inode, void *data) sbi->build_time_nsec; inode->i_size =le32_to_cpu (v1->i_size); +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + nblks =le32_to_cpu (v1->i_u.compressed_blocks); }else {errln ("unsupported on-disk inode version %u of nid %llu" ,__inode_version (advise), vi->nid);
@@ -97,8 +104,11 @@ static int read_inode(struct inode *inode, void *data)return -EIO ; } -/* measure inode.i_blocks as the generic filesystem */ - inode->i_blocks = ((inode->i_size -1 ) >>9 ) +1 ; +if (!nblks) +/* measure inode.i_blocks as generic filesystems */ + inode->i_blocks =roundup (inode->i_size,EROFS_BLKSIZ ) >>9 ; +else + inode->i_blocks = nblks <<LOG_SECTORS_PER_BLOCK ;return 0 ; }
Signature · 1 line
2.17.1
Re: [PATCH v3 2/2] staging: erofs: fix i_blocks calculation
Quoted 7 lines · Gao Xiang
For compressed files,
i_blocksshould not be calculated by usingi_size. use i_u.compressed_blocks instead.In addition,
i_blockswas miscalculated for non-compressed files previously, fix it as well.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Thanks,
Quoted 5 lines · Gao Xiang
statx()has already been supported in commita528d35e8bfc("statx: Add a system call to make enhanced file info available"), user programs can get more useful attributes.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Thanks,
Quoted 19 lines · Gao Xiang
statx()has already been supported in commita528d35e8bfc("statx: Add a system call to make enhanced file info available"), user programs can get more useful attributes.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>--- drivers/staging/erofs/inode.c | 18 ++++++++++++++++++ drivers/staging/erofs/internal.h | 2 ++ drivers/staging/erofs/namei.c | 1 + 3 files changed, 21 insertions(+)drivers/staging/erofs/inode.c +0
-0@@ -285,7 +285,23 @@ struct inode *erofs_iget(struct super_block *sb,return inode; }
drivers/staging/erofs/inode.c struct inode *erofs_iget(struct super_block *sb, · line 297
Quoted 10 lines
drivers/staging/erofs/inode.c +10
-0+int erofs_getattr (const struct path *path,struct kstat *stat, +u32 request_mask,unsigned int query_flags) +{ +struct inode *const inode =d_inode (path->dentry); +struct erofs_vnode *const vi =EROFS_V (inode); + +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + stat->attributes |=STATX_ATTR_COMPRESSED ; + + stat->attributes |=STATX_ATTR_IMMUTABLE ;
Xiang,
Should update stat->attributes_mask as well to indicate all erofs supported attributes bits.
Thanks,
Quoted 52 lines
drivers/staging/erofs/inode.c +8
-0+ +generic_fillattr (inode, stat); +return 0 ; +} +const struct inode_operations erofs_generic_iops = { + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif@@ -294,6 +310,7 @@ const struct inode_operations erofs_generic_iops = {const struct inode_operations erofs_symlink_iops = { .get_link = page_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif@@ -302,6 +319,7 @@ const struct inode_operations erofs_symlink_iops = {const struct inode_operations erofs_fast_symlink_iops = { .get_link = simple_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endifdrivers/staging/erofs/internal.h +2
-0@@ -556,6 +556,8 @@ static inline bool is_inode_fast_symlink(struct inode *inode) }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);/* namei.c */ extern const struct inode_operations erofs_dir_iops;drivers/staging/erofs/namei.c +1
-0@@ -247,6 +247,7 @@ static struct dentry *erofs_lookup(struct inode *dir,const struct inode_operations erofs_dir_iops = { .lookup = erofs_lookup, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
Hi Chao,
Quoted 33 lines · Chao Yu
Quoted 19 lines · Gao Xiang
statx()has already been supported in commita528d35e8bfc("statx: Add a system call to make enhanced file info available"), user programs can get more useful attributes.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>--- drivers/staging/erofs/inode.c | 18 ++++++++++++++++++ drivers/staging/erofs/internal.h | 2 ++ drivers/staging/erofs/namei.c | 1 + 3 files changed, 21 insertions(+)drivers/staging/erofs/inode.c +0
-0@@ -285,7 +285,23 @@ struct inode *erofs_iget(struct super_block *sb,return inode; }drivers/staging/erofs/inode.c struct inode *erofs_iget(struct super_block *sb, · line 297
Quoted 10 lines
drivers/staging/erofs/inode.c +10
-0+int erofs_getattr (const struct path *path,struct kstat *stat, +u32 request_mask,unsigned int query_flags) +{ +struct inode *const inode =d_inode (path->dentry); +struct erofs_vnode *const vi =EROFS_V (inode); + +if (vi->data_mapping_mode ==EROFS_INODE_LAYOUT_COMPRESSION ) + stat->attributes |=STATX_ATTR_COMPRESSED ; + + stat->attributes |=STATX_ATTR_IMMUTABLE ;Xiang,
Quoted 2 lines
Should update
stat->attributes_maskas well to indicate all erofs supported attributes bits.
opps, my fault... I just verified these patches stability. Will do in the next version.
Thanks,
Gao Xiang
Quoted 55 lines
Thanks,
Quoted 52 lines
drivers/staging/erofs/inode.c +8
-0+ +generic_fillattr (inode, stat); +return 0 ; +} +const struct inode_operations erofs_generic_iops = { + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif@@ -294,6 +310,7 @@ const struct inode_operations erofs_generic_iops = {const struct inode_operations erofs_symlink_iops = { .get_link = page_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif@@ -302,6 +319,7 @@ const struct inode_operations erofs_symlink_iops = {const struct inode_operations erofs_fast_symlink_iops = { .get_link = simple_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endifdrivers/staging/erofs/internal.h +2
-0@@ -556,6 +556,8 @@ static inline bool is_inode_fast_symlink(struct inode *inode) }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);/* namei.c */ extern const struct inode_operations erofs_dir_iops;drivers/staging/erofs/namei.c +1
-0@@ -247,6 +247,7 @@ static struct dentry *erofs_lookup(struct inode *dir,const struct inode_operations erofs_dir_iops = { .lookup = erofs_lookup, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif