From owner-svn-src-stable-10@FreeBSD.ORG Wed Jun 10 02:20:59 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A915EA25; Wed, 10 Jun 2015 02:20:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.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 8B3541E16; Wed, 10 Jun 2015 02:20:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5A2KxMu079005; Wed, 10 Jun 2015 02:20:59 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5A2KxXr079003; Wed, 10 Jun 2015 02:20:59 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201506100220.t5A2KxXr079003@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 10 Jun 2015 02:20:59 +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: r284202 - 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-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jun 2015 02:20:59 -0000 Author: kib Date: Wed Jun 10 02:20:58 2015 New Revision: 284202 URL: https://svnweb.freebsd.org/changeset/base/284202 Log: MFC r283601: Add V_MNTREF flag, to indicate that caller of vn_start*_write() already owns a reference on the mount point, and the functions can consume it. Modified: stable/10/sys/kern/vfs_vnops.c stable/10/sys/sys/vnode.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_vnops.c ============================================================================== --- stable/10/sys/kern/vfs_vnops.c Wed Jun 10 02:14:33 2015 (r284201) +++ stable/10/sys/kern/vfs_vnops.c Wed Jun 10 02:20:58 2015 (r284202) @@ -1619,14 +1619,14 @@ unlock: } int -vn_start_write(vp, mpp, flags) - struct vnode *vp; - struct mount **mpp; - int flags; +vn_start_write(struct vnode *vp, struct mount **mpp, int flags) { struct mount *mp; int error; + KASSERT((flags & V_MNTREF) == 0 || (*mpp != NULL && vp == NULL), + ("V_MNTREF requires mp")); + error = 0; /* * If a vnode is provided, get and return the mount point that @@ -1651,7 +1651,7 @@ vn_start_write(vp, mpp, flags) * emulate a vfs_ref(). */ MNT_ILOCK(mp); - if (vp == NULL) + if (vp == NULL && (flags & V_MNTREF) == 0) MNT_REF(mp); return (vn_start_write_locked(mp, flags)); @@ -1665,14 +1665,14 @@ vn_start_write(vp, mpp, flags) * time, these operations are halted until the suspension is over. */ int -vn_start_secondary_write(vp, mpp, flags) - struct vnode *vp; - struct mount **mpp; - int flags; +vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags) { struct mount *mp; int error; + KASSERT((flags & V_MNTREF) == 0 || (*mpp != NULL && vp == NULL), + ("V_MNTREF requires mp")); + retry: if (vp != NULL) { if ((error = VOP_GETWRITEMOUNT(vp, mpp)) != 0) { @@ -1697,7 +1697,7 @@ vn_start_secondary_write(vp, mpp, flags) * emulate a vfs_ref(). */ MNT_ILOCK(mp); - if (vp == NULL) + if (vp == NULL && (flags & V_MNTREF) == 0) MNT_REF(mp); if ((mp->mnt_kern_flag & (MNTK_SUSPENDED | MNTK_SUSPEND2)) == 0) { mp->mnt_secondary_writes++; Modified: stable/10/sys/sys/vnode.h ============================================================================== --- stable/10/sys/sys/vnode.h Wed Jun 10 02:14:33 2015 (r284201) +++ stable/10/sys/sys/vnode.h Wed Jun 10 02:20:58 2015 (r284202) @@ -395,6 +395,7 @@ extern int vttoif_tab[]; #define V_WAIT 0x0001 /* vn_start_write: sleep for suspend */ #define V_NOWAIT 0x0002 /* vn_start_write: don't sleep for suspend */ #define V_XSLEEP 0x0004 /* vn_start_write: just return after sleep */ +#define V_MNTREF 0x0010 /* vn_start_write: mp is already ref-ed */ #define VR_START_WRITE 0x0001 /* vfs_write_resume: start write atomically */ #define VR_NO_SUSPCLR 0x0002 /* vfs_write_resume: do not clear suspension */