mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git
synced 2024-11-27 03:33:35 +08:00
f2fs-tools: clean up addrs_per_{inode,block}()
Introduce a new help addrs_per_page() to wrap common code from addrs_per_inode() and addrs_per_block() for cleanup. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
250d610d62
commit
d31d5f26ae
@ -927,10 +927,10 @@ static_assert(sizeof(struct node_footer) == 24, "");
|
||||
- sizeof(struct node_footer)) / sizeof(__le32))
|
||||
#define CUR_ADDRS_PER_INODE(inode) (DEF_ADDRS_PER_INODE - \
|
||||
__get_extra_isize(inode))
|
||||
#define ADDRS_PER_INODE(i) addrs_per_inode(i)
|
||||
#define ADDRS_PER_INODE(i) addrs_per_page(i, true)
|
||||
/* Address Pointers in a Direct Block */
|
||||
#define DEF_ADDRS_PER_BLOCK ((F2FS_BLKSIZE - sizeof(struct node_footer)) / sizeof(__le32))
|
||||
#define ADDRS_PER_BLOCK(i) addrs_per_block(i)
|
||||
#define ADDRS_PER_BLOCK(i) addrs_per_page(i, false)
|
||||
/* Node IDs in an Indirect Block */
|
||||
#define NIDS_PER_BLOCK ((F2FS_BLKSIZE - sizeof(struct node_footer)) / sizeof(__le32))
|
||||
|
||||
@ -1570,8 +1570,7 @@ struct f2fs_configuration {
|
||||
extern int utf8_to_utf16(char *, const char *, size_t, size_t);
|
||||
extern int utf16_to_utf8(char *, const char *, size_t, size_t);
|
||||
extern int log_base_2(uint32_t);
|
||||
extern unsigned int addrs_per_inode(struct f2fs_inode *);
|
||||
extern unsigned int addrs_per_block(struct f2fs_inode *);
|
||||
extern unsigned int addrs_per_page(struct f2fs_inode *, bool);
|
||||
extern unsigned int f2fs_max_file_offset(struct f2fs_inode *);
|
||||
extern __u32 f2fs_inode_chksum(struct f2fs_node *);
|
||||
extern __u32 f2fs_checkpoint_chksum(struct f2fs_checkpoint *);
|
||||
|
@ -516,9 +516,10 @@ opaque_seq:
|
||||
return __f2fs_dentry_hash(name, len);
|
||||
}
|
||||
|
||||
unsigned int addrs_per_inode(struct f2fs_inode *i)
|
||||
unsigned int addrs_per_page(struct f2fs_inode *i, bool is_inode)
|
||||
{
|
||||
unsigned int addrs = CUR_ADDRS_PER_INODE(i) - get_inline_xattr_addrs(i);
|
||||
unsigned int addrs = is_inode ? CUR_ADDRS_PER_INODE(i) -
|
||||
get_inline_xattr_addrs(i) : DEF_ADDRS_PER_BLOCK;
|
||||
|
||||
if (!LINUX_S_ISREG(le16_to_cpu(i->i_mode)) ||
|
||||
!(le32_to_cpu(i->i_flags) & F2FS_COMPR_FL))
|
||||
@ -526,14 +527,6 @@ unsigned int addrs_per_inode(struct f2fs_inode *i)
|
||||
return ALIGN_DOWN(addrs, 1 << i->i_log_cluster_size);
|
||||
}
|
||||
|
||||
unsigned int addrs_per_block(struct f2fs_inode *i)
|
||||
{
|
||||
if (!LINUX_S_ISREG(le16_to_cpu(i->i_mode)) ||
|
||||
!(le32_to_cpu(i->i_flags) & F2FS_COMPR_FL))
|
||||
return DEF_ADDRS_PER_BLOCK;
|
||||
return ALIGN_DOWN(DEF_ADDRS_PER_BLOCK, 1 << i->i_log_cluster_size);
|
||||
}
|
||||
|
||||
unsigned int f2fs_max_file_offset(struct f2fs_inode *i)
|
||||
{
|
||||
if (!LINUX_S_ISREG(le16_to_cpu(i->i_mode)) ||
|
||||
|
Loading…
Reference in New Issue
Block a user