Skip to contentSkip to conversation

Resize metadata corruption

f2fs-dev uplinkr--- via Linux-f2fs-devel 2 participants 18 messages Apr 6, 2025 – Apr 14, 2025

lore
Share & tools
lore
#0 lore raw

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment manager (-117)

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#1 lore raw

Hi all,

I also encountered something similar a while back with resizing but didn't report it and just manually migrated the files.
I assisted him to ensure using the latest kernel/f2fs-tools, but his metadata seems pretty bad right now and I suggested him to ask the mailing list directly.

The URL there should be https://arter97.com/.f2fs-20250406/fsck.log , a little typo there.

Can we have some sort of CI/automated testing for the resizing as well?

Thanks.

Quoted 27 lines · On Sun, Apr 6, 2025 at 1:26 AM uplinkr--- via Linux-f2fs-devel…

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment

manager (-117)

Quoted 7 lines

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw

Hello everyone,

I have also decided to take a look at the partition with data recovery tools such as Photorec. It seems all my data is intact! As such, I was considering an alternate data recovery solution.

Judging by F2FS's documentation, it is blocks who keep track of their path rather than the checkpoint. If I could export all directory and file names, perhaps I could recover my data manually. Is this the simpler solution, or should fsck be explicitly patched to resolve both the corruption recovery failure and resize block misalignment?

Thanks.

Quoted 11 lines · Juhyung Park

Hi all,

I also encountered something similar a while back with resizing but didn't report it and just manually migrated the files.
I assisted him to ensure using the latest kernel/f2fs-tools, but his metadata seems pretty bad right now and I suggested him to ask the mailing list directly.

The URL there should be https://arter97.com/.f2fs-20250406/fsck.log , a little typo there.

Quoted 40 lines

Can we have some sort of CI/automated testing for the resizing as well?

Thanks.

Quoted 34 lines · On Sun, Apr 6, 2025 at 1:26 AM uplinkr--- via Linux-f2fs-devel…

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment

manager (-117)

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#15 lore raw
In reply to uplinkr--- via Linux-f2fs-devel
Quoted 10 lines · On 4/6/25 16:04, uplinkr--- via Linux-f2fs-devel wrote:

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Quoted 8 lines

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment manager (-117)

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

Hello,

Could you please upload fsck.log in bugzilla.kernel.org, or somewhere else? I can not download it from above link address, sorry.

Thanks,

Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#16 lore raw

Hello,

I made a typo in the URL earlier. It should be https://arter97.com/.f2fs-20250406/fsck.log . Could you try it, please?

Thanks.

Quoted 18 lines · Chao Yu
Quoted 17 lines · On 4/6/25 16:04, uplinkr--- via Linux-f2fs-devel wrote:

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment manager (-117)

Quoted 15 lines
Quoted 1 line

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

Hello,

Could you please upload fsck.log in bugzilla.kernel.org, or somewhere else? I can not download it from above link address, sorry.

Thanks,

Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#17 lore raw
Quoted 3 lines · On 4/8/25 14:10, [email protected] wrote:

Hello,

I made a typo in the URL earlier. It should be https://arter97.com/.f2fs-20250406/fsck.log . Could you try it, please?

Ah, alright.

Now, I can access it, thank you. Let me check the details in the log.

Thanks,

Quoted 37 lines

Thanks.

Quoted 33 lines · Chao Yu
Quoted 10 lines · On 4/6/25 16:04, uplinkr--- via Linux-f2fs-devel wrote:

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Quoted 8 lines

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment manager (-117)

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

Hello,

Could you please upload fsck.log in bugzilla.kernel.org, or somewhere else? I can not download it from above link address, sorry.

Thanks,

Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
In reply to Juhyung Park
Quoted 4 lines · Juhyung Park

Hi all,

I also encountered something similar a while back with resizing but didn't report it and just manually migrated the files.

Hi Juhyung,

Did you develop an individual tool to migrate specified inode to target block address?

Quoted 3 lines

I assisted him to ensure using the latest kernel/f2fs-tools, but his metadata seems pretty bad right now and I suggested him to ask the mailing list directly.

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

To Jaegeuk, any thoughts about this problem?

Quoted 3 lines

The URL there should be https://arter97.com/.f2fs-20250406/fsck.log , a little typo there.

Thanks, I didn't notice this previously.

Quoted 2 lines

Can we have some sort of CI/automated testing for the resizing as well?

Agreed, will work on some testcases for resize.f2fs when I get some free slots.

Thanks,

Quoted 41 lines

