Skip to content

Commit 890e963

Browse files
liujinbao1Jaegeuk Kim
authored andcommitted
inject.f2fs: fix injecting nat/sit journal in compact summary
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> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 7f887c3 commit 890e963

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

fsck/inject.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,14 @@ static void rewrite_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid,
675675
}
676676
}
677677

678+
if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
679+
blkaddr = start_sum_block(sbi);
680+
ret = dev_write(&journal->n_nats, blkaddr << F2FS_BLKSIZE_BITS,
681+
SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
682+
ASSERT(ret >= 0);
683+
return;
684+
}
685+
678686
if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
679687
blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_HOT_DATA);
680688
else
@@ -806,6 +814,14 @@ static void rewrite_sit_in_journal(struct f2fs_sb_info *sbi, unsigned int segno,
806814
}
807815
}
808816

817+
if (is_set_ckpt_flags(cp, CP_COMPACT_SUM_FLAG)) {
818+
blkaddr = start_sum_block(sbi);
819+
ret = dev_write(&journal->n_sits, (blkaddr << F2FS_BLKSIZE_BITS) + SUM_JOURNAL_SIZE,
820+
SUM_JOURNAL_SIZE, WRITE_LIFE_NONE);
821+
ASSERT(ret >= 0);
822+
return;
823+
}
824+
809825
if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
810826
blkaddr = sum_blk_addr(sbi, NR_CURSEG_TYPE, CURSEG_COLD_DATA);
811827
else

0 commit comments

Comments
 (0)