From owner-svn-src-all@freebsd.org Sat Jul 11 16:28:13 2015 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 B4FC399932C; Sat, 11 Jul 2015 16:28:13 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 8C347202A; Sat, 11 Jul 2015 16:28:13 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6BGSD52074636; Sat, 11 Jul 2015 16:28:13 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6BGSDPp074635; Sat, 11 Jul 2015 16:28:13 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201507111628.t6BGSDPp074635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 11 Jul 2015 16:28:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285392 - head/sys/kern X-SVN-Group: head 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.20 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: Sat, 11 Jul 2015 16:28:13 -0000 Author: mjg Date: Sat Jul 11 16:28:12 2015 New Revision: 285392 URL: https://svnweb.freebsd.org/changeset/base/285392 Log: vfs: move si_usecount manipulation to dedicated functions Reviewed by: kib Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Sat Jul 11 16:22:48 2015 (r285391) +++ head/sys/kern/vfs_subr.c Sat Jul 11 16:28:12 2015 (r285392) @@ -105,6 +105,8 @@ static void v_incr_usecount(struct vnode static void v_decr_usecount(struct vnode *); static void v_decr_useonly(struct vnode *); static void v_upgrade_usecount(struct vnode *); +static void v_incr_devcount(struct vnode *); +static void v_decr_devcount(struct vnode *); static void vnlru_free(int); static void vgonel(struct vnode *); static void vfs_knllock(void *arg); @@ -2082,11 +2084,7 @@ v_incr_usecount(struct vnode *vp) CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vholdl(vp); vp->v_usecount++; - if (vp->v_type == VCHR && vp->v_rdev != NULL) { - dev_lock(); - vp->v_rdev->si_usecount++; - dev_unlock(); - } + v_incr_devcount(vp); } /* @@ -2099,11 +2097,7 @@ v_upgrade_usecount(struct vnode *vp) CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_usecount++; - if (vp->v_type == VCHR && vp->v_rdev != NULL) { - dev_lock(); - vp->v_rdev->si_usecount++; - dev_unlock(); - } + v_incr_devcount(vp); } /* @@ -2120,11 +2114,7 @@ v_decr_usecount(struct vnode *vp) ("v_decr_usecount: negative usecount")); CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_usecount--; - if (vp->v_type == VCHR && vp->v_rdev != NULL) { - dev_lock(); - vp->v_rdev->si_usecount--; - dev_unlock(); - } + v_decr_devcount(vp); vdropl(vp); } @@ -2143,6 +2133,36 @@ v_decr_useonly(struct vnode *vp) ("v_decr_useonly: negative usecount")); CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_usecount--; + v_decr_devcount(vp); +} + +/* + * Increment si_usecount of the associated device, if any. + */ +static void +v_incr_devcount(struct vnode *vp) +{ + +#ifdef INVARIANTS + /* getnewvnode() calls v_incr_usecount() without holding interlock. */ + if (vp->v_type != VNON || vp->v_data != NULL) + ASSERT_VI_LOCKED(vp, __FUNCTION__); +#endif + if (vp->v_type == VCHR && vp->v_rdev != NULL) { + dev_lock(); + vp->v_rdev->si_usecount++; + dev_unlock(); + } +} + +/* + * Decrement si_usecount of the associated device, if any. + */ +static void +v_decr_devcount(struct vnode *vp) +{ + + ASSERT_VI_LOCKED(vp, __FUNCTION__); if (vp->v_type == VCHR && vp->v_rdev != NULL) { dev_lock(); vp->v_rdev->si_usecount--;