* [f2fs-dev] [PATCH RFC] f2fs: revalidate empty segment when checkpoint is disabled
@ 2024-10-18 10:01 Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; only message in thread
From: Chao Yu via Linux-f2fs-devel @ 2024-10-18 10:01 UTC (permalink / raw)
To: jaegeuk; +Cc: Qi Han, linux-kernel, Daniel Rosenberg, linux-f2fs-devel
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 <drosen@google.com>
Reported-by: Qi Han <hanqi@vivo.com>
Signed-off-by: Chao Yu <chao@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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-10-18 10:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 10:01 [f2fs-dev] [PATCH RFC] f2fs: revalidate empty segment when checkpoint is disabled Chao Yu via Linux-f2fs-devel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).