summaryrefslogtreecommitdiffstats
path: root/sys/net/radix.h
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2008-12-07 21:15:43 +0000
committerkmacy <kmacy@FreeBSD.org>2008-12-07 21:15:43 +0000
commit598b522b42d772cdb7895eda77507500d0507864 (patch)
tree16533ece1c017ec68e8457a3d70ddbcf41a9dec9 /sys/net/radix.h
parenteaa93f5a2f480f7198abc747e36a95b2e814d0e7 (diff)
downloadFreeBSD-src-598b522b42d772cdb7895eda77507500d0507864.zip
FreeBSD-src-598b522b42d772cdb7895eda77507500d0507864.tar.gz
- convert radix node head lock from mutex to rwlock
- make radix node head lock not recursive - fix LOR in rtexpunge - fix LOR in rtredirect Reviewed by: sam
Diffstat (limited to 'sys/net/radix.h')
-rw-r--r--sys/net/radix.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/net/radix.h b/sys/net/radix.h
index 376fdda..e84072f 100644
--- a/sys/net/radix.h
+++ b/sys/net/radix.h
@@ -36,6 +36,7 @@
#ifdef _KERNEL
#include <sys/_lock.h>
#include <sys/_mutex.h>
+#include <sys/_rwlock.h>
#endif
#ifdef MALLOC_DECLARE
@@ -132,7 +133,7 @@ struct radix_node_head {
struct radix_node rnh_nodes[3]; /* empty tree for common case */
int rnh_multipath; /* multipath capable ? */
#ifdef _KERNEL
- struct mtx rnh_mtx; /* locks entire radix tree */
+ struct rwlock rnh_lock; /* locks entire radix tree */
#endif
};
@@ -146,11 +147,17 @@ struct radix_node_head {
#define Free(p) free((caddr_t)p, M_RTABLE);
#define RADIX_NODE_HEAD_LOCK_INIT(rnh) \
- mtx_init(&(rnh)->rnh_mtx, "radix node head", NULL, MTX_DEF | MTX_RECURSE)
-#define RADIX_NODE_HEAD_LOCK(rnh) mtx_lock(&(rnh)->rnh_mtx)
-#define RADIX_NODE_HEAD_UNLOCK(rnh) mtx_unlock(&(rnh)->rnh_mtx)
-#define RADIX_NODE_HEAD_DESTROY(rnh) mtx_destroy(&(rnh)->rnh_mtx)
-#define RADIX_NODE_HEAD_LOCK_ASSERT(rnh) mtx_assert(&(rnh)->rnh_mtx, MA_OWNED)
+ rw_init_flags(&(rnh)->rnh_lock, "radix node head", 0)
+#define RADIX_NODE_HEAD_LOCK(rnh) rw_wlock(&(rnh)->rnh_lock)
+#define RADIX_NODE_HEAD_UNLOCK(rnh) rw_wunlock(&(rnh)->rnh_lock)
+#define RADIX_NODE_HEAD_RLOCK(rnh) rw_rlock(&(rnh)->rnh_lock)
+#define RADIX_NODE_HEAD_RUNLOCK(rnh) rw_runlock(&(rnh)->rnh_lock)
+#define RADIX_NODE_HEAD_LOCK_TRY_UPGRADE(rnh) rw_try_upgrade(&(rnh)->rnh_lock)
+
+
+#define RADIX_NODE_HEAD_DESTROY(rnh) rw_destroy(&(rnh)->rnh_lock)
+#define RADIX_NODE_HEAD_LOCK_ASSERT(rnh) rw_assert(&(rnh)->rnh_lock, RA_LOCKED)
+#define RADIX_NODE_HEAD_WLOCK_ASSERT(rnh) rw_assert(&(rnh)->rnh_lock, RA_WLOCKED)
#endif /* _KERNEL */
void rn_init(void);
OpenPOWER on IntegriCloud