Module Name:    src
Committed By:   jdolecek
Date:           Sun Dec  9 20:45:37 UTC 2018

Modified Files:
        src/sys/uvm: uvm_bio.c

Log Message:
for direct map case, avoid PGO_NOBLOCKALLOC when writing, it makes
genfs_getpages() return unallocated pages using the zero page and
PG_RDONLY; the old code relied on fault logic to get it allocated, which
the direct case can't rely on

instead just allocate the blocks right away; pass PGO_JOURNALLOCKED
so that code wouldn't try to take wapbl lock, this code path is called
with it already held

this should fix KASSERT() due to PG_RDONLY on write with wapbl

towards resolution of PR kern/53124


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/uvm/uvm_bio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/uvm_bio.c
diff -u src/sys/uvm/uvm_bio.c:1.98 src/sys/uvm/uvm_bio.c:1.99
--- src/sys/uvm/uvm_bio.c:1.98	Tue Nov 20 20:07:19 2018
+++ src/sys/uvm/uvm_bio.c	Sun Dec  9 20:45:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_bio.c,v 1.98 2018/11/20 20:07:19 jdolecek Exp $	*/
+/*	$NetBSD: uvm_bio.c,v 1.99 2018/12/09 20:45:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.98 2018/11/20 20:07:19 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.99 2018/12/09 20:45:37 jdolecek Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -814,8 +814,7 @@ ubc_alloc_direct(struct uvm_object *uobj
 {
 	voff_t pgoff;
 	int error;
-	int gpflags = flags | PGO_NOTIMESTAMP | PGO_SYNCIO | PGO_ALLPAGES
-	    | PGO_NOBLOCKALLOC;
+	int gpflags = flags | PGO_NOTIMESTAMP | PGO_SYNCIO | PGO_ALLPAGES;
 	int access_type = VM_PROT_READ;
 	UVMHIST_FUNC("ubc_alloc_direct"); UVMHIST_CALLED(ubchist);
 
@@ -826,8 +825,15 @@ ubc_alloc_direct(struct uvm_object *uobj
 		KASSERT(!UVM_OBJ_NEEDS_WRITEFAULT(uobj));
 #endif
 
-		gpflags |= PGO_PASTEOF;
+		/*
+		 * Tell genfs_getpages() we already have the journal lock,
+		 * allow allocation past current EOF.
+		 */
+		gpflags |= PGO_JOURNALLOCKED | PGO_PASTEOF;
 		access_type |= VM_PROT_WRITE;
+	} else {
+		/* Don't need the empty blocks allocated, PG_RDONLY is okay */
+		gpflags |= PGO_NOBLOCKALLOC;
 	}
 
 	pgoff = (offset & PAGE_MASK);

Reply via email to