Simple test (on a p9fs mounted filesystem) date > foo ln foo bar rm bar ls And you will see it is file foo that gets deleted, not bar! This doesn't happen from a linux VM so this is definitely a p9fs problem. I suspect this has to do with wrong fid (that of foo) being used when the file is being removed.
I made an attempt at fixing this: https://reviews.freebsd.org/D47438 It fixes the example, but more testing would be very appreciated.
The review says "Just manual testing in bhyve. It's a bit tricky to write regression tests without having a socket-based transport, since that'd make it easy to implement a simple server using contrib/lib9p..." Wasn't there /sys/dev/virtio/9pnet/ in the original Juniper Networks code? Wouldn't that help with this sort of thing? AFAIK there are at least two servers that implement 9P2000.L: https://github.com/chaos/diod and https://github.com/hugelgupf/p9
(In reply to Bakul Shah from comment #2) Looking at 9pnet from an old repo, only the virtio transport is implemented. I want a socket-based transport so that the client and server can run in the same host. It looks like most of the abstractions needed are there already.
Verified this bug is fixed. Thanks!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1d99e8d9a37e1ba528628186df57b79fe74e196c commit 1d99e8d9a37e1ba528628186df57b79fe74e196c Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-11-07 18:23:32 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-11-07 18:23:32 +0000 p9fs: Use UNLINKAT instead of REMOVE to implement removals REMOVE doesn't work properly in the face of hard links. Use UNLINKAT instead, which is implemented by qemu and bhyve and lets the client specify the name being removed. PR: 282432 Reviewed by: dfr Differential Revision: https://reviews.freebsd.org/D47438 sys/fs/p9fs/p9_client.c | 21 +++++++++++++++++++++ sys/fs/p9fs/p9_client.h | 1 + sys/fs/p9fs/p9_protocol.h | 2 ++ sys/fs/p9fs/p9fs_vnops.c | 21 ++++++++++++++------- 4 files changed, 38 insertions(+), 7 deletions(-)
Thanks for the report.