From owner-svn-src-all@freebsd.org Wed May 18 11:58:18 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 45857B408CE; Wed, 18 May 2016 11:58:18 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1DA4106B; Wed, 18 May 2016 11:58:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4IBwHZp058916; Wed, 18 May 2016 11:58:17 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4IBwH3R058914; Wed, 18 May 2016 11:58:17 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201605181158.u4IBwH3R058914@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 May 2016 11:58:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r300140 - in stable/10/sys: kern sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2016 11:58:18 -0000 Author: kib Date: Wed May 18 11:58:16 2016 New Revision: 300140 URL: https://svnweb.freebsd.org/changeset/base/300140 Log: MFC r299412: Add vfs_hash_ref(9) function, which finds a vnode by the hash value and returns it referenced. Modified: stable/10/sys/kern/vfs_hash.c stable/10/sys/sys/vnode.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_hash.c ============================================================================== --- stable/10/sys/kern/vfs_hash.c Wed May 18 11:51:17 2016 (r300139) +++ stable/10/sys/kern/vfs_hash.c Wed May 18 11:58:16 2016 (r300140) @@ -103,6 +103,36 @@ vfs_hash_get(const struct mount *mp, u_i } void +vfs_hash_ref(const struct mount *mp, u_int hash, struct thread *td, + struct vnode **vpp, vfs_hash_cmp_t *fn, void *arg) +{ + struct vnode *vp; + + while (1) { + mtx_lock(&vfs_hash_mtx); + LIST_FOREACH(vp, vfs_hash_bucket(mp, hash), v_hashlist) { + if (vp->v_hash != hash) + continue; + if (vp->v_mount != mp) + continue; + if (fn != NULL && fn(vp, arg)) + continue; + vhold(vp); + mtx_unlock(&vfs_hash_mtx); + vref(vp); + vdrop(vp); + *vpp = vp; + return; + } + if (vp == NULL) { + mtx_unlock(&vfs_hash_mtx); + *vpp = NULL; + return; + } + } +} + +void vfs_hash_remove(struct vnode *vp) { Modified: stable/10/sys/sys/vnode.h ============================================================================== --- stable/10/sys/sys/vnode.h Wed May 18 11:51:17 2016 (r300139) +++ stable/10/sys/sys/vnode.h Wed May 18 11:58:16 2016 (r300140) @@ -849,6 +849,8 @@ int vfs_hash_get(const struct mount *mp, 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_ref(const struct mount *mp, u_int hash, 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);