HEAD requires 2.6.9 and above, so we remove older code.
The majority of the remaining compatibility code is in libcfs and lnet.
i=andreas
i=isaac
])
#
-# LIBCFS_STRUCT_PAGE_LIST
-#
-# 2.6.4 no longer has page->list
-#
-AC_DEFUN([LIBCFS_STRUCT_PAGE_LIST],
-[AC_MSG_CHECKING([if struct page has a list field])
-LB_LINUX_TRY_COMPILE([
- #include <linux/mm.h>
-],[
- struct page page;
- &page.list;
-],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
-],[
- AC_MSG_RESULT([no])
-])
-])
-
-#
-# LIBCFS_STRUCT_SIGHAND
-#
-# red hat 2.4 adds sighand to struct task_struct
-#
-AC_DEFUN([LIBCFS_STRUCT_SIGHAND],
-[AC_MSG_CHECKING([if task_struct has a sighand field])
-LB_LINUX_TRY_COMPILE([
- #include <linux/sched.h>
-],[
- struct task_struct p;
- p.sighand = NULL;
-],[
- AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
- AC_MSG_RESULT([yes])
-],[
- AC_MSG_RESULT([no])
-])
-])
-
-#
# LIBCFS_FUNC_CPU_ONLINE
#
# cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
AC_DEFUN([LIBCFS_FUNC_CPU_ONLINE],
[AC_MSG_CHECKING([if kernel defines cpu_online()])
LB_LINUX_TRY_COMPILE([
- #include <linux/sched.h>
+ #include <linux/sched.h>
],[
- cpu_online(0);
+ cpu_online(0);
],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
],[
- AC_MSG_RESULT([no])
+ AC_MSG_RESULT([no])
])
])
])
#
-# LIBCFS_TYPE_CPUMASK_T
-#
-# same goes for cpumask_t
-#
-AC_DEFUN([LIBCFS_TYPE_CPUMASK_T],
-[AC_MSG_CHECKING([if kernel defines cpumask_t])
-LB_LINUX_TRY_COMPILE([
- #include <linux/sched.h>
-],[
- return sizeof (cpumask_t);
-],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
-],[
- AC_MSG_RESULT([no])
-])
-])
-
-#
# LIBCFS_FUNC_SHOW_TASK
#
# we export show_task(), but not all kernels have it (yet)
[
LIBCFS_FUNC_CPU_ONLINE
LIBCFS_TYPE_GFP_T
-LIBCFS_TYPE_CPUMASK_T
LIBCFS_CONFIG_PANIC_DUMPLOG
-LIBCFS_STRUCT_PAGE_LIST
-LIBCFS_STRUCT_SIGHAND
LIBCFS_FUNC_SHOW_TASK
LIBCFS_U64_LONG_LONG
LIBCFS_TASK_RCU
#ifdef HAVE_MM_INLINE
# include <linux/mm_inline.h>
#endif
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-# include <linux/kallsyms.h>
-# include <linux/moduleparam.h>
-#endif
+#include <linux/kallsyms.h>
+#include <linux/moduleparam.h>
#include <linux/scatterlist.h>
#include <libcfs/linux/portals_compat25.h>
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-#define schedule_work schedule_task
-#define prepare_work(wq,cb,cbdata) \
-do { \
- INIT_TQUEUE((wq), 0, 0); \
- PREPARE_TQUEUE((wq), (cb), (cbdata)); \
-} while (0)
-
-#define PageUptodate Page_Uptodate
-#define our_recalc_sigpending(current) recalc_sigpending(current)
-#define cfs_num_online_cpus() smp_num_cpus
-#define work_struct_t struct tq_struct
-#define cfs_get_work_data(type,field,data) (data)
-#else
-
#ifdef HAVE_3ARGS_INIT_WORK
#define prepare_work(wq,cb,cbdata) \
#define strtok(a,b) strpbrk(a, b)
#define work_struct_t struct work_struct
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
-
#ifdef CONFIG_SMP
#define LASSERT_SPIN_LOCKED(lock) LASSERT(spin_is_locked(lock))
#define LINVRNT_SPIN_LOCKED(lock) LINVRNT(spin_is_locked(lock))
/* ------------------------------------------------------------------- */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-
-#define PORTAL_SYMBOL_REGISTER(x) inter_module_register(#x, THIS_MODULE, &x)
-#define PORTAL_SYMBOL_UNREGISTER(x) inter_module_unregister(#x)
-
-#define PORTAL_SYMBOL_GET(x) ((typeof(&x))inter_module_get(#x))
-#define PORTAL_SYMBOL_PUT(x) inter_module_put(#x)
-
-#define PORTAL_MODULE_USE MOD_INC_USE_COUNT
-#define PORTAL_MODULE_UNUSE MOD_DEC_USE_COUNT
-#else
-
#define PORTAL_SYMBOL_REGISTER(x)
#define PORTAL_SYMBOL_UNREGISTER(x)
#define PORTAL_MODULE_USE try_module_get(THIS_MODULE)
#define PORTAL_MODULE_UNUSE module_put(THIS_MODULE)
-#endif
/******************************************************************************/
/* Module parameter support */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-# define CFS_MODULE_PARM(name, t, type, perm, desc) \
- MODULE_PARM(name, t);\
- MODULE_PARM_DESC(name, desc)
-
-#else
-# define CFS_MODULE_PARM(name, t, type, perm, desc) \
+#define CFS_MODULE_PARM(name, t, type, perm, desc) \
module_param(name, type, perm);\
MODULE_PARM_DESC(name, desc)
-#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
-# define CFS_SYSFS_MODULE_PARM 0 /* no sysfs module parameters */
-#else
-# define CFS_SYSFS_MODULE_PARM 1 /* module parameters accessible via sysfs */
-#endif
+#define CFS_SYSFS_MODULE_PARM 1 /* module parameters accessible via sysfs */
+
/******************************************************************************/
#if (__GNUC__)
#else
#define cfs_num_possible_cpus() num_possible_cpus()
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-#define i_size_read(a) ((a)->i_size)
-#endif
-
/******************************************************************************/
/* Light-weight trace
/*
* Symbol register
*/
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-#define cfs_symbol_register(s, p) inter_module_register(s, THIS_MODULE, p)
-#define cfs_symbol_unregister(s) inter_module_unregister(s)
-#define cfs_symbol_get(s) inter_module_get(s)
-#define cfs_symbol_put(s) inter_module_put(s)
-#define cfs_module_get() MOD_INC_USE_COUNT
-#else
#define cfs_symbol_register(s, p) do {} while(0)
#define cfs_symbol_unregister(s) do {} while(0)
#define cfs_symbol_get(s) symbol_get(s)
#define __cfs_module_get(m) __module_get(m)
#define cfs_module_put(m) module_put(m)
#define cfs_module_refcount(m) module_refcount(m)
-#endif
typedef struct module cfs_module_t;
typedef struct socket cfs_socket_t;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72))
-# define sk_allocation allocation
-# define sk_data_ready data_ready
-# define sk_write_space write_space
-# define sk_user_data user_data
-# define sk_prot prot
-# define sk_sndbuf sndbuf
-# define sk_rcvbuf rcvbuf
-# define sk_socket socket
-# define sk_sleep sleep
-#endif
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
-# define sk_wmem_queued wmem_queued
-# define sk_err err
-# define sk_route_caps route_caps
-#endif
-
#define SOCK_SNDBUF(so) ((so)->sk->sk_sndbuf)
#define SOCK_TEST_NOSPACE(so) test_bit(SOCK_NOSPACE, &(so)->flags)
#include <libcfs/linux/portals_compat25.h>
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-
-/*
- * old kernels---CURRENT_TIME is struct timeval
- */
-typedef struct timeval cfs_fs_time_t;
-
-static inline void cfs_fs_time_usec(cfs_fs_time_t *t, struct timeval *v)
-{
- *v = *t;
-}
-
-static inline void cfs_fs_time_nsec(cfs_fs_time_t *t, struct timespec *s)
-{
- s->tv_sec = t->tv_sec;
- s->tv_nsec = t->tv_usec * 1000;
-}
-
-/*
- * internal helper function used by cfs_fs_time_before*()
- */
-static inline unsigned long long __cfs_fs_time_flat(cfs_fs_time_t *t)
-{
- return (unsigned long long)t->tv_sec * ONE_MILLION + t->tv_usec;
-}
-
-#define CURRENT_KERN_TIME xtime
-
-#else
-/* (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) */
-
/*
* post 2.5 kernels.
*/
#define CURRENT_KERN_TIME CURRENT_TIME
-/* (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) */
-#endif
-
/*
* Generic kernel stuff
*/
typedef cycles_t cfs_cycles_t;
static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
-{
+{
return time_before(t1, t2);
}
static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2)
-{
+{
return time_before_eq(t1, t2);
}
#endif
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-
#define cfs_time_current_64 get_jiffies_64
static inline __u64 cfs_time_add_64(__u64 t, __u64 d)
return (__s64)t2 - (__s64)t1 >= 0;
}
-#else
-#define cfs_time_current_64 cfs_time_current
-#define cfs_time_add_64 cfs_time_add
-#define cfs_time_shift_64 cfs_time_shift
-#define cfs_time_before_64 cfs_time_before
-#define cfs_time_beforeq_64 cfs_time_beforeq
-#endif
/*
* One jiffy
// XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved
#if defined(SPINLOCK_DEBUG) && SPINLOCK_DEBUG
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) || defined(CONFIG_RH_2_4_20)
# define SIGNAL_MASK_ASSERT() \
LASSERT(current->sighand->siglock.magic == SPINLOCK_MAGIC)
-# else
-# define SIGNAL_MASK_ASSERT() \
- LASSERT(current->sigmask_lock.magic == SPINLOCK_MAGIC)
-# endif
#else
# define SIGNAL_MASK_ASSERT()
#endif
// XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
-
-# define SIGNAL_MASK_LOCK(task, flags) \
+#define SIGNAL_MASK_LOCK(task, flags) \
spin_lock_irqsave(&task->sighand->siglock, flags)
-# define SIGNAL_MASK_UNLOCK(task, flags) \
+#define SIGNAL_MASK_UNLOCK(task, flags) \
spin_unlock_irqrestore(&task->sighand->siglock, flags)
-# define USERMODEHELPER(path, argv, envp) \
+#define USERMODEHELPER(path, argv, envp) \
call_usermodehelper(path, argv, envp, 1)
-# define RECALC_SIGPENDING recalc_sigpending()
-# define CLEAR_SIGPENDING clear_tsk_thread_flag(current, \
- TIF_SIGPENDING)
+#define RECALC_SIGPENDING recalc_sigpending()
+#define CLEAR_SIGPENDING clear_tsk_thread_flag(current, \
+ TIF_SIGPENDING)
# define CURRENT_SECONDS get_seconds()
# define smp_num_cpus num_online_cpus()
+#define cfs_wait_event_interruptible(wq, condition, ret) \
+ ret = wait_event_interruptible(wq, condition)
+#define cfs_wait_event_interruptible_exclusive(wq, condition, ret) \
+ ret = wait_event_interruptible(wq, condition)
-#elif defined(CONFIG_RH_2_4_20) /* RH 2.4.x */
-
-# define SIGNAL_MASK_LOCK(task, flags) \
- spin_lock_irqsave(&task->sighand->siglock, flags)
-# define SIGNAL_MASK_UNLOCK(task, flags) \
- spin_unlock_irqrestore(&task->sighand->siglock, flags)
-# define USERMODEHELPER(path, argv, envp) \
- call_usermodehelper(path, argv, envp)
-# define RECALC_SIGPENDING recalc_sigpending()
-# define CLEAR_SIGPENDING (current->sigpending = 0)
-# define CURRENT_SECONDS CURRENT_TIME
-# define wait_event_interruptible_exclusive(wq, condition) \
- wait_event_interruptible(wq, condition)
-
-#else /* 2.4.x */
-
-# define SIGNAL_MASK_LOCK(task, flags) \
- spin_lock_irqsave(&task->sigmask_lock, flags)
-# define SIGNAL_MASK_UNLOCK(task, flags) \
- spin_unlock_irqrestore(&task->sigmask_lock, flags)
-# define USERMODEHELPER(path, argv, envp) \
- call_usermodehelper(path, argv, envp)
-# define RECALC_SIGPENDING recalc_sigpending(current)
-# define CLEAR_SIGPENDING (current->sigpending = 0)
-# define CURRENT_SECONDS CURRENT_TIME
-# define wait_event_interruptible_exclusive(wq, condition) \
- wait_event_interruptible(wq, condition)
-
-#endif
-
-# define cfs_wait_event_interruptible(wq, condition, ret) \
- ret = wait_event_interruptible(wq, condition)
-# define cfs_wait_event_interruptible_exclusive(wq, condition, ret) \
- ret = wait_event_interruptible(wq, condition)
-
-#if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
-#define UML_PID(tsk) ((tsk)->thread.extern_pid)
-#elif defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-#define UML_PID(tsk) ((tsk)->thread.mode.tt.extern_pid)
-#else
#define UML_PID(tsk) ((tsk)->pid)
-#endif
-#if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-# define THREAD_NAME(comm, len, fmt, a...) \
- snprintf(comm, len,fmt"|%d", ## a, UML_PID(current))
-#else
-# define THREAD_NAME(comm, len, fmt, a...) \
+#define THREAD_NAME(comm, len, fmt, a...) \
snprintf(comm, len, fmt, ## a)
-#endif
-#ifdef HAVE_PAGE_LIST
-/* 2.4 alloc_page users can use page->list */
-#define PAGE_LIST_ENTRY list
-#define PAGE_LIST(page) ((page)->list)
-#else
/* 2.6 alloc_page users can use page->lru */
#define PAGE_LIST_ENTRY lru
#define PAGE_LIST(page) ((page)->lru)
-#endif
#ifndef HAVE_CPU_ONLINE
#define cfs_cpu_online(cpu) ((1<<cpu) & (cpu_online_map))
#else
#define cfs_cpu_online(cpu) cpu_online(cpu)
#endif
-#ifndef HAVE_CPUMASK_T
-typedef unsigned long cfs_cpumask_t;
-#define cfs_cpu_set(cpu, map) set_bit(cpu, &(map))
-#define cpus_clear(map) memset(&(map), 0, sizeof(cfs_cpumask_t))
-#endif
#ifndef __user
#define __user
*/
nob += snprintf(cmdbuf+nob, LTRACE_MAX_NOB, "%02x:%06x:%d:%lu.%06lu ",
S_RPC >> 24, D_VFSTRACE, 0, tv.tv_sec, tv.tv_usec);
-
- if (underuml && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))) {
- nob += snprintf (cmdbuf+nob, LTRACE_MAX_NOB,
- "(%s:%d:%s() %d | %d+%lu): ",
- "lltrace.h", __LINE__, __FUNCTION__, 0, 0, 0L);
- }
- else {
- nob += snprintf (cmdbuf+nob, LTRACE_MAX_NOB,
- "(%s:%d:%s() %d+%lu): ",
- "lltrace.h", __LINE__, __FUNCTION__, 0, 0L);
- }
-
+ nob += snprintf (cmdbuf+nob, LTRACE_MAX_NOB, "(%s:%d:%s() %d+%lu): ",
+ "lltrace.h", __LINE__, __FUNCTION__, 0, 0L);
nob += snprintf(cmdbuf+nob, LTRACE_MAX_NOB, " %%p %%c\" >> %s", fname);
system(cmdbuf);
}
{
int nr;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
task_lock(current);
nr = current_cred()->group_info->ngroups;
task_unlock(current);
-#else
- nr = current->ngroups;
-#endif
return nr;
}
void cfs_curproc_groups_dump(gid_t *array, int size)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
task_lock(current);
size = min_t(int, size, current_cred()->group_info->ngroups);
memcpy(array, current_cred()->group_info->blocks[0], size * sizeof(__u32));
task_unlock(current);
-#else
- LASSERT(size <= NGROUPS);
- size = min_t(int, size, current->ngroups);
- memcpy(array, current->groups, size * sizeof(__u32));
-#endif
}
#include "tracefile.h"
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
#include <linux/kallsyms.h>
-#endif
char lnet_upcall[1024] = "/usr/lib/lustre/lnet_upcall";
char lnet_debug_log_upcall[1024] = "/usr/lib/lustre/lnet_debug_log_upcall";
{
unsigned int mflags = 0;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
- if (flags & CFS_ALLOC_ATOMIC)
- mflags |= __GFP_HIGH;
- else if (flags & CFS_ALLOC_WAIT)
- mflags |= __GFP_WAIT;
- else
- mflags |= (__GFP_HIGH | __GFP_WAIT);
- if (flags & CFS_ALLOC_IO)
- mflags |= __GFP_IO | __GFP_HIGHIO;
-#else
if (flags & CFS_ALLOC_ATOMIC)
mflags |= __GFP_HIGH;
else
mflags |= __GFP_NOWARN;
if (flags & CFS_ALLOC_IO)
mflags |= __GFP_IO;
-#endif
if (flags & CFS_ALLOC_FS)
mflags |= __GFP_FS;
if (flags & CFS_ALLOC_HIGH)
#include <linux/in.h>
#include <linux/file.h>
/* For sys_open & sys_close */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#include <linux/syscalls.h>
-#else
-#include <linux/fs.h>
-#endif
int
libcfs_sock_ioctl(int cmd, unsigned long arg)
header->ph_stack = stack;
header->ph_pid = current->pid;
header->ph_line_num = line;
-#if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
- header->ph_extern_pid = current->thread.extern_pid;
-#elif defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
- header->ph_extern_pid = current->thread.mode.tt.extern_pid;
-#else
header->ph_extern_pid = 0;
-#endif
return;
}
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-#include <linux/locks.h> /* wait_on_buffer */
-#else
#include <linux/buffer_head.h> /* wait_on_buffer */
-#endif
#include <linux/unistd.h>
#include <net/sock.h>
#include <linux/uio.h>
return (0);
}
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-struct tcp_opt *sock2tcp_opt(struct sock *sk)
-{
- return &(sk->tp_pinfo.af_tcp);
-}
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
#define sock2tcp_opt(sk) tcp_sk(sk)
#else
struct tcp_opt *sock2tcp_opt(struct sock *sk)
#include <linux/sysctl.h>
#include <asm/uaccess.h>
#include <asm/div64.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-# include <linux/syscalls.h>
-#endif
+#include <linux/syscalls.h>
#include <libcfs/libcfs.h>
#include <libcfs/linux/portals_compat25.h>
#endif
}
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7))
-# define SOCKNAL_WSPACE(sk) sk_stream_wspace(sk)
-# define SOCKNAL_MIN_WSPACE(sk) sk_stream_min_wspace(sk)
-#else
-# define SOCKNAL_WSPACE(sk) tcp_wspace(sk)
-# define SOCKNAL_MIN_WSPACE(sk) (((sk)->sk_sndbuf*8)/10)
-#endif
+#define SOCKNAL_WSPACE(sk) sk_stream_wspace(sk)
+#define SOCKNAL_MIN_WSPACE(sk) sk_stream_min_wspace(sk)
#ifndef CONFIG_SMP
static inline
#endif
-/* always adopt 2.5 definitions */
+/* always adopt 2.6.9 definitions */
#define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
-#define LINUX_VERSION_CODE KERNEL_VERSION(2,6,5)
+#define LINUX_VERSION_CODE KERNEL_VERSION(2,6,9)
#ifndef page_private
#define page_private(page) ((page)->private)
#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
vfs_symlink(dir, dentry, path)
#endif
-#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
-#define ll_set_dflags(dentry, flags) do { dentry->d_vfs_flags |= flags; } while(0)
-#else
#define ll_set_dflags(dentry, flags) do { \
cfs_spin_lock(&dentry->d_lock); \
dentry->d_flags |= flags; \
GOTO(out, rc);
}
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8))
- rc = vfs_follow_link(nd, symname);
-#else
#ifdef HAVE_COOKIE_FOLLOW_LINK
nd_set_link(nd, symname);
/* @symname may contain a pointer to the request message buffer,
nd_set_link(nd, symname);
RETURN(0);
#endif
-#endif
out:
ptlrpc_req_finished(request);
#ifdef HAVE_COOKIE_FOLLOW_LINK