f2fs: revalidate empty segment when checkpoint is disabled
Chao Yu
maintainerRFC PATCH 1/1 f2fs: revalidate empty segment when checkpoint is disabled
If checkpoint is off, let's set segment as free once all newly written datas were removed, it fixes below case:
dd if=/dev/zero of=f2fs.img bs=1M count=64 mkfs.f2fs -f f2fs.img
mount -o checkpoint=disable:10% f2fs.img mnt dd if=/dev/zero of=mnt/file bs=1M count=19 sync
rm mnt/file
dd if=/dev/zero of=mnt/file bs=1M count=9
dd: error writing 'mnt/file': No space left on device
Cc Daniel Rosenberg <[email protected]>
Reported-by Qi Han <[email protected]>
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/segment.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +12 -1
@@ -849,6 +849,17 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno) valid_blocks =get_valid_blocks (sbi, segno, false); ckpt_valid_blocks =get_ckpt_valid_blocks (sbi, segno, false); +/* +* If checkpoint is off, let's set segment as free once all newly +* written datas were removed. +*/ +if (is_sbi_flag_set (sbi,SBI_CP_DISABLED ) && + valid_blocks ==0 && ckpt_valid_blocks ==0 ) { +__remove_dirty_segment (sbi, segno,DIRTY ); +__set_test_and_free (sbi, segno, false); + goto out_lock; + } +if (valid_blocks ==0 && (!is_sbi_flag_set (sbi,SBI_CP_DISABLED ) || ckpt_valid_blocks == usable_blocks)) {__locate_dirty_segment (sbi, segno,PRE );
@@ -859,7 +870,7 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)/* Recovery routine with SSR needs this */ __remove_dirty_segment (sbi, segno,DIRTY ); } - +out_lock:mutex_unlock (&dirty_i->seglist_lock); }
Signature · 1 line
2.40.1