From owner-svn-src-all@freebsd.org Fri Feb 24 11:34:02 2017 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 09DABCEA791; Fri, 24 Feb 2017 11:34:02 +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 A59EA18B3; Fri, 24 Feb 2017 11:34:01 +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 v1OBY0ZY021669; Fri, 24 Feb 2017 11:34:00 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1OBY0T6021668; Fri, 24 Feb 2017 11:34:00 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201702241134.v1OBY0T6021668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 24 Feb 2017 11:34:00 +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: r314202 - stable/10/sys/kern 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.23 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: Fri, 24 Feb 2017 11:34:02 -0000 Author: kib Date: Fri Feb 24 11:34:00 2017 New Revision: 314202 URL: https://svnweb.freebsd.org/changeset/base/314202 Log: MFC r313496: Increase a chance of devfs_close() calling d_close cdevsw method. Modified: stable/10/sys/kern/vfs_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_vnops.c ============================================================================== --- stable/10/sys/kern/vfs_vnops.c Fri Feb 24 11:30:28 2017 (r314201) +++ stable/10/sys/kern/vfs_vnops.c Fri Feb 24 11:34:00 2017 (r314202) @@ -412,12 +412,9 @@ vn_writechk(vp) /* * Vnode close call */ -int -vn_close(vp, flags, file_cred, td) - register struct vnode *vp; - int flags; - struct ucred *file_cred; - struct thread *td; +static int +vn_close1(struct vnode *vp, int flags, struct ucred *file_cred, + struct thread *td, bool keep_ref) { struct mount *mp; int error, lock_flags; @@ -438,11 +435,22 @@ vn_close(vp, flags, file_cred, td) __func__, vp, vp->v_writecount); } error = VOP_CLOSE(vp, flags, file_cred, td); - vput(vp); + if (keep_ref) + VOP_UNLOCK(vp, 0); + else + vput(vp); vn_finished_write(mp); return (error); } +int +vn_close(struct vnode *vp, int flags, struct ucred *file_cred, + struct thread *td) +{ + + return (vn_close1(vp, flags, file_cred, td, false)); +} + /* * Heuristic to detect sequential operation. */ @@ -1624,16 +1632,15 @@ vn_closefile(fp, td) struct vnode *vp; struct flock lf; int error; + bool ref; vp = fp->f_vnode; fp->f_ops = &badfileops; + ref= (fp->f_flag & FHASLOCK) != 0 && fp->f_type == DTYPE_VNODE; - if (fp->f_type == DTYPE_VNODE && fp->f_flag & FHASLOCK) - vref(vp); - - error = vn_close(vp, fp->f_flag, fp->f_cred, td); + error = vn_close1(vp, fp->f_flag, fp->f_cred, td, ref); - if (fp->f_type == DTYPE_VNODE && fp->f_flag & FHASLOCK) { + if (__predict_false(ref)) { lf.l_whence = SEEK_SET; lf.l_start = 0; lf.l_len = 0;