Module Name:    src
Committed By:   riz
Date:           Mon Nov 22 02:53:19 UTC 2010

Modified Files:
        src/sys/kern [netbsd-5-1]: vfs_wapbl.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1477):
        sys/kern/vfs_wapbl.c: revision 1.38
Wapbl_register_deallocation(): the taken reader lock is not sufficient to
protect wl_dealloc* members.  Take the mutex here and change the lock
requirements of these fields to "writer lock or mutex".
This error lead to file system corruption and "freeing free block" panics.


To generate a diff of this commit:
cvs rdiff -u -r1.3.8.2 -r1.3.8.2.2.1 src/sys/kern/vfs_wapbl.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/kern/vfs_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.3.8.2 src/sys/kern/vfs_wapbl.c:1.3.8.2.2.1
--- src/sys/kern/vfs_wapbl.c:1.3.8.2	Mon Sep 13 19:52:49 2010
+++ src/sys/kern/vfs_wapbl.c	Mon Nov 22 02:53:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.3.8.2 2010/09/13 19:52:49 snj Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.3.8.2.2.1 2010/11/22 02:53:19 riz Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  * This implements file system independent write ahead filesystem logging.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.3.8.2 2010/09/13 19:52:49 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.3.8.2.2.1 2010/11/22 02:53:19 riz Exp $");
 
 #include <sys/param.h>
 
@@ -95,6 +95,7 @@
  *		r = read-only after init
  *		l = rwlock held
  *		m = mutex held
+ *		lm = rwlock held writing or mutex held
  *		u = unlocked access ok
  *		b = bufcache_lock held
  */
@@ -162,9 +163,9 @@
 	size_t wl_unsynced_bufbytes; /* Byte count of unsynced buffers */
 #endif
 
-	daddr_t *wl_deallocblks;/* l:	address of block */
-	int *wl_dealloclens;	/* l:	size of block (fragments, kom ih�g) */
-	int wl_dealloccnt;	/* l:	total count */
+	daddr_t *wl_deallocblks;/* lm:	address of block */
+	int *wl_dealloclens;	/* lm:	size of block */
+	int wl_dealloccnt;	/* lm:	total count */
 	int wl_dealloclim;	/* l:	max count */
 
 	/* hashtable of inode numbers for allocated but unlinked inodes */
@@ -1668,6 +1669,7 @@
 
 	wapbl_jlock_assert(wl);
 
+	mutex_enter(&wl->wl_mtx);
 	/* XXX should eventually instead tie this into resource estimation */
 	/* XXX this KASSERT needs locking/mutex analysis */
 	KASSERT(wl->wl_dealloccnt < wl->wl_dealloclim);
@@ -1676,6 +1678,7 @@
 	wl->wl_dealloccnt++;
 	WAPBL_PRINTF(WAPBL_PRINT_ALLOC,
 	    ("wapbl_register_deallocation: blk=%"PRId64" len=%d\n", blk, len));
+	mutex_exit(&wl->wl_mtx);
 }
 
 /****************************************************************/

Reply via email to