f2fs-tools: set cold flag for non-dir node

Signed-off-by: Wuyun Zhao <zhaowuyun@wingtech.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Wuyun Zhao 2020-06-18 20:48:07 +08:00 committed by Jaegeuk Kim
parent 895b26e118
commit 712aca364f
3 changed files with 13 additions and 0 deletions

View File

@ -522,6 +522,7 @@ static void init_inode_block(struct f2fs_sb_info *sbi,
node_blk->footer.nid = cpu_to_le32(de->ino);
node_blk->footer.flag = 0;
node_blk->footer.cp_ver = ckpt->checkpoint_ver;
set_cold_node(node_blk, S_ISDIR(mode));
if (S_ISDIR(mode)) {
make_empty_dir(sbi, node_blk);

View File

@ -79,6 +79,7 @@ block_t new_node_block(struct f2fs_sb_info *sbi,
node_blk->footer.ino = f2fs_inode->footer.ino;
node_blk->footer.flag = cpu_to_le32(ofs << OFFSET_BIT_SHIFT);
node_blk->footer.cp_ver = ckpt->checkpoint_ver;
set_cold_node(node_blk, S_ISDIR(le16_to_cpu(f2fs_inode->i.i_mode)));
type = CURSEG_COLD_NODE;
if (IS_DNODE(node_blk)) {

View File

@ -161,6 +161,17 @@ static inline int is_node(struct f2fs_node *node_blk, int type)
return le32_to_cpu(node_blk->footer.flag) & (1 << type);
}
static inline void set_cold_node(struct f2fs_node *rn, bool is_dir)
{
unsigned int flag = le32_to_cpu(rn->footer.flag);
if (is_dir)
flag &= ~(0x1 << COLD_BIT_SHIFT);
else
flag |= (0x1 << COLD_BIT_SHIFT);
rn->footer.flag = cpu_to_le32(flag);
}
#define is_fsync_dnode(node_blk) is_node(node_blk, FSYNC_BIT_SHIFT)
#define is_dent_dnode(node_blk) is_node(node_blk, DENT_BIT_SHIFT)