Whamcloud - gitweb
LU-506 kernel: FC15 - small changes
authoryangsheng <ys@whamcloud.com>
Thu, 5 Jan 2012 17:14:34 +0000 (01:14 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 9 Jan 2012 14:44:34 +0000 (09:44 -0500)
   -- stacktrace_ops.{warning(), warning_symbol()} removed.
   -- sk_sleep() helper added.
   -- quota_on() 4 parameter change to use 'struct path'.
   -- fs_struct.lock change to use spin_lock.
   -- other trivial changes.

Change-Id: Ic9bf47454b19c1cfc3e41cd3aebbabb074f6110f
Signed-off-by: Yang Sheng <ys@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1864
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-tcpip.h
libcfs/libcfs/linux/linux-debug.c
libcfs/libcfs/linux/linux-tcpip.c
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/obdclass/genops.c

index 10a8583..e292852 100644 (file)
@@ -489,6 +489,20 @@ AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
                AC_MSG_RESULT(no)
        ],[
        ])
+       AC_MSG_CHECKING([whether stacktrace_ops.warning is exist])
+       LB_LINUX_TRY_COMPILE([
+               struct task_struct;
+               struct pt_regs;
+               #include <asm/stacktrace.h>
+       ],[
+               ((struct stacktrace_ops *)0)->warning(NULL, NULL);
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_STACKTRACE_WARNING, 1, [stacktrace_ops.warning is exist])
+       ],[
+               AC_MSG_RESULT(no)
+       ],[
+       ])
        AC_MSG_CHECKING([dump_trace want address])
        LB_LINUX_TRY_COMPILE([
                struct task_struct;
@@ -734,6 +748,22 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+#
+# 2.6.35 kernel has sk_sleep function
+#
+AC_DEFUN([LC_SK_SLEEP],
+[AC_MSG_CHECKING([if kernel has sk_sleep])
+LB_LINUX_TRY_COMPILE([
+        #include <net/sock.h>
+],[
+        sk_sleep(NULL);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
+],[
+        AC_MSG_RESULT(no)
+])
+])
 
 #
 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
@@ -811,6 +841,8 @@ LIBCFS_OOMADJ_IN_SIG
 LIBCFS_SYSCTL_CTLNAME
 # 2.6.34
 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
+# 2.6.35
+LC_SK_SLEEP
 # 2.6.40 fc15
 LC_SHRINK_CONTROL
 ])
index f0b7666..17068d7 100644 (file)
@@ -83,6 +83,13 @@ libcfs_sock_wmem_queued(struct socket *sock)
         return sock->sk->sk_wmem_queued;
 }
 
+#ifndef HAVE_SK_SLEEP
+static inline wait_queue_head_t *sk_sleep(struct sock *sk)
+{
+        return sk->sk_sleep;
+}
+#endif
+
 #ifdef HAVE_INIT_NET
 #define DEFAULT_NET    (&init_net)
 #else
index 7b2d3a9..a3bf02f 100644 (file)
@@ -208,6 +208,7 @@ void lbug_with_loc(const char *file, const char *func, const int line)
 #include <linux/nmi.h>
 #include <asm/stacktrace.h>
 
+#ifdef HAVE_STACKTRACE_WARNING
 static void
 print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
 {
@@ -220,6 +221,7 @@ static void print_trace_warning(void *data, char *msg)
 {
        printk("%s%s\n", (char *)data, msg);
 }
+#endif
 
 static int print_trace_stack(void *data, char *name)
 {
@@ -245,8 +247,10 @@ static void print_trace_address(void *data, unsigned long addr)
 }
 
 static DUMP_TRACE_CONST struct stacktrace_ops print_trace_ops = {
+#ifdef HAVE_STACKTRACE_WARNING
        .warning = print_trace_warning,
        .warning_symbol = print_trace_warning_symbol,
+#endif
        .stack = print_trace_stack,
        .address = print_trace_address,
 #ifdef STACKTRACE_OPS_HAVE_WALK_STACK
index 95136c1..07f9a36 100644 (file)
@@ -615,7 +615,7 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
         newsock->ops = sock->ops;
 
         set_current_state(TASK_INTERRUPTIBLE);
-        add_wait_queue(sock->sk->sk_sleep, &wait);
+        add_wait_queue(sk_sleep(sock->sk), &wait);
 
         rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
         if (rc == -EAGAIN) {
@@ -624,7 +624,7 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
                 rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
         }
 
-        remove_wait_queue(sock->sk->sk_sleep, &wait);
+        remove_wait_queue(sk_sleep(sock->sk), &wait);
         set_current_state(TASK_RUNNING);
 
         if (rc != 0)
@@ -643,7 +643,7 @@ EXPORT_SYMBOL(libcfs_sock_accept);
 void
 libcfs_sock_abort_accept (struct socket *sock)
 {
-        wake_up_all(sock->sk->sk_sleep);
+        wake_up_all(sk_sleep(sock->sk));
 }
 
 EXPORT_SYMBOL(libcfs_sock_abort_accept);
index 4fea8cc..45146fe 100644 (file)
@@ -979,11 +979,10 @@ EXTRA_KCFLAGS="-Werror"
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
-        struct super_operations *sop = NULL;
-        sop->statfs((struct dentry *)0, (struct kstatfs*)0);
+        ((struct super_operations *)0)->statfs((struct dentry *)0, (struct kstatfs*)0);
 ],[
         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
-                [super_ops.statfs() first parameter is dentry])
+                  [super_ops.statfs() first parameter is dentry])
         AC_MSG_RESULT([yes])
 ],[
         AC_MSG_RESULT([no])
@@ -1159,19 +1158,20 @@ LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_PAGE_CHECKED],
 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
 LB_LINUX_TRY_COMPILE([
+        #include <linux/mm.h>
 #ifdef HAVE_LINUX_MMTYPES_H
         #include <linux/mm_types.h>
 #endif
-       #include <linux/page-flags.h>
+        #include <linux/page-flags.h>
 ],[
-       struct page *p;
+        struct page *p = NULL;
 
         /* before 2.6.26 this define*/
         #ifndef PageChecked    
-       /* 2.6.26 use function instead of define for it */
-       SetPageChecked(p);
-       PageChecked(p);
-       #endif
+        /* 2.6.26 use function instead of define for it */
+        SetPageChecked(p);
+        PageChecked(p);
+        #endif
 ],[
         AC_MSG_RESULT(yes)
         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
@@ -2077,6 +2077,26 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 2.6.36 fs_struct.lock use spinlock instead of rwlock.
+#
+AC_DEFUN([LC_FS_STRUCT_RWLOCK],
+[AC_MSG_CHECKING([if fs_struct.lock use rwlock])
+LB_LINUX_TRY_COMPILE([
+        #include <asm/atomic.h>
+        #include <linux/spinlock.h>
+        #include <linux/fs_struct.h>
+],[
+        ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
+],[
+        AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1,
+                  [fs_struct.lock use rwlock])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
 # 2.6.36 super_operations add evict_inode method. it hybird of
 # delete_inode & clear_inode.
 #
@@ -2146,6 +2166,28 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 2.6.38 use path as 4th parameter in quota_on.
+#
+AC_DEFUN([LC_QUOTA_ON_USE_PATH],
+[AC_MSG_CHECKING([quota_on use path as parameter])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+        #include <linux/quota.h>
+],[
+        ((struct quotactl_ops *)0)->quota_on(NULL, 0, 0, ((struct path*)0));
+],[
+        AC_DEFINE(HAVE_QUOTA_ON_USE_PATH, 1,
+                [quota_on use path as 4th paramter])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+#
 # 2.6.39 remove unplug_fn from request_queue.
 #
 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
@@ -2342,12 +2384,14 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_FILE_FSYNC
 
          # 2.6.36
+         LC_FS_STRUCT_RWLOCK
          LC_SBOPS_EVICT_INODE
 
          # 2.6.38
          LC_ATOMIC_MNT_COUNT
          LC_BLKDEV_GET_BY_DEV
          LC_GENERIC_PERMISSION
+         LC_QUOTA_ON_USE_PATH
 
          # 2.6.39
          LC_REQUEST_QUEUE_UNPLUG_FN
index f44b7b0..d13ea31 100644 (file)
@@ -47,6 +47,7 @@
 #endif
 
 #include <linux/fs_struct.h>
+#include <linux/namei.h>
 #include <libcfs/linux/portals_compat25.h>
 
 #include <linux/lustre_patchless_compat.h>
@@ -68,6 +69,14 @@ struct ll_iattr {
 #define ll_iattr iattr
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) */
 
+#ifdef HAVE_FS_STRUCT_RWLOCK
+# define LOCK_FS_STRUCT(fs)   cfs_write_lock(&(fs)->lock)
+# define UNLOCK_FS_STRUCT(fs) cfs_write_unlock(&(fs)->lock)
+#else
+# define LOCK_FS_STRUCT(fs)   cfs_spin_lock(&(fs)->lock)
+# define UNLOCK_FS_STRUCT(fs) cfs_spin_unlock(&(fs)->lock)
+#endif
+
 #ifdef HAVE_FS_STRUCT_USE_PATH
 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
                                  struct dentry *dentry)
@@ -77,11 +86,11 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
 
         path.mnt = mnt;
         path.dentry = dentry;
-        write_lock(&fs->lock);
+        LOCK_FS_STRUCT(fs);
         old_pwd = fs->pwd;
         path_get(&path);
         fs->pwd = path;
-        write_unlock(&fs->lock);
+        UNLOCK_FS_STRUCT(fs);
 
         if (old_pwd.dentry)
                 path_put(&old_pwd);
@@ -95,12 +104,12 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
         struct dentry *old_pwd;
         struct vfsmount *old_pwdmnt;
 
-        cfs_write_lock(&fs->lock);
+        LOCK_FS_STRUCT(fs);
         old_pwd = fs->pwd;
         old_pwdmnt = fs->pwdmnt;
         fs->pwdmnt = mntget(mnt);
         fs->pwd = dget(dentry);
-        cfs_write_unlock(&fs->lock);
+        UNLOCK_FS_STRUCT(fs);
 
         if (old_pwd) {
                 dput(old_pwd);
@@ -774,7 +783,9 @@ static inline long labs(long x)
 #define ll_sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type)
 #endif
 
-#ifdef HAVE_SB_ANY_QUOTA_ACTIVE
+#ifdef DQUOT_USAGE_ENABLED
+#define ll_sb_any_quota_active(sb) sb_any_quota_loaded(sb)
+#elif defined(HAVE_SB_ANY_QUOTA_ACTIVE)
 #define ll_sb_any_quota_active(sb) sb_any_quota_active(sb)
 #else
 #define ll_sb_any_quota_active(sb) sb_any_quota_enabled(sb)
@@ -783,12 +794,30 @@ static inline long labs(long x)
 static inline int
 ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
 {
+        int rc;
+
         if (sb->s_qcop->quota_on) {
-                return sb->s_qcop->quota_on(sb, off, ver, name
+#ifdef HAVE_QUOTA_ON_USE_PATH
+                struct path path;
+
+                rc = kern_path(name, LOOKUP_FOLLOW, &path);
+                if (!rc)
+                        return rc;
+#endif
+                rc = sb->s_qcop->quota_on(sb, off, ver
+#ifdef HAVE_QUOTA_ON_USE_PATH
+                                            , &path
+#else
+                                            , name
+#endif
 #ifdef HAVE_QUOTA_ON_5ARGS
                                             , remount
 #endif
                                            );
+#ifdef HAVE_QUOTA_ON_USE_PATH
+                path_put(&path);
+#endif
+                return rc;
         }
         else
                 return -ENOSYS;
@@ -889,5 +918,20 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount)
 #define HAVE_NODE_TO_CPUMASK
 #endif
 
+#ifndef QUOTA_OK
+# define QUOTA_OK 0
+#endif
+#ifndef NO_QUOTA
+# define NO_QUOTA (-EDQUOT)
+#endif
+
+#if !defined(_ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_) && !defined(ext2_set_bit)
+# define ext2_set_bit             __test_and_set_bit_le
+# define ext2_clear_bit           __test_and_clear_bit_le
+# define ext2_test_bit            test_bit_le
+# define ext2_find_first_zero_bit find_first_zero_bit_le
+# define ext2_find_next_zero_bit  find_next_zero_bit_le
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */
index e44da95..59ab55e 100644 (file)
@@ -1581,8 +1581,7 @@ static void obd_zombie_export_add(struct obd_export *exp) {
         cfs_list_add(&exp->exp_obd_chain, &obd_zombie_exports);
         cfs_spin_unlock(&obd_zombie_impexp_lock);
 
-        if (obd_zombie_impexp_notify != NULL)
-                obd_zombie_impexp_notify();
+        obd_zombie_impexp_notify();
 }
 
 /**
@@ -1596,8 +1595,7 @@ static void obd_zombie_import_add(struct obd_import *imp) {
         cfs_list_add(&imp->imp_zombie_chain, &obd_zombie_imports);
         cfs_spin_unlock(&obd_zombie_impexp_lock);
 
-        if (obd_zombie_impexp_notify != NULL)
-                obd_zombie_impexp_notify();
+        obd_zombie_impexp_notify();
 }
 
 /**