Writing to an existing base-image file via overlay succeeds, but reading it back returns empty content.
Steps to reproduce
make && cd tests && sudo ./test_overlay.sh -v
The "Modify existing file via overlay" test fails:
Running: Modify existing file via overlay
FAIL: Overlay modify
Content mismatch: ''
The test does:
echo "Modified via overlay" > "$MNT/modify_me.txt"
content=$(cat "$MNT/modify_me.txt")
# content is '' instead of 'Modified via overlay'
Environment
- Kernel: 6.19.6-arch1-1 (x86_64)
- Reproduced on both host and inside QEMU
- Affects all 20+ commits since f6ebde1
Root cause
daxfs_setattr() relies on setattr_copy() to update VFS i_size when handling ATTR_SIZE (e.g. O_TRUNC). However, the kernel's setattr_copy() does not handle ATTR_SIZE — the filesystem must update i_size itself.
This causes the following sequence when overwriting an existing file:
- Shell redirect > opens with O_TRUNC → daxfs_setattr(ATTR_SIZE=0) creates an overlay inode with size=0, but VFS i_size stays at the original base image size (e.g. 23)
- Write 21 bytes → pos(21) <= i_size(23) → the "update size if extending" check in write_iter is skipped, so the overlay inode size is never updated from 0
- On read, daxfs_refresh_isize() reads overlay size=0 and sets VFS i_size=0 → read returns 0 bytes
Introduced by
Bisected to f6ebde1 ("daxfs: Refresh i_size from overlay on read paths for cross-host coherency"). The underlying setattr bug was latent before that commit but only became observable when daxfs_refresh_isize() started reading overlay size on the read path.
Writing to an existing base-image file via overlay succeeds, but reading it back returns empty content.
Steps to reproduce
The "Modify existing file via overlay" test fails:
The test does:
Environment
Root cause
daxfs_setattr() relies on setattr_copy() to update VFS i_size when handling ATTR_SIZE (e.g. O_TRUNC). However, the kernel's setattr_copy() does not handle ATTR_SIZE — the filesystem must update i_size itself.
This causes the following sequence when overwriting an existing file:
Introduced by
Bisected to f6ebde1 ("daxfs: Refresh i_size from overlay on read paths for cross-host coherency"). The underlying setattr bug was latent before that commit but only became observable when daxfs_refresh_isize() started reading overlay size on the read path.