Hi, all.
Recently i test xfstest virtiofs, i met below error
```
[root@localhost xfstests]# ./check -virtiofs generic/615
FSTYP -- virtiofs
PLATFORM -- Linux/aarch64 localhost 4.18.0-240.el8.aarch64 #1 SMP
Wed Sep 23 05:09:38 EDT 2020
MKFS_OPTIONS -- nfsmyfs1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 nfsmyfs1
/mnt/scratch
generic/615 37s ... - output mismatch (see
/root/xfstests/results//generic/615.out.bad)
--- tests/generic/615.out 2020-11-25 18:53:52.209183050 +0800
+++ /root/xfstests/results//generic/615.out.bad 2020-11-26
09:11:42.864359280 +0800
@@ -1,3 +1,4 @@
QA output created by 615
Testing buffered writes
+error: stat(2) reported zero blocks
Testing direct IO writes
...
(Run 'diff -u /root/xfstests/tests/generic/615.out
/root/xfstests/results//generic/615.out.bad' to see the entire diff)
Ran: generic/615
Failures: generic/615
Failed 1 of 1 tests
```
Env setting
```
Local NFS Server setting
# cat /etc/exports
/home/nfs/share0 127.0.0.1(insecure,no_root_squash,rw,async)
/home/nfs/share1 127.0.0.1(insecure,no_root_squash,rw,async)
Mount nfs option
# mount | grep nfs
[snip]
127.0.0.1:/home/nfs/share0 on /mnt/nfs/share0 type nfs4
(rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=127.0.0.1,local_lock=none,addr=127.0.0.1)
127.0.0.1:/home/nfs/share1 on /mnt/nfs/share1 type nfs4
(rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=127.0.0.1,local_lock=none,addr=127.0.0.1)
```
How to reproduce
1. start a guest with virtiofsd and mount host nfsdir
Please refer to my guest xml
```
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs'/>
<binary path='/usr/libexec/virtiofsd'>
<lock posix='off' flock='off'/>
</binary>
<source dir='/mnt/nfs/share0'/>
<target dir='nfsmyfs0'/>
<address type='pci' domain='0x0000' bus='0x0a' slot='0x00'
function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs'/>
<binary path='/usr/libexec/virtiofsd'>
<lock posix='off' flock='off'/>
</binary>
<source dir='/mnt/nfs/share1'/>
<target dir='nfsmyfs1'/>
<address type='pci' domain='0x0000' bus='0x0b' slot='0x00'
function='0x0'/>
</filesystem>
```
2. Install xfstest and setup local.config
```
export TEST_DEV=nfsmyfs0
export TEST_DIR=/mnt/test
export SCRATCH_DEV=nfsmyfs1
export SCRATCH_MNT=/mnt/scratch
export FSX_AVOID="-E"
```
3. run cmd './check -virtiofs generic/615'
generic/615 test for non-zero used blocks while writing into a file,
this test keeps overwriting an entire file and use stat cmd to check
zero blocks,
if zero-blocks exist, test failed.
nfsv4 cache feature is enabled by default, so i think cache feature may
cause this failure.
When nfs cache files, write content will be temporarily placed in memory
then write to disk.
There will be a delay before the write content is finally written to the
file.
So when we first time use stat cmd, write content is under memory, file
maybe empty, that is why test failed.
So i set nfsv4 noac option, test really passed.
But it is interesting that this test passed on nfsv3 without any special
setting.
Anybody could help explain it?
Very appreciate and feel free to comment out if i am wrong. ;-)
--
Best Regards.
Liu Yiding