[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <247c6055-c004-72a6-5093-3949c2ed8495@huawei.com>
Date: Fri, 23 Apr 2021 09:30:09 +0800
From: Chao Yu <yuchao0@...wei.com>
To: Yangtao Li <frank.li@...o.com>, <jaegeuk@...nel.org>,
<chao@...nel.org>, <linux-f2fs-devel@...ts.sourceforge.net>,
<linux-kernel@...r.kernel.org>
Subject: Re: [f2fs-dev] [PATCH] f2fs: set prefree as free segments after clear
prefree segments
On 2021/4/22 20:59, Yangtao Li wrote:
> 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.
That's not correct.
/*
* Should call f2fs_clear_prefree_segments after checkpoint is done.
*/
static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)
Comments above set_prefree_as_free_segments() should have told you
the rule, otherwise if checkpoint failed, valid data in last valid
checkpoint could be corrupted after segment reuse.
Thanks,
>
> 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)
>
Powered by blists - more mailing lists