Re: VFS mount rollback for virtio 9pfs

From: Daniel O'Connor <darius_at_dons.net.au>
Date: Tue, 12 Jul 2022 23:12:29 UTC

> On 13 Jul 2022, at 00:03, Mark Johnston <markj@freebsd.org> wrote:
>> 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.

Yes good point, I don't think it ever gets woken up - it just times out.

Without any changes (ie what is in my git tree at now) it returns EBUSY.

If I change it like so:
       if (mntflags & MNT_FORCE || mp->mnt_kern_flag & MNTK_UNMOUNTF)
               flags |= FORCECLOSE;

And then later to squash the return value to 0 if FORCECLOSE is set then mount hangs:

load: 0.46  cmd: mount 988 [mntref] 1.42r 0.00u 0.03s 0% 2252k
mi_switch+0xc2 _sleep+0x1fc vfs_mount_destroy+0xa4 vfs_domount_first+0x382 vfs_domount+0x2ad vfs_donmount+0x8f8 sys_nmount+0x69 amd64_syscall+0x10c fast_syscall_common+0xf8

--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum