Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Aug 2019 20:24:52 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r351194 - in head/sys: compat/linux kern vm
Message-ID:  <201908182024.x7IKOqRD020512@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Aug 18 20:24:52 2019
New Revision: 351194
URL: https://svnweb.freebsd.org/changeset/base/351194

Log:
  Change locking requirements for VOP_UNSET_TEXT().
  
  Require the vnode to be locked for the VOP_UNSET_TEXT() call.  This
  will be used by the following bug fix for a tmpfs issue.
  
  Tested by:	sbruno, pho (previous version)
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/kern/vnode_if.src
  head/sys/vm/vm_map.c

Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c	Sun Aug 18 18:40:12 2019	(r351193)
+++ head/sys/compat/linux/linux_misc.c	Sun Aug 18 20:24:52 2019	(r351194)
@@ -472,8 +472,13 @@ cleanup:
 		locked = false;
 		VOP_CLOSE(vp, FREAD, td->td_ucred, td);
 	}
-	if (textset)
+	if (textset) {
+		if (!locked) {
+			locked = true;
+			VOP_LOCK(vp, LK_SHARED | LK_RETRY);
+		}
 		VOP_UNSET_TEXT_CHECKED(vp);
+	}
 	if (locked)
 		VOP_UNLOCK(vp, 0);
 

Modified: head/sys/kern/vnode_if.src
==============================================================================
--- head/sys/kern/vnode_if.src	Sun Aug 18 18:40:12 2019	(r351193)
+++ head/sys/kern/vnode_if.src	Sun Aug 18 20:24:52 2019	(r351194)
@@ -695,7 +695,7 @@ vop_set_text {
 };
 
 
-%% vop_unset_text	vp	= = =
+%% vop_unset_text	vp	L L L
 
 vop_unset_text {
 	IN struct vnode *vp;

Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c	Sun Aug 18 18:40:12 2019	(r351193)
+++ head/sys/vm/vm_map.c	Sun Aug 18 20:24:52 2019	(r351194)
@@ -547,12 +547,20 @@ vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool
 		    "entry %p, object %p, add %d", entry, object, add));
 	}
 	if (vp != NULL) {
-		if (add)
+		if (add) {
 			VOP_SET_TEXT_CHECKED(vp);
-		else
+			VM_OBJECT_RUNLOCK(object);
+		} else {
+			vhold(vp);
+			VM_OBJECT_RUNLOCK(object);
+			vn_lock(vp, LK_SHARED | LK_RETRY);
 			VOP_UNSET_TEXT_CHECKED(vp);
+			VOP_UNLOCK(vp, 0);
+			vdrop(vp);
+		}
+	} else {
+		VM_OBJECT_RUNLOCK(object);
 	}
-	VM_OBJECT_RUNLOCK(object);
 }
 
 static void



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