Whamcloud - gitweb
b=15863
[fs/lustre-release.git] / lustre / obdclass / obd_config.c
index 676a7ad..b2a15f0 100644 (file)
 #include <lprocfs_status.h>
 #include <libcfs/list.h>
 #include <lustre_param.h>
+#include <class_hash.h>
+
+extern struct lustre_hash_operations uuid_hash_operations;
+extern struct lustre_hash_operations nid_hash_operations;
 
 /*********** string parsing utils *********/
 
@@ -116,8 +120,9 @@ EXPORT_SYMBOL(class_parse_nid);
 
 /********************** class fns **********************/
 
-/* Create a new device and set the type, name and uuid.  If
- * successful, the new device can be accessed by either name or uuid.
+/**
+ * Create a new device and set the type, name and uuid.  If successful, the new
+ * device can be accessed by either name or uuid.
  */
 int class_attach(struct lustre_cfg *lcfg)
 {
@@ -164,11 +169,16 @@ int class_attach(struct lustre_cfg *lcfg)
         LASSERTF(strncmp(obd->obd_name, name, strlen(name)) == 0, "%p obd_name %s != %s\n",
                  obd, obd->obd_name, name);
 
+        rwlock_init(&obd->obd_pool_lock);
+        obd->obd_pool_limit = 0;
+        obd->obd_pool_slv = 0;
+
         CFS_INIT_LIST_HEAD(&obd->obd_exports);
         CFS_INIT_LIST_HEAD(&obd->obd_exports_timed);
+        CFS_INIT_LIST_HEAD(&obd->obd_nid_stats);
+        spin_lock_init(&obd->obd_nid_lock);
         spin_lock_init(&obd->obd_dev_lock);
         sema_init(&obd->obd_dev_sem, 1);
-        sema_init(&obd->obd_proc_exp_sem, 1);
         spin_lock_init(&obd->obd_osfs_lock);
         /* obd->obd_osfs_age must be set to a value in the distant
          * past to guarantee a fresh statfs is fetched on mount. */
@@ -179,17 +189,20 @@ int class_attach(struct lustre_cfg *lcfg)
         cfs_init_timer(&obd->obd_recovery_timer);
         spin_lock_init(&obd->obd_processing_task_lock);
         cfs_waitq_init(&obd->obd_next_transno_waitq);
+        cfs_waitq_init(&obd->obd_evict_inprogress_waitq);
         CFS_INIT_LIST_HEAD(&obd->obd_req_replay_queue);
         CFS_INIT_LIST_HEAD(&obd->obd_lock_replay_queue);
         CFS_INIT_LIST_HEAD(&obd->obd_final_req_queue);
 
+        llog_group_init(&obd->obd_olg, OBD_LLOG_GROUP);
+
         spin_lock_init(&obd->obd_uncommitted_replies_lock);
         CFS_INIT_LIST_HEAD(&obd->obd_uncommitted_replies);
 
         len = strlen(uuid);
         if (len >= sizeof(obd->obd_uuid)) {
-                CERROR("uuid must be < "LPSZ" bytes long\n",
-                       sizeof(obd->obd_uuid));
+                CERROR("uuid must be < %d bytes long\n",
+                       (int)sizeof(obd->obd_uuid));
                 GOTO(out, rc = -EINVAL);
         }
         memcpy(obd->obd_uuid.uuid, uuid, len);
@@ -254,9 +267,28 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         obd->obd_starting = 1;
         spin_unlock(&obd->obd_dev_lock);
 
+        /* create an uuid-export hash body */
+        err = lustre_hash_init(&obd->obd_uuid_hash_body, "UUID_HASH", 
+                               128, &uuid_hash_operations);
+        if (err)
+                GOTO(err_hash, err);
+
+        /* create a nid-export hash body */
+        err = lustre_hash_init(&obd->obd_nid_hash_body, "NID_HASH", 
+                               128, &nid_hash_operations);
+        if (err)
+                GOTO(err_hash, err);
+
+        /* create a nid-stats hash body */
+        err = lustre_hash_init(&obd->obd_nid_stats_hash_body, "NID_STATS",
+                               128, &nid_stat_hash_operations);
+        if (err)
+                GOTO(err_hash, err);
+
         exp = class_new_export(obd, &obd->obd_uuid);
         if (IS_ERR(exp))
                 RETURN(PTR_ERR(exp));
+
         obd->obd_self_export = exp;
         list_del_init(&exp->exp_obd_chain_timed);
         class_export_put(exp);
@@ -278,10 +310,14 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         RETURN(0);
 
 err_exp:
-        CERROR("setup %s failed (%d)\n", obd->obd_name, err);
         class_unlink_export(obd->obd_self_export);
         obd->obd_self_export = NULL;
+err_hash:
+        lustre_hash_exit(&obd->obd_uuid_hash_body);
+        lustre_hash_exit(&obd->obd_nid_hash_body);
+        lustre_hash_exit(&obd->obd_nid_stats_hash_body);
         obd->obd_starting = 0;
+        CERROR("setup %s failed (%d)\n", obd->obd_name, err);
         RETURN(err);
 }
 
