The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix start segno of large section
@ 2024-07-06  9:16 Sheng Yong
  2024-07-08  6:09 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Sheng Yong @ 2024-07-06  9:16 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Sheng Yong

get_ckpt_valid_blocks() checks valid ckpt blocks in current section.
It counts all vblocks from the first to the last segment in the
large section. However, START_SEGNO() is used to get the first segno
in an SIT block. This patch fixes that to get the correct start segno.

Fixes: 61461fc921b7 ("f2fs: fix to avoid touching checkpointed data in get_victim()")
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
 fs/f2fs/segment.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index e1c0f418aa11..6ed5bc811d2c 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -347,7 +347,8 @@ static inline unsigned int get_ckpt_valid_blocks(struct f2fs_sb_info *sbi,
 				unsigned int segno, bool use_section)
 {
 	if (use_section && __is_large_section(sbi)) {
-		unsigned int start_segno = START_SEGNO(segno);
+		unsigned int start_segno = segno / SEGS_PER_SEC(sbi) *
+							SEGS_PER_SEC(sbi);
 		unsigned int blocks = 0;
 		int i;
 
-- 
2.40.1


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

* Re: [PATCH] f2fs: fix start segno of large section
  2024-07-06  9:16 [PATCH] f2fs: fix start segno of large section Sheng Yong
@ 2024-07-08  6:09 ` Chao Yu
  2024-07-08  6:18   ` Sheng Yong
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2024-07-08  6:09 UTC (permalink / raw)
  To: Sheng Yong, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

On 2024/7/6 17:16, Sheng Yong wrote:
> get_ckpt_valid_blocks() checks valid ckpt blocks in current section.
> It counts all vblocks from the first to the last segment in the
> large section. However, START_SEGNO() is used to get the first segno
> in an SIT block. This patch fixes that to get the correct start segno.
> 
> Fixes: 61461fc921b7 ("f2fs: fix to avoid touching checkpointed data in get_victim()")
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
> ---
>   fs/f2fs/segment.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index e1c0f418aa11..6ed5bc811d2c 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -347,7 +347,8 @@ static inline unsigned int get_ckpt_valid_blocks(struct f2fs_sb_info *sbi,
>   				unsigned int segno, bool use_section)
>   {
>   	if (use_section && __is_large_section(sbi)) {
> -		unsigned int start_segno = START_SEGNO(segno);
> +		unsigned int start_segno = segno / SEGS_PER_SEC(sbi) *
> +							SEGS_PER_SEC(sbi);

How about using macro?

	unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
	unsigned int start_seno = GET_SEG_FROM_SEC(sbi, secno);

Thanks,

>   		unsigned int blocks = 0;
>   		int i;
>   

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

* Re: [PATCH] f2fs: fix start segno of large section
  2024-07-08  6:09 ` Chao Yu
@ 2024-07-08  6:18   ` Sheng Yong
  0 siblings, 0 replies; 3+ messages in thread
From: Sheng Yong @ 2024-07-08  6:18 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel



On 2024/7/8 14:09, Chao Yu wrote:
> On 2024/7/6 17:16, Sheng Yong wrote:
>> get_ckpt_valid_blocks() checks valid ckpt blocks in current section.
>> It counts all vblocks from the first to the last segment in the
>> large section. However, START_SEGNO() is used to get the first segno
>> in an SIT block. This patch fixes that to get the correct start segno.
>>
>> Fixes: 61461fc921b7 ("f2fs: fix to avoid touching checkpointed data in get_victim()")
>> Signed-off-by: Sheng Yong <shengyong@oppo.com>
>> ---
>>   fs/f2fs/segment.h | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
>> index e1c0f418aa11..6ed5bc811d2c 100644
>> --- a/fs/f2fs/segment.h
>> +++ b/fs/f2fs/segment.h
>> @@ -347,7 +347,8 @@ static inline unsigned int get_ckpt_valid_blocks(struct f2fs_sb_info *sbi,
>>                   unsigned int segno, bool use_section)
>>   {
>>       if (use_section && __is_large_section(sbi)) {
>> -        unsigned int start_segno = START_SEGNO(segno);
>> +        unsigned int start_segno = segno / SEGS_PER_SEC(sbi) *
>> +                            SEGS_PER_SEC(sbi);
> 
> How about using macro?
> 
>      unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
>      unsigned int start_seno = GET_SEG_FROM_SEC(sbi, secno);

I will update it in next version.

thanks,
shengyong
> 
> Thanks,
> 
>>           unsigned int blocks = 0;
>>           int i;

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

end of thread, other threads:[~2024-07-08  6:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-06  9:16 [PATCH] f2fs: fix start segno of large section Sheng Yong
2024-07-08  6:09 ` Chao Yu
2024-07-08  6:18   ` Sheng Yong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox