FreeBSD/sys/kern/vfs_mount.c
/*
 * Destroy the mount struct previously allocated by vfs_mount_alloc().
 */
Destroy the mount struct previously allocated by vfs_mount_alloc().
Destroy the mount struct previously allocated by vfs_mount_alloc () .
void
vfs_mount_destroy(struct mount *mp)
{
	MNT_ILOCK(mp);
	mp->mnt_kern_flag |= MNTK_REFEXPIRE;
	if (mp->mnt_kern_flag & MNTK_MWAIT) {
		mp->mnt_kern_flag &= ~MNTK_MWAIT;
		wakeup(mp);
	}
	while (mp->mnt_ref)
		msleep(mp, MNT_MTX(mp), PVFS, "mntref", 0);
	KASSERT(mp->mnt_ref == 0,
	    ("%s: invalid refcount in the drain path @ %s:%d", __func__,
	    __FILE__, __LINE__));
	if (mp->mnt_writeopcount != 0)
		panic("vfs_mount_destroy: nonzero writeopcount");
	if (mp->mnt_secondary_writes != 0)
		panic("vfs_mount_destroy: nonzero secondary_writes");
	atomic_subtract_rel_int(&mp->mnt_vfc->vfc_refcount, 1);
	if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) {
		struct vnode *vp;
		TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes)
			vprint("", vp);
		panic("unmount: dangling vnode");
	}
	KASSERT(TAILQ_EMPTY(&mp->mnt_uppers), ("mnt_uppers"));
	if (mp->mnt_nvnodelistsize != 0)
		panic("vfs_mount_destroy: nonzero nvnodelistsize");
	if (mp->mnt_activevnodelistsize != 0)
		panic("vfs_mount_destroy: nonzero activevnodelistsize");
	if (mp->mnt_lockref != 0)
		panic("vfs_mount_destroy: nonzero lock refcount");
	MNT_IUNLOCK(mp);
#ifdef MAC
	mac_mount_destroy(mp);
#endif
	if (mp->mnt_opt != NULL)
		vfs_freeopts(mp->mnt_opt);
	crfree(mp->mnt_cred);
	uma_zfree(mount_zone, mp);
}
void vfs_mount_destroy ( struct mount * mp ) { MNT_ILOCK ( mp ) ; mp -> mnt_kern_flag |= MNTK_REFEXPIRE ; if ( mp -> mnt_kern_flag & MNTK_MWAIT ) { mp -> mnt_kern_flag &= ~ MNTK_MWAIT ; wakeup ( mp ) ; } while ( mp -> mnt_ref ) msleep ( mp , MNT_MTX ( mp ) , PVFS , " " , 0 ) ; KASSERT ( mp -> mnt_ref == 0 , ( " " , __func__ , __FILE__ , __LINE__ ) ) ; if ( mp -> mnt_writeopcount != 0 ) panic ( " " ) ; if ( mp -> mnt_secondary_writes != 0 ) panic ( " " ) ; atomic_subtract_rel_int ( & mp -> mnt_vfc -> vfc_refcount , 1 ) ; if ( ! TAILQ_EMPTY ( & mp -> mnt_nvnodelist ) ) { struct vnode * vp ; TAILQ_FOREACH ( vp , & mp -> mnt_nvnodelist , v_nmntvnodes ) vprint ( " " , vp ) ; panic ( " " ) ; } KASSERT ( TAILQ_EMPTY ( & mp -> mnt_uppers ) , ( " " ) ) ; if ( mp -> mnt_nvnodelistsize != 0 ) panic ( " " ) ; if ( mp -> mnt_activevnodelistsize != 0 ) panic ( " " ) ; if ( mp -> mnt_lockref != 0 ) panic ( " " ) ; MNT_IUNLOCK ( mp ) ; #ifdef MAC mac_mount_destroy ( mp ) ; #endif if ( mp -> mnt_opt != NULL ) vfs_freeopts ( mp -> mnt_opt ) ; crfree ( mp -> mnt_cred ) ; uma_zfree ( mount_zone , mp ) ; }
Destroy the mount struct previously allocated by vfs_mount_alloc().
Destroy the mount struct previously allocated by vfs_mount_alloc () .