Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Dec 2012 13:22:32 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r244658 - in stable/9/sys: compat/linux fs/coda fs/nfsserver kern nfsserver vm
Message-ID:  <201212241322.qBODMWtQ012631@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Dec 24 13:22:32 2012
New Revision: 244658
URL: http://svnweb.freebsd.org/changeset/base/244658

Log:
  MFC r241025:
  Fix the mis-handling of the VV_TEXT on the nullfs vnodes.
  Add a set of VOPs for the VV_TEXT query, set and clear operations,
  which are correctly bypassed to lower vnode.

Modified:
  stable/9/sys/compat/linux/linux_misc.c
  stable/9/sys/fs/coda/coda_subr.c
  stable/9/sys/fs/nfsserver/nfs_nfsdport.c
  stable/9/sys/kern/imgact_elf.c
  stable/9/sys/kern/kern_exec.c
  stable/9/sys/kern/vfs_default.c
  stable/9/sys/kern/vfs_vnops.c
  stable/9/sys/kern/vnode_if.src
  stable/9/sys/nfsserver/nfs_serv.c
  stable/9/sys/vm/vm_object.c
  stable/9/sys/vm/vnode_pager.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/compat/linux/linux_misc.c
==============================================================================
--- stable/9/sys/compat/linux/linux_misc.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/compat/linux/linux_misc.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -372,7 +372,7 @@ linux_uselib(struct thread *td, struct l
 	 * XXX: Note that if any of the VM operations fail below we don't
 	 * clear this flag.
 	 */
-	vp->v_vflag |= VV_TEXT;
+	VOP_SET_TEXT(vp);
 
 	/*
 	 * Lock no longer needed

Modified: stable/9/sys/fs/coda/coda_subr.c
==============================================================================
--- stable/9/sys/fs/coda/coda_subr.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/fs/coda/coda_subr.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -486,7 +486,7 @@ handleDownCall(struct coda_mntinfo *mnt,
 			cache_purge(CTOV(cp));
 			cp->c_flags &= ~(C_VATTR | C_ACCCACHE);
 			ASSERT_VOP_LOCKED(CTOV(cp), "coda HandleDownCall");
-			if (CTOV(cp)->v_vflag & VV_TEXT)
+			if (VOP_IS_TEXT(CTOV(cp)))
 				error = coda_vmflush(cp);
 			CODADEBUG(CODA_ZAPFILE,
 			myprintf(("zapfile: fid = %s, refcnt = %d, error = "
@@ -532,7 +532,7 @@ handleDownCall(struct coda_mntinfo *mnt,
 			cp->c_flags &= ~(C_VATTR | C_ACCCACHE);
 			ASSERT_VOP_LOCKED(CTOV(cp), "coda HandleDownCall");
 			if (!(IS_DIR(out->coda_purgefid.Fid))
-			    && (CTOV(cp)->v_vflag & VV_TEXT))
+			    && VOP_IS_TEXT(CTOV(cp)))
 				error = coda_vmflush(cp);
 			CODADEBUG(CODA_PURGEFID, myprintf(("purgefid: fid "
 			    "= %s, refcnt = %d, error = %d\n",

Modified: stable/9/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- stable/9/sys/fs/nfsserver/nfs_nfsdport.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/fs/nfsserver/nfs_nfsdport.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -253,7 +253,7 @@ nfsvno_accchk(struct vnode *vp, accmode_
 		 * the inode, try to free it up once.  If
 		 * we fail, we can't allow writing.
 		 */
-		if ((vp->v_vflag & VV_TEXT) != 0 && error == 0)
+		if (VOP_IS_TEXT(vp) && error == 0)
 			error = ETXTBSY;
 	}
 	if (error != 0) {

Modified: stable/9/sys/kern/imgact_elf.c
==============================================================================
--- stable/9/sys/kern/imgact_elf.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/kern/imgact_elf.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -646,7 +646,7 @@ __elfN(load_file)(struct proc *p, const 
 	 * Also make certain that the interpreter stays the same, so set
 	 * its VV_TEXT flag, too.
 	 */
-	nd->ni_vp->v_vflag |= VV_TEXT;
+	VOP_SET_TEXT(nd->ni_vp);
 
 	imgp->object = nd->ni_vp->v_object;
 

Modified: stable/9/sys/kern/kern_exec.c
==============================================================================
--- stable/9/sys/kern/kern_exec.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/kern/kern_exec.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -473,9 +473,8 @@ interpret:
 	 * Remember if this was set before and unset it in case this is not
 	 * actually an executable image.
 	 */
-	textset = imgp->vp->v_vflag & VV_TEXT;
-	ASSERT_VOP_ELOCKED(imgp->vp, "vv_text");
-	imgp->vp->v_vflag |= VV_TEXT;
+	textset = VOP_IS_TEXT(imgp->vp);
+	VOP_SET_TEXT(imgp->vp);
 
 	error = exec_map_first_page(imgp);
 	if (error)
@@ -506,10 +505,8 @@ interpret:
 
 	if (error) {
 		if (error == -1) {
-			if (textset == 0) {
-				ASSERT_VOP_ELOCKED(imgp->vp, "vv_text");
-				imgp->vp->v_vflag &= ~VV_TEXT;
-			}
+			if (textset == 0)
+				VOP_UNSET_TEXT(imgp->vp);
 			error = ENOEXEC;
 		}
 		goto exec_fail_dealloc;
@@ -527,7 +524,7 @@ interpret:
 		 * VV_TEXT will be set. The vnode lock is held over this
 		 * entire period so nothing should illegitimately be blocked.
 		 */
-		imgp->vp->v_vflag &= ~VV_TEXT;
+		VOP_UNSET_TEXT(imgp->vp);
 		/* free name buffer and old vnode */
 		if (args->fname != NULL)
 			NDFREE(&nd, NDF_ONLY_PNBUF);

Modified: stable/9/sys/kern/vfs_default.c
==============================================================================
--- stable/9/sys/kern/vfs_default.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/kern/vfs_default.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -78,6 +78,10 @@ static int	dirent_exists(struct vnode *v
 
 #define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4)
 
+static int vop_stdis_text(struct vop_is_text_args *ap);
+static int vop_stdset_text(struct vop_set_text_args *ap);
+static int vop_stdunset_text(struct vop_unset_text_args *ap);
+
 /*
  * This vnode table stores what we want to do if the filesystem doesn't
  * implement a particular VOP.
@@ -126,6 +130,9 @@ struct vop_vector default_vnodeops = {
 	.vop_unp_bind =		vop_stdunp_bind,
 	.vop_unp_connect =	vop_stdunp_connect,
 	.vop_unp_detach =	vop_stdunp_detach,
+	.vop_is_text =		vop_stdis_text,
+	.vop_set_text =		vop_stdset_text,
+	.vop_unset_text =	vop_stdunset_text,
 };
 
 /*
@@ -1073,6 +1080,29 @@ vop_stdunp_detach(struct vop_unp_detach_
 	return (0);
 }
 
+static int
+vop_stdis_text(struct vop_is_text_args *ap)
+{
+
+	return ((ap->a_vp->v_vflag & VV_TEXT) != 0);
+}
+
+static int
+vop_stdset_text(struct vop_set_text_args *ap)
+{
+
+	ap->a_vp->v_vflag |= VV_TEXT;
+	return (0);
+}
+
+static int
+vop_stdunset_text(struct vop_unset_text_args *ap)
+{
+
+	ap->a_vp->v_vflag &= ~VV_TEXT;
+	return (0);
+}
+
 /*
  * vfs default ops
  * used to fill the vfs function table to get reasonable default return values.

Modified: stable/9/sys/kern/vfs_vnops.c
==============================================================================
--- stable/9/sys/kern/vfs_vnops.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/kern/vfs_vnops.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -282,7 +282,7 @@ vn_writechk(vp)
 	 * the vnode, try to free it up once.  If
 	 * we fail, we can't allow writing.
 	 */
-	if (vp->v_vflag & VV_TEXT)
+	if (VOP_IS_TEXT(vp))
 		return (ETXTBSY);
 
 	return (0);

Modified: stable/9/sys/kern/vnode_if.src
==============================================================================
--- stable/9/sys/kern/vnode_if.src	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/kern/vnode_if.src	Mon Dec 24 13:22:32 2012	(r244658)
@@ -658,6 +658,24 @@ vop_unp_detach {
 	IN struct vnode *vp;
 };
 
+%% is_text	vp	L L L
+
+vop_is_text {
+	IN struct vnode *vp;
+};
+
+%% set_text	vp	E E E
+
+vop_set_text {
+	IN struct vnode *vp;
+};
+
+%% vop_unset_text	vp	E E E
+
+vop_unset_text {
+	IN struct vnode *vp;
+};
+
 # The VOPs below are spares at the end of the table to allow new VOPs to be
 # added in stable branches without breaking the KBI.  New VOPs in HEAD should
 # be added above these spares.  When merging a new VOP to a stable branch,

Modified: stable/9/sys/nfsserver/nfs_serv.c
==============================================================================
--- stable/9/sys/nfsserver/nfs_serv.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/nfsserver/nfs_serv.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -3891,7 +3891,7 @@ nfsrv_access(struct vnode *vp, accmode_t
 		 * If there's shared text associated with
 		 * the inode, we can't allow writing.
 		 */
-		if (vp->v_vflag & VV_TEXT)
+		if (VOP_IS_TEXT(vp))
 			return (ETXTBSY);
 	}
 

Modified: stable/9/sys/vm/vm_object.c
==============================================================================
--- stable/9/sys/vm/vm_object.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/vm/vm_object.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -455,7 +455,7 @@ vm_object_vndeallocate(vm_object_t objec
 			VOP_UNLOCK(vp, 0);
 		} else {
 			if (object->ref_count == 0)
-				vp->v_vflag &= ~VV_TEXT;
+				VOP_UNSET_TEXT(vp);
 			VM_OBJECT_UNLOCK(object);
 			vput(vp);
 		}

Modified: stable/9/sys/vm/vnode_pager.c
==============================================================================
--- stable/9/sys/vm/vnode_pager.c	Mon Dec 24 13:22:22 2012	(r244657)
+++ stable/9/sys/vm/vnode_pager.c	Mon Dec 24 13:22:32 2012	(r244658)
@@ -275,7 +275,7 @@ vnode_pager_dealloc(object)
 		vp->v_writecount--;
 	}
 	vp->v_object = NULL;
-	vp->v_vflag &= ~VV_TEXT;
+	VOP_UNSET_TEXT(vp);
 	VM_OBJECT_UNLOCK(object);
 	while (refs-- > 0)
 		vunref(vp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212241322.qBODMWtQ012631>