Re: VFS mount rollback for virtio 9pfs

From: Mark Johnston <markj_at_freebsd.org>
Date: Tue, 12 Jul 2022 14:33:04 UTC
On Mon, Jul 11, 2022 at 10:46:33PM +0930, Daniel O'Connor wrote:
> Hi,
> I am attempting to get the Juniper virtfs code (http://github.com/Juniper/virtfs) working and I have managed to get it to a point where it mounts and things seem to work (https://github.com/DanielO/freebsd-src/tree/9pfs) although I have only tested on bhyve so far (but feel free to test elsewhere :)
> 
> During the process I found the Juniper code would ask for 9p2000.u but is written for 9p2000.L (I think bhyve is more rigid about what it allows than Xen etc).
> 
> This was easily fixed but I want to make the handling of a similar error in future correct. The virtfs_unmount code as it stands will fail when the kernel tries to rollback the mount. The end result is the ref count for the file system is not decremented so the KLD can't be unloaded.

How does virtfs_unmount() fail?  The tsleep() call there looks
suspicious, it's using the address of a local variable as a wait
channel, so I don't understand how it'll ever get signalled.

> I attempted to fix this by squashing the return value to 0 in the event of a forced unmount but that results in the mount rollback hanging in 'mntref' while it waits for the mount ref count to go to 0.
> 
> I assume I am missing something obvious but I can't work out what it is so any clue much appreciated.
> 
> Thanks.
> 
> --
> Daniel O'Connor
> "The nice thing about standards is that there
> are so many of them to choose from."
> -- Andrew Tanenbaum
> 
>