diff options
| author | oster <oster@NetBSD.org> | 2002-08-08 02:54:29 +0000 |
|---|---|---|
| committer | oster <oster@NetBSD.org> | 2002-08-08 02:54:29 +0000 |
| commit | 7c2df6a96d6dbe1462352df4a27b851a43da29d5 (patch) | |
| tree | 2becc313602394e70e309ae03c1e33c49b3ccd7f /sys/dev/raidframe | |
| parent | 813fbd6152b5d5a3fba5f9629481b5fd557fef3a (diff) | |
Initial kick at some functions to provide lockmgr lock support
instead of only simplelock support.
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_threadstuff.c | 44 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_threadstuff.h | 24 |
2 files changed, 64 insertions, 4 deletions
diff --git a/sys/dev/raidframe/rf_threadstuff.c b/sys/dev/raidframe/rf_threadstuff.c index 36dda159b65..9c61923547c 100644 --- a/sys/dev/raidframe/rf_threadstuff.c +++ b/sys/dev/raidframe/rf_threadstuff.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_threadstuff.c,v 1.7 2001/11/13 07:11:17 lukem Exp $ */ +/* $NetBSD: rf_threadstuff.c,v 1.8 2002/08/08 02:54:29 oster Exp $ */ /* * rf_threadstuff.c */ @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_threadstuff.c,v 1.7 2001/11/13 07:11:17 lukem Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_threadstuff.c,v 1.8 2002/08/08 02:54:29 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -92,6 +92,30 @@ RF_DECLARE_MUTEX(*m) return (rc); } + +int +_rf_create_managed_lkmgr_mutex(listp, m, file, line) + RF_ShutdownList_t **listp; +RF_DECLARE_LKMGR_MUTEX(*m) + char *file; + int line; +{ + int rc, rc1; + + rc = rf_lkmgr_mutex_init(m); + if (rc) + return (rc); + rc = _rf_ShutdownCreate(listp, mutex_destroyer, (void *) m, file, line); + if (rc) { + RF_ERRORMSG1("RAIDFRAME: Error %d adding shutdown entry\n", rc); + rc1 = rf_lkmgr_mutex_destroy(m); + if (rc1) { + RF_ERRORMSG1("RAIDFRAME: Error %d destroying mutex\n", rc1); + } + } + return (rc); +} + int _rf_create_managed_cond(listp, c, file, line) RF_ShutdownList_t **listp; @@ -188,6 +212,22 @@ decl_simple_lock_data(, *m) return (0); } +int +rf_lkmgr_mutex_init(m) +decl_lock_data(, *m) +{ + lockinit(m,PRIBIO,"RAIDframe lock",0,0); + return(0); +} + +int +rf_lkmgr_mutex_destroy(m) +decl_lock_data(, *m) +{ + return(0); +} + + int rf_cond_init(c) RF_DECLARE_COND(*c) diff --git a/sys/dev/raidframe/rf_threadstuff.h b/sys/dev/raidframe/rf_threadstuff.h index b109b092083..15445948cc9 100644 --- a/sys/dev/raidframe/rf_threadstuff.h +++ b/sys/dev/raidframe/rf_threadstuff.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_threadstuff.h,v 1.11 2001/10/04 15:58:56 oster Exp $ */ +/* $NetBSD: rf_threadstuff.h,v 1.12 2002/08/08 02:54:30 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -64,6 +64,7 @@ _rf_init_managed_threadgroup(RF_ShutdownList_t ** listp, RF_ThreadGroup_t * g, char *file, int line); #include <sys/lock.h> + #define decl_simple_lock_data(a,b) a struct simplelock b; #define simple_lock_addr(a) ((struct simplelock *)&(a)) @@ -81,6 +82,18 @@ typedef void *RF_ThreadArg_t; #define RF_LOCK_MUTEX(_m_) simple_lock(&(_m_)) #define RF_UNLOCK_MUTEX(_m_) simple_unlock(&(_m_)) + +/* non-spinlock */ +#define decl_lock_data(a,b) a struct lock b; + +#define RF_DECLARE_LKMGR_MUTEX(_m_) decl_lock_data(,(_m_)) +#define RF_DECLARE_LKMGR_STATIC_MUTEX(_m_) decl_lock_data(static,(_m_)) +#define RF_DECLARE_LKMGR_EXTERN_MUTEX(_m_) decl_lock_data(extern,(_m_)) + +#define RF_LOCK_LKMGR_MUTEX(_m_) lockmgr(&(_m_),LK_EXCLUSIVE,NULL) +#define RF_UNLOCK_LKMGR_MUTEX(_m_) lockmgr(&(_m_),LK_RELEASE,NULL) + + /* * In NetBSD, kernel threads are simply processes which share several * substructures and never run in userspace. @@ -164,12 +177,19 @@ struct RF_ThreadGroup_s { } #endif - int rf_mutex_init(struct simplelock *); int rf_mutex_destroy(struct simplelock *); int _rf_create_managed_mutex(RF_ShutdownList_t **, struct simplelock *, char *, int); + +int rf_lkmgr_mutex_init(struct lock *); +int rf_lkmgr_mutex_destroy(struct lock *); +int +_rf_create_managed_lkmgr_mutex(RF_ShutdownList_t **, struct lock *, + char *, int); + + int _rf_create_managed_cond(RF_ShutdownList_t ** listp, int *, char *file, int line); |
