Files corrupted on ZFS
Posted: Tue Feb 21, 2023 7:36 am
I am using ZFS 2.1.6 on macOS Ventura 13.2.1 (Intel) and am experiencing repeatable file corruption in certain circumstances.
I have spent some time tracking down a minimal set of files needed to reproduce this issue. I have staged the three files in a Git repo. Steps to reproduce are:
The Makefile patches src/dune. The last few lines of the file are shown below:
After patching the file, it should end up looking like this and be 244 bytes long.
However, the file size remains 262 bytes and the original content in those last few bytes is retained.
The key to the failure appears to be files extracted by tar. Looking in the Makefile, you'll see I create an archive of the file and extract it before patching. If you delete these steps, then the patching works as expected.
If you run this on a normal APFS volume, there is no issue, regardless of whether the files are tared or not.
I cannot reproduce this issue on Monterey.
I have spent some time tracking down a minimal set of files needed to reproduce this issue. I have staged the three files in a Git repo. Steps to reproduce are:
- Code: Select all
git clone https://github.com/mtelvers/zfs-test.git
cd zfs-test
make
The Makefile patches src/dune. The last few lines of the file are shown below:
- Code: Select all
(library
(name base64_rfc2045)
(modules base64_rfc2045)
(public_name base64.rfc2045)
(libraries bytes))
After patching the file, it should end up looking like this and be 244 bytes long.
- Code: Select all
(library
(name base64_rfc2045)
(modules base64_rfc2045)
(public_name base64.rfc2045))
However, the file size remains 262 bytes and the original content in those last few bytes is retained.
- Code: Select all
(library
(name base64_rfc2045)
(modules base64_rfc2045)
(public_name base64.rfc2045))
libraries bytes))
The key to the failure appears to be files extracted by tar. Looking in the Makefile, you'll see I create an archive of the file and extract it before patching. If you delete these steps, then the patching works as expected.
If you run this on a normal APFS volume, there is no issue, regardless of whether the files are tared or not.
- Code: Select all
# zfs version
zfs-macOS-2.1.6-1
zfs-kmod-2.1.6-1
# sw_vers
ProductName: macOS
ProductVersion: 13.2.1
BuildVersion: 22D68
# patch -v
patch 2.0-12u11-Apple
# tar --version
bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8
I cannot reproduce this issue on Monterey.