Thanks.

Quoted 27 lines · On Sun, Apr 6, 2025 at 1:26 AM uplinkr--- via Linux-f2fs-devel…

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment

manager (-117)

Quoted 7 lines

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#4 lore raw

Hi Chao,

Quoted 11 lines · Chao Yu
Quoted 4 lines · Juhyung Park

Hi all,

I also encountered something similar a while back with resizing but didn't report it and just manually migrated the files.

Hi Juhyung,

Did you develop an individual tool to migrate specified inode to target block address?

Nope. And neither did @uplinkr use any custom tools to mess around the f2fs partition.

Quoted 8 lines
Quoted 4 lines

I assisted him to ensure using the latest kernel/f2fs-tools, but his metadata seems pretty bad right now and I suggested him to ask the mailing list directly.

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Yeah, having fsck.f2fs segfault mid-way post resize won't help either.

Quoted 7 lines

To Jaegeuk, any thoughts about this problem?

Quoted 3 lines

The URL there should be https://arter97.com/.f2fs-20250406/fsck.log , a little typo there.

Quoted 7 lines

Thanks, I didn't notice this previously.

Quoted 2 lines

Can we have some sort of CI/automated testing for the resizing as well?

Agreed, will work on some testcases for resize.f2fs when I get some free slots.

Should we mark this experimental for the time being?

Thanks.

Quoted 49 lines

Thanks,

Quoted 45 lines

Thanks.

Quoted 27 lines · On Sun, Apr 6, 2025 at 1:26 AM uplinkr--- via Linux-f2fs-devel…

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment

manager (-117)

Quoted 7 lines

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#8 lore raw
In reply to Chao Yu via Linux-f2fs-devel
Quoted 3 lines · Chao Yu

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Hello,

The issue is the corrupt partition in question contains a lot of unbackupped, valuable data for me. I wasn't aware or informed of the potential issues resizing on F2FS has (the ArchWiki listed none) and as such recovery of this partition is a lifeline for me.

Could you please write this tool or a patch that I can try in fsck?

Thanks.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#5 lore raw
In reply to Juhyung Park
Quoted 10 lines · Juhyung Park

Hi Chao,

Quoted 7 lines · Chao Yu
Quoted 4 lines · Juhyung Park

Hi all,

I also encountered something similar a while back with resizing but didn't report it and just manually migrated the files.

Quoted 7 lines
Quoted 4 lines

Hi Juhyung,

Did you develop an individual tool to migrate specified inode to target block address?

Nope. And neither did @uplinkr use any custom tools to mess around the f2fs partition.

Oh, so how did you migrate files manually?

Quoted 22 lines
Quoted 9 lines
Quoted 5 lines

I assisted him to ensure using the latest kernel/f2fs-tools, but his metadata seems pretty bad right now and I suggested him to ask the mailing list directly.

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Yeah, having fsck.f2fs segfault mid-way post resize won't help either.

Quoted 10 lines

To Jaegeuk, any thoughts about this problem?

Quoted 3 lines

The URL there should be https://arter97.com/.f2fs-20250406/fsck.log , a little typo there.

Thanks, I didn't notice this previously.

Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Can we have some sort of CI/automated testing for the resizing as well?

Agreed, will work on some testcases for resize.f2fs when I get some free slots.

Should we mark this experimental for the time being?

Agreed.

Thanks,

Quoted 52 lines

Thanks.

Quoted 49 lines

Thanks,

Quoted 45 lines

Thanks.

Quoted 27 lines · On Sun, Apr 6, 2025 at 1:26 AM uplinkr--- via Linux-f2fs-devel…

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment

manager (-117)

Quoted 7 lines

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#6 lore raw
Quoted 14 lines · Chao Yu
Quoted 12 lines · Juhyung Park

Hi Chao,

Quoted 9 lines · Chao Yu
Quoted 4 lines · Juhyung Park

Hi all,

I also encountered something similar a while back with resizing but didn't report it and just manually migrated the files.

Hi Juhyung,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Did you develop an individual tool to migrate specified inode to target block address?

Nope. And neither did @uplinkr use any custom tools to mess around the f2fs partition.

Oh, so how did you migrate files manually?

You remember the extended node bitmap fiasco :)
After that, whenever I run fsck (or in this case, resize), I wrap the entire raw block device to a dm-snapshot so that original stays intact and run if on top of the dm, so that I don't run into corner cases.

