All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Juhyung Park <qkrwngud825@gmail.com>
Cc: uplinkr@airmail.cc, jaegeuk@kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] resize.f2fs: fix to always change metadata for expand resize
Date: Wed, 16 Apr 2025 13:51:31 +0800	[thread overview]
Message-ID: <8ee817b1-df95-46ee-9207-3b5d13b4e90f@kernel.org> (raw)
In-Reply-To: <CAD14+f38jfkMUsoAdVU45fmvbAqdBD4tveXx0ireSX7nr3ZD1Q@mail.gmail.com>

On 4/16/25 11:40, Juhyung Park wrote:
> Just checked gparted's source code:
> https://github.com/GNOME/gparted/blob/GPARTED_1_7_0/src/f2fs.cc#L135
> 
> Seems unlikely. :/

Alright, seems still we need another testcase for reproducing. :(

Thanks,

> 
> On Tue, Apr 15, 2025 at 8:34 PM Chao Yu <chao@kernel.org> wrote:
>>
>> On 4/16/25 03:28, Juhyung Park wrote:
>>> Hm.
>>>
>>> Would this be what @uplinkr might have encountered?
>>
>> Maybe, :)
>>
>> @uplinkr, previously, if you used '-s' parameter while expand-resizing,
>> that could be the reason it corrupted your partition.
>>
>> Thanks,
>>
>>>
>>> On Mon, Apr 14, 2025 at 4:13 AM Chao Yu via Linux-f2fs-devel
>>> <linux-f2fs-devel@lists.sourceforge.net> wrote:
>>>>
>>>> w/ below testcase, resize will generate a corrupted image which
>>>> contains inconsistent metadata:
>>>>
>>>> touch img
>>>> truncate -s $((512*1024*1024*1024)) img
>>>> mkfs.f2fs -f img $((256*1024*1024))
>>>> resize.f2fs -s img -t $((1024*1024*1024))
>>>> mount img /mnt/f2fs
>>>>
>>>> [   31.725200] F2FS-fs (loop0): Wrong bitmap size: sit: 192, sit_blk_cnt:4762
>>>> [   31.728441] F2FS-fs (loop0): Failed to get valid F2FS checkpoint
>>>>
>>>> The root cause is safe mode (via -s option) is not compatible
>>>> w/ expand resize, due to in safe mode, we will keep all parameters
>>>> related to NAT, SIT, SSA area, e.g. sit_bitmap_size, however, we
>>>> will update segment_count_main according new partition size, result
>>>> in there is no enough sit_bitmap and SIT blocks to address the
>>>> entire block address of new partition.
>>>>
>>>> Adding a check condition to avoid expanding partition in safe
>>>> mode, and change manual accordingly.
>>>>
>>>> Signed-off-by: Chao Yu <chao@kernel.org>
>>>> ---
>>>>  fsck/resize.c     | 12 ++++++++----
>>>>  man/resize.f2fs.8 |  2 +-
>>>>  2 files changed, 9 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/fsck/resize.c b/fsck/resize.c
>>>> index 1ab7d75..58914ec 100644
>>>> --- a/fsck/resize.c
>>>> +++ b/fsck/resize.c
>>>> @@ -756,18 +756,22 @@ int f2fs_resize(struct f2fs_sb_info *sbi)
>>>>
>>>>         /* may different sector size */
>>>>         if ((c.target_sectors * c.sector_size >>
>>>> -                       get_sb(log_blocksize)) < get_sb(block_count))
>>>> +                       get_sb(log_blocksize)) < get_sb(block_count)) {
>>>>                 if (!c.safe_resize) {
>>>>                         ASSERT_MSG("Nothing to resize, now only supports resizing with safe resize flag\n");
>>>>                         return -1;
>>>>                 } else {
>>>>                         return f2fs_resize_shrink(sbi);
>>>>                 }
>>>> -       else if (((c.target_sectors * c.sector_size >>
>>>> +       } else if (((c.target_sectors * c.sector_size >>
>>>>                         get_sb(log_blocksize)) > get_sb(block_count)) ||
>>>> -                       c.ignore_error)
>>>> +                       c.ignore_error) {
>>>> +               if (c.safe_resize) {
>>>> +                       ASSERT_MSG("Expanding resize doesn't support safe resize flag");
>>>> +                       return -1;
>>>> +               }
>>>>                 return f2fs_resize_grow(sbi);
>>>> -       else {
>>>> +       } else {
>>>>                 MSG(0, "Nothing to resize.\n");
>>>>                 return 0;
>>>>         }
>>>> diff --git a/man/resize.f2fs.8 b/man/resize.f2fs.8
>>>> index bdda4fd..5b6daf5 100644
>>>> --- a/man/resize.f2fs.8
>>>> +++ b/man/resize.f2fs.8
>>>> @@ -69,7 +69,7 @@ Skip caution dialogue and resize partition directly.
>>>>  Specify support write hint.
>>>>  .TP
>>>>  .BI \-s
>>>> -Enable safe resize.
>>>> +Enable safe resize, it can only be used w/ shrink resize.
>>>>  .TP
>>>>  .BI \-V
>>>>  Print the version number and exit.
>>>> --
>>>> 2.49.0
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Linux-f2fs-devel mailing list
>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

      reply	other threads:[~2025-04-16  5:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14 11:11 [f2fs-dev] [PATCH] resize.f2fs: fix to always change metadata for expand resize Chao Yu via Linux-f2fs-devel
2025-04-15 19:28 ` Juhyung Park
2025-04-16  3:33   ` Chao Yu via Linux-f2fs-devel
2025-04-16  3:40     ` Juhyung Park
2025-04-16  5:51       ` Chao Yu via Linux-f2fs-devel [this message]

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=8ee817b1-df95-46ee-9207-3b5d13b4e90f@kernel.org \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=qkrwngud825@gmail.com \
    --cc=uplinkr@airmail.cc \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.