Module Name: src
Committed By: rmind
Date: Wed Nov 11 09:15:42 UTC 2009
Modified Files:
src/sys/kern: vfs_bio.c
src/sys/sys: buf.h
Log Message:
Add a small comment on buffer cache locking, fix mark letter b_objlock.
To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.114 -r1.115 src/sys/sys/buf.h
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_bio.c
diff -u src/sys/kern/vfs_bio.c:1.220 src/sys/kern/vfs_bio.c:1.221
--- src/sys/kern/vfs_bio.c:1.220 Wed Nov 11 07:22:33 2009
+++ src/sys/kern/vfs_bio.c Wed Nov 11 09:15:42 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.220 2009/11/11 07:22:33 rmind Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.221 2009/11/11 09:15:42 rmind Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -100,14 +100,30 @@
*/
/*
+ * The buffer cache subsystem.
+ *
* Some references:
* Bach: The Design of the UNIX Operating System (Prentice Hall, 1986)
* Leffler, et al.: The Design and Implementation of the 4.3BSD
* UNIX Operating System (Addison Welley, 1989)
+ *
+ * Locking
+ *
+ * There are three locks:
+ * - bufcache_lock: protects global buffer cache state.
+ * - BC_BUSY: a long term per-buffer lock.
+ * - buf_t::b_objlock: lock on completion (biowait vs biodone).
+ *
+ * For buffers associated with vnodes (a most common case) b_objlock points
+ * to the vnode_t::v_interlock. Otherwise, it points to generic buffer_lock.
+ *
+ * Lock order:
+ * bufcache_lock ->
+ * buf_t::b_objlock
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.220 2009/11/11 07:22:33 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.221 2009/11/11 09:15:42 rmind Exp $");
#include "fs_ffs.h"
#include "opt_bufcache.h"
Index: src/sys/sys/buf.h
diff -u src/sys/sys/buf.h:1.114 src/sys/sys/buf.h:1.115
--- src/sys/sys/buf.h:1.114 Wed Nov 11 07:22:34 2009
+++ src/sys/sys/buf.h Wed Nov 11 09:15:42 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.114 2009/11/11 07:22:34 rmind Exp $ */
+/* $NetBSD: buf.h,v 1.115 2009/11/11 09:15:42 rmind Exp $ */
/*-
* Copyright (c) 1999, 2000, 2007, 2008 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
* b thread of execution that holds BC_BUSY, does not correspond
* directly to any particular LWP
* c bufcache_lock
- * l b_objlock
+ * o b_objlock
*
* For buffers associated with a vnode, b_objlock points to vp->v_interlock.
* If not associated with a vnode, it points to the generic buffer_lock.