From: Simon Wilkinson Date: Tue, 17 Nov 2009 19:52:15 +0000 (+0000) Subject: Move GLOCK initialisation to platform directories X-Git-Tag: openafs-devel-1_5_69~20 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=1a027a3ee151c7f77bbfa74c8002c8ff4b406985;p=packages%2Fo%2Fopenafs.git Move GLOCK initialisation to platform directories Rework the GLOCK initialisation code so that it's moved out into platform directories, rather than all being done in osi_Init. Change-Id: I1aae76ba12cd4e45f54881f5573ed1713159b64b Reviewed-on: http://gerrit.openafs.org/837 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afs/AIX/osi_machdep.h b/src/afs/AIX/osi_machdep.h index ffab0ae5c..1cd8b908a 100644 --- a/src/afs/AIX/osi_machdep.h +++ b/src/afs/AIX/osi_machdep.h @@ -74,6 +74,17 @@ extern simple_lock_data afs_global_lock; } while(0) #define ISAFS_GLOCK() lock_mine((void *)&afs_global_lock) +#if defined(AFS_AIX41_ENV) +#define osi_InitGlock() \ + do { \ + lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1); \ + simple_lock_init((void *)&afs_global_lock); \ + } while(0) +#else +#define osi_InitGlock() \ + mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL) +#endif + #define ifnet_flags(x) (x?(x)->if_flags:0) #endif diff --git a/src/afs/DARWIN/osi_machdep.h b/src/afs/DARWIN/osi_machdep.h index 3fe44ffc6..a0ad9c218 100644 --- a/src/afs/DARWIN/osi_machdep.h +++ b/src/afs/DARWIN/osi_machdep.h @@ -174,6 +174,10 @@ extern lck_mtx_t *afs_global_lock; afs_global_owner = 0; \ lck_mtx_unlock(afs_global_lock); \ } while(0) +#define osi_InitGlock() \ + do { \ + afs_global_owner = 0; \ + } while (0) #else /* Should probably use mach locks rather than bsd locks, since we use the mach thread control api's elsewhere (mach locks not used for consistency @@ -192,6 +196,11 @@ extern struct lock__bsd__ afs_global_lock; afs_global_owner = 0; \ lockmgr(&afs_global_lock, LK_RELEASE, 0, current_proc()); \ } while(0) +#define osi_InitGlock() \ + do { \ + lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \ + afs_global_owner = 0; \ + } while (0) #endif #define ISAFS_GLOCK() (afs_global_owner == current_thread()) diff --git a/src/afs/FBSD/osi_machdep.h b/src/afs/FBSD/osi_machdep.h index 954295a2b..dff2e40c7 100644 --- a/src/afs/FBSD/osi_machdep.h +++ b/src/afs/FBSD/osi_machdep.h @@ -119,6 +119,19 @@ extern struct mtx afs_global_mtx; #define AFS_GLOCK() mtx_lock(&afs_global_mtx) #define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx) #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx)) +#if defined(AFS_FBSD80_ENV) && defined(WITNESS) +# define osi_InitGlock() \ + do { \ + memset(&afs_global_mtx, 0, sizeof(struct mtx)); \ + mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \ + afs_global_owner = 0; \ + } while(0) +#else +# define osi_InitGlock() \ + do { \ + mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \ + afs_global_owner = 0; \ + } while (0) #else /* FBSD50 */ extern struct lock afs_global_lock; #define osi_curcred() (curproc->p_cred->pc_ucred) @@ -141,6 +154,11 @@ extern struct proc *afs_global_owner; lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \ } while(0) #define ISAFS_GLOCK() (afs_global_owner == curproc && curproc) +#define osi_InitGlock() \ + do { \ + lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \ + afs_global_owner = 0; \ + } while (0) #endif /* FBSD50 */ #undef SPLVAR diff --git a/src/afs/IRIX/osi_machdep.h b/src/afs/IRIX/osi_machdep.h index 444c24cd8..3885aff20 100644 --- a/src/afs/IRIX/osi_machdep.h +++ b/src/afs/IRIX/osi_machdep.h @@ -194,7 +194,13 @@ extern long afs_global_owner; #endif /* KERNEL */ - +#if defined(AFS_SGI62_ENV) +# define osi_InitGlock() \ + mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock"); +#else +# define osi_InitGlock() \ + mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL); +#endif #ifdef AFS_SGI64_ENV #define gop_rdwr(rw,gp,base,len,offset,segflg,ioflag,ulimit,cr,aresid) \ diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h index bfd11c1ab..f807ae2f4 100644 --- a/src/afs/LINUX/osi_machdep.h +++ b/src/afs/LINUX/osi_machdep.h @@ -292,6 +292,9 @@ do { \ afs_global_owner = 0; \ mutex_unlock(&afs_global_lock); \ } while (0) + +#define osi_InitGlock() + #else #define AFS_GLOCK() #define AFS_GUNLOCK() diff --git a/src/afs/LINUX24/osi_machdep.h b/src/afs/LINUX24/osi_machdep.h index 24bcd6791..0f2de981e 100644 --- a/src/afs/LINUX24/osi_machdep.h +++ b/src/afs/LINUX24/osi_machdep.h @@ -269,6 +269,9 @@ do { \ afs_global_owner = 0; \ mutex_unlock(&afs_global_lock); \ } while (0) + +#define osi_InitGlock() + #else #define AFS_GLOCK() #define AFS_GUNLOCK() diff --git a/src/afs/NBSD/osi_machdep.h b/src/afs/NBSD/osi_machdep.h index 91e98bc7f..db7440ad9 100644 --- a/src/afs/NBSD/osi_machdep.h +++ b/src/afs/NBSD/osi_machdep.h @@ -77,6 +77,11 @@ extern thread_t afs_global_owner; do { \ simple_unlock(&afs_global_lock); \ } while(0) +#define osi_InitGlock() \ + do { \ + lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \ + afs_global_owner = 0; \ + } while (0) #endif /* 0 */ #undef SPLVAR diff --git a/src/afs/OBSD/osi_machdep.h b/src/afs/OBSD/osi_machdep.h index 906ec104d..33a8af658 100644 --- a/src/afs/OBSD/osi_machdep.h +++ b/src/afs/OBSD/osi_machdep.h @@ -226,6 +226,12 @@ extern struct lock afs_global_lock; #define USERPRI splx(splvar) #endif /* KERNEL */ +#define osi_InitGlock() \ + do { \ + lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \ + afs_global_owner = 0; \ + } while (0) + /* vnodes */ extern int (**afs_vnodeop_p) (); #define vType(vc) AFSTOV(vc)->v_type diff --git a/src/afs/SOLARIS/osi_machdep.h b/src/afs/SOLARIS/osi_machdep.h index 56b2bdd45..0faf3631d 100644 --- a/src/afs/SOLARIS/osi_machdep.h +++ b/src/afs/SOLARIS/osi_machdep.h @@ -81,6 +81,8 @@ extern kmutex_t afs_global_lock; #define AFS_GLOCK() mutex_enter(&afs_global_lock); #define AFS_GUNLOCK() mutex_exit(&afs_global_lock); #define ISAFS_GLOCK() mutex_owned(&afs_global_lock) +#define osi_InitGlock() \ + mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL); #endif diff --git a/src/afs/UKERNEL/osi_machdep.h b/src/afs/UKERNEL/osi_machdep.h index ad08918ef..b41b261e0 100644 --- a/src/afs/UKERNEL/osi_machdep.h +++ b/src/afs/UKERNEL/osi_machdep.h @@ -76,6 +76,8 @@ extern usr_mutex_t afs_global_lock; } while(0) #define AFS_ASSERT_GLOCK() \ do { if (!ISAFS_GLOCK()) { osi_Panic("afs global lock not held"); } } while(0) +#define osi_GlockInit() \ + usr_mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL) extern int afs_bufferpages; diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index 695a327f8..4e5e21f35 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -74,33 +74,8 @@ osi_Init(void) static int once = 0; if (once++ > 0) /* just in case */ return; -#if defined(AFS_HPUX_ENV) + osi_InitGlock(); -#else /* AFS_HPUX_ENV */ -#if defined(AFS_GLOBAL_SUNLOCK) -#if defined(AFS_SGI62_ENV) - mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock"); -#elif defined(AFS_FBSD50_ENV) -#if defined(AFS_FBSD80_ENV) && defined(WITNESS) - /* "lock_initalized" (sic) can panic, checks a flag bit - * is unset _before_ init */ - memset(&afs_global_mtx, 0, sizeof(struct mtx)); -#endif - mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); -#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -#if !defined(AFS_DARWIN80_ENV) - lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); -#endif - afs_global_owner = 0; -#elif defined(AFS_AIX41_ENV) - lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1); - simple_lock_init((void *)&afs_global_lock); -#elif !defined(AFS_LINUX22_ENV) - /* Linux initialization in osi directory. Should move the others. */ - mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL); -#endif -#endif /* AFS_GLOBAL_SUNLOCK */ -#endif /* AFS_HPUX_ENV */ if (!afs_osicred_initialized) { #if defined(AFS_DARWIN80_ENV)