summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_usrreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/uipc_usrreq.c')
-rw-r--r--sys/kern/uipc_usrreq.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 33365ee..8f329fd 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -2300,6 +2300,45 @@ unp_scan(struct mbuf *m0, void (*op)(struct file *))
}
}
+/*
+ * A helper function called by VFS before socket-type vnode reclamation.
+ * For an active vnode it clears unp_vnode pointer and decrements unp_vnode
+ * use count.
+ */
+void
+vfs_unp_reclaim(struct vnode *vp)
+{
+ struct socket *so;
+ struct unpcb *unp;
+ int active;
+
+ ASSERT_VOP_ELOCKED(vp, "vfs_unp_reclaim");
+ KASSERT(vp->v_type == VSOCK,
+ ("vfs_unp_reclaim: vp->v_type != VSOCK"));
+
+ active = 0;
+ UNP_LINK_WLOCK();
+ so = vp->v_socket;
+ if (so == NULL)
+ goto done;
+ unp = sotounpcb(so);
+ if (unp == NULL)
+ goto done;
+ UNP_PCB_LOCK(unp);
+ if (unp->unp_vnode != NULL) {
+ KASSERT(unp->unp_vnode == vp,
+ ("vfs_unp_reclaim: vp != unp->unp_vnode"));
+ vp->v_socket = NULL;
+ unp->unp_vnode = NULL;
+ active = 1;
+ }
+ UNP_PCB_UNLOCK(unp);
+done:
+ UNP_LINK_WUNLOCK();
+ if (active)
+ vunref(vp);
+}
+
#ifdef DDB
static void
db_print_indent(int indent)
OpenPOWER on IntegriCloud