mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: 李扬韬 <frank.li@vivo.com>
Cc: <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 11:37:05 +0800	[thread overview]
Message-ID: <3323e5c0-cd52-528a-6a57-5982db05a4bf@huawei.com> (raw)
In-Reply-To: <AIMAXgAnDv8vtlWxuL6mq4q3.3.1619145657480.Hmail.frank.li@vivo.com>

Hi Yangtao,

On 2021/4/23 10:40, 李扬韬 wrote:
> HI Chao,
>   
>>> 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.

Oh, it seems I misunderstood what the patch did, please ignore above
comments.

> 
> For do_checkpoint sucess:
> 
> f2fs_write_checkpoint
> ->f2fs_flush_sit_entries
>      ->set_prefree_as_free_segments
> ->do_checkpoint
> ->f2fs_clear_prefree_segments
> 
> 
> Calling set_prefree_as_free_segments when do_checkpoint fails,
> seems to be incorrect. I think clear free bitmap should be after
> clear prefree bitmap.
> 
> For do_checkpoint fail:
> 
> f2fs_write_checkpoint
> ->f2fs_flush_sit_entries
>      ->set_prefree_as_free_segments
> ->do_checkpoint
> ->f2fs_release_discard_addrs
> 
> The prefree bitmap is not cleared, but free bitmap is cleared,which means
> we can use these segments that are marked as free. When the free segments
> is used, the next f2fs_clear_prefree_segments will mark prefree as free again,
> causing some problem.

Okay, I can understand that.

But the problem here is, after applying this patch, successful checkpoint
may record wrong free_segment value:

- f2fs_write_checkpoint
  - f2fs_flush_sit_entries
  - do_checkpoint
   - ckpt->free_segment_count = cpu_to_le32(free_segments(sbi));
  - f2fs_clear_prefree_segments
   - __set_test_and_free
    - free_i->free_segments++;

I guess for the case of do_checkpoint() fails, maybe we can reset
free segment to prefree status.

Thoughts?

Thanks,

> 
> With this patch, for do_checkpoint fail:
> 
> f2fs_write_checkpoint
> ->f2fs_flush_sit_entries
> ->do_checkpoint
> ->f2fs_release_discard_addrs
> 
> At this time, we did not mark prefree as free segments, so these segments will not be used.
> 
> Thx
> 

  reply	other threads:[~2021-04-23  3:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 12:59 Yangtao Li
2021-04-23  1:30 ` [f2fs-dev] " Chao Yu
2021-04-23  2:40   ` 李扬韬
2021-04-23  3:37     ` Chao Yu [this message]
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=3323e5c0-cd52-528a-6a57-5982db05a4bf@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

all inboxes | Powered by JetHome®