Whamcloud - gitweb
LU-709 build: clean up quota_read, follow_link and RCU
authorPeng Tao <tao.peng@emc.com>
Thu, 14 Jun 2012 07:08:42 +0000 (15:08 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 19 Jul 2012 04:14:23 +0000 (00:14 -0400)
1. super_operations.quota_read exists since v2.6.12
2. inode_operations->follow_link returns a cookie since v2.6.13
3. RCU exists since v2.6.12

Signed-off-by: Peng Tao <tao.peng@emc.com>
Change-Id: Id79df5dcb0e3db9eb424337fd71d896ed8fefcd6
Reviewed-on: http://review.whamcloud.com/2316
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/include/darwin/lustre_handles.h
lustre/include/linux/lustre_handles.h
lustre/include/lustre_handles.h
lustre/include/obd_support.h
lustre/llite/symlink.c
lustre/lvfs/fsfilt_ext3.c
lustre/lvfs/quotafmt_test.c
lustre/obdclass/lustre_handles.c
lustre/quota/quota_context.c

index daed428..7a4b5b7 100644 (file)
@@ -451,76 +451,6 @@ AC_DEFUN([LC_CONFIG_GSS],
  fi
 ])
 
  fi
 ])
 
-AC_DEFUN([LC_QUOTA_READ],
-[AC_MSG_CHECKING([if kernel supports quota_read])
-LB_LINUX_TRY_COMPILE([
-       #include <linux/fs.h>
-],[
-       struct super_operations sp;
-        void *i = (void *)sp.quota_read;
-],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
-],[
-       AC_MSG_RESULT([no])
-])
-])
-
-#
-# LC_COOKIE_FOLLOW_LINK
-#
-# kernel 2.6.13+ ->follow_link returns a cookie
-#
-AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
-[AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
-        #include <linux/namei.h>
-],[
-        struct dentry *dentry = NULL;
-        struct nameidata nd;
-
-        dentry->d_inode->i_op->put_link(dentry, &nd, NULL);
-],[
-        AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
-        AC_MSG_RESULT([yes])
-],[
-        AC_MSG_RESULT([no])
-])
-])
-
-#
-# LC_FUNC_RCU
-#
-# kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
-# call_rcu takes three parameters.
-#
-AC_DEFUN([LC_FUNC_RCU],
-[AC_MSG_CHECKING([if kernel have RCU supported])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/rcupdate.h>
-],[],[
-        AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
-        AC_MSG_RESULT([yes])
-
-        AC_MSG_CHECKING([if call_rcu takes three parameters])
-        LB_LINUX_TRY_COMPILE([
-                #include <linux/rcupdate.h>
-        ],[
-                struct rcu_head rh;
-                call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
-        ],[
-                AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
-                AC_MSG_RESULT([yes])
-        ],[
-                AC_MSG_RESULT([no])
-        ])
-
-],[
-        AC_MSG_RESULT([no])
-])
-])
-
 AC_DEFUN([LC_PERCPU_COUNTER],
 [AC_MSG_CHECKING([if have struct percpu_counter defined])
 LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_PERCPU_COUNTER],
 [AC_MSG_CHECKING([if have struct percpu_counter defined])
 LB_LINUX_TRY_COMPILE([
@@ -2080,9 +2010,6 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_CAPA_CRYPTO
          LC_CONFIG_RMTCLIENT
          LC_CONFIG_GSS
          LC_CAPA_CRYPTO
          LC_CONFIG_RMTCLIENT
          LC_CONFIG_GSS
-         LC_QUOTA_READ
-         LC_COOKIE_FOLLOW_LINK
-         LC_FUNC_RCU
          LC_PERCPU_COUNTER
          LC_TASK_CLENV_STORE
 
          LC_PERCPU_COUNTER
          LC_TASK_CLENV_STORE
 
index f6abf4b..225929e 100644 (file)
@@ -42,4 +42,6 @@
 #include <libcfs/list.h>
 #include <libcfs/libcfs.h>
 
 #include <libcfs/list.h>
 #include <libcfs/libcfs.h>
 
+#define call_rcu(rcu, cb)              (cb)(rcu)
+
 #endif
 #endif
index 586351d..365010b 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
-# ifdef HAVE_RCU
-#  include <linux/rcupdate.h> /* for rcu_head{} */
+#include <linux/rcupdate.h> /* for rcu_head{} */
 typedef struct rcu_head cfs_rcu_head_t;
 typedef struct rcu_head cfs_rcu_head_t;
-# endif
 
 #endif /* ifdef __KERNEL__ */
 
 
 #endif /* ifdef __KERNEL__ */
 
index eddb04a..75854be 100644 (file)
@@ -52,9 +52,9 @@
 
 #include <libcfs/libcfs.h>
 
 
 #include <libcfs/libcfs.h>
 
-#if !defined(HAVE_RCU) || !defined(__KERNEL__)
+#ifndef __KERNEL__
 typedef struct {
 typedef struct {
-        int foo;
+       int foo;
 } cfs_rcu_head_t;
 #endif
 
 } cfs_rcu_head_t;
 #endif
 
index c32b09f..665dc89 100644 (file)
@@ -704,16 +704,6 @@ do {                                                                          \
 } while(0)
 
 
 } while(0)
 
 
-#ifdef HAVE_RCU
-# ifdef HAVE_CALL_RCU_PARAM
-#  define my_call_rcu(rcu, cb)            call_rcu(rcu, cb, rcu)
-# else
-#  define my_call_rcu(rcu, cb)            call_rcu(rcu, cb)
-# endif
-#else
-# define my_call_rcu(rcu, cb)             (cb)(rcu)
-#endif
-
 #define OBD_FREE_RCU(ptr, size, handle)                                              \
 do {                                                                         \
        struct portals_handle *__h = (handle);                                \
 #define OBD_FREE_RCU(ptr, size, handle)                                              \
 do {                                                                         \
        struct portals_handle *__h = (handle);                                \
@@ -721,7 +711,7 @@ do {                                                                              \
        LASSERT(handle != NULL);                                              \
        __h->h_cookie = (unsigned long)(ptr);                                 \
        __h->h_size = (size);                                                 \
        LASSERT(handle != NULL);                                              \
        __h->h_cookie = (unsigned long)(ptr);                                 \
        __h->h_size = (size);                                                 \
-       my_call_rcu(&__h->h_rcu, class_handle_free_cb);                       \
+       call_rcu(&__h->h_rcu, class_handle_free_cb);                          \
        POISON_PTR(ptr);                                                      \
 } while(0)
 
        POISON_PTR(ptr);                                                      \
 } while(0)
 
index 34ce707..67a3107 100644 (file)
@@ -139,20 +139,13 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen)
        RETURN(rc);
 }
 
        RETURN(rc);
 }
 
-#ifdef HAVE_COOKIE_FOLLOW_LINK
-# define LL_FOLLOW_LINK_RETURN_TYPE void *
-#else
-# define LL_FOLLOW_LINK_RETURN_TYPE int
-#endif
-
-static LL_FOLLOW_LINK_RETURN_TYPE ll_follow_link(struct dentry *dentry,
-                                                 struct nameidata *nd)
+static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
 {
-        struct inode *inode = dentry->d_inode;
-        struct ptlrpc_request *request = NULL;
-        int rc;
-        char *symname;
-        ENTRY;
+       struct inode *inode = dentry->d_inode;
+       struct ptlrpc_request *request = NULL;
+       int rc;
+       char *symname;
+       ENTRY;
 
         CDEBUG(D_VFSTRACE, "VFS Op\n");
         /* Limit the recursive symlink depth to 5 instead of default
 
         CDEBUG(D_VFSTRACE, "VFS Op\n");
         /* Limit the recursive symlink depth to 5 instead of default
@@ -173,48 +166,30 @@ static LL_FOLLOW_LINK_RETURN_TYPE ll_follow_link(struct dentry *dentry,
                 GOTO(out, rc);
         }
 
                 GOTO(out, rc);
         }
 
-#ifdef HAVE_COOKIE_FOLLOW_LINK
-        nd_set_link(nd, symname);
-        /* @symname may contain a pointer to the request message buffer,
-           we delay request releasing until ll_put_link then. */
-        RETURN(request);
-#else
-        if (lli->lli_symlink_name == NULL) {
-                /* falling back to recursive follow link if the request
-                 * needs to be cleaned up still. */
-                rc = vfs_follow_link(nd, symname);
-                GOTO(out, rc);
-        }
-        nd_set_link(nd, symname);
-        RETURN(0);
-#endif
+       nd_set_link(nd, symname);
+       /* symname may contain a pointer to the request message buffer,
+        * we delay request releasing until ll_put_link then.
+        */
+       RETURN(request);
 out:
 out:
-        ptlrpc_req_finished(request);
-#ifdef HAVE_COOKIE_FOLLOW_LINK
-        RETURN(ERR_PTR(rc));
-#else
-        RETURN(rc);
-#endif
+       ptlrpc_req_finished(request);
+       RETURN(ERR_PTR(rc));
 }
 
 }
 
-#ifdef HAVE_COOKIE_FOLLOW_LINK
 static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
 {
 static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
 {
-        ptlrpc_req_finished(cookie);
+       ptlrpc_req_finished(cookie);
 }
 }
-#endif
 
 struct inode_operations ll_fast_symlink_inode_operations = {
 
 struct inode_operations ll_fast_symlink_inode_operations = {
-        .readlink       = ll_readlink,
-        .setattr        = ll_setattr,
-        .follow_link    = ll_follow_link,
-#ifdef HAVE_COOKIE_FOLLOW_LINK
-        .put_link       = ll_put_link,
-#endif
-        .getattr        = ll_getattr,
-        .permission     = ll_inode_permission,
-        .setxattr       = ll_setxattr,
-        .getxattr       = ll_getxattr,
-        .listxattr      = ll_listxattr,
-        .removexattr    = ll_removexattr,
+       .readlink       = ll_readlink,
+       .setattr        = ll_setattr,
+       .follow_link    = ll_follow_link,
+       .put_link       = ll_put_link,
+       .getattr        = ll_getattr,
+       .permission     = ll_inode_permission,
+       .setxattr       = ll_setxattr,
+       .getxattr       = ll_getxattr,
+       .listxattr      = ll_listxattr,
+       .removexattr    = ll_removexattr,
 };
 };
