mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
f2fs: introduce cur_cp_version function to reduce code size
This patch introduces a new inline function, cur_cp_version, to reduce redundant codes. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
e518ff81c3
commit
d71b5564c0
@ -379,7 +379,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
|
||||
if (!f2fs_crc_valid(crc, cp_block, crc_offset))
|
||||
goto invalid_cp1;
|
||||
|
||||
pre_version = le64_to_cpu(cp_block->checkpoint_ver);
|
||||
pre_version = cur_cp_version(cp_block);
|
||||
|
||||
/* Read the 2nd cp block in this CP pack */
|
||||
cp_addr += le32_to_cpu(cp_block->cp_pack_total_block_count) - 1;
|
||||
@ -394,7 +394,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
|
||||
if (!f2fs_crc_valid(crc, cp_block, crc_offset))
|
||||
goto invalid_cp2;
|
||||
|
||||
cur_version = le64_to_cpu(cp_block->checkpoint_ver);
|
||||
cur_version = cur_cp_version(cp_block);
|
||||
|
||||
if (cur_version == pre_version) {
|
||||
*version = cur_version;
|
||||
@ -799,7 +799,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
|
||||
* Increase the version number so that
|
||||
* SIT entries and seg summaries are written at correct place
|
||||
*/
|
||||
ckpt_ver = le64_to_cpu(ckpt->checkpoint_ver);
|
||||
ckpt_ver = cur_cp_version(ckpt);
|
||||
ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver);
|
||||
|
||||
/* write cached NAT/SIT entries to NAT/SIT area */
|
||||
|
@ -503,6 +503,11 @@ static inline void F2FS_RESET_SB_DIRT(struct f2fs_sb_info *sbi)
|
||||
sbi->s_dirty = 0;
|
||||
}
|
||||
|
||||
static inline unsigned long long cur_cp_version(struct f2fs_checkpoint *cp)
|
||||
{
|
||||
return le64_to_cpu(cp->checkpoint_ver);
|
||||
}
|
||||
|
||||
static inline bool is_set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
|
||||
{
|
||||
unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
|
||||
@ -691,7 +696,7 @@ static inline block_t __start_cp_addr(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
block_t start_addr;
|
||||
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
|
||||
unsigned long long ckpt_version = le64_to_cpu(ckpt->checkpoint_ver);
|
||||
unsigned long long ckpt_version = cur_cp_version(ckpt);
|
||||
|
||||
start_addr = le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_blkaddr);
|
||||
|
||||
|
@ -161,8 +161,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
|
||||
need_cp = true;
|
||||
else if (!is_checkpointed_node(sbi, F2FS_I(inode)->i_pino))
|
||||
need_cp = true;
|
||||
else if (F2FS_I(inode)->xattr_ver ==
|
||||
le64_to_cpu(F2FS_CKPT(sbi)->checkpoint_ver))
|
||||
else if (F2FS_I(inode)->xattr_ver == cur_cp_version(F2FS_CKPT(sbi)))
|
||||
need_cp = true;
|
||||
|
||||
if (need_cp) {
|
||||
|
@ -117,7 +117,7 @@ static int recover_inode(struct inode *inode, struct page *node_page)
|
||||
|
||||
static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
|
||||
{
|
||||
unsigned long long cp_ver = le64_to_cpu(sbi->ckpt->checkpoint_ver);
|
||||
unsigned long long cp_ver = cur_cp_version(F2FS_CKPT(sbi));
|
||||
struct curseg_info *curseg;
|
||||
struct page *page;
|
||||
block_t blkaddr;
|
||||
@ -355,7 +355,7 @@ err:
|
||||
static int recover_data(struct f2fs_sb_info *sbi,
|
||||
struct list_head *head, int type)
|
||||
{
|
||||
unsigned long long cp_ver = le64_to_cpu(sbi->ckpt->checkpoint_ver);
|
||||
unsigned long long cp_ver = cur_cp_version(F2FS_CKPT(sbi));
|
||||
struct curseg_info *curseg;
|
||||
struct page *page;
|
||||
int err = 0;
|
||||
|
@ -488,7 +488,7 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
||||
}
|
||||
|
||||
/* store checkpoint version for conducting checkpoint during fsync */
|
||||
fi->xattr_ver = le64_to_cpu(F2FS_CKPT(sbi)->checkpoint_ver);
|
||||
fi->xattr_ver = cur_cp_version(F2FS_CKPT(sbi));
|
||||
|
||||
if (ipage)
|
||||
update_inode(inode, ipage);
|
||||
|
Loading…
Reference in New Issue
Block a user