The root cause behind this report has been found and fixed upstream.
vmhgfs-fuse never invalidates its attribute cache when a file is opened with
O_TRUNC. The truncation is carried out by the HGFS server as part of the open
(hgfs_open() -> HgfsGetOpenFlags() -> HGFS_OPEN_EMPTY / HGFS_OPEN_CREATE_EMPTY),
but hgfs_open() is the only callback that changes a file and leaves the cache
alone — hgfs_unlink(), hgfs_rmdir(), hgfs_rename() and hgfs_write() call
HgfsInvalidateAttrCache(), and hgfs_truncate() calls HgfsSetAttrCache(). So for
up to HGFS_DEFAULT_TTL (one second) the client keeps reporting the pre-truncate
size, and an append issued inside that window is positioned past the end of the
already truncated file, leaving a hole of NUL bytes at the start.
That is exactly what git does: git fetch truncates .git/FETCH_HEAD and appends
to it from a child process roughly 1.5 s later, so FETCH_HEAD starts with NUL
bytes and doubles in size on every fetch, and git pull fails with "no such ref
was fetched". Reproducer without git:
import os
p = '/mnt/hgfs/share/probe'
open(p, 'wb').write(b'A' * 236)
os.stat(p) # warm the attribute cache
fd = os.open(p, os.O_WRONLY | os.O_TRUNC); os.close(fd)
fd = os.open(p, os.O_WRONLY | os.O_APPEND)
print(os.lseek(fd, 0, os.SEEK_END)) # 236 -> stale, 0 -> correct
Worth noting that part of what was reported in this bug was already addressed
upstream in 2017 by commit 159ff344 ("Hgfs Fuse Client: fix attribute caching
from hardcoded 5 seconds"): it added the missing HgfsInvalidateAttrCache(absto)
to hgfs_rename() — the patch proposed in comment #7 here — and cut the hardcoded
five-second cache timeout down to one second. The O_TRUNC path is what remained.
Upstream issue: https://github.com/vmware/open-vm-tools/issues/90
Upstream fix: https://github.com/vmware/open-vm-tools/pull/801
Ubuntu bug with SRU template and debdiffs for resolute and stonking: LP:
#2164929
** Bug watch added: github.com/vmware/open-vm-tools/issues #90
https://github.com/vmware/open-vm-tools/issues/90
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1579544
Title:
vmhgfs-fuse inconsistencies cause Git index corruption and Bus Error
crashes; older vmhgfs was fine
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/open-vm-tools/+bug/1579544/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs