linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs-tools: set cold flag for non-dir node
@ 2020-06-18 12:48 zhaowuyun
  2020-06-19  1:31 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: zhaowuyun @ 2020-06-18 12:48 UTC (permalink / raw)
  To: yuchao0, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, zhaowuyun

From: Wuyun Zhao <zhaowuyun@wingtech.com>

Signed-off-by: Wuyun Zhao <zhaowuyun@wingtech.com>
---
 fsck/dir.c  |  1 +
 fsck/node.c |  1 +
 fsck/node.h | 11 +++++++++++
 3 files changed, 13 insertions(+)

diff --git a/fsck/dir.c b/fsck/dir.c
index 5f4f75e..dc03c98 100644
--- a/fsck/dir.c
+++ b/fsck/dir.c
@@ -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);
diff --git a/fsck/node.c b/fsck/node.c
index 229a99c..1d291ca 100644
--- a/fsck/node.c
+++ b/fsck/node.c
@@ -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)) {
diff --git a/fsck/node.h b/fsck/node.h
index 6bce1fb..99139b1 100644
--- a/fsck/node.h
+++ b/fsck/node.h
@@ -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)
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] f2fs-tools: set cold flag for non-dir node
  2020-06-18 12:48 [PATCH] f2fs-tools: set cold flag for non-dir node zhaowuyun
@ 2020-06-19  1:31 ` Chao Yu
  2020-06-19  2:21   ` 回复: " Zac
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2020-06-19  1:31 UTC (permalink / raw)
  To: zhaowuyun, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

On 2020/6/18 20:48, zhaowuyun@wingtech.com wrote:
> From: Wuyun Zhao <zhaowuyun@wingtech.com>

Thanks for the patch. :)

Please add commit message here.

> 
> Signed-off-by: Wuyun Zhao <zhaowuyun@wingtech.com>
> ---
>  fsck/dir.c  |  1 +
>  fsck/node.c |  1 +
>  fsck/node.h | 11 +++++++++++
>  3 files changed, 13 insertions(+)
> 
> diff --git a/fsck/dir.c b/fsck/dir.c
> index 5f4f75e..dc03c98 100644
> --- a/fsck/dir.c
> +++ b/fsck/dir.c
> @@ -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);
> diff --git a/fsck/node.c b/fsck/node.c
> index 229a99c..1d291ca 100644
> --- a/fsck/node.c
> +++ b/fsck/node.c
> @@ -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)));

How about wrapping these node footer fields assignment into a function? then
we can reuse this in other places.

void set_node_footer(nid, ino, ofs, ver, is_dir)
{
	node_blk->footer.nid = cpu_to_le32(nid);
	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)) {
> diff --git a/fsck/node.h b/fsck/node.h
> index 6bce1fb..99139b1 100644
> --- a/fsck/node.h
> +++ b/fsck/node.h
> @@ -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);
>  }

Beside this, I think we need to use set_node_footer() in:
- f2fs_write_root_inode
- f2fs_write_qf_inode
- f2fs_write_lpf_inode

as well to fix mkfs bugs.

Thanks,

>  
> +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)
>  
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 回复: [PATCH] f2fs-tools: set cold flag for non-dir node
  2020-06-19  1:31 ` Chao Yu
@ 2020-06-19  2:21   ` Zac
  2020-06-19  2:48     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Zac @ 2020-06-19  2:21 UTC (permalink / raw)
  To: 'Chao Yu', jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

> On 2020/6/18 20:48, zhaowuyun@wingtech.com wrote:
> > From: Wuyun Zhao <zhaowuyun@wingtech.com>
> 
> Thanks for the patch. :)
> 
> Please add commit message here.

OK

