]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
f2fs: introduce cur_cp_version function to reduce code size
authorJaegeuk Kim <jaegeuk.kim@samsung.com>
Fri, 9 Aug 2013 06:03:21 +0000 (15:03 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Fri, 9 Aug 2013 06:25:37 +0000 (15:25 +0900)
This patch introduces a new inline function, cur_cp_version, to reduce redundant
codes.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/recovery.c
fs/f2fs/xattr.c

index c5a5c390a5cc6a91dc524de04f10526ff55674c1..bb312201ca950114782f6a811725102da3baa718 100644 (file)
@@ -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 */
index c1c9670e642f75789ff5ef45d3c23c29f9579b55..5348b63adbe9b17a681352a6c582572bd76e7a44 100644 (file)
@@ -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);
 
index 8ef3184b003782a9ad8e01e9386c6bc39135c37c..bd4184e3552503712a6726abdc8bc28367e58bc1 100644 (file)
@@ -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) {
index 639eb34652869101461db01f8f42ffd3bf2e8883..c6908b5d9d8437858f7f8c3f068cf4b09ed90928 100644 (file)
@@ -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;
index 0f6d2a1b9a7aa80e3c0e19891b4a3dc5b42a1369..fb16f71e4c23122c6f1d53143740003779eee85e 100644 (file)
@@ -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);