Whamcloud - gitweb
LU-11233 build: support for gcc8
[fs/lustre-release.git] / lustre / obdclass / genops.c
index 22ad827..0a840c9 100644 (file)
@@ -52,9 +52,6 @@ DEFINE_RWLOCK(obd_dev_lock);
 static struct obd_device *obd_devs[MAX_OBD_DEVICES];
 
 static struct kmem_cache *obd_device_cachep;
-struct kmem_cache *obdo_cachep;
-EXPORT_SYMBOL(obdo_cachep);
-static struct kmem_cache *import_cachep;
 
 static struct workqueue_struct *zombie_wq;
 
@@ -242,7 +239,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
        if (enable_proc) {
                type->typ_procroot = lprocfs_register(type->typ_name,
                                                      proc_lustre_root,
-                                                     vars, type);
+                                                     NULL, type);
                if (IS_ERR(type->typ_procroot)) {
                        rc = PTR_ERR(type->typ_procroot);
                        type->typ_procroot = NULL;
@@ -265,7 +262,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 
        type->typ_debugfs_entry = ldebugfs_register(type->typ_name,
                                                    debugfs_lustre_root,
-                                                   NULL, type);
+                                                   vars, type);
        if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) {
                rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
                                             : -ENOMEM;
@@ -448,7 +445,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
 
        newdev->obd_conn_inprogress = 0;
 
-       strncpy(newdev->obd_uuid.uuid, uuid, strlen(uuid));
+       strncpy(newdev->obd_uuid.uuid, uuid, UUID_MAX);
 
        CDEBUG(D_IOCTL, "Allocate new device %s (%p)\n",
               newdev->obd_name, newdev);
@@ -903,14 +900,6 @@ void obd_cleanup_caches(void)
                kmem_cache_destroy(obd_device_cachep);
                 obd_device_cachep = NULL;
         }
-        if (obdo_cachep) {
-               kmem_cache_destroy(obdo_cachep);
-                obdo_cachep = NULL;
-        }
-        if (import_cachep) {
-               kmem_cache_destroy(import_cachep);
-                import_cachep = NULL;
-        }
 
         EXIT;
 }
@@ -927,19 +916,6 @@ int obd_init_caches(void)
        if (!obd_device_cachep)
                GOTO(out, rc = -ENOMEM);
 
-       LASSERT(obdo_cachep == NULL);
-       obdo_cachep = kmem_cache_create("ll_obdo_cache", sizeof(struct obdo),
-                                       0, 0, NULL);
-       if (!obdo_cachep)
-               GOTO(out, rc = -ENOMEM);
-
-       LASSERT(import_cachep == NULL);
-       import_cachep = kmem_cache_create("ll_import_cache",
-                                         sizeof(struct obd_import),
-                                         0, 0, NULL);
-       if (!import_cachep)
-               GOTO(out, rc = -ENOMEM);
-
        RETURN(0);
 out:
        obd_cleanup_caches();
@@ -976,18 +952,6 @@ struct obd_device *class_exp2obd(struct obd_export *exp)
 }
 EXPORT_SYMBOL(class_exp2obd);
 
-struct obd_device *class_conn2obd(struct lustre_handle *conn)
-{
-        struct obd_export *export;
-        export = class_conn2export(conn);
-        if (export) {
-                struct obd_device *obd = export->exp_obd;
-                class_export_put(export);
-                return obd;
-        }
-        return NULL;
-}
-
 struct obd_import *class_exp2cliimp(struct obd_export *exp)
 {
         struct obd_device *obd = exp->exp_obd;
@@ -997,14 +961,6 @@ struct obd_import *class_exp2cliimp(struct obd_export *exp)
 }
 EXPORT_SYMBOL(class_exp2cliimp);
 
