git: 356e698011b2 - main - unionfs(): destroy root vnode if upper registration fails

From: Jason A. Harmening <jah_at_FreeBSD.org>
Date: Sun, 07 May 2023 23:52:04 UTC
The branch main has been updated by jah:

URL: https://cgit.FreeBSD.org/src/commit/?id=356e698011b20ccba9c0a3f211e2a7761490875c

commit 356e698011b20ccba9c0a3f211e2a7761490875c
Author:     Jason A. Harmening <jah@FreeBSD.org>
AuthorDate: 2023-03-26 01:50:55 +0000
Commit:     Jason A. Harmening <jah@FreeBSD.org>
CommitDate: 2023-05-07 23:30:43 +0000

    unionfs(): destroy root vnode if upper registration fails
    
    If unionfs_domount() fails, the mount path will not call VFS_UNMOUNT()
    to clean up after it.  If this failure happens during upper vnode
    registration, the unionfs root vnode will already be allocated.
    vflush() it in order to prevent the vnode from being leaked and the
    subsequent vfs_mount_destroy() call from getting stuck waiting for
    the mountpoint reference count to drain.
    
    Reviewed by:    kib, markj
    Tested by:      pho
    Differential Revision: https://reviews.freebsd.org/D39767
---
 sys/fs/unionfs/union_vfsops.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c
index cd6c7bd90655..9ef239aaad1d 100644
--- a/sys/fs/unionfs/union_vfsops.c
+++ b/sys/fs/unionfs/union_vfsops.c
@@ -318,6 +318,7 @@ unionfs_domount(struct mount *mp)
 			vfs_unregister_upper(lowermp, &ump->um_lower_link);
 		if (uppermp != NULL)
 			vfs_unregister_upper(uppermp, &ump->um_upper_link);
+		vflush(mp, 1, FORCECLOSE, curthread);
 		free(ump, M_UNIONFSMNT);
 		mp->mnt_data = NULL;
 		return (ENOENT);