All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary
@ 2026-05-30 12:30 liujinbao1
  2026-07-02 14:16 ` liujinbao1
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: liujinbao1 @ 2026-05-30 12:30 UTC (permalink / raw)
  To: jaegeuk; +Cc: jinbaoliu365, Sheng Yong, liujinbao1, linux-f2fs-devel

From: liujinbao1 <liujinbao1@xiaomi.com>

When CP has CP_COMPACT_SUM_FLAG set, the nat/sit journal is stored in
compact summary blocks at start_sum_block() rather than in the regular
summary area. However, rewrite_nat_in_journal() and
rewrite_sit_in_journal() only handled CP_UMOUNT_FLAG and the running
state, missing the compact summary case.This caused the fault injection
to fail.

Fix this by adding the CP_COMPACT_SUM_FLAG check before the existing
CP_UMOUNT_FLAG check in both functions, writing the journal to the
correct compact summary block location.

Test steps:
1. NAT journal injection (nid=4, quota file):
  inject.f2fs --nat 0 --mb block_addr --nid 4 --val 12345 /dev/block/by-name/userdata
  Before: blkaddr unchanged (308225)
  After:  blkaddr = 12345

2. SIT journal injection (segno=61075, CURSEG_COLD_DATA):
  inject.f2fs --sit 0 --blk 0x1e1da00 --mb vblocks --val 123 /dev/block/by-name/userdata
  Before: vblocks unchanged (0)
  After:  vblocks = 123

Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
Signed-off-by: liujinbao1 <liujinbao1@xiaomi.com>
---
 fsck/inject.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/fsck/inject.c b/fsck/inject.c
index b00e356..60a2d20 100644
--- a/fsck/inject.c
+++ b/fsck/inject.c
@@ -675,6 +675,14 @@ static void rewrite_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid,
 		}
 	}
 
+	if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
+		blkaddr = start_sum_block(sbi);
+		ret = dev_write(&journal->n_nats, blkaddr << F2FS_BLKSIZE_BITS,
+				SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
+		ASSERT(ret >= 0);
+		return;
+	}
+
 	if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
 		blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_HOT_DATA);
 	else
@@ -806,6 +814,14 @@ static void rewrite_sit_in_journal(struct f2fs_sb_info *sbi, unsigned int segno,
 		}
 	}
 
+	if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
+		blkaddr = start_sum_block(sbi);
+		ret = dev_write(&journal->n_sits, (blkaddr << F2FS_BLKSIZE_BITS) + SUM_JOURNAL_SIZE,
+				SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
+		ASSERT(ret >= 0);
+		return;
+	}
+
 	if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
 		blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_COLD_DATA);
 	else
-- 
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary
  2026-05-30 12:30 [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary liujinbao1
@ 2026-07-02 14:16 ` liujinbao1
  2026-07-08  2:34 ` Chao Yu via Linux-f2fs-devel
  2026-07-14  2:45 ` Jaegeuk Kim via Linux-f2fs-devel
  2 siblings, 0 replies; 4+ messages in thread
From: liujinbao1 @ 2026-07-02 14:16 UTC (permalink / raw)
  To: jaegeuk; +Cc: Sheng Yong, liujinbao1, linux-f2fs-devel

ping

