[Midnightbsd-cvs] src [8641] trunk/sys/kern/vfs_subr.c: set the v_hash for a new vnode in the getnewvnode() to the value calculated based on the structure address.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 14:18:47 EDT 2016
Revision: 8641
http://svnweb.midnightbsd.org/src/?rev=8641
Author: laffer1
Date: 2016-09-25 14:18:47 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
set the v_hash for a new vnode in the getnewvnode() to the value calculated based on the structure address.
Modified Paths:
--------------
trunk/sys/kern/vfs_subr.c
Modified: trunk/sys/kern/vfs_subr.c
===================================================================
--- trunk/sys/kern/vfs_subr.c 2016-09-25 18:18:02 UTC (rev 8640)
+++ trunk/sys/kern/vfs_subr.c 2016-09-25 18:18:47 UTC (rev 8641)
@@ -282,6 +282,8 @@
#define VSHOULDFREE(vp) (!((vp)->v_iflag & VI_FREE) && !(vp)->v_holdcnt)
#define VSHOULDBUSY(vp) (((vp)->v_iflag & VI_FREE) && (vp)->v_holdcnt)
+/* Shift count for (uintptr_t)vp to initialize vp->v_hash. */
+static int vnsz2log;
/*
* Initialize the vnode management data structures.
@@ -296,6 +298,7 @@
static void
vntblinit(void *dummy __unused)
{
+ u_int i;
int physvnodes, virtvnodes;
/*
@@ -337,6 +340,9 @@
syncer_maxdelay = syncer_mask + 1;
mtx_init(&sync_mtx, "Syncer mtx", NULL, MTX_DEF);
cv_init(&sync_wakeup, "syncer");
+ for (i = 1; i <= sizeof(struct vnode); i <<= 1)
+ vnsz2log++;
+ vnsz2log--;
}
SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_FIRST, vntblinit, NULL);
@@ -1077,6 +1083,14 @@
}
rangelock_init(&vp->v_rl);
+ /*
+ * For the filesystems which do not use vfs_hash_insert(),
+ * still initialize v_hash to have vfs_hash_index() useful.
+ * E.g., nullfs uses vfs_hash_index() on the lower vnode for
+ * its own hashing.
+ */
+ vp->v_hash = (uintptr_t)vp >> vnsz2log;
+
*vpp = vp;
return (0);
}
More information about the Midnightbsd-cvs
mailing list