Commit bed6b031 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: 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: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 7309871c
...@@ -3227,21 +3227,15 @@ static inline bool f2fs_need_compress_data(struct inode *inode) ...@@ -3227,21 +3227,15 @@ static inline bool f2fs_need_compress_data(struct inode *inode)
return false; return false;
} }
static inline unsigned int addrs_per_inode(struct inode *inode) static inline unsigned int addrs_per_page(struct inode *inode,
bool is_inode)
{ {
unsigned int addrs = CUR_ADDRS_PER_INODE(inode) - unsigned int addrs = is_inode ? (CUR_ADDRS_PER_INODE(inode) -
get_inline_xattr_addrs(inode); get_inline_xattr_addrs(inode)) : DEF_ADDRS_PER_BLOCK;
if (!f2fs_compressed_file(inode)) if (f2fs_compressed_file(inode))
return addrs; return ALIGN_DOWN(addrs, F2FS_I(inode)->i_cluster_size);
return ALIGN_DOWN(addrs, F2FS_I(inode)->i_cluster_size); return addrs;
}
static inline unsigned int addrs_per_block(struct inode *inode)
{
if (!f2fs_compressed_file(inode))
return DEF_ADDRS_PER_BLOCK;
return ALIGN_DOWN(DEF_ADDRS_PER_BLOCK, F2FS_I(inode)->i_cluster_size);
} }
static inline void *inline_xattr_addr(struct inode *inode, struct page *page) static inline void *inline_xattr_addr(struct inode *inode, struct page *page)
......
...@@ -259,15 +259,14 @@ struct node_footer { ...@@ -259,15 +259,14 @@ struct node_footer {
#define CUR_ADDRS_PER_INODE(inode) (DEF_ADDRS_PER_INODE - \ #define CUR_ADDRS_PER_INODE(inode) (DEF_ADDRS_PER_INODE - \
get_extra_isize(inode)) get_extra_isize(inode))
#define DEF_NIDS_PER_INODE 5 /* Node IDs in an Inode */ #define DEF_NIDS_PER_INODE 5 /* Node IDs in an Inode */
#define ADDRS_PER_INODE(inode) addrs_per_inode(inode) #define ADDRS_PER_INODE(inode) addrs_per_page(inode, true)
/* Address Pointers in a Direct Block */ /* Address Pointers in a Direct Block */
#define DEF_ADDRS_PER_BLOCK ((F2FS_BLKSIZE - sizeof(struct node_footer)) / sizeof(__le32)) #define DEF_ADDRS_PER_BLOCK ((F2FS_BLKSIZE - sizeof(struct node_footer)) / sizeof(__le32))
#define ADDRS_PER_BLOCK(inode) addrs_per_block(inode) #define ADDRS_PER_BLOCK(inode) addrs_per_page(inode, false)
/* Node IDs in an Indirect Block */ /* Node IDs in an Indirect Block */
#define NIDS_PER_BLOCK ((F2FS_BLKSIZE - sizeof(struct node_footer)) / sizeof(__le32)) #define NIDS_PER_BLOCK ((F2FS_BLKSIZE - sizeof(struct node_footer)) / sizeof(__le32))
#define ADDRS_PER_PAGE(page, inode) \ #define ADDRS_PER_PAGE(page, inode) (addrs_per_page(inode, IS_INODE(page)))
(IS_INODE(page) ? ADDRS_PER_INODE(inode) : ADDRS_PER_BLOCK(inode))
#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1) #define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1)
#define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2) #define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment