Module Name:    src
Committed By:   pooka
Date:           Thu Sep  9 09:50:21 UTC 2010

Modified Files:
        src/sys/rump/librump/rumpvfs: vm_vfs.c

Log Message:
Use proper locking before unbusying pages.

Caught after yesterday's changes by the test suite (the ffs snapshot
test, to be precise).


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/rump/librump/rumpvfs/vm_vfs.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/rump/librump/rumpvfs/vm_vfs.c
diff -u src/sys/rump/librump/rumpvfs/vm_vfs.c:1.20 src/sys/rump/librump/rumpvfs/vm_vfs.c:1.21
--- src/sys/rump/librump/rumpvfs/vm_vfs.c:1.20	Mon Sep  6 21:33:07 2010
+++ src/sys/rump/librump/rumpvfs/vm_vfs.c	Thu Sep  9 09:50:21 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_vfs.c,v 1.20 2010/09/06 21:33:07 pooka Exp $	*/
+/*	$NetBSD: vm_vfs.c,v 1.21 2010/09/09 09:50:21 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.20 2010/09/06 21:33:07 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.21 2010/09/09 09:50:21 pooka Exp $");
 
 #include <sys/param.h>
 
@@ -47,11 +47,13 @@
 void
 uvm_aio_aiodone(struct buf *bp)
 {
+	struct uvm_object *uobj;
 	int i, npages = bp->b_bufsize >> PAGE_SHIFT;
 	struct vm_page **pgs;
 	vaddr_t va;
 	int pageout = 0;
 
+	KASSERT(npages > 0);
 	pgs = kmem_alloc(npages * sizeof(*pgs), KM_SLEEP);
 	for (i = 0; i < npages; i++) {
 		va = (vaddr_t)bp->b_data + (i << PAGE_SHIFT);
@@ -65,7 +67,16 @@
 
 	uvm_pagermapout((vaddr_t)bp->b_data, npages);
 	uvm_pageout_done(pageout);
+
+	/* get uobj because we need it after pages might be recycled */
+	uobj = pgs[0]->uobject;
+	KASSERT(uobj);
+
+	mutex_enter(&uobj->vmobjlock);
+	mutex_enter(&uvm_pageqlock);
 	uvm_page_unbusy(pgs, npages);
+	mutex_exit(&uvm_pageqlock);
+	mutex_exit(&uobj->vmobjlock);
 
 	if (BUF_ISWRITE(bp) && (bp->b_cflags & BC_AGE) != 0) {
 		mutex_enter(bp->b_objlock);

Reply via email to