Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Add vinsheadfree, a small function to push vnodes t...



details:   https://anonhg.NetBSD.org/src/rev/f0f17d748664
branches:  trunk
changeset: 493957:f0f17d748664
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Tue Jun 27 23:34:45 2000 +0000

description:
Add vinsheadfree, a small function to push vnodes that have just
been allocated by getnewvnode, back onto the head of the free list.
Needed in some VFS_VGET functions to deal with races.

diffstat:

 sys/kern/vfs_subr.c |  32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diffs (46 lines):

diff -r 04a338df36b9 -r f0f17d748664 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Tue Jun 27 21:30:03 2000 +0000
+++ b/sys/kern/vfs_subr.c       Tue Jun 27 23:34:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.129 2000/06/27 17:41:49 mrg Exp $       */
+/*     $NetBSD: vfs_subr.c,v 1.130 2000/06/27 23:34:45 fvdl Exp $      */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -540,6 +540,36 @@
 }
 
 /*
+ * This is really just the reverse of getnewvnode(). Needed for
+ * VFS_VGET functions who may need to push back a vnode in case
+ * of a locking race.
+ */
+void
+vinsheadfree(vp)
+       struct vnode *vp;
+{
+#ifdef DIAGNOSTIC
+       if (vp->v_usecount != 1)
+               panic("vinsheadfree: busy vnode");
+#endif
+       vp->v_usecount--;
+       insmntque(vp, NULL);
+       vp->v_type = VBAD;
+
+       simple_lock(&vp->v_interlock);
+       /* 
+        * Insert at head of LRU list
+        */
+       simple_lock(&vnode_free_list_slock);
+       if (vp->v_holdcnt > 0)
+               TAILQ_INSERT_HEAD(&vnode_hold_list, vp, v_freelist);
+       else
+               TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
+       simple_unlock(&vnode_free_list_slock); 
+       simple_unlock(&vp->v_interlock);
+}
+
+/*
  * Move a vnode from one mount queue to another.
  */
 void



Home | Main Index | Thread Index | Old Index