Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Btrfs-convert causing corruption on sectors filled with zeros (NULs) #916

Closed
dakusan opened this issue Nov 4, 2024 · 4 comments
Closed

Comments

@dakusan
Copy link

dakusan commented Nov 4, 2024

btrfs-progs v6.6.3

I've converted at least 8 of my ext4 drives recently to btrfs with btrfs-convert, but have had problems with 2.

3 of the drives I've converted were HDDs. There were no errors reported during conversion on any of the drives. All 3 of these drives were backup drives holding disk image files, so file sizes ranged from 4GB-500GB, with a total of maybe 100-200 files each. I kept MD5 sums of all files on these drives to confirm their validity.

  • Drive 1 was encrypted with luks and had ~6.4TB to convert. About 95% of its files were corrupted.
  • Drive 2 was encrypted with veracrypt and had ~7TB to convert. No files were corrupted.
  • Drive 3 was encrypted with veracrypt and was a file mirror (not sector mirror) of Drive 2. I stopped checking how many files were corrupted after 5/10 that I checked were. It's crazy that of the 2 mirror drives only 1 had corrupt sectors. I'm currently running a sync on this drive to find out how much corruption there was.

I didn't verify this 100% but it seemed that the only sectors that ever got corrupted were ones that were filled with just 0s (NULs). The corruption was that random sectors that were supposed to be zero-filled were instead filled with random data. I'd say well under 1% of the sectors in each file were corrupted.

On drive #3 I kept the original ext4 image (I accidentally deleted it on Drive #1). I kept 1 file as corrupted for testing purposes to hopefully solve this bug. I checked the file on the ext2_saved backup image, and it had no corruption. Only the file on the btrfs volume.

This file is ~4914.4MB large. It only had 1022 zero-filled sectors (4096 bytes each). ALL zero-filled sectors were changed to random data. Meaning 0.081% corruption.


Ope, it just happened again on a SSD drive. This drive is luks encrypted and had ~500GB total of data over ~2.5 million files. Only 1 file got corrupted. It was ~1.3MB and contained all zeros. The ext2_saved backup had it correct, the btrfs file is filled with random data from start to finish.


Is there anything I can do to help debug this problem? I'm keeping around 2 problematic files on the 2 drives so we can check the used sectors or whatnot.

@adam900710
Copy link
Collaborator

Btrfs-progs version is too old.

There is a known bug in convert that it doesn't handle unwritten ext4 extents (aka, preallocated), it should be filled with a hole/preallocated extent, but is treated as regular data, causing those should be zero extents to be read from disk, causing garbage.

This is fixed in v6.9. And there is also a tiny fix related to convert in v6.10 (shouldn't really affect anyone though).

Thus I'd recommend to retry with v6.11 (the latest release) and check if everything is fine.

@dakusan
Copy link
Author

dakusan commented Nov 4, 2024

Agh, all that data collecting for nothing! hehe.

Thanks for letting me know about this. I had no idea the prepackaged btrfs on the latest version of linux mint was so old.

@adam900710
Copy link
Collaborator

If you do not want to use a PPA repo or compile btrfs-progs by youself, it's recommended to use some liveCD/USB from some rolling distros, and just do the btrfs-convert from that liveCD/USB and verify.

@dakusan
Copy link
Author

dakusan commented Nov 4, 2024

I'll look into getting my btrfs updated. Thanks again.

@dakusan dakusan closed this as completed Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants