svn commit: r211771 - projects/ofed/head/sys/ofed/include/linux
Jeff Roberson
jeff at FreeBSD.org
Tue Aug 24 20:41:05 UTC 2010
Author: jeff
Date: Tue Aug 24 20:41:05 2010
New Revision: 211771
URL: http://svn.freebsd.org/changeset/base/211771
Log:
- Zero all locks before calling the appropriate init function as linux
passes uninitialized memory in when locks are created and bsd expects
it to be zeroed. This is much more reliable than converting all
necessary sites to zero.
Sponsored by: Isilon Systems, iX Systems, and Panasas
Modified:
projects/ofed/head/sys/ofed/include/linux/mutex.h
projects/ofed/head/sys/ofed/include/linux/rwlock.h
projects/ofed/head/sys/ofed/include/linux/rwsem.h
projects/ofed/head/sys/ofed/include/linux/semaphore.h
projects/ofed/head/sys/ofed/include/linux/spinlock.h
Modified: projects/ofed/head/sys/ofed/include/linux/mutex.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/mutex.h Tue Aug 24 20:40:12 2010 (r211770)
+++ projects/ofed/head/sys/ofed/include/linux/mutex.h Tue Aug 24 20:41:05 2010 (r211771)
@@ -38,8 +38,6 @@ typedef struct mutex {
struct sx sx;
} mutex_t;
-#define mutex_init(_m) sx_init_flags(&(_m)->sx, \
- "lnxmtx", SX_NOWITNESS)
#define mutex_lock(_m) sx_xlock(&(_m)->sx)
#define mutex_lock_nested(_m, _s) mutex_lock(_m)
#define mutex_lock_interruptible(_m) ({ mutex_lock((_m)); 0; })
@@ -50,4 +48,14 @@ typedef struct mutex {
mutex_t lock; \
SX_SYSINIT_FLAGS(lock, &(lock).sx, "lnxmtx", SX_NOWITNESS)
+static inline void
+linux_mutex_init(mutex_t *m)
+{
+
+ memset(&m->sx, 0, sizeof(m->sx));
+ sx_init_flags(&m->sx, "lnxmtx", SX_NOWITNESS);
+}
+
+#define mutex_init linux_mutex_init
+
#endif /* _LINUX_MUTEX_H_ */
Modified: projects/ofed/head/sys/ofed/include/linux/rwlock.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/rwlock.h Tue Aug 24 20:40:12 2010 (r211770)
+++ projects/ofed/head/sys/ofed/include/linux/rwlock.h Tue Aug 24 20:41:05 2010 (r211771)
@@ -35,7 +35,6 @@ typedef struct {
struct rwlock rw;
} rwlock_t;
-#define rwlock_init(_l) rw_init_flags(&(_l)->rw, "lnxrw", RW_NOWITNESS)
#define read_lock(_l) rw_rlock(&(_l)->rw)
#define write_lock(_l) rw_wlock(&(_l)->rw)
#define read_unlock(_l) rw_runlock(&(_l)->rw)
@@ -53,4 +52,12 @@ typedef struct {
#define write_unlock_irqrestore(lock, flags) \
do { write_unlock(lock); } while (0)
+static inline void
+rwlock_init(rwlock_t *lock)
+{
+
+ memset(&lock->rw, 0, sizeof(lock->rw));
+ rw_init_flags(&lock->rw, "lnxrw", RW_NOWITNESS);
+}
+
#endif /* _LINUX_RWLOCK_H_ */
Modified: projects/ofed/head/sys/ofed/include/linux/rwsem.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/rwsem.h Tue Aug 24 20:40:12 2010 (r211770)
+++ projects/ofed/head/sys/ofed/include/linux/rwsem.h Tue Aug 24 20:41:05 2010 (r211771)
@@ -36,8 +36,6 @@ struct rw_semaphore {
struct sx sx;
};
-#define init_rwsem(_rw) sx_init_flags(&(_rw)->sx, \
- "lnxrwsem", SX_NOWITNESS)
#define down_write(_rw) sx_xlock(&(_rw)->sx)
#define up_write(_rw) sx_xunlock(&(_rw)->sx)
#define down_read(_rw) sx_slock(&(_rw)->sx)
@@ -47,4 +45,12 @@ struct rw_semaphore {
#define downgrade_write(_rw) sx_downgrade(&(_rw)->sx)
#define down_read_nested(_rw, _sc) down_read(_rw)
+static inline void
+init_rwsem(struct rw_semaphore *rw)
+{
+
+ memset(&rw->sx, 0, sizeof(rw->sx));
+ sx_init_flags(&rw->sx, "lnxrwsem", SX_NOWITNESS);
+}
+
#endif /* _LINUX_RWSEM_H_ */
Modified: projects/ofed/head/sys/ofed/include/linux/semaphore.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/semaphore.h Tue Aug 24 20:40:12 2010 (r211770)
+++ projects/ofed/head/sys/ofed/include/linux/semaphore.h Tue Aug 24 20:41:05 2010 (r211771)
@@ -49,6 +49,7 @@ static inline void
linux_sema_init(struct semaphore *sem, int val)
{
+ memset(&sem->sema, 0, sizeof(sem->sema));
sema_init(&sem->sema, val, "lnxsema");
}
@@ -56,6 +57,7 @@ static inline void
init_MUTEX(struct semaphore *sem)
{
+ memset(&sem->sema, 0, sizeof(sem->sema));
sema_init(&sem->sema, 1, "lnxsema");
}
Modified: projects/ofed/head/sys/ofed/include/linux/spinlock.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/spinlock.h Tue Aug 24 20:40:12 2010 (r211770)
+++ projects/ofed/head/sys/ofed/include/linux/spinlock.h Tue Aug 24 20:41:05 2010 (r211771)
@@ -42,8 +42,6 @@ typedef struct {
struct mtx m;
} spinlock_t;
-#define spin_lock_init(_l) mtx_init(&(_l)->m, "lnxspin", NULL, \
- MTX_DEF | MTX_NOWITNESS)
#define spin_lock(_l) mtx_lock(&(_l)->m)
#define spin_unlock(_l) mtx_unlock(&(_l)->m)
#define spin_lock_nested(_l, _n) mtx_lock_flags(&(_l)->m, MTX_DUPOK)
@@ -54,6 +52,14 @@ typedef struct {
#define spin_unlock_irqrestore(lock, flags) \
do { spin_unlock(lock); } while (0)
+static inline void
+spin_lock_init(spinlock_t *lock)
+{
+
+ memset(&lock->m, 0, sizeof(lock->m));
+ mtx_init(&lock->m, "lnxspin", NULL, MTX_DEF | MTX_NOWITNESS);
+}
+
#define DEFINE_SPINLOCK(lock) \
spinlock_t lock; \
MTX_SYSINIT(lock, &(lock).m, "lnxspin", MTX_DEF)
More information about the svn-src-projects
mailing list