mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-06 05:02:31 +00:00
f2fs: introduce get_dnode_addr() to clean up codes
Just cleanup, no logic changes. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
bb6e1c8fa5
commit
2020cd48e4
@ -1181,16 +1181,9 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page,
|
||||
|
||||
static void __set_data_blkaddr(struct dnode_of_data *dn)
|
||||
{
|
||||
struct f2fs_node *rn = F2FS_NODE(dn->node_page);
|
||||
__le32 *addr_array;
|
||||
int base = 0;
|
||||
__le32 *addr = get_dnode_addr(dn->inode, dn->node_page);
|
||||
|
||||
if (IS_INODE(dn->node_page) && f2fs_has_extra_attr(dn->inode))
|
||||
base = get_extra_isize(dn->inode);
|
||||
|
||||
/* Get physical address of data block */
|
||||
addr_array = blkaddr_in_node(rn);
|
||||
addr_array[base + dn->ofs_in_node] = cpu_to_le32(dn->data_blkaddr);
|
||||
addr[dn->ofs_in_node] = cpu_to_le32(dn->data_blkaddr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3277,12 +3277,13 @@ static inline bool f2fs_is_cow_file(struct inode *inode)
|
||||
return is_inode_flag_set(inode, FI_COW_FILE);
|
||||
}
|
||||
|
||||
static inline __le32 *get_dnode_addr(struct inode *inode,
|
||||
struct page *node_page);
|
||||
static inline void *inline_data_addr(struct inode *inode, struct page *page)
|
||||
{
|
||||
struct f2fs_inode *ri = F2FS_INODE(page);
|
||||
int extra_size = get_extra_isize(inode);
|
||||
__le32 *addr = get_dnode_addr(inode, page);
|
||||
|
||||
return (void *)&(ri->i_addr[extra_size + DEF_INLINE_RESERVED_SIZE]);
|
||||
return (void *)(addr + DEF_INLINE_RESERVED_SIZE);
|
||||
}
|
||||
|
||||
static inline int f2fs_has_inline_dentry(struct inode *inode)
|
||||
@ -3427,6 +3428,17 @@ static inline int get_inline_xattr_addrs(struct inode *inode)
|
||||
return F2FS_I(inode)->i_inline_xattr_size;
|
||||
}
|
||||
|
||||
static inline __le32 *get_dnode_addr(struct inode *inode,
|
||||
struct page *node_page)
|
||||
{
|
||||
int base = 0;
|
||||
|
||||
if (IS_INODE(node_page) && f2fs_has_extra_attr(inode))
|
||||
base = get_extra_isize(inode);
|
||||
|
||||
return blkaddr_in_node(F2FS_NODE(node_page)) + base;
|
||||
}
|
||||
|
||||
#define f2fs_get_inode_mode(i) \
|
||||
((is_inode_flag_set(i, FI_ACL_MODE)) ? \
|
||||
(F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
|
||||
|
@ -557,20 +557,14 @@ static int f2fs_file_open(struct inode *inode, struct file *filp)
|
||||
void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count)
|
||||
{
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
|
||||
struct f2fs_node *raw_node;
|
||||
int nr_free = 0, ofs = dn->ofs_in_node, len = count;
|
||||
__le32 *addr;
|
||||
int base = 0;
|
||||
bool compressed_cluster = false;
|
||||
int cluster_index = 0, valid_blocks = 0;
|
||||
int cluster_size = F2FS_I(dn->inode)->i_cluster_size;
|
||||
bool released = !atomic_read(&F2FS_I(dn->inode)->i_compr_blocks);
|
||||
|
||||
if (IS_INODE(dn->node_page) && f2fs_has_extra_attr(dn->inode))
|
||||
base = get_extra_isize(dn->inode);
|
||||
|
||||
raw_node = F2FS_NODE(dn->node_page);
|
||||
addr = blkaddr_in_node(raw_node) + base + ofs;
|
||||
addr = get_dnode_addr(dn->inode, dn->node_page) + ofs;
|
||||
|
||||
/* Assumption: truncation starts with cluster */
|
||||
for (; count > 0; count--, addr++, dn->ofs_in_node++, cluster_index++) {
|
||||
|
@ -61,35 +61,31 @@ void f2fs_set_inode_flags(struct inode *inode)
|
||||
S_ENCRYPTED|S_VERITY|S_CASEFOLD);
|
||||
}
|
||||
|
||||
static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
|
||||
static void __get_inode_rdev(struct inode *inode, struct page *node_page)
|
||||
{
|
||||
int extra_size = get_extra_isize(inode);
|
||||
__le32 *addr = get_dnode_addr(inode, node_page);
|
||||
|
||||
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
|
||||
S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
|
||||
if (ri->i_addr[extra_size])
|
||||
inode->i_rdev = old_decode_dev(
|
||||
le32_to_cpu(ri->i_addr[extra_size]));
|
||||
if (addr[0])
|
||||
inode->i_rdev = old_decode_dev(le32_to_cpu(addr[0]));
|
||||
else
|
||||
inode->i_rdev = new_decode_dev(
|
||||
le32_to_cpu(ri->i_addr[extra_size + 1]));
|
||||
inode->i_rdev = new_decode_dev(le32_to_cpu(addr[1]));
|
||||
}
|
||||
}
|
||||
|
||||
static void __set_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
|
||||
static void __set_inode_rdev(struct inode *inode, struct page *node_page)
|
||||
{
|
||||
int extra_size = get_extra_isize(inode);
|
||||
__le32 *addr = get_dnode_addr(inode, node_page);
|
||||
|
||||
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
|
||||
if (old_valid_dev(inode->i_rdev)) {
|
||||
ri->i_addr[extra_size] =
|
||||
cpu_to_le32(old_encode_dev(inode->i_rdev));
|
||||
ri->i_addr[extra_size + 1] = 0;
|
||||
addr[0] = cpu_to_le32(old_encode_dev(inode->i_rdev));
|
||||
addr[1] = 0;
|
||||
} else {
|
||||
ri->i_addr[extra_size] = 0;
|
||||
ri->i_addr[extra_size + 1] =
|
||||
cpu_to_le32(new_encode_dev(inode->i_rdev));
|
||||
ri->i_addr[extra_size + 2] = 0;
|
||||
addr[0] = 0;
|
||||
addr[1] = cpu_to_le32(new_encode_dev(inode->i_rdev));
|
||||
addr[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -463,7 +459,7 @@ static int do_read_inode(struct inode *inode)
|
||||
}
|
||||
|
||||
/* get rdev by using inline_info */
|
||||
__get_inode_rdev(inode, ri);
|
||||
__get_inode_rdev(inode, node_page);
|
||||
|
||||
if (!f2fs_need_inode_block_update(sbi, inode->i_ino))
|
||||
fi->last_disk_size = inode->i_size;
|
||||
@ -736,7 +732,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
|
||||
}
|
||||
}
|
||||
|
||||
__set_inode_rdev(inode, ri);
|
||||
__set_inode_rdev(inode, node_page);
|
||||
|
||||
/* deleted inode */
|
||||
if (inode->i_nlink == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user