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 <dro...@google.com> Reported-by: Qi Han <ha...@vivo.com> Signed-off-by: Chao Yu <c...@kernel.org> --- fs/f2fs/segment.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index e172b3d0aec3..4f480bfc9618 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -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); } -- 2.40.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel