]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-linux-updates-20060309
authorChas Williams <chas@cmf.nrl.navy.mil>
Thu, 9 Mar 2006 21:41:51 +0000 (21:41 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 9 Mar 2006 21:41:51 +0000 (21:41 +0000)
FIXES 27589

update for new mutexes

(cherry picked from commit 6e7d51187c881e6a785b88ccddbb083e52d58448)

acinclude.m4
src/afs/LINUX/osi_machdep.h
src/afs/LINUX/osi_module.c
src/afs/sysincludes.h
src/rx/LINUX/rx_kmutex.c
src/rx/LINUX/rx_kmutex.h

index c4256b7c4a9dae3e994ded353acbe5fd316cc967..fe62a0cf8390b0c8ba5d752350f2c42688aa1fc7 100644 (file)
@@ -691,6 +691,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 if test "x$ac_cv_linux_fs_struct_inode_has_i_security" = "xyes"; then 
                  AC_DEFINE(STRUCT_INODE_HAS_I_SECURITY, 1, [define if you struct inode has i_security])
                 fi
+                if test "x$ac_cv_linux_fs_struct_inode_has_i_mutex" = "xyes"; then 
+                 AC_DEFINE(STRUCT_INODE_HAS_I_MUTEX, 1, [define if you struct inode has i_mutex])
+                fi
                 if test "x$ac_cv_linux_fs_struct_inode_has_i_sb_list" = "xyes"; then 
                  AC_DEFINE(STRUCT_INODE_HAS_I_SB_LIST, 1, [define if you struct inode has i_sb_list])
                 fi
index fd28337b24e1194b278fa10a9d4934abc4ba011c..3656bd4e5abe89d49493a4a233b79808bb152184 100644 (file)
@@ -187,15 +187,22 @@ extern unsigned long afs_linux_page_offset;
 #define afs_linux_page_address(page) (afs_linux_page_offset + PAGE_SIZE * (page - mem_map))
 
 #if defined(__KERNEL__)
-#include "../h/sched.h"
-#include "linux/wait.h"
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+extern struct mutex afs_global_lock;
+#else
 extern struct semaphore afs_global_lock;
+#define mutex_lock(lock) down(lock)
+#define mutex_unlock(lock) up(lock)
+#endif
 extern int afs_global_owner;
 
 #define AFS_GLOCK() \
 do { \
-        down(&afs_global_lock); \
+        mutex_lock(&afs_global_lock); \
         if (afs_global_owner) \
             osi_Panic("afs_global_lock already held by pid %d", \
                       afs_global_owner); \
@@ -209,10 +216,8 @@ do { \
     if (!ISAFS_GLOCK()) \
        osi_Panic("afs global lock not held at %s:%d", __FILE__, __LINE__); \
     afs_global_owner = 0; \
-    up(&afs_global_lock); \
+    mutex_unlock(&afs_global_lock); \
 } while (0)
-
-
 #else
 #define AFS_GLOCK()
 #define AFS_GUNLOCK()
index fcc42b0f92f4bbd22d54fef8ea1bdbee402bd646..1e79a8af2e82690204965f6d27dcabf9405006eb 100644 (file)
@@ -48,7 +48,9 @@ extern struct file_system_type afs_fs_type;
 static long get_page_offset(void);
 #endif
 
-#if defined(AFS_LINUX24_ENV)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+DEFINE_MUTEX(afs_global_lock);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 DECLARE_MUTEX(afs_global_lock);
 #else
 struct semaphore afs_global_lock = MUTEX;
index cb7fe5cd0188e2a82bd1369d11ee49012c96a2a2..e67c7bc3383ebe8e907a56398a27e855e9418fa6 100644 (file)
@@ -97,6 +97,9 @@ struct xfs_inode_info {
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <asm/semaphore.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#include <linux/mutex.h>
+#endif
 #include <linux/errno.h>
 #ifdef COMPLETION_H_EXISTS
 #include <linux/completion.h>
index b1d8bf99aabd37e24866ee3331c8c0d85d2645b3..dbd3b32e122345fcd8e9177f94246b8ffb947d92 100644 (file)
@@ -26,7 +26,9 @@ RCSID
 void
 afs_mutex_init(afs_kmutex_t * l)
 {
-#if defined(AFS_LINUX24_ENV)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+    mutex_init(&l->mutex);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     init_MUTEX(&l->sem);
 #else
     l->sem = MUTEX;
@@ -37,7 +39,11 @@ afs_mutex_init(afs_kmutex_t * l)
 void
 afs_mutex_enter(afs_kmutex_t * l)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+    mutex_lock(&l->mutex);
+#else
     down(&l->sem);
+#endif
     if (l->owner)
        osi_Panic("mutex_enter: 0x%x held by %d", l, l->owner);
     l->owner = current->pid;
@@ -46,7 +52,11 @@ afs_mutex_enter(afs_kmutex_t * l)
 int
 afs_mutex_tryenter(afs_kmutex_t * l)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+    if (mutex_trylock(&l->mutex) == 0)
+#else
     if (down_trylock(&l->sem))
+#endif
        return 0;
     l->owner = current->pid;
     return 1;
@@ -58,7 +68,11 @@ afs_mutex_exit(afs_kmutex_t * l)
     if (l->owner != current->pid)
        osi_Panic("mutex_exit: 0x%x held by %d", l, l->owner);
     l->owner = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+    mutex_unlock(&l->mutex);
+#else
     up(&l->sem);
+#endif
 }
 
 /* CV_WAIT and CV_TIMEDWAIT sleep until the specified event occurs, or, in the
index cf6828e46f20d32b07f73fde194bc55ba40f1ae8..6ea4faf07812764524e1bbd9d6625c1798182976 100644 (file)
 struct coda_inode_info {
 };
 #endif
-#include "linux/wait.h"
-#include "linux/sched.h"
+#include <linux/version.h>
+#include <linux/wait.h>
+#include <linux/sched.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#include <linux/mutex.h>
+#else
+#include <asm/semaphore.h>
+#endif
 
 typedef struct afs_kmutex {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+    struct mutex mutex;
+#else
     struct semaphore sem;
+#endif
     int owner;
 } afs_kmutex_t;