在 2026/5/30 20:30, liujinbao1 写道:
> From: liujinbao1 <liujinbao1@xiaomi.com>
>
> When CP has CP_COMPACT_SUM_FLAG set, the nat/sit journal is stored in
> compact summary blocks at start_sum_block() rather than in the regular
> summary area. However, rewrite_nat_in_journal() and
> rewrite_sit_in_journal() only handled CP_UMOUNT_FLAG and the running
> state, missing the compact summary case.This caused the fault injection
> to fail.
>
> Fix this by adding the CP_COMPACT_SUM_FLAG check before the existing
> CP_UMOUNT_FLAG check in both functions, writing the journal to the
> correct compact summary block location.
>
> Test steps:
> 1. NAT journal injection (nid=4, quota file):
>    inject.f2fs --nat 0 --mb block_addr --nid 4 --val 12345 /dev/block/by-name/userdata
>    Before: blkaddr unchanged (308225)
>    After:  blkaddr = 12345
>
> 2. SIT journal injection (segno=61075, CURSEG_COLD_DATA):
>    inject.f2fs --sit 0 --blk 0x1e1da00 --mb vblocks --val 123 /dev/block/by-name/userdata
>    Before: vblocks unchanged (0)
>    After:  vblocks = 123
>
> Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
> Signed-off-by: liujinbao1 <liujinbao1@xiaomi.com>
> ---
>   fsck/inject.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
>
> diff --git a/fsck/inject.c b/fsck/inject.c
> index b00e356..60a2d20 100644
> --- a/fsck/inject.c
> +++ b/fsck/inject.c
> @@ -675,6 +675,14 @@ static void rewrite_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid,
>   		}
>   	}
>   
> +	if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
> +		blkaddr = start_sum_block(sbi);
> +		ret = dev_write(&journal->n_nats, blkaddr << F2FS_BLKSIZE_BITS,
> +				SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
> +		ASSERT(ret >= 0);
> +		return;
> +	}
> +
>   	if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
>   		blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_HOT_DATA);
>   	else
> @@ -806,6 +814,14 @@ static void rewrite_sit_in_journal(struct f2fs_sb_info *sbi, unsigned int segno,
>   		}
>   	}
>   
> +	if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
> +		blkaddr = start_sum_block(sbi);
> +		ret = dev_write(&journal->n_sits, (blkaddr << F2FS_BLKSIZE_BITS) + SUM_JOURNAL_SIZE,
> +				SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
> +		ASSERT(ret >= 0);
> +		return;
> +	}
> +
>   	if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
>   		blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_COLD_DATA);
>   	else


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary
  2026-05-30 12:30 [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary liujinbao1
  2026-07-02 14:16 ` liujinbao1
@ 2026-07-08  2:34 ` Chao Yu via Linux-f2fs-devel
  2026-07-14  2:45 ` Jaegeuk Kim via Linux-f2fs-devel
  2 siblings, 0 replies; 4+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-07-08  2:34 UTC (permalink / raw)
  To: liujinbao1, jaegeuk; +Cc: Sheng Yong, liujinbao1, linux-f2fs-devel

On 5/30/26 20:30, liujinbao1 wrote:
> From: liujinbao1 <liujinbao1@xiaomi.com>
> 
> When CP has CP_COMPACT_SUM_FLAG set, the nat/sit journal is stored in
> compact summary blocks at start_sum_block() rather than in the regular
> summary area. However, rewrite_nat_in_journal() and
> rewrite_sit_in_journal() only handled CP_UMOUNT_FLAG and the running
> state, missing the compact summary case.This caused the fault injection
> to fail.
> 
> Fix this by adding the CP_COMPACT_SUM_FLAG check before the existing
> CP_UMOUNT_FLAG check in both functions, writing the journal to the
> correct compact summary block location.
> 
> Test steps:
> 1. NAT journal injection (nid=4, quota file):
>   inject.f2fs --nat 0 --mb block_addr --nid 4 --val 12345 /dev/block/by-name/userdata
>   Before: blkaddr unchanged (308225)
>   After:  blkaddr = 12345
> 
> 2. SIT journal injection (segno=61075, CURSEG_COLD_DATA):
>   inject.f2fs --sit 0 --blk 0x1e1da00 --mb vblocks --val 123 /dev/block/by-name/userdata
>   Before: vblocks unchanged (0)
>   After:  vblocks = 123
> 
> Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
> Signed-off-by: liujinbao1 <liujinbao1@xiaomi.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary
  2026-05-30 12:30 [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary liujinbao1
  2026-07-02 14:16 ` liujinbao1
  2026-07-08  2:34 ` Chao Yu via Linux-f2fs-devel
@ 2026-07-14  2:45 ` Jaegeuk Kim via Linux-f2fs-devel
  2 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2026-07-14  2:45 UTC (permalink / raw)
  To: liujinbao1; +Cc: Sheng Yong, liujinbao1, linux-f2fs-devel

Could you please rebase on top of f2fs-tools?

Thanks,

On 05/30, liujinbao1 wrote:
> From: liujinbao1 <liujinbao1@xiaomi.com>
> 
> When CP has CP_COMPACT_SUM_FLAG set, the nat/sit journal is stored in
> compact summary blocks at start_sum_block() rather than in the regular
> summary area. However, rewrite_nat_in_journal() and
> rewrite_sit_in_journal() only handled CP_UMOUNT_FLAG and the running
> state, missing the compact summary case.This caused the fault injection
> to fail.
> 
> Fix this by adding the CP_COMPACT_SUM_FLAG check before the existing
> CP_UMOUNT_FLAG check in both functions, writing the journal to the
> correct compact summary block location.
> 
> Test steps:
> 1. NAT journal injection (nid=4, quota file):
>   inject.f2fs --nat 0 --mb block_addr --nid 4 --val 12345 /dev/block/by-name/userdata
>   Before: blkaddr unchanged (308225)
>   After:  blkaddr = 12345
> 
> 2. SIT journal injection (segno=61075, CURSEG_COLD_DATA):
>   inject.f2fs --sit 0 --blk 0x1e1da00 --mb vblocks --val 123 /dev/block/by-name/userdata
>   Before: vblocks unchanged (0)
>   After:  vblocks = 123
> 
> Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
> Signed-off-by: liujinbao1 <liujinbao1@xiaomi.com>
> ---
>  fsck/inject.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/fsck/inject.c b/fsck/inject.c
> index b00e356..60a2d20 100644
> --- a/fsck/inject.c
> +++ b/fsck/inject.c
> @@ -675,6 +675,14 @@ static void rewrite_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid,
>  		}
>  	}
>  
> +	if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
> +		blkaddr = start_sum_block(sbi);
> +		ret = dev_write(&journal->n_nats, blkaddr << F2FS_BLKSIZE_BITS,
> +				SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
> +		ASSERT(ret >= 0);
> +		return;
> +	}
> +
>  	if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
>  		blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_HOT_DATA);
>  	else
> @@ -806,6 +814,14 @@ static void rewrite_sit_in_journal(struct f2fs_sb_info *sbi, unsigned int segno,
>  		}
>  	}
>  
> +	if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
> +		blkaddr = start_sum_block(sbi);
> +		ret = dev_write(&journal->n_sits, (blkaddr << F2FS_BLKSIZE_BITS) + SUM_JOURNAL_SIZE,
> +				SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
> +		ASSERT(ret >= 0);
> +		return;
> +	}
> +
>  	if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
>  		blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_COLD_DATA);
>  	else
> -- 
> 2.43.0
> 
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2026-07-14  2:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-30 12:30 [f2fs-dev] [PATCH] inject.f2fs: fix injecting nat/sit journal in compact summary liujinbao1
2026-07-02 14:16 ` liujinbao1
2026-07-08  2:34 ` Chao Yu via Linux-f2fs-devel
2026-07-14  2:45 ` Jaegeuk Kim via Linux-f2fs-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.