From: Chas Williams Date: Thu, 9 Mar 2006 21:41:51 +0000 (+0000) Subject: STABLE14-linux-updates-20060309 X-Git-Tag: openafs-stable-1_4_1-rc10~13 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=52e0966d0b1e7d622afdea24251aac70a76c8ee1;p=packages%2Fo%2Fopenafs.git STABLE14-linux-updates-20060309 FIXES 27589 update for new mutexes (cherry picked from commit 6e7d51187c881e6a785b88ccddbb083e52d58448) --- diff --git a/acinclude.m4 b/acinclude.m4 index c4256b7c4..fe62a0cf8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h index fd28337b2..3656bd4e5 100644 --- a/src/afs/LINUX/osi_machdep.h +++ b/src/afs/LINUX/osi_machdep.h @@ -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 +#include +#include +#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() diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index fcc42b0f9..1e79a8af2 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -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; diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h index cb7fe5cd0..e67c7bc33 100644 --- a/src/afs/sysincludes.h +++ b/src/afs/sysincludes.h @@ -97,6 +97,9 @@ struct xfs_inode_info { #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include +#endif #include #ifdef COMPLETION_H_EXISTS #include diff --git a/src/rx/LINUX/rx_kmutex.c b/src/rx/LINUX/rx_kmutex.c index b1d8bf99a..dbd3b32e1 100644 --- a/src/rx/LINUX/rx_kmutex.c +++ b/src/rx/LINUX/rx_kmutex.c @@ -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 diff --git a/src/rx/LINUX/rx_kmutex.h b/src/rx/LINUX/rx_kmutex.h index cf6828e46..6ea4faf07 100644 --- a/src/rx/LINUX/rx_kmutex.h +++ b/src/rx/LINUX/rx_kmutex.h @@ -31,11 +31,21 @@ struct coda_inode_info { }; #endif -#include "linux/wait.h" -#include "linux/sched.h" +#include +#include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include +#else +#include +#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;