> >
> > Signed-off-by: Wuyun Zhao <zhaowuyun@wingtech.com>
> > ---
> >  fsck/dir.c  |  1 +
> >  fsck/node.c |  1 +
> >  fsck/node.h | 11 +++++++++++
> >  3 files changed, 13 insertions(+)
> >
> > diff --git a/fsck/dir.c b/fsck/dir.c
> > index 5f4f75e..dc03c98 100644
> > --- a/fsck/dir.c
> > +++ b/fsck/dir.c
> > @@ -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);
> > diff --git a/fsck/node.c b/fsck/node.c
> > index 229a99c..1d291ca 100644
> > --- a/fsck/node.c
> > +++ b/fsck/node.c
> > @@ -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)));
> 
> How about wrapping these node footer fields assignment into a function?
> then
> we can reuse this in other places.
> 
> void set_node_footer(nid, ino, ofs, ver, is_dir)
> {
> 	node_blk->footer.nid = cpu_to_le32(nid);
> 	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)));
> }

Ok, That's good.

> >
> >  	type = CURSEG_COLD_NODE;
> >  	if (IS_DNODE(node_blk)) {
> > diff --git a/fsck/node.h b/fsck/node.h
> > index 6bce1fb..99139b1 100644
> > --- a/fsck/node.h
> > +++ b/fsck/node.h
> > @@ -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);
> >  }
> 
> Beside this, I think we need to use set_node_footer() in:
> - f2fs_write_root_inode
> - f2fs_write_qf_inode
> - f2fs_write_lpf_inode
> 
> as well to fix mkfs bugs.

the root inode and the lpf inode is dir, need to set cold flag? 

> Thanks,
> 
> >
> > +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)
> >
> >


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 回复: [PATCH] f2fs-tools: set cold flag for non-dir node
  2020-06-19  2:21   ` 回复: " Zac
@ 2020-06-19  2:48     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2020-06-19  2:48 UTC (permalink / raw)
  To: Zac, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

On 2020/6/19 10:21, Zac wrote:
>> On 2020/6/18 20:48, zhaowuyun@wingtech.com wrote:
>>> From: Wuyun Zhao <zhaowuyun@wingtech.com>
>>
>> Thanks for the patch. :)
>>
>> Please add commit message here.
> 
> OK
> 
>>>
>>> Signed-off-by: Wuyun Zhao <zhaowuyun@wingtech.com>
>>> ---
>>>  fsck/dir.c  |  1 +
>>>  fsck/node.c |  1 +
>>>  fsck/node.h | 11 +++++++++++
>>>  3 files changed, 13 insertions(+)
>>>
>>> diff --git a/fsck/dir.c b/fsck/dir.c
>>> index 5f4f75e..dc03c98 100644
>>> --- a/fsck/dir.c
>>> +++ b/fsck/dir.c
>>> @@ -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);
>>> diff --git a/fsck/node.c b/fsck/node.c
>>> index 229a99c..1d291ca 100644
>>> --- a/fsck/node.c
>>> +++ b/fsck/node.c
>>> @@ -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)));
>>
>> How about wrapping these node footer fields assignment into a function?
>> then
>> we can reuse this in other places.
>>
>> void set_node_footer(nid, ino, ofs, ver, is_dir)
>> {
>> 	node_blk->footer.nid = cpu_to_le32(nid);
>> 	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)));
>> }
> 
> Ok, That's good.
> 
>>>
>>>  	type = CURSEG_COLD_NODE;
>>>  	if (IS_DNODE(node_blk)) {
>>> diff --git a/fsck/node.h b/fsck/node.h
>>> index 6bce1fb..99139b1 100644
>>> --- a/fsck/node.h
>>> +++ b/fsck/node.h
>>> @@ -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);
>>>  }
>>
>> Beside this, I think we need to use set_node_footer() in:
>> - f2fs_write_root_inode
>> - f2fs_write_qf_inode
>> - f2fs_write_lpf_inode
>>
>> as well to fix mkfs bugs.
> 
> the root inode and the lpf inode is dir, need to set cold flag? 

No, but it is worth to use set_node_footer(..., is_dir:true) for cleanup.

Thanks,

> 
>> Thanks,
>>
>>>
>>> +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)
>>>
>>>
> 
> .
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-19  2:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 12:48 [PATCH] f2fs-tools: set cold flag for non-dir node zhaowuyun
2020-06-19  1:31 ` Chao Yu
2020-06-19  2:21   ` 回复: " Zac
2020-06-19  2:48     ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).