MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vfs_mount_destroy

Function vfs_mount_destroy

freebsd/kern/vfs_mount.c:538–596  ·  view source on GitHub ↗

* Destroy the mount struct previously allocated by vfs_mount_alloc(). */

Source from the content-addressed store, hash-verified

536 * Destroy the mount struct previously allocated by vfs_mount_alloc().
537 */
538void
539vfs_mount_destroy(struct mount *mp)
540{
541
542 if (mp->mnt_vfs_ops == 0)
543 panic("%s: entered with zero vfs_ops\n", __func__);
544
545 vfs_assert_mount_counters(mp);
546
547 MNT_ILOCK(mp);
548 mp->mnt_kern_flag |= MNTK_REFEXPIRE;
549 if (mp->mnt_kern_flag & MNTK_MWAIT) {
550 mp->mnt_kern_flag &= ~MNTK_MWAIT;
551 wakeup(mp);
552 }
553 while (mp->mnt_ref)
554 msleep(mp, MNT_MTX(mp), PVFS, "mntref", 0);
555 KASSERT(mp->mnt_ref == 0,
556 ("%s: invalid refcount in the drain path @ %s:%d", __func__,
557 __FILE__, __LINE__));
558 if (mp->mnt_writeopcount != 0)
559 panic("vfs_mount_destroy: nonzero writeopcount");
560 if (mp->mnt_secondary_writes != 0)
561 panic("vfs_mount_destroy: nonzero secondary_writes");
562 atomic_subtract_rel_int(&mp->mnt_vfc->vfc_refcount, 1);
563 if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) {
564 struct vnode *vp;
565
566 TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes)
567 vn_printf(vp, "dangling vnode ");
568 panic("unmount: dangling vnode");
569 }
570 KASSERT(TAILQ_EMPTY(&mp->mnt_uppers), ("mnt_uppers"));
571 if (mp->mnt_nvnodelistsize != 0)
572 panic("vfs_mount_destroy: nonzero nvnodelistsize");
573 if (mp->mnt_lazyvnodelistsize != 0)
574 panic("vfs_mount_destroy: nonzero lazyvnodelistsize");
575 if (mp->mnt_lockref != 0)
576 panic("vfs_mount_destroy: nonzero lock refcount");
577 MNT_IUNLOCK(mp);
578
579 if (mp->mnt_vfs_ops != 1)
580 panic("%s: vfs_ops should be 1 but %d found\n", __func__,
581 mp->mnt_vfs_ops);
582
583 if (mp->mnt_rootvnode != NULL)
584 panic("%s: mount point still has a root vnode %p\n", __func__,
585 mp->mnt_rootvnode);
586
587 if (mp->mnt_vnodecovered != NULL)
588 vrele(mp->mnt_vnodecovered);
589#ifdef MAC
590 mac_mount_destroy(mp);
591#endif
592 if (mp->mnt_opt != NULL)
593 vfs_freeopts(mp->mnt_opt);
594 crfree(mp->mnt_cred);
595 uma_zfree(mount_zone, mp);

Callers 3

mount_snapshotFunction · 0.85
vfs_domount_firstFunction · 0.85
dounmountFunction · 0.85

Calls 9

vn_printfFunction · 0.85
mac_mount_destroyFunction · 0.85
vfs_freeoptsFunction · 0.85
panicFunction · 0.70
wakeupFunction · 0.70
vreleFunction · 0.70
crfreeFunction · 0.70
uma_zfreeFunction · 0.50

Tested by

no test coverage detected