Whamcloud - gitweb
LU-2435 osd-zfs: use zfs native dnode accounting
[fs/lustre-release.git] / lustre / quota / lquota_lib.c
index bc0716e..a9e903b 100644 (file)
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2011, 2012, Intel, Inc.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Johann Lombardi <johann.lombardi@intel.com>
  * Author: Niu    Yawei    <yawei.niu@intel.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
 #include <linux/version.h>
@@ -40,7 +36,7 @@
 
 #include "lquota_internal.h"
 
-cfs_mem_cache_t *lqe_kmem;
+struct kmem_cache *lqe_kmem;
 
 struct lu_kmem_descr lquota_caches[] = {
        {
@@ -82,7 +78,7 @@ struct dt_object *acct_obj_lookup(const struct lu_env *env,
                RETURN(obj);
 
        if (!dt_object_exists(obj)) {
-               lu_object_put(env, &obj->do_lu);
+               dt_object_put(env, obj);
                RETURN(ERR_PTR(-ENOENT));
        }
 
@@ -96,7 +92,7 @@ struct dt_object *acct_obj_lookup(const struct lu_env *env,
                               " acct object rc:%d\n",
                               dev->dd_lu_dev.ld_obd->obd_name,
                               QTYPE_NAME(type), rc);
-                       lu_object_put(env, &obj->do_lu);
+                       dt_object_put(env, obj);
                        RETURN(ERR_PTR(rc));
                }
        }
@@ -127,7 +123,7 @@ static struct dt_object *quota_obj_lookup(const struct lu_env *env,
                RETURN(obj);
 
        if (!dt_object_exists(obj)) {
-               lu_object_put(env, &obj->do_lu);
+               dt_object_put(env, obj);
                RETURN(ERR_PTR(-ENOENT));
        }
 
@@ -142,7 +138,7 @@ static struct dt_object *quota_obj_lookup(const struct lu_env *env,
                               " slave index object rc:%d\n",
                               dev->dd_lu_dev.ld_obd->obd_name,
                               QTYPE_NAME(type), rc);
-                       lu_object_put(env, &obj->do_lu);
+                       dt_object_put(env, obj);
                        RETURN(ERR_PTR(rc));
                }
        }
@@ -194,7 +190,7 @@ int lquotactl_slv(const struct lu_env *env, struct dt_device *dev,
 
        /* lookup record storing space accounting information for this ID */
        rc = dt_lookup(env, obj, (struct dt_rec *)&qti->qti_acct_rec,
-                      (struct dt_key *)&key, BYPASS_CAPA);
+                      (struct dt_key *)&key);
        if (rc < 0)
                GOTO(out, rc);
 
@@ -203,7 +199,7 @@ int lquotactl_slv(const struct lu_env *env, struct dt_device *dev,
        dqblk->dqb_curinodes    = qti->qti_acct_rec.ispace;
        dqblk->dqb_valid        = QIF_USAGE;
 
-       lu_object_put(env, &obj->do_lu);
+       dt_object_put(env, obj);
 
        /* Step 2: collect enforcement information */
 
@@ -216,7 +212,7 @@ int lquotactl_slv(const struct lu_env *env, struct dt_device *dev,
        memset(&qti->qti_slv_rec, 0, sizeof(qti->qti_slv_rec));
        /* lookup record storing enforcement information for this ID */
        rc = dt_lookup(env, obj, (struct dt_rec *)&qti->qti_slv_rec,
-                      (struct dt_key *)&key, BYPASS_CAPA);
+                      (struct dt_key *)&key);
        if (rc < 0 && rc != -ENOENT)
                GOTO(out, rc = 0);
 
@@ -231,8 +227,8 @@ int lquotactl_slv(const struct lu_env *env, struct dt_device *dev,
 
        GOTO(out, rc = 0);
 out:
-       lu_object_put(env, &obj->do_lu);
-        return rc;
+       dt_object_put(env, obj);
+       return rc;
 }
 EXPORT_SYMBOL(lquotactl_slv);
 
@@ -293,50 +289,7 @@ int lquota_extract_fid(const struct lu_fid *fid, int *pool_id, int *pool_type,
        RETURN(0);
 }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2,7,50,0)
-/* Index features supported by the global index objects.
- * We actually use one dt_index_features structure for each quota combination
- * of quota type x [inode, block] to allow the ldiskfs OSD to recognize those
- * objects and to handle the conversion from the old administrative quota file
- * format */
-struct dt_index_features dt_quota_iusr_features;
-EXPORT_SYMBOL(dt_quota_iusr_features);
-struct dt_index_features dt_quota_busr_features;
-EXPORT_SYMBOL(dt_quota_busr_features);
-struct dt_index_features dt_quota_igrp_features;
-EXPORT_SYMBOL(dt_quota_igrp_features);
-struct dt_index_features dt_quota_bgrp_features;
-EXPORT_SYMBOL(dt_quota_bgrp_features);
-
-/**
- * Helper routine returning the right index feature structure to be used
- * depending on the FID of the global index.
- */
-const struct dt_index_features *glb_idx_feature(struct lu_fid *fid)
-{
-       int     res_type, quota_type, rc;
-
-       rc = lquota_extract_fid(fid, NULL, &res_type, &quota_type);
-       if (rc)
-               return ERR_PTR(rc);
-
-       if (quota_type == USRQUOTA) {
-               if (res_type == LQUOTA_RES_MD)
-                       return &dt_quota_iusr_features;
-               else
-                       return &dt_quota_busr_features;
-       } else {
-               if (res_type == LQUOTA_RES_MD)
-                       return &dt_quota_igrp_features;
-               else
-                       return &dt_quota_bgrp_features;
-       }
-}
-#else
-#warning "remove old quota compatibility code"
-#endif
-
-static int __init init_lquota(void)
+static int __init lquota_init(void)
 {
        int     rc;
        ENTRY;
@@ -344,13 +297,6 @@ static int __init init_lquota(void)
        lquota_key_init_generic(&lquota_thread_key, NULL);
        lu_context_key_register(&lquota_thread_key);
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2,7,50,0)
-       dt_quota_iusr_features = dt_quota_busr_features = dt_quota_glb_features;
-       dt_quota_igrp_features = dt_quota_bgrp_features = dt_quota_glb_features;
-#else
-#warning "remove old quota compatibility code"
-#endif
-
        rc = lu_kmem_init(lquota_caches);
        if (rc)
                GOTO(out_key, rc);
@@ -374,7 +320,7 @@ out_key:
        return rc;
 }
 
-static void exit_lquota(void)
+static void __exit lquota_exit(void)
 {
        qsd_glb_fini();
        qmt_glb_fini();
@@ -382,8 +328,10 @@ static void exit_lquota(void)
        lu_context_key_degister(&lquota_thread_key);
 }
 
-MODULE_AUTHOR("Intel, Inc. <http://www.intel.com/>");
+MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Quota");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(lquota, "2.4.0", init_lquota, exit_lquota);
+module_init(lquota_init);
+module_exit(lquota_exit);