corruption reading files with cache=loose
Host environment
- Operating system: NixOS Unstable
- OS/kernel version: Linux rigter 6.12.22 #1-NixOS SMP PREEMPT_DYNAMIC Mon Apr 7 08:08:37 UTC 2025 x86_64 GNU/Linux
- Architecture: x86
- QEMU flavor: qemu-system-x86_64
- QEMU version: 9.2.3
- QEMU command line:
./qemu-system-x86_64 -virtfs local,path=/nix/store,security_model=none,mount_tag=nix-store
Emulated/Virtualized environment
- Operating system: NixOS
- OS/kernel version: Linux nixos 6.15.1 #1-NixOS SMP PREEMPT_DYNAMIC Wed Jun 4 12:46:27 UTC 2025 x86_64 GNU/Linux
- Architecture: x86
Description of problem
The mounted disk:
nix-store on /nix/.ro-store type 9p (rw,relatime,debug=d,cache=f,access=client,msize=16384,trans=virtio)
sometimes has files for which all bytes after 0x3000 are zero:
$ hexdump -C /nix/store/jqaxxkl2xnp74sb1r3vj8z921r7c7fhl-onlyoffice-documentserver-8.3.2/etc/onlyoffice/documentserver/default.json | tail
00002fa0 79 63 6c 65 22 3a 20 22 32 6d 22 0a 09 09 09 7d |ycle": "2m"....}|
00002fb0 2c 0a 09 09 09 22 64 6f 77 6e 6c 6f 61 64 41 74 |,...."downloadAt|
00002fc0 74 65 6d 70 74 4d 61 78 43 6f 75 6e 74 22 3a 20 |temptMaxCount": |
00002fd0 33 2c 0a 09 09 09 22 64 6f 77 6e 6c 6f 61 64 41 |3,...."downloadA|
00002fe0 74 74 65 6d 70 74 44 65 6c 61 79 22 3a 20 31 30 |ttemptDelay": 10|
00002ff0 30 30 2c 0a 09 09 09 22 6d 61 78 70 72 6f 63 65 |00,...."maxproce|
00003000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00003280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |...............|
0000328f
This problem seems to persist across rebuilds of the emulated system. Removing cache=loose makes the problem go away. Changing the msize parameter also seems to influence whether the problem appears, though I haven't found a pattern in which values do and don't exhibit the problem.
Additional information
I'd be happy to collect additional information, but would appreciate some pointers as to where to look.
I've enabled qemu logs and noticed logs showing v9fs_open_return tag 0 id 12 qid={type 0 version 3315969 path 19049134} iounit 12288 which might be interesting as 12288 is 0x3000.