Commit 94dac22e authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: introduce raw_nat_from_node_info() to simplfy codes

This patch introduce raw_nat_from_node_info() to simplfy some codes, and also
use exist function node_info_from_raw_nat() to do the same job.
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
parent 876dc59e
...@@ -179,9 +179,7 @@ static void cache_nat_entry(struct f2fs_nm_info *nm_i, nid_t nid, ...@@ -179,9 +179,7 @@ static void cache_nat_entry(struct f2fs_nm_info *nm_i, nid_t nid,
write_unlock(&nm_i->nat_tree_lock); write_unlock(&nm_i->nat_tree_lock);
goto retry; goto retry;
} }
nat_set_blkaddr(e, le32_to_cpu(ne->block_addr)); node_info_from_raw_nat(&e->ni, ne);
nat_set_ino(e, le32_to_cpu(ne->ino));
nat_set_version(e, ne->version);
} }
write_unlock(&nm_i->nat_tree_lock); write_unlock(&nm_i->nat_tree_lock);
} }
...@@ -1755,9 +1753,7 @@ static bool flush_nats_in_journal(struct f2fs_sb_info *sbi) ...@@ -1755,9 +1753,7 @@ static bool flush_nats_in_journal(struct f2fs_sb_info *sbi)
write_unlock(&nm_i->nat_tree_lock); write_unlock(&nm_i->nat_tree_lock);
goto retry; goto retry;
} }
nat_set_blkaddr(ne, le32_to_cpu(raw_ne.block_addr)); node_info_from_raw_nat(&ne->ni, &raw_ne);
nat_set_ino(ne, le32_to_cpu(raw_ne.ino));
nat_set_version(ne, raw_ne.version);
__set_nat_cache_dirty(nm_i, ne); __set_nat_cache_dirty(nm_i, ne);
write_unlock(&nm_i->nat_tree_lock); write_unlock(&nm_i->nat_tree_lock);
} }
...@@ -1790,7 +1786,6 @@ void flush_nat_entries(struct f2fs_sb_info *sbi) ...@@ -1790,7 +1786,6 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
nid_t nid; nid_t nid;
struct f2fs_nat_entry raw_ne; struct f2fs_nat_entry raw_ne;
int offset = -1; int offset = -1;
block_t new_blkaddr;
if (nat_get_blkaddr(ne) == NEW_ADDR) if (nat_get_blkaddr(ne) == NEW_ADDR)
continue; continue;
...@@ -1826,11 +1821,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi) ...@@ -1826,11 +1821,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
f2fs_bug_on(!nat_blk); f2fs_bug_on(!nat_blk);
raw_ne = nat_blk->entries[nid - start_nid]; raw_ne = nat_blk->entries[nid - start_nid];
flush_now: flush_now:
new_blkaddr = nat_get_blkaddr(ne); raw_nat_from_node_info(&raw_ne, &ne->ni);
raw_ne.ino = cpu_to_le32(nat_get_ino(ne));
raw_ne.block_addr = cpu_to_le32(new_blkaddr);
raw_ne.version = nat_get_version(ne);
if (offset < 0) { if (offset < 0) {
nat_blk->entries[nid - start_nid] = raw_ne; nat_blk->entries[nid - start_nid] = raw_ne;
......
...@@ -75,6 +75,14 @@ static inline void node_info_from_raw_nat(struct node_info *ni, ...@@ -75,6 +75,14 @@ static inline void node_info_from_raw_nat(struct node_info *ni,
ni->version = raw_ne->version; ni->version = raw_ne->version;
} }
static inline void raw_nat_from_node_info(struct f2fs_nat_entry *raw_ne,
struct node_info *ni)
{
raw_ne->ino = cpu_to_le32(ni->ino);
raw_ne->block_addr = cpu_to_le32(ni->blk_addr);
raw_ne->version = ni->version;
}
enum nid_type { enum nid_type {
FREE_NIDS, /* indicates the free nid list */ FREE_NIDS, /* indicates the free nid list */
NAT_ENTRIES /* indicates the cached nat entry */ NAT_ENTRIES /* indicates the cached nat entry */
......
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