When I was migrating my personal f2fs setup to another SSD, I had similar resize/fsck warnings/errors. (I should've reported this back then, sorry.)
So I decided to just rsync the whole partition after mounting it and migrate under VFS and not risk the potential corner case.

So for my case, it was before the damage was done (with dm-snapshot) unlike @uplinkr.

Quoted 25 lines
Quoted 25 lines
Quoted 10 lines
Quoted 6 lines

I assisted him to ensure using the latest kernel/f2fs-tools, but his metadata seems pretty bad right now and I suggested him to ask the mailing list directly.

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Yeah, having fsck.f2fs segfault mid-way post resize won't help either.

Quoted 12 lines

To Jaegeuk, any thoughts about this problem?

Quoted 3 lines

The URL there should be https://arter97.com/.f2fs-20250406/fsck.log , a little typo there.

Thanks, I didn't notice this previously.

Quoted 2 lines

Can we have some sort of CI/automated testing for the resizing as well?

Quoted 62 lines
Quoted 4 lines
Quoted 2 lines

Agreed, will work on some testcases for resize.f2fs when I get some free slots.

Should we mark this experimental for the time being?

Agreed.

Thanks,

Quoted 52 lines

Thanks.

Quoted 49 lines

Thanks,

Quoted 45 lines

Thanks.

Quoted 27 lines · On Sun, Apr 6, 2025 at 1:26 AM uplinkr--- via Linux-f2fs-devel…

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment

manager (-117)

Quoted 7 lines

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#9 lore raw
In reply to uplinkr--- via Linux-f2fs-devel
Quoted 9 lines · On 4/10/25 14:19, [email protected] wrote:
Quoted 3 lines · Chao Yu

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Hello,

The issue is the corrupt partition in question contains a lot of unbackupped, valuable data for me. I wasn't aware or informed of the potential issues resizing on F2FS has (the ArchWiki listed none) and as such recovery of this partition is a lifeline for me.

Sorry about this, we should give a explicit caution about resize tool use.

But still I didn't get why we can run into this situation, since as you said, resize went through successfully. Could you please provide more details about process of resize? Parameters for resize? Logs you kept during resize? etc.

Quoted 2 lines

Could you please write this tool or a patch that I can try in fsck?

I will try my best.

Quoted 2 lines

Thanks.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#10 lore raw
Quoted 4 lines · Chao Yu

But still I didn't get why we can run into this situation, since as you said, resize went through successfully. Could you please provide more details about process of resize? Parameters for resize? Logs you kept during resize? etc.

Hello,

I'm afraid I don't have any logs beyond fsck because I was running all operations off a live ISO and didn't have the foresight to save the logs. I will attempt to replicate my actions on a VM to have further insight.

I started the resize in GParted. It initially went through with its GPT workflow (resize the GPT partition, move F2FS to the left, exact steps are unclear). Proceeding to growing the filesystem, however, it errored with "Mount unclean image to replay log". I initially didn't take this at face value and rebooted into the system to see my filesystem completely intact (regrettably, not taking a backup).

Afterwards, I rebooted back into the live ISO, mounted and unmounted the partition and ran "Check" in GParted. It first triggered an fsck (which suggested it the filesystem could grow), launched resize.f2fs (which went through successfully) and ran fsck again. This is where the fun stopped: GParted freezed dead. I killed it and ran fsck in a terminal with the same args as GParted (-f -a) and regrettably pressed y on restoring lost files. It listed a lot of my files (which I recognized by filenames) and went on for about two minutes before erroring with "Segmentation Error".

I hope this will be helpful. Thanks.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#7 lore raw
In reply to Juhyung Park
Quoted 18 lines · Juhyung Park
Quoted 17 lines · Chao Yu
Quoted 15 lines · Juhyung Park

Hi Chao,

Quoted 11 lines · Chao Yu
Quoted 4 lines · Juhyung Park

Hi all,

I also encountered something similar a while back with resizing but didn't report it and just manually migrated the files.

Hi Juhyung,

Did you develop an individual tool to migrate specified inode to target block address?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Nope. And neither did @uplinkr use any custom tools to mess around the f2fs partition.

Oh, so how did you migrate files manually?

You remember the extended node bitmap fiasco :)

Oh, yes, luckily, you reported that bug so quickly, so that we can fix that in time, thank you!

Quoted 3 lines

After that, whenever I run fsck (or in this case, resize), I wrap the entire raw block device to a dm-snapshot so that original stays intact and run if on top of the dm, so that I don't run into corner cases.

I think it's a good habit to always make important data being backuped.

Quoted 4 lines

