linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Yangtao Li <frank.li@vivo.com>, <jaegeuk@kernel.org>,
	<chao@kernel.org>, <linux-f2fs-devel@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [f2fs-dev] [PATCH] f2fs: set prefree as free segments after clear prefree segments
Date: Fri, 23 Apr 2021 09:30:09 +0800	[thread overview]
Message-ID: <247c6055-c004-72a6-5093-3949c2ed8495@huawei.com> (raw)
In-Reply-To: <20210422125910.127871-1-frank.li@vivo.com>

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@vivo.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)
> 

  reply	other threads:[~2021-04-23  1:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 12:59 [PATCH] f2fs: set prefree as free segments after clear prefree segments Yangtao Li
2021-04-23  1:30 ` Chao Yu [this message]
2021-04-23  2:40   ` Re:Re: [f2fs-dev] " 李扬韬
2021-04-23  3:37     ` Chao Yu
2021-04-23  9:02       ` 李扬韬

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=247c6055-c004-72a6-5093-3949c2ed8495@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=chao@kernel.org \
    --cc=frank.li@vivo.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).