diff options
author | Jingbo Xu <jefflexu@linux.alibaba.com> | 2023-03-13 21:53:08 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@linux.alibaba.com> | 2023-04-17 01:15:44 +0800 |
commit | 3acea5fc335420ba7ef53947cf2d98d07fac39f7 (patch) | |
tree | d534a44c83da8d605453a49e5d8edb7e67f67baa /fs/erofs/xattr.h | |
parent | 09a9639e56c01c7a00d6c0ca63f4c7c41abe075d (diff) | |
download | lwn-3acea5fc335420ba7ef53947cf2d98d07fac39f7.tar.gz lwn-3acea5fc335420ba7ef53947cf2d98d07fac39f7.zip |
erofs: avoid hardcoded blocksize for subpage block support
As the first step of converting hardcoded blocksize to that specified in
on-disk superblock, convert all call sites of hardcoded blocksize to
sb->s_blocksize except for:
1) use sbi->blkszbits instead of sb->s_blocksize in
erofs_superblock_csum_verify() since sb->s_blocksize has not been
updated with the on-disk blocksize yet when the function is called.
2) use inode->i_blkbits instead of sb->s_blocksize in erofs_bread(),
since the inode operated on may be an anonymous inode in fscache mode.
Currently the anonymous inode is allocated from an anonymous mount
maintained in erofs, while in the near future we may allocate anonymous
inodes from a generic API directly and thus have no access to the
anonymous inode's i_sb. Thus we keep the block size in i_blkbits for
anonymous inodes in fscache mode.
Be noted that this patch only gets rid of the hardcoded blocksize, in
preparation for actually setting the on-disk block size in the following
patch. The hard limit of constraining the block size to PAGE_SIZE still
exists until the next patch.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Yue Hu <huyue2@coolpad.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20230313135309.75269-2-jefflexu@linux.alibaba.com
[ Gao Xiang: fold a patch to fix incorrect truncated offsets. ]
Link: https://lore.kernel.org/r/20230413035734.15457-1-zhujia.zj@bytedance.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Diffstat (limited to 'fs/erofs/xattr.h')
-rw-r--r-- | fs/erofs/xattr.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/erofs/xattr.h b/fs/erofs/xattr.h index 0a43c9ee9f8f..f7a21aaa9755 100644 --- a/fs/erofs/xattr.h +++ b/fs/erofs/xattr.h @@ -19,21 +19,21 @@ static inline unsigned int inlinexattr_header_size(struct inode *inode) sizeof(u32) * EROFS_I(inode)->xattr_shared_count; } -static inline erofs_blk_t xattrblock_addr(struct erofs_sb_info *sbi, +static inline erofs_blk_t xattrblock_addr(struct super_block *sb, unsigned int xattr_id) { #ifdef CONFIG_EROFS_FS_XATTR - return sbi->xattr_blkaddr + - xattr_id * sizeof(__u32) / EROFS_BLKSIZ; + return EROFS_SB(sb)->xattr_blkaddr + + xattr_id * sizeof(__u32) / sb->s_blocksize; #else return 0; #endif } -static inline unsigned int xattrblock_offset(struct erofs_sb_info *sbi, +static inline unsigned int xattrblock_offset(struct super_block *sb, unsigned int xattr_id) { - return (xattr_id * sizeof(__u32)) % EROFS_BLKSIZ; + return (xattr_id * sizeof(__u32)) % sb->s_blocksize; } #ifdef CONFIG_EROFS_FS_XATTR |