summaryrefslogtreecommitdiffstats
path: root/sys/sys/bufobj.h
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2008-03-22 09:15:16 +0000
committerjeff <jeff@FreeBSD.org>2008-03-22 09:15:16 +0000
commita9d123c3ab34baa9fe2c8c25bd9acfbfb31b381e (patch)
tree5fedc50643363d96cefce7e3cd6edbdbf2d7fb2b /sys/sys/bufobj.h
parentb283b3e59a3e18ec4e7cf225a3a9922139733a73 (diff)
downloadFreeBSD-src-a9d123c3ab34baa9fe2c8c25bd9acfbfb31b381e.zip
FreeBSD-src-a9d123c3ab34baa9fe2c8c25bd9acfbfb31b381e.tar.gz
- Complete part of the unfinished bufobj work by consistently using
BO_LOCK/UNLOCK/MTX when manipulating the bufobj. - Create a new lock in the bufobj to lock bufobj fields independently. This leaves the vnode interlock as an 'identity' lock while the bufobj is an io lock. The bufobj lock is ordered before the vnode interlock and also before the mnt ilock. - Exploit this new lock order to simplify softdep_check_suspend(). - A few sync related functions are marked with a new XXX to note that we may not properly interlock against a non-zero bv_cnt when attempting to sync all vnodes on a mountlist. I do not believe this race is important. If I'm wrong this will make these locations easier to find. Reviewed by: kib (earlier diff) Tested by: kris, pho (earlier diff)
Diffstat (limited to 'sys/sys/bufobj.h')
-rw-r--r--sys/sys/bufobj.h24
1 files changed, 8 insertions, 16 deletions
diff --git a/sys/sys/bufobj.h b/sys/sys/bufobj.h
index 9ad572a..e491ce1 100644
--- a/sys/sys/bufobj.h
+++ b/sys/sys/bufobj.h
@@ -52,6 +52,8 @@
#if defined(_KERNEL) || defined(_KVM_VNODE)
#include <sys/queue.h>
+#include <sys/_lock.h>
+#include <sys/_mutex.h>
struct bufobj;
struct buf_ops;
@@ -87,7 +89,7 @@ struct buf_ops {
#define BO_BDFLUSH(bo, bp) ((bo)->bo_ops->bop_bdflush((bo), (bp)))
struct bufobj {
- struct mtx *bo_mtx; /* Mutex which protects "i" things */
+ struct mtx bo_mtx; /* Mutex which protects "i" things */
struct bufv bo_clean; /* i Clean buffers */
struct bufv bo_dirty; /* i Dirty buffers */
long bo_numoutput; /* i Writes in progress */
@@ -112,21 +114,11 @@ struct bufobj {
#define BO_WWAIT (1 << 1) /* Wait for output to complete */
#define BO_NEEDSGIANT (1 << 2) /* Require giant for child buffers. */
-#define BO_LOCK(bo) \
- do { \
- KASSERT((bo)->bo_mtx != NULL, ("No lock in bufobj")); \
- mtx_lock((bo)->bo_mtx); \
- } while (0)
-
-#define BO_UNLOCK(bo) \
- do { \
- KASSERT((bo)->bo_mtx != NULL, ("No lock in bufobj")); \
- mtx_unlock((bo)->bo_mtx); \
- } while (0)
-
-#define BO_MTX(bo) ((bo)->bo_mtx)
-#define ASSERT_BO_LOCKED(bo) mtx_assert(bo->bo_mtx, MA_OWNED)
-#define ASSERT_BO_UNLOCKED(bo) mtx_assert(bo->bo_mtx, MA_NOTOWNED)
+#define BO_MTX(bo) (&(bo)->bo_mtx)
+#define BO_LOCK(bo) mtx_lock(BO_MTX((bo)))
+#define BO_UNLOCK(bo) mtx_unlock(BO_MTX((bo)))
+#define ASSERT_BO_LOCKED(bo) mtx_assert(BO_MTX((bo)), MA_OWNED)
+#define ASSERT_BO_UNLOCKED(bo) mtx_assert(BO_MTX((bo)), MA_NOTOWNED)
void bufobj_wdrop(struct bufobj *bo);
void bufobj_wref(struct bufobj *bo);
OpenPOWER on IntegriCloud