-struct obd_import *class_conn2cliimp(struct lustre_handle *conn)
-{
-        struct obd_device *obd = class_conn2obd(conn);
-        if (obd == NULL)
-                return NULL;
-        return obd->u.cli.cl_import;
-}
-
 /* Export management functions */
 static void class_export_destroy(struct obd_export *exp)
 {
@@ -1130,7 +1086,7 @@ struct obd_export *__class_new_export(struct obd_device *obd,
        spin_lock_init(&export->exp_uncommitted_replies_lock);
        INIT_LIST_HEAD(&export->exp_uncommitted_replies);
        INIT_LIST_HEAD(&export->exp_req_replay_queue);
-       INIT_LIST_HEAD(&export->exp_handle.h_link);
+       INIT_LIST_HEAD_RCU(&export->exp_handle.h_link);
        INIT_LIST_HEAD(&export->exp_hp_rpcs);
        INIT_LIST_HEAD(&export->exp_reg_rpcs);
        class_handle_hash(&export->exp_handle, &export_handle_ops);
@@ -1260,7 +1216,7 @@ void class_unlink_export(struct obd_export *exp)
 EXPORT_SYMBOL(class_unlink_export);
 
 /* Import management functions */
-static void class_import_destroy(struct obd_import *imp)
+static void obd_zombie_import_free(struct obd_import *imp)
 {
         ENTRY;
 
@@ -1283,20 +1239,10 @@ static void class_import_destroy(struct obd_import *imp)
 
         LASSERT(imp->imp_sec == NULL);
         class_decref(imp->imp_obd, "import", imp);
-        OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle);
-        EXIT;
-}
-
-static void import_handle_addref(void *import)
-{
-        class_import_get(import);
+       OBD_FREE_PTR(imp);
+       EXIT;
 }
 
-static struct portals_handle_ops import_handle_ops = {
-       .hop_addref = import_handle_addref,
-       .hop_free   = NULL,
-};
-
 struct obd_import *class_import_get(struct obd_import *import)
 {
        atomic_inc(&import->imp_refcount);
@@ -1345,7 +1291,7 @@ static void obd_zombie_imp_cull(struct work_struct *ws)
        struct obd_import *import;
 
        import = container_of(ws, struct obd_import, imp_zombie_work);
-       class_import_destroy(import);
+       obd_zombie_import_free(import);
 }
 
 struct obd_import *class_new_import(struct obd_device *obd)
@@ -1384,8 +1330,6 @@ struct obd_import *class_new_import(struct obd_device *obd)
        atomic_set(&imp->imp_replay_inflight, 0);
        atomic_set(&imp->imp_inval_count, 0);
        INIT_LIST_HEAD(&imp->imp_conn_list);
-       INIT_LIST_HEAD(&imp->imp_handle.h_link);
-       class_handle_hash(&imp->imp_handle, &import_handle_ops);
        init_imp_at(&imp->imp_at);
 
        /* the default magic is V2, will be used in connect RPC, and
@@ -1401,8 +1345,6 @@ void class_destroy_import(struct obd_import *import)
        LASSERT(import != NULL);
        LASSERT(import != LP_POISON);
 
-       class_handle_unhash(&import->imp_handle);
-
        spin_lock(&import->imp_lock);
        import->imp_generation++;
        spin_unlock(&import->imp_lock);
@@ -2283,8 +2225,6 @@ int obd_set_max_mod_rpcs_in_flight(struct client_obd *cli, __u16 max)
 }
 EXPORT_SYMBOL(obd_set_max_mod_rpcs_in_flight);
 
-
-#define pct(a, b) (b ? a * 100 / b : 0)
 int obd_mod_rpc_stats_seq_show(struct client_obd *cli,
                               struct seq_file *seq)
 {
@@ -2310,7 +2250,7 @@ int obd_mod_rpc_stats_seq_show(struct client_obd *cli,
        for (i = 0; i < OBD_HIST_MAX; i++) {
                unsigned long mod = cli->cl_mod_rpcs_hist.oh_buckets[i];
                mod_cum += mod;
-               seq_printf(seq, "%d:\t\t%10lu %3lu %3lu\n",
+               seq_printf(seq, "%d:\t\t%10lu %3u %3u\n",
                           i, mod, pct(mod, mod_tot),
                           pct(mod_cum, mod_tot));
                if (mod_cum == mod_tot)
@@ -2322,8 +2262,6 @@ int obd_mod_rpc_stats_seq_show(struct client_obd *cli,
        return 0;
 }
 EXPORT_SYMBOL(obd_mod_rpc_stats_seq_show);
-#undef pct
-
 
 /* The number of modify RPCs sent in parallel is limited
  * because the server has a finite number of slots per client to
@@ -2419,8 +2357,9 @@ __u16 obd_get_mod_rpc_slot(struct client_obd *cli, __u32 opc,
                       "opc %u, max %hu\n",
                       cli->cl_import->imp_obd->obd_name, opc, max);
 
-               l_wait_event(cli->cl_mod_rpcs_waitq,
-                            obd_mod_rpc_slot_avail(cli, close_req), &lwi);
+               l_wait_event_exclusive(cli->cl_mod_rpcs_waitq,
+                                      obd_mod_rpc_slot_avail(cli, close_req),
+                                      &lwi);
        } while (true);
 }
 EXPORT_SYMBOL(obd_get_mod_rpc_slot);