Whamcloud - gitweb
LU-5092 nodemap: transfer nodemaps between MGS, MDTs, and OSTs
[fs/lustre-release.git] / lustre / ptlrpc / nodemap_handler.c
index 28f34c9..5f82521 100644 (file)
@@ -92,6 +92,8 @@ static void nodemap_destroy(struct lu_nodemap *nodemap)
 void nodemap_getref(struct lu_nodemap *nodemap)
 {
        atomic_inc(&nodemap->nm_refcount);
+       CDEBUG(D_INFO, "GETting nodemap %s(p=%p) : new refcount %d\n",
+              nodemap->nm_name, nodemap, atomic_read(&nodemap->nm_refcount));
 }
 
 /**
@@ -105,6 +107,10 @@ void nodemap_putref(struct lu_nodemap *nodemap)
 
        LASSERT(atomic_read(&nodemap->nm_refcount) > 0);
 
+       CDEBUG(D_INFO, "PUTting nodemap %s(p=%p) : new refcount %d\n",
+              nodemap->nm_name, nodemap,
+              atomic_read(&nodemap->nm_refcount) - 1);
+
        if (atomic_dec_and_test(&nodemap->nm_refcount))
                nodemap_destroy(nodemap);
 }
@@ -1202,10 +1208,31 @@ static int nodemap_cleanup_iter_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd,
        return 0;
 }
 
+struct nodemap_config *nodemap_config_alloc(void)
+{
+       struct nodemap_config *config;
+       int rc = 0;
+
+       OBD_ALLOC_PTR(config);
+       if (config == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       rc = nodemap_init_hash(config);
+       if (rc != 0) {
+               OBD_FREE_PTR(config);
+               return ERR_PTR(rc);
+       }
+
+       init_rwsem(&config->nmc_range_tree_lock);
+
+       return config;
+}
+EXPORT_SYMBOL(nodemap_config_alloc);
+
 /**
  * Walk the nodemap_hash and remove all nodemaps.
  */
-void nodemap_config_cleanup(struct nodemap_config *config)
+void nodemap_config_dealloc(struct nodemap_config *config)
 {
        struct lu_nodemap       *nodemap = NULL;
        struct lu_nodemap       *nodemap_temp;
@@ -1223,6 +1250,9 @@ void nodemap_config_cleanup(struct nodemap_config *config)
        list_for_each_entry_safe(nodemap, nodemap_temp, &nodemap_list_head,
                                 nm_list) {
                down_write(&config->nmc_range_tree_lock);
+
+               /* move members to new config */
+               nm_member_reclassify_nodemap(nodemap);
                list_for_each_entry_safe(range, range_temp, &nodemap->nm_ranges,
                                         rn_list)
                        range_delete(&config->nmc_range_tree, range);
@@ -1230,33 +1260,9 @@ void nodemap_config_cleanup(struct nodemap_config *config)
 
                nodemap_putref(nodemap);
        }
-}
-
-struct nodemap_config *nodemap_config_alloc(void)
-{
-       struct nodemap_config *config;
-       int rc = 0;
-
-       OBD_ALLOC_PTR(config);
-       if (config == NULL)
-               return ERR_PTR(-ENOMEM);
-
-       rc = nodemap_init_hash(config);
-       if (rc != 0) {
-               OBD_FREE_PTR(config);
-               return ERR_PTR(rc);
-       }
-
-       init_rwsem(&config->nmc_range_tree_lock);
-
-       return config;
-}
-
-void nodemap_config_dealloc(struct nodemap_config *config)
-{
-       nodemap_config_cleanup(config);
        OBD_FREE_PTR(config);
 }
+EXPORT_SYMBOL(nodemap_config_dealloc);
 
 static int nm_hash_list_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd,
                           struct hlist_node *hnode,
@@ -1319,6 +1325,7 @@ void nodemap_config_set_active(struct nodemap_config *config)
 
        EXIT;
 }
+EXPORT_SYMBOL(nodemap_config_set_active);
 
 /**
  * Cleanup nodemap module on exit