index ab6e403..88fb592 100644 (file)
@@ -2044,15 +2044,11 @@ static int fsfilt_ext3_quotacheck(struct super_block *sb,
                         continue;
 
 
                         continue;
 
 
-                LASSERT(sb_dqopt(sb)->files[i] != NULL);
-                CFS_INIT_LIST_HEAD(&id_list);
-#ifndef KERNEL_SUPPORTS_QUOTA_READ
-                rc = lustre_get_qids(sb_dqopt(sb)->files[i], NULL, i, &id_list);
-#else
-                rc = lustre_get_qids(NULL, sb_dqopt(sb)->files[i], i, &id_list);
-#endif
-                if (rc)
-                        CERROR("read old limits failed. (rc:%d)\n", rc);
+               LASSERT(sb_dqopt(sb)->files[i] != NULL);
+               CFS_INIT_LIST_HEAD(&id_list);
+               rc = lustre_get_qids(NULL, sb_dqopt(sb)->files[i], i, &id_list);
+               if (rc)
+                       CERROR("read old limits failed. (rc:%d)\n", rc);
 
                 cfs_list_for_each_entry_safe(dqid, tmp, &id_list, di_link) {
                         cfs_list_del_init(&dqid->di_link);
 
                 cfs_list_for_each_entry_safe(dqid, tmp, &id_list, di_link) {
                         cfs_list_del_init(&dqid->di_link);
index a964aa7..98bb156 100644 (file)
@@ -373,37 +373,6 @@ static int quotfmt_test_4(struct lustre_quota_info *lqi)
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int quotfmt_test_5(struct lustre_quota_info *lqi)
-{
-#ifndef KERNEL_SUPPORTS_QUOTA_READ
-        int i, rc = 0;
-
-        for (i = USRQUOTA; i < MAXQUOTAS && !rc; i++) {
-                cfs_list_t list;
-                struct dquot_id *dqid, *tmp;
-
-                CFS_INIT_LIST_HEAD(&list);
-                rc = lustre_get_qids(lqi->qi_files[i], NULL, i, &list);
-                if (rc) {
-                        CERROR("%s get all %ss (rc:%d):\n",
-                               rc ? "error" : "success",
-                               i == USRQUOTA ? "uid" : "gid", rc);
-                }
-                cfs_list_for_each_entry_safe(dqid, tmp, &list, di_link) {
-                        cfs_list_del_init(&dqid->di_link);
-                        if (rc == 0)
-                                CDEBUG(D_INFO, "%d ", dqid->di_id);
-                        kfree(dqid);
-                }
-                CDEBUG(D_INFO, "\n");
-        }
-        return rc;
-#else
-        CWARN("kernel supports quota_read OR kernel version >= 2.6.12, test skipped\n");
-        return 0;
-#endif
-}
-
 static int quotfmt_run_tests(struct obd_device *obd, struct obd_device *tgt)
 {
         struct lvfs_run_ctxt saved;
 static int quotfmt_run_tests(struct obd_device *obd, struct obd_device *tgt)
 {
         struct lvfs_run_ctxt saved;
@@ -450,14 +419,7 @@ static int quotfmt_run_tests(struct obd_device *obd, struct obd_device *tgt)
                 GOTO(out, rc);
         }
 
                 GOTO(out, rc);
         }
 
-        CWARN("=== test 5: walk through quota file to get all ids\n");
-        rc = quotfmt_test_5(lqi);
-        if (rc) {
-                CERROR("walk through quota file failed\n");
-                GOTO(out, rc);
-        }
-
-      out:
+out:
         CWARN("=== Finalize quotafile test\n");
         rc = quotfmt_finalize(lqi, tgt, &saved);
         OBD_FREE(lqi, sizeof(*lqi));
         CWARN("=== Finalize quotafile test\n");
         rc = quotfmt_finalize(lqi, tgt, &saved);
         OBD_FREE(lqi, sizeof(*lqi));
index 4776b27..c3013fd 100644 (file)
@@ -47,7 +47,7 @@
 #include <lustre_handles.h>
 #include <lustre_lib.h>
 
 #include <lustre_handles.h>
 #include <lustre_lib.h>
 
-#if !defined(HAVE_RCU) || !defined(__KERNEL__)
+#ifndef __KERNEL__
 # define list_add_rcu            cfs_list_add
 # define list_del_rcu            cfs_list_del
 # define list_for_each_rcu       cfs_list_for_each
 # define list_add_rcu            cfs_list_add
 # define list_del_rcu            cfs_list_del
 # define list_for_each_rcu       cfs_list_for_each
@@ -55,7 +55,7 @@
 # define list_for_each_entry_rcu cfs_list_for_each_entry
 # define rcu_read_lock()         cfs_spin_lock(&bucket->lock)
 # define rcu_read_unlock()       cfs_spin_unlock(&bucket->lock)
 # define list_for_each_entry_rcu cfs_list_for_each_entry
 # define rcu_read_lock()         cfs_spin_lock(&bucket->lock)
 # define rcu_read_unlock()       cfs_spin_unlock(&bucket->lock)
-#endif /* ifndef HAVE_RCU */
+#endif /* !__KERNEL__ */
 
 static __u64 handle_base;
 #define HANDLE_INCR 7
 
 static __u64 handle_base;
 #define HANDLE_INCR 7
index b6905f4..a201e66 100644 (file)
@@ -1522,16 +1522,12 @@ static int qslave_recovery_main(void *arg)
                         break;
                 }
 
                         break;
                 }
 
-                LASSERT(dqopt->files[type] != NULL);
-                CFS_INIT_LIST_HEAD(&id_list);
-#ifndef KERNEL_SUPPORTS_QUOTA_READ
-                rc = fsfilt_qids(obd, dqopt->files[type], NULL, type, &id_list);
-#else
-                rc = fsfilt_qids(obd, NULL, dqopt->files[type], type, &id_list);
-#endif
-                UNLOCK_DQONOFF_MUTEX(dqopt);
-                if (rc)
-                        CERROR("Get ids from quota file failed. (rc:%d)\n", rc);
+               LASSERT(dqopt->files[type] != NULL);
+               CFS_INIT_LIST_HEAD(&id_list);
+               rc = fsfilt_qids(obd, NULL, dqopt->files[type], type, &id_list);
+               UNLOCK_DQONOFF_MUTEX(dqopt);
+               if (rc)
+                       CERROR("Get ids from quota file failed. (rc:%d)\n", rc);
 
                 cfs_list_for_each_entry_safe(dqid, tmp, &id_list, di_link) {
                         cfs_list_del_init(&dqid->di_link);
 
                 cfs_list_for_each_entry_safe(dqid, tmp, &id_list, di_link) {
                         cfs_list_del_init(&dqid->di_link);
@@ -1611,12 +1607,12 @@ inline int quota_is_off(struct lustre_quota_ctxt *qctxt,
         return !(qctxt->lqc_flags & UGQUOTA2LQC(oqctl->qc_type));
 }
 
         return !(qctxt->lqc_flags & UGQUOTA2LQC(oqctl->qc_type));
 }
 
-/**
+/*
  * When quotaon, build a lqs for every uid/gid who has been set limitation
  * for quota. After quota_search_lqs, it will hold one ref for the lqs.
  * It will be released when qctxt_cleanup() is executed b=18574
  *
  * When quotaon, build a lqs for every uid/gid who has been set limitation
  * for quota. After quota_search_lqs, it will hold one ref for the lqs.
  * It will be released when qctxt_cleanup() is executed b=18574
  *
- * Should be called with obt->obt_quotachecking held. b=20152 
+ * Should be called with obt->obt_quotachecking held. b=20152
  */
 void build_lqs(struct obd_device *obd)
 {
  */
 void build_lqs(struct obd_device *obd)
 {
@@ -1633,13 +1629,8 @@ void build_lqs(struct obd_device *obd)
                 if (sb_dqopt(qctxt->lqc_sb)->files[i] == NULL)
                         continue;
 
                 if (sb_dqopt(qctxt->lqc_sb)->files[i] == NULL)
                         continue;
 
-#ifndef KERNEL_SUPPORTS_QUOTA_READ
-                rc = fsfilt_qids(obd, sb_dqopt(qctxt->lqc_sb)->files[i], NULL,
-                                 i, &id_list);
-#else
-                rc = fsfilt_qids(obd, NULL, sb_dqopt(qctxt->lqc_sb)->files[i],
-                                 i, &id_list);
-#endif
+               rc = fsfilt_qids(obd, NULL, sb_dqopt(qctxt->lqc_sb)->files[i],
+                                i, &id_list);
                 if (rc) {
                         CERROR("%s: failed to get %s qids!\n", obd->obd_name,
                                i ? "group" : "user");
                 if (rc) {
                         CERROR("%s: failed to get %s qids!\n", obd->obd_name,
                                i ? "group" : "user");