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 <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
/************** 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)
#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) {
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
}
* 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
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
#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() \
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
#include <linux/sunrpc/svcauth.h>
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));
#include <linux/kernel.h>
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;
/* 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
* 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
#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)
# else
# include <asm/semaphore.h>
# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
-# include <linux/mutex.h>
-# endif
+# include <linux/mutex.h>
# include <linux/errno.h>
# include <linux/completion.h>
# if defined(HAVE_LINUX_EXPORTFS_H)
#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 */
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;
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;
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
#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;