From 91a576142e36fa423ee1a571a040b5ccf16d10d7 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Wed, 16 Dec 2020 19:48:46 -0700 Subject: [PATCH] Cleanup usage of LINUX_VERSION_CODE for older kernels 2.6.18 is the minimum supported linux kernel level. There are preprocessor checks for specific kernel versions that predate 2.6.18. Refactor the use of the LINUX_VERSION_CODE that checks for kernel versions older than 2.6.18. In addition, there are a couple of locations where the kernel version is checked with an additional test to see if module_param or module_param_array are defined. These checks are used to determine whether to use the macros module_param/module_param_array or to use the macro MODULE_PARM. The macros module_param and module_param_array were present in Linux prior to 2.6.12. The macro MODULE_PARM was marked as deprecated prior to 2.6.12 and removed in Linux 2.6.17 (8d3b33f67fd '[PATCH] Remove MODULE_PARM'). Remove the preprocessor checks for module_param/module_param_array and remove the use of MODULE_PARM. The updates should have no functional changes. Change-Id: I1dc5dca1252abfc865917757989df235c75059a6 Reviewed-on: https://gerrit.openafs.org/14389 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/afs/LINUX/osi_alloc.c | 4 ---- src/afs/LINUX/osi_gcpags.c | 23 +++-------------------- src/afs/LINUX/osi_groups.c | 6 +++--- src/afs/LINUX/osi_machdep.h | 6 ------ src/afs/LINUX/osi_module.c | 4 ---- src/afs/LINUX/osi_nfssrv.c | 4 ---- src/afs/LINUX/osi_pag_module.c | 13 +------------ src/afs/LINUX/osi_probe.c | 28 ---------------------------- src/afs/LINUX/osi_vnodeops.c | 4 ---- src/afs/sysincludes.h | 4 +--- src/config/param.linux26.h | 4 +--- src/rx/LINUX/rx_kmutex.c | 18 ------------------ src/rx/LINUX/rx_kmutex.h | 8 -------- 13 files changed, 9 insertions(+), 117 deletions(-) diff --git a/src/afs/LINUX/osi_alloc.c b/src/afs/LINUX/osi_alloc.c index f66fe02..482a0c7 100644 --- a/src/afs/LINUX/osi_alloc.c +++ b/src/afs/LINUX/osi_alloc.c @@ -228,11 +228,7 @@ linux_alloc_init(void) /************** Linux memory allocator interface functions **********/ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) DEFINE_MUTEX(afs_linux_alloc_sem); -#else -DECLARE_MUTEX(afs_linux_alloc_sem); -#endif void * osi_linux_alloc(unsigned int asize, int drop_glock) diff --git a/src/afs/LINUX/osi_gcpags.c b/src/afs/LINUX/osi_gcpags.c index ed4e28e..34ceb06 100644 --- a/src/afs/LINUX/osi_gcpags.c +++ b/src/afs/LINUX/osi_gcpags.c @@ -31,16 +31,7 @@ afs_osi_TraverseProcTable(void) #if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_STRUCT_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK)) struct task_struct *p; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) - if (&tasklist_lock) - read_lock(&tasklist_lock); -#endif /* EXPORTED_TASKLIST_LOCK */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) - else -#endif /* EXPORTED_TASKLIST_LOCK && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ - rcu_read_lock(); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */ + rcu_read_lock(); #if defined(for_each_process) for_each_process(p) if (p->pid) { @@ -65,16 +56,8 @@ afs_osi_TraverseProcTable(void) afs_GCPAGs_perproc_func(p); } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) - if (&tasklist_lock) - read_unlock(&tasklist_lock); -#endif /* EXPORTED_TASKLIST_LOCK */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK) - else -#endif /* EXPORTED_TASKLIST_LOCK && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ - rcu_read_unlock(); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */ + + rcu_read_unlock(); #endif } diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index 87d149f..2b910a5 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -564,13 +564,13 @@ void osi_keyring_init(void) * If that's not available, then keyring based PAGs won't work. */ -#if defined(EXPORTED_TASKLIST_LOCK) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(HAVE_LINUX_RCU_READ_LOCK)) +#if defined(EXPORTED_TASKLIST_LOCK) || defined(HAVE_LINUX_RCU_READ_LOCK) if (__key_type_keyring == NULL) { # ifdef EXPORTED_TASKLIST_LOCK if (&tasklist_lock) read_lock(&tasklist_lock); # endif -# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(HAVE_LINUX_RCU_READ_LOCK)) +# if defined(HAVE_LINUX_RCU_READ_LOCK) # ifdef EXPORTED_TASKLIST_LOCK else # endif @@ -587,7 +587,7 @@ void osi_keyring_init(void) if (&tasklist_lock) read_unlock(&tasklist_lock); # endif -# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(HAVE_LINUX_RCU_READ_LOCK)) +# if defined(HAVE_LINUX_RCU_READ_LOCK) # ifdef EXPORTED_TASKLIST_LOCK else # endif diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h index 34940c6..87d351c 100644 --- a/src/afs/LINUX/osi_machdep.h +++ b/src/afs/LINUX/osi_machdep.h @@ -362,13 +362,7 @@ struct uio { #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() \ diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index 79ba57c..cb09cc6 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -35,11 +35,7 @@ extern struct file_system_type afs_fs_type; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) DEFINE_MUTEX(afs_global_lock); -#else -DECLARE_MUTEX(afs_global_lock); -#endif int afs_global_owner = 0; #ifdef HAVE_LINUX_KUID_T diff --git a/src/afs/LINUX/osi_nfssrv.c b/src/afs/LINUX/osi_nfssrv.c index 27f3444..e6693c5 100644 --- a/src/afs/LINUX/osi_nfssrv.c +++ b/src/afs/LINUX/osi_nfssrv.c @@ -25,11 +25,7 @@ #include static unsigned long authtab_addr = 0; -#if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param(authtab_addr, long, 0); -#else -MODULE_PARM(authtab_addr, "l"); -#endif MODULE_PARM_DESC(authtab_addr, "Address of the authtab array."); extern struct auth_ops *authtab[] __attribute__((weak)); diff --git a/src/afs/LINUX/osi_pag_module.c b/src/afs/LINUX/osi_pag_module.c index e832c5a..5583207 100644 --- a/src/afs/LINUX/osi_pag_module.c +++ b/src/afs/LINUX/osi_pag_module.c @@ -31,26 +31,15 @@ #include static unsigned long nfs_server_addr = 0; -#if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param(nfs_server_addr, long, 0); -#else -MODULE_PARM(nfs_server_addr, "l"); -#endif MODULE_PARM_DESC(nfs_server_addr, "IP Address of NFS Server"); static char *this_cell = 0; -#if defined(module_param_array) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param(this_cell, charp, 0); -#else -MODULE_PARM(this_cell, "s"); -#endif MODULE_PARM_DESC(this_cell, "Local cell name"); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) DEFINE_MUTEX(afs_global_lock); -#else -DECLARE_MUTEX(afs_global_lock); -#endif + struct proc_dir_entry *openafs_procfs; int afs_global_owner = 0; diff --git a/src/afs/LINUX/osi_probe.c b/src/afs/LINUX/osi_probe.c index 9b06fa7..1b0f830 100644 --- a/src/afs/LINUX/osi_probe.c +++ b/src/afs/LINUX/osi_probe.c @@ -123,28 +123,16 @@ /* Allow the user to specify sys_call_table addresses */ static unsigned long sys_call_table_addr[4] = { 0,0,0,0 }; -#if defined(module_param_array) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param_array(sys_call_table_addr, long, NULL, 0); -#else -MODULE_PARM(sys_call_table_addr, "1-4l"); -#endif MODULE_PARM_DESC(sys_call_table_addr, "Location of system call tables"); /* If this is set, we are more careful about avoiding duplicate matches */ static int probe_carefully = 1; -#if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param(probe_carefully, int, 0); -#else -MODULE_PARM(probe_carefully, "i"); -#endif MODULE_PARM_DESC(probe_carefully, "Probe for system call tables carefully"); static int probe_ignore_syscalls[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -#if defined(module_param_array) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param_array(probe_ignore_syscalls, int, NULL, 0); -#else -MODULE_PARM(probe_ignore_syscalls, "1-8i"); -#endif MODULE_PARM_DESC(probe_ignore_syscalls, "Syscalls to ignore in table checks"); #ifdef OSI_PROBE_DEBUG @@ -160,35 +148,19 @@ MODULE_PARM_DESC(probe_ignore_syscalls, "Syscalls to ignore in table checks"); * 0x0080 - detail - check_table_readable */ static int probe_debug = 0x41; -#if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param(probe_debug, int, 0); -#else -MODULE_PARM(probe_debug, "i"); -#endif MODULE_PARM_DESC(probe_debug, "Debugging level"); static unsigned long probe_debug_addr[4] = { 0,0,0,0 }; -#if defined(module_param_array) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param_array(probe_debug_addr, long, NULL, 0); -#else -MODULE_PARM(probe_debug_addr, "1-4l"); -#endif MODULE_PARM_DESC(probe_debug_addr, "Debug range starting locations"); static unsigned long probe_debug_range = 0; -#if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param(probe_debug_range, long, 0); -#else -MODULE_PARM(probe_debug_range, "l"); -#endif MODULE_PARM_DESC(probe_debug_range, "Debug range length"); static unsigned long probe_debug_tag = 0; -#if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) module_param(probe_debug_tag, long, 0); -#else -MODULE_PARM(probe_debug_tag, "l"); -#endif MODULE_PARM_DESC(probe_debug_tag, "Debugging output start tag"); #endif diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index b5b2aa5..efadeda 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1241,11 +1241,7 @@ static inline void dentry_race_unlock(void) {} #else -# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) static DEFINE_MUTEX(dentry_race_sem); -# else -static DECLARE_MUTEX(dentry_race_sem); -# endif static inline void dentry_race_lock(void) diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h index e1312f6..bea5aab 100644 --- a/src/afs/sysincludes.h +++ b/src/afs/sysincludes.h @@ -169,9 +169,7 @@ struct xfs_inode_info { # else # include # endif -# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) -# include -# endif +# include # include # include # if defined(HAVE_LINUX_EXPORTFS_H) diff --git a/src/config/param.linux26.h b/src/config/param.linux26.h index ab13064..75466f0 100644 --- a/src/config/param.linux26.h +++ b/src/config/param.linux26.h @@ -25,9 +25,7 @@ #define AFS_USERSPACE_IP_ADDR 1 #define RXK_LISTENER_ENV 1 #define AFS_GCPAGS 1 /* Set to Userdisabled, allow sysctl to override */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4) -# define AFS_PAG_ONEGROUP_ENV 1 -#endif +#define AFS_PAG_ONEGROUP_ENV 1 #define AFS_HAVE_FFS 1 /* Use system's ffs */ #define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ #define AFS_VM_RDWR_ENV 1 /* read/write implemented via VM */ diff --git a/src/rx/LINUX/rx_kmutex.c b/src/rx/LINUX/rx_kmutex.c index be36c74..3f4190f 100644 --- a/src/rx/LINUX/rx_kmutex.c +++ b/src/rx/LINUX/rx_kmutex.c @@ -26,24 +26,14 @@ void afs_mutex_init(afs_kmutex_t * l) { -#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; -#endif l->owner = 0; } 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%lx held by %d", (unsigned long)l, l->owner); l->owner = current->pid; @@ -52,11 +42,7 @@ 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; @@ -68,11 +54,7 @@ afs_mutex_exit(afs_kmutex_t * l) if (l->owner != current->pid) osi_Panic("mutex_exit: 0x%lx held by %d", (unsigned long)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 eb396e3..be3ca88 100644 --- a/src/rx/LINUX/rx_kmutex.h +++ b/src/rx/LINUX/rx_kmutex.h @@ -28,18 +28,10 @@ struct coda_inode_info { #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; -- 1.9.4