@@ -307,10 +343,10 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)
                obd->obd_name, obd->obd_uuid.uuid);
 
         class_decref(obd);
-        
+
         /* not strictly necessary, but cleans up eagerly */
         obd_zombie_impexp_cull();
-        
+
         RETURN(0);
 }
 
@@ -410,6 +446,15 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
         }
         LASSERT(obd->obd_self_export);
 
+        /* destroy an uuid-export hash body */
+        lustre_hash_exit(&obd->obd_uuid_hash_body);
+
+        /* destroy a nid-export hash body */
+        lustre_hash_exit(&obd->obd_nid_hash_body);
+
+        /* destroy a nid-stats hash body */
+        lustre_hash_exit(&obd->obd_nid_stats_hash_body);
+
         /* Precleanup stage 1, we must make sure all exports (other than the
            self-export) get destroyed. */
         err = obd_precleanup(obd, OBD_CLEANUP_EXPORTS);
@@ -547,36 +592,6 @@ int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
         RETURN(rc);
 }
 
-int class_sec_flavor(struct obd_device *obd, struct lustre_cfg *lcfg)
-{
-        struct sec_flavor_config *conf;
-        ENTRY;
-
-        if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) &&
-            strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME)) {
-                CERROR("Can't set security flavor on obd %s\n",
-                       obd->obd_type->typ_name);
-                RETURN(-EINVAL);
-        }
-
-        if (LUSTRE_CFG_BUFLEN(lcfg, 1) != sizeof(*conf)) {
-                CERROR("invalid data\n");
-                RETURN(-EINVAL);
-        }
-
-        conf = &obd->u.cli.cl_sec_conf;
-        memcpy(conf, lustre_cfg_buf(lcfg, 1), sizeof(*conf));
-
-#ifdef __BIG_ENDIAN
-        __swab32s(&conf->sfc_rpc_flavor);
-        __swab32s(&conf->sfc_bulk_csum);
-        __swab32s(&conf->sfc_bulk_priv);
-        __swab32s(&conf->sfc_flags);
-#endif
-
-        RETURN(0);
-}
-
 CFS_LIST_HEAD(lustre_profile_list);
 
 struct lustre_profile *class_get_profile(const char * prof)
@@ -741,6 +756,7 @@ int class_process_config(struct lustre_cfg *lcfg)
                 CDEBUG(D_IOCTL, "changing lustre timeout from %d to %d\n",
                        obd_timeout, lcfg->lcfg_num);
                 obd_timeout = max(lcfg->lcfg_num, 1U);
+                obd_health_check_timeout = HEALTH_CHECK_TIMEOUT;
                 GOTO(out, err = 0);
         }
         case LCFG_SET_UPCALL: {
@@ -801,10 +817,6 @@ int class_process_config(struct lustre_cfg *lcfg)
                 err = class_del_conn(obd, lcfg);
                 GOTO(out, err = 0);
         }
-        case LCFG_SEC_FLAVOR: {
-                err = class_sec_flavor(obd, lcfg);
-                GOTO(out, err = 0);
-        }
         default: {
                 err = obd_process_config(obd, sizeof(*lcfg), lcfg);
                 GOTO(out, err);