Whamcloud - gitweb
LU-1347 build: remove the vim/emacs modelines
[fs/lustre-release.git] / libcfs / include / libcfs / linux / kp30.h
index 3b4c44b..7400039 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #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)                                            \
@@ -121,8 +104,6 @@ do {                                                                          \
 #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))
@@ -130,7 +111,9 @@ do {                                                                          \
 #define LASSERT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0)
 #define LINVRNT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0)
 #endif
+
 #define LASSERT_SEM_LOCKED(sem) LASSERT(down_trylock(sem) != 0)
+#define LASSERT_MUTEX_LOCKED(x) LASSERT(mutex_is_locked(x))
 
 #ifdef HAVE_SEM_COUNT_ATOMIC
 #define SEM_COUNT(sem)          (atomic_read(&(sem)->count))
@@ -142,18 +125,6 @@ do {                                                                          \
 
 /* ------------------------------------------------------------------- */
 
-#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)
 
@@ -163,26 +134,15 @@ do {                                                                          \
 #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__)
@@ -206,10 +166,6 @@ do {                                                                          \
 #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
@@ -347,16 +303,18 @@ extern int  lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size,
 
 #if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \
     (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG))
-# define LPU64 "%Lu"
-# define LPD64 "%Ld"
-# define LPX64 "%#Lx"
-# define LPX64i "%Lx"
+# define LPU64 "%llu"
+# define LPD64 "%lld"
+# define LPX64 "%#llx"
+# define LPX64i "%llx"
+# define LPO64 "%#llo"
 # define LPF64 "L"
 #else
 # define LPU64 "%lu"
 # define LPD64 "%ld"
 # define LPX64 "%#lx"
 # define LPX64i "%lx"
+# define LPO64 "%#lo"
 # define LPF64 "l"
 #endif
 
@@ -372,20 +330,6 @@ extern int  lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size,
  */
 # define LPPID "%d"
 
-#ifdef HAVE_SIZE_T_LONG
-# define LPSZ  "%lu"
-# define LPSZX "%lx"
-#else
-# define LPSZ  "%u"
-# define LPSZX "%x"
-#endif
-
-#ifdef HAVE_SSIZE_T_LONG
-# define LPSSZ "%ld"
-#else
-# define LPSSZ "%d"
-#endif
-
 #ifndef LPU64
 # error "No word size defined"
 #endif
@@ -418,4 +362,12 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
 # define cfs_put_cpu()   put_cpu()
 #endif /* get_cpu & put_cpu */
 
+#ifdef HAVE_SYSCTL_CTLNAME
+#define INIT_CTL_NAME(a) .ctl_name = a,
+#define INIT_STRATEGY(a) .strategy = a,
+#else
+#define INIT_CTL_NAME(a)
+#define INIT_STRATEGY(a)
+#endif
+
 #endif