svn commit: r354394 - in stable/12/sys: sys vm

Konstantin Belousov kib at FreeBSD.org
Wed Nov 6 14:41:08 UTC 2019


Author: kib
Date: Wed Nov  6 14:41:07 2019
New Revision: 354394
URL: https://svnweb.freebsd.org/changeset/base/354394

Log:
  MFC r353890:
  Add VV_VMSIZEVNLOCK flag.
  
  MFC note: OBJ_SIZEVNLOCK value was changed due to differences between
  stable/12 and HEAD.

Modified:
  stable/12/sys/sys/vnode.h
  stable/12/sys/vm/vm_fault.c
  stable/12/sys/vm/vm_object.h
  stable/12/sys/vm/vnode_pager.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/sys/vnode.h
==============================================================================
--- stable/12/sys/sys/vnode.h	Wed Nov  6 14:34:14 2019	(r354393)
+++ stable/12/sys/sys/vnode.h	Wed Nov  6 14:41:07 2019	(r354394)
@@ -246,6 +246,7 @@ struct xvnode {
 #define	VV_NOSYNC	0x0004	/* unlinked, stop syncing */
 #define	VV_ETERNALDEV	0x0008	/* device that is never destroyed */
 #define	VV_CACHEDLABEL	0x0010	/* Vnode has valid cached MAC label */
+#define	VV_VMSIZEVNLOCK	0x0020	/* object size check requires vnode lock */
 #define	VV_COPYONWRITE	0x0040	/* vnode is doing copy-on-write */
 #define	VV_SYSTEM	0x0080	/* vnode being used by kernel */
 #define	VV_PROCDEP	0x0100	/* vnode is process dependent */

Modified: stable/12/sys/vm/vm_fault.c
==============================================================================
--- stable/12/sys/vm/vm_fault.c	Wed Nov  6 14:34:14 2019	(r354393)
+++ stable/12/sys/vm/vm_fault.c	Wed Nov  6 14:41:07 2019	(r354394)
@@ -896,6 +896,13 @@ RetryFault_oom:
 		 */
 		if (fs.object->type != OBJT_DEFAULT ||
 		    fs.object == fs.first_object) {
+			if ((fs.object->flags & OBJ_SIZEVNLOCK) != 0) {
+				rv = vm_fault_lock_vnode(&fs);
+				MPASS(rv == KERN_SUCCESS ||
+				    rv == KERN_RESOURCE_SHORTAGE);
+				if (rv == KERN_RESOURCE_SHORTAGE)
+					goto RetryFault;
+			}
 			if (fs.pindex >= fs.object->size) {
 				unlock_and_deallocate(&fs);
 				return (KERN_OUT_OF_BOUNDS);

Modified: stable/12/sys/vm/vm_object.h
==============================================================================
--- stable/12/sys/vm/vm_object.h	Wed Nov  6 14:34:14 2019	(r354393)
+++ stable/12/sys/vm/vm_object.h	Wed Nov  6 14:41:07 2019	(r354394)
@@ -189,6 +189,7 @@ struct vm_object {
 #define	OBJ_MIGHTBEDIRTY 0x0100		/* object might be dirty, only for vnode */
 #define	OBJ_TMPFS_NODE	0x0200		/* object belongs to tmpfs VREG node */
 #define	OBJ_TMPFS_DIRTY	0x0400		/* dirty tmpfs obj */
+#define	OBJ_SIZEVNLOCK	0x0800		/* lock vnode to check obj size */
 #define	OBJ_COLORED	0x1000		/* pg_color is defined */
 #define	OBJ_ONEMAPPING	0x2000		/* One USE (a single, non-forked) mapping flag */
 #define	OBJ_DISCONNECTWNT 0x4000	/* disconnect from vnode wanted */

Modified: stable/12/sys/vm/vnode_pager.c
==============================================================================
--- stable/12/sys/vm/vnode_pager.c	Wed Nov  6 14:34:14 2019	(r354393)
+++ stable/12/sys/vm/vnode_pager.c	Wed Nov  6 14:41:07 2019	(r354394)
@@ -256,8 +256,12 @@ retry:
 		object->un_pager.vnp.vnp_size = size;
 		object->un_pager.vnp.writemappings = 0;
 		object->domain.dr_policy = vnode_domainset;
-
 		object->handle = handle;
+		if ((vp->v_vflag & VV_VMSIZEVNLOCK) != 0) {
+			VM_OBJECT_WLOCK(object);
+			vm_object_set_flag(object, OBJ_SIZEVNLOCK);
+			VM_OBJECT_WUNLOCK(object);
+		}
 		VI_LOCK(vp);
 		if (vp->v_object != NULL) {
 			/*


More information about the svn-src-stable mailing list