[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210422125910.127871-1-frank.li@vivo.com>
Date: Thu, 22 Apr 2021 20:59:10 +0800
From: Yangtao Li <frank.li@...o.com>
To: jaegeuk@...nel.org, chao@...nel.org,
linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Cc: Yangtao Li <frank.li@...o.com>
Subject: [PATCH] f2fs: set prefree as free segments after clear prefree segments
For now, when do_checkpoint fails, the prefree bitmap is not cleared,
but these segments are already in the free state. If these segments
are used, the segments in use will be reset to the free state when
f2fs_clear_prefree_segments is called next time.
So move set_prefree_as_free_segments after clear_prefree_segments.
Signed-off-by: Yangtao Li <frank.li@...o.com>
---
fs/f2fs/segment.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index c2866561263e..ea1334e17a0d 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1945,20 +1945,6 @@ void f2fs_release_discard_addrs(struct f2fs_sb_info *sbi)
release_discard_addr(entry);
}
-/*
- * Should call f2fs_clear_prefree_segments after checkpoint is done.
- */
-static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)
-{
- struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
- unsigned int segno;
-
- mutex_lock(&dirty_i->seglist_lock);
- for_each_set_bit(segno, dirty_i->dirty_segmap[PRE], MAIN_SEGS(sbi))
- __set_test_and_free(sbi, segno, false);
- mutex_unlock(&dirty_i->seglist_lock);
-}
-
void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
struct cp_control *cpc)
{
@@ -1993,6 +1979,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
for (i = start; i < end; i++) {
if (test_and_clear_bit(i, prefree_map))
dirty_i->nr_dirty[PRE]--;
+ __set_test_and_free(sbi, i, false);
}
if (!f2fs_realtime_discard_enable(sbi))
@@ -4188,8 +4175,6 @@ void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
cpc->trim_start = trim_start;
}
up_write(&sit_i->sentry_lock);
-
- set_prefree_as_free_segments(sbi);
}
static int build_sit_info(struct f2fs_sb_info *sbi)
--
2.25.1
Powered by blists - more mailing lists