You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for the mysterious title. We've been implementing a fuse-rs based FS and implemented a fuzzer for simple filesystem operations like read/write/seek. We encountered an issue where our implementation was behaving very strangely, returning zeros or sometimes stale data under certain circumstances. The smallest example I reduced it to:
New file X is open twice, once in read mode R and once in write mode W.
R is read -> empty data. This step is important as it triggers a kernel read request of size 4096, and it seems as if the kernel is caching the returned data
W is written with N bytes -> success.
R is read again -> the read bytes have the correct length N, but they are all zeros. The filesystem is not contacted by the kernel at all. It seems as if the kernel has updated the file metadata during 3, but has not invalidated the cached read.
I have tried reproducing with the regular libfusepassthrough.c implementation, but the issue did not reproduce. I did notice a larger version skew between the libfuse vs fuse-rs ABI versions.
$ cargo test --example hello stale_data_bug -- --nocapture
...
running 1 test
buffer1 [73, 110, 105, 116]
buffer2 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
test stale_data_bug ... ok
(I've added an initial write of "Init" to demonstrate that the basic write functionality works)
As you can see, the first READ request comes through fine, however after the write of "Hello World!", no new read requests arrive, the kernel simply returns zeros.
Any ideas? Is this a kernel bug? Or perhaps an ABI skew issue? I'm running a 5.15.63 kernel
The text was updated successfully, but these errors were encountered:
Turns out the issue is with open() returning the same flags that were passed to it, which inadvertently set the FOPEN_KEEP_CACHE flag, causing the kernel cache to not be invalidated properly.
Sorry for the mysterious title. We've been implementing a fuse-rs based FS and implemented a fuzzer for simple filesystem operations like read/write/seek. We encountered an issue where our implementation was behaving very strangely, returning zeros or sometimes stale data under certain circumstances. The smallest example I reduced it to:
X
is open twice, once in read modeR
and once in write modeW
.R
is read -> empty data. This step is important as it triggers a kernel read request of size 4096, and it seems as if the kernel is caching the returned dataW
is written withN
bytes -> success.R
is read again -> the read bytes have the correct lengthN
, but they are all zeros. The filesystem is not contacted by the kernel at all. It seems as if the kernel has updated the file metadata during 3, but has not invalidated the cached read.I have tried reproducing with the regular
libfuse
passthrough.c
implementation, but the issue did not reproduce. I did notice a larger version skew between thelibfuse
vsfuse-rs
ABI versions.Then I tried modifying
hello.rs
to add the required features (write
andsetattr
) with as minimal changes as possible, and the issue did reproduce. The code can be found here: https://github.com/zargony/fuse-rs/compare/master...decentriq:fuse-rs:aslemmer/zeros-read-bug?expand=1, note that it branches off the latest release tag, not master.In particular, the reproducing test:
fuse-rs/examples/hello.rs
Lines 139 to 153 in 10df620
When running this test, the filesystem output:
The test output:
(I've added an initial write of
"Init"
to demonstrate that the basic write functionality works)As you can see, the first READ request comes through fine, however after the write of
"Hello World!"
, no new read requests arrive, the kernel simply returns zeros.Any ideas? Is this a kernel bug? Or perhaps an ABI skew issue? I'm running a
5.15.63
kernelThe text was updated successfully, but these errors were encountered: