Whamcloud - gitweb
b=15863
[fs/lustre-release.git] / lustre / obdclass / obd_config.c
index def7410..b2a15f0 100644 (file)
@@ -120,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)
 {
@@ -168,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. */
@@ -195,8 +201,8 @@ int class_attach(struct lustre_cfg *lcfg)
 
         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);
@@ -264,9 +270,8 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         /* create an uuid-export hash body */
         err = lustre_hash_init(&obd->obd_uuid_hash_body, "UUID_HASH", 
                                128, &uuid_hash_operations);
-        if (err) {
+        if (err)
                 GOTO(err_hash, err);
-        }
 
         /* create a nid-export hash body */
         err = lustre_hash_init(&obd->obd_nid_hash_body, "NID_HASH", 
@@ -274,9 +279,16 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         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);
@@ -303,6 +315,7 @@ err_exp:
 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);
@@ -330,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);
 }
 
@@ -439,6 +452,9 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
         /* 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);