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

Function freevnode

freebsd/kern/vfs_subr.c:1833–1889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1831}
1832
1833static void __noinline
1834freevnode(struct vnode *vp)
1835{
1836 struct bufobj *bo;
1837
1838 /*
1839 * The vnode has been marked for destruction, so free it.
1840 *
1841 * The vnode will be returned to the zone where it will
1842 * normally remain until it is needed for another vnode. We
1843 * need to cleanup (or verify that the cleanup has already
1844 * been done) any residual data left from its current use
1845 * so as not to contaminate the freshly allocated vnode.
1846 */
1847 CTR2(KTR_VFS, "%s: destroying the vnode %p", __func__, vp);
1848 /*
1849 * Paired with vgone.
1850 */
1851 vn_seqc_write_end_free(vp);
1852
1853 bo = &vp->v_bufobj;
1854 VNASSERT(vp->v_data == NULL, vp, ("cleaned vnode isn't"));
1855 VNPASS(vp->v_holdcnt == VHOLD_NO_SMR, vp);
1856 VNASSERT(vp->v_usecount == 0, vp, ("Non-zero use count"));
1857 VNASSERT(vp->v_writecount == 0, vp, ("Non-zero write count"));
1858 VNASSERT(bo->bo_numoutput == 0, vp, ("Clean vnode has pending I/O's"));
1859 VNASSERT(bo->bo_clean.bv_cnt == 0, vp, ("cleanbufcnt not 0"));
1860 VNASSERT(pctrie_is_empty(&bo->bo_clean.bv_root), vp,
1861 ("clean blk trie not empty"));
1862 VNASSERT(bo->bo_dirty.bv_cnt == 0, vp, ("dirtybufcnt not 0"));
1863 VNASSERT(pctrie_is_empty(&bo->bo_dirty.bv_root), vp,
1864 ("dirty blk trie not empty"));
1865 VNASSERT(TAILQ_EMPTY(&vp->v_cache_dst), vp, ("vp has namecache dst"));
1866 VNASSERT(LIST_EMPTY(&vp->v_cache_src), vp, ("vp has namecache src"));
1867 VNASSERT(vp->v_cache_dd == NULL, vp, ("vp has namecache for .."));
1868 VNASSERT(TAILQ_EMPTY(&vp->v_rl.rl_waiters), vp,
1869 ("Dangling rangelock waiters"));
1870 VNASSERT((vp->v_iflag & (VI_DOINGINACT | VI_OWEINACT)) == 0, vp,
1871 ("Leaked inactivation"));
1872 VI_UNLOCK(vp);
1873#ifdef MAC
1874 mac_vnode_destroy(vp);
1875#endif
1876 if (vp->v_pollinfo != NULL) {
1877 destroy_vpollinfo(vp->v_pollinfo);
1878 vp->v_pollinfo = NULL;
1879 }
1880 vp->v_mountedhere = NULL;
1881 vp->v_unpcb = NULL;
1882 vp->v_rdev = NULL;
1883 vp->v_fifoinfo = NULL;
1884 vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0;
1885 vp->v_iflag = 0;
1886 vp->v_vflag = 0;
1887 bo->bo_flag = 0;
1888 vn_free(vp);
1889}
1890

Callers 1

vdropl_finalFunction · 0.85

Calls 5

vn_seqc_write_end_freeFunction · 0.85
pctrie_is_emptyFunction · 0.85
mac_vnode_destroyFunction · 0.85
destroy_vpollinfoFunction · 0.85
vn_freeFunction · 0.85

Tested by

no test coverage detected