When I was migrating my personal f2fs setup to another SSD, I had similar resize/fsck warnings/errors. (I should've reported this back then, sorry.)

Alright, anyway, I'd like to say please feel free to report any bugs of f2fs you encounter later, will be appreciate for that. :)

Quoted 5 lines

So I decided to just rsync the whole partition after mounting it and migrate under VFS and not risk the potential corner case.

So for my case, it was before the damage was done (with dm-snapshot) unlike @uplinkr.

Okay, got it, thanks for the details.

Thanks,

Quoted 82 lines
Quoted 82 lines
Quoted 24 lines
Quoted 11 lines
Quoted 7 lines

I assisted him to ensure using the latest kernel/f2fs-tools, but his metadata seems pretty bad right now and I suggested him to ask the mailing list directly.

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Yeah, having fsck.f2fs segfault mid-way post resize won't help either.

Quoted 10 lines

To Jaegeuk, any thoughts about this problem?

Quoted 3 lines

The URL there should be https://arter97.com/.f2fs-20250406/fsck.log , a little typo there.

Thanks, I didn't notice this previously.

Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Can we have some sort of CI/automated testing for the resizing as well?

Agreed, will work on some testcases for resize.f2fs when I get some free slots.

Should we mark this experimental for the time being?

Agreed.

Thanks,

Quoted 47 lines

Thanks.

Quoted 44 lines

Thanks,

Quoted 41 lines

Thanks.

Quoted 34 lines · On Sun, Apr 6, 2025 at 1:26 AM uplinkr--- via Linux-f2fs-devel…

Hello everyone,

I am having trouble with F2FS. Specifically, I believe metadata got corrupted when I resized it. I have a 512 GB drive. My F2FS partition was approximately located on 369-497 GB (128 GB size). Using GParted, I resized it to 0.5-497 GB. While the partition resizing went through successfully, filesystem resizing initially failed with "Mount unclean image to replay log". I have done that and retried resizing.

Afterwards, however, fsck started giving out a lot of errors, at one point it asked if I wished to restore lost data, which I agreed to. Logs specified a lot of my files (which I could tell by filenames) and mid-way through the process, it segfaulted. Now, when I run fsck, no files are asked to be restored, and it completes successfully. However, when I attempt to mount it, I get an error saying "Structure needs cleaning".

Could someone help me restore my metadata (at least, long enough to extract my files)? Thanks.

dmesg logs:

[   96.184127] F2FS-fs (nvme0n1p5): Mismatch valid blocks 769 vs. 68
[   96.188050] F2FS-fs (nvme0n1p5): Failed to initialize F2FS segment

manager (-117)

fsck.f2fs --dry-run -d 3 logs: https://arter.com/.f2fs-20250406/fsck.log

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#11 lore raw
In reply to Chao Yu via Linux-f2fs-devel

Hi Chao.

Good news!

It appears that by some miracle, @uplinkr managed to dodge all odds:
1. gparted did not perform shrink as they didn't write the fool-proof shrink size calculation code yet
2. The new location within the partition table did not overlap with the old partition
3. The faulty fsck run did not touch the old partition's area

We managed to get the older partition's location via testdisk (which looks for f2fs magic code) and restore the entire partition.

I insisted that he use this opportunity to reproduce the issue in a safe fashion, communicate with upstream and make sure no one else has to go through the same thing (after a full backup, obviously).

I'll walk him through setting up a dm-snapshot and gather the initial/proper resize, mount, fsck log after the backup.

One thing to note here is that he said that the utilization was very
full: only 8G left. Maybe this is the corner case that we need to look out for?

Thanks,

Quoted 21 lines · Chao Yu
Quoted 9 lines · On 4/10/25 14:19, [email protected] wrote:
Quoted 3 lines · Chao Yu

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Hello,

The issue is the corrupt partition in question contains a lot of unbackupped, valuable data for me. I wasn't aware or informed of the potential issues resizing on F2FS has (the ArchWiki listed none) and as such recovery of this partition is a lifeline for me.

Sorry about this, we should give a explicit caution about resize tool use.

But still I didn't get why we can run into this situation, since as you said, resize went through successfully. Could you please provide more details about process of resize? Parameters for resize? Logs you kept during resize? etc.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Could you please write this tool or a patch that I can try in fsck?

I will try my best.

Quoted 2 lines

Thanks.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#12 lore raw
Quoted 11 lines · Juhyung Park

Hi Chao.

Good news!

It appears that by some miracle, @uplinkr managed to dodge all odds:
1. gparted did not perform shrink as they didn't write the fool-proof shrink size calculation code yet
2. The new location within the partition table did not overlap with the old partition
3. The faulty fsck run did not touch the old partition's area

Quoted 2 lines

We managed to get the older partition's location via testdisk (which looks for f2fs magic code) and restore the entire partition.

Juhyung,

Great! That's really good news.

I'm too focused on the bug/repair to miss that point, anyway that's really good point to try to restore data by checking and reading from original location.

Quoted 4 lines

I insisted that he use this opportunity to reproduce the issue in a safe fashion, communicate with upstream and make sure no one else has to go through the same thing (after a full backup, obviously).

Thanks, it's really important for us and other uses.

I'm planning to post revert patch for -i support today, and also I'm thinking about adding a -f option to allow distros user to forcing running resize, w/o -f option, let it only print caution message of the risk.

Quoted 7 lines

I'll walk him through setting up a dm-snapshot and gather the initial/proper resize, mount, fsck log after the backup.

One thing to note here is that he said that the utilization was very
full: only 8G left. Maybe this is the corner case that we need to look out for?

Thanks for the hint, let me create testcases based on such condition to see whether it can trigger the bug.

Thanks,

Quoted 32 lines

Thanks,

Quoted 28 lines · Chao Yu
Quoted 9 lines · On 4/10/25 14:19, [email protected] wrote:
Quoted 3 lines · Chao Yu

I checked the log, I guess it actually seems pretty bad... I guess we need to find out those file which has not been migrated correctly, and try to correct them, may be w/ a new tool.

Hello,

The issue is the corrupt partition in question contains a lot of unbackupped, valuable data for me. I wasn't aware or informed of the potential issues resizing on F2FS has (the ArchWiki listed none) and as such recovery of this partition is a lifeline for me.

Sorry about this, we should give a explicit caution about resize tool use.

But still I didn't get why we can run into this situation, since as you said, resize went through successfully. Could you please provide more details about process of resize? Parameters for resize? Logs you kept during resize? etc.

Quoted 2 lines

Could you please write this tool or a patch that I can try in fsck?

I will try my best.

Quoted 2 lines

Thanks.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#13 lore raw

Hello everyone,

I'm sorry to not have anything constructive to add, but I'm about as flabbergasted as I could be. I retraced all my steps (exactly as I went through with them before!) and was unable to replicate the corruption. On the contrary, the filesystem grew completely as expected.

After restoring my partition and backing it up, I ran fsck on it. fsck reported no issues with the data, so I pressed on. I opened up GParted and expanded it like last time. This time, however, I didn't end up with no "Mount unclean image to replay log" error, and the resize went through as expected. The partition mounted perfectly well, and when I ran fsck, it too reported no corruption.

I recall that the "Mount unclean image to replay log" error was present through reboots and live ISOs. Perhaps that's the culprit?

Thanks, sincerely.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#14 lore raw
Quoted 4 lines · On 4/11/25 23:49, [email protected] wrote:

Hello everyone,

I'm sorry to not have anything constructive to add, but I'm about as flabbergasted as I could be. I retraced all my steps (exactly as I went through with them before!) and was unable to replicate the corruption. On the contrary, the filesystem grew completely as expected.

Hi uplinkr,

Thanks a lot for helping to reproduce this bug.

Quoted 5 lines

After restoring my partition and backing it up, I ran fsck on it. fsck reported no issues with the data, so I pressed on. I opened up GParted and expanded it like last time. This time, however, I didn't end up with no "Mount unclean image to replay log" error, and the resize went through as expected. The partition mounted perfectly well, and when I ran fsck, it too reported no corruption.

I recall that the "Mount unclean image to replay log" error was present through reboots and live ISOs. Perhaps that's the culprit?

	if (c.func != FSCK && c.func != DUMP && c.func != INJECT &&
		!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG)) {
		ERR_MSG("Mount unclean image to replay log first\n");
		return -1;
	}

If we run resize on an uncleaned image (suffer sudden power cut), it will reports "Mount unclean image to replay log first" message, once you mount this image, and umount it normally, then we can run resize on it successfully.

So I doubt it's not the key point of resize bug, one thing I suspect more is space usage, as Juhyung reported:

"One thing to note here is that he said that the utilization was very
full: only 8G left. Maybe this is the corner case that we need to look out for?"

Maybe, we can try resizing w/ almost fully used image to check whether there is any corner case we missed to handle.

Please let me know, if you find more special status of your data.

Thanks,

Quoted 2 lines

Thanks, sincerely.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel