Add exported vfs_hash_index() function, which calculates the canonical

pre-masked hash for the given vnode.  The function assumes that
vp->v_hash is initialized by the filesystem vnode instantiation
function.  At the moment, it is only done if filesystem uses
vfs_hash_insert().

Reviewed by:	peter
Tested by:	peter, pho (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	5 days
This commit is contained in:
Konstantin Belousov 2013-01-14 05:41:40 +00:00
parent 7b982bc831
commit f6af8e375c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245406
2 changed files with 8 additions and 0 deletions

View File

@ -54,6 +54,13 @@ vfs_hashinit(void *dummy __unused)
/* Must be SI_ORDER_SECOND so desiredvnodes is available */
SYSINIT(vfs_hash, SI_SUB_VFS, SI_ORDER_SECOND, vfs_hashinit, NULL);
u_int
vfs_hash_index(struct vnode *vp)
{
return (vp->v_hash + vp->v_mount->mnt_hashseed);
}
static struct vfs_hash_head *
vfs_hash_bucket(const struct mount *mp, u_int hash)
{

View File

@ -812,6 +812,7 @@ int fifo_printinfo(struct vnode *);
typedef int vfs_hash_cmp_t(struct vnode *vp, void *arg);
int vfs_hash_get(const struct mount *mp, u_int hash, int flags, struct thread *td, struct vnode **vpp, vfs_hash_cmp_t *fn, void *arg);
u_int vfs_hash_index(struct vnode *vp);
int vfs_hash_insert(struct vnode *vp, u_int hash, int flags, struct thread *td, struct vnode **vpp, vfs_hash_cmp_t *fn, void *arg);
void vfs_hash_rehash(struct vnode *vp, u_int hash);
void vfs_hash_remove(struct vnode *vp);