diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3311,6 +3311,8 @@ vget_finish_ref(struct vnode *vp, enum vgetstate vs) { int old; + struct mount *mp; + uint64_t *fsvninusep; VNPASS(vs == VGET_HOLDCNT || vs == VGET_USECOUNT, vp); VNPASS(vp->v_holdcnt > 0, vp); @@ -3333,6 +3335,13 @@ #else refcount_release(&vp->v_holdcnt); #endif + } else { + mp = vp->v_mount; + if (NULL != mp) { + fsvninusep = mp->mnt_fsvninusep; + if (NULL != fsvninusep) + atomic_add_rel_64(fsvninusep, 1); + } } } @@ -3490,10 +3499,23 @@ { int error; bool want_unlock; + struct mount *mp; + uint64_t *fsvninusep; CTR2(KTR_VFS, "%s: vp %p", __func__, vp); VNPASS(vp->v_holdcnt > 0, vp); + mp = vp->v_mount; + /* + * The filesystem-local in-use vnode count is not incremented if + * insmntque() fails. vp->v_data is set to NULL in such the case. + */ + if ((NULL != mp) && (NULL != vp->v_data)) { + fsvninusep = mp->mnt_fsvninusep; + if (NULL != fsvninusep) + atomic_subtract_rel_64(fsvninusep, 1); + } + VI_LOCK(vp); /* diff --git a/sys/sys/mount.h b/sys/sys/mount.h --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -256,6 +256,7 @@ int mnt_secondary_accwrites;/* (i) secondary wr. starts */ struct thread *mnt_susp_owner; /* (i) thread owning suspension */ struct ucred *mnt_exjail; /* (i) jail which did exports */ + uint64_t *mnt_fsvninusep; /* per-filesystem count of vnodes in use */ #define mnt_endzero mnt_gjprovider char *mnt_gjprovider; /* gjournal provider name */ struct mtx mnt_listmtx;