f2fs: skip further SIT updates for already invalidated blocks
Subsystems (2)
PATCH v2 1/1 f2fs: skip further SIT updates for already invalidated blocks
When update_sit_entry_for_release() encounters a block whose bit is already cleared in cur_valid_map, it reports the inconsistency and corrects se->valid_blocks and del. However, it still proceeds with the discard bitmap and checkpoint accounting updates.
This can clear the discard bit unnecessarily and incorrectly decrement the segment and section ckpt_valid_blocks counters when the block is not marked in ckpt_valid_map.
Continue to the next block after correcting se->valid_blocks and del, so that an already invalidated block does not trigger further discard bitmap or checkpoint counter updates.
---
V1 -> V2:
- Add Cc: [email protected].
- Add a Fixes tag for the discard bitmap handling.
Fixes tags:
- 81ffbd224e5f introduced the segment checkpoint accounting regression by replacing the del-based adjustment with a fixed decrement.
- a66cdd985532 introduced the discard bitmap update that still runs when the block is already invalid.
fs/f2fs/segment.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +4 -1
@@ -2560,7 +2560,10 @@ static int update_sit_entry_for_release(struct f2fs_sb_info *sbi, struct seg_entf2fs_bug_on (sbi,1 ); se->valid_blocks++; del +=1 ; - }else if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) { +continue ; + } + +if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) {/* * If checkpoints are off, we must not reuse data that * was used in the previous checkpoint. If it was used
Signature · 1 line
2.53.0
Quoted 9 lines · Seongjae Jeong
When
update_sit_entry_for_release()encounters a block whose bit is already cleared incur_valid_map, it reports the inconsistency and correctsse->valid_blocksand del. However, it still proceeds with the discard bitmap and checkpoint accounting updates.This can clear the discard bit unnecessarily and incorrectly decrement the segment and section
ckpt_valid_blockscounters when the block is not marked inckpt_valid_map.
Quoted 7 lines
Continue to the next block after correcting
se->valid_blocksand del, so that an already invalidated block does not trigger further discard bitmap or checkpoint counter updates.Fixes 81ffbd224e5f ("f2fs: update_sit_entry_for_release() supports consecutive blocks.")Fixes a66cdd985532 ("f2fs: introduce discard_map for f2fs_trim_fs")
Should use Fixes: 81ffbd224e5f ("f2fs: update_sit_entry_for_release() supports consecutive blocks.") instead of above two Fixes lines as discussed w/ Seongjae in
https://lore.kernel.org/linux-f2fs-devel/CAPHXVrx8AESeQdo+nsnHZsBaJ4=_t00cqaT6G1TGh-JLN_pHog@mail.gmail.com
Quoted 1 line
Signed-off-by Seongjae Jeong <[email protected]>
Thanks,