Whamcloud - gitweb
LU-17431 nodemap: determine if nodemap is currently loading 01/55001/2
authorSebastien Buisson <sbuisson@ddn.com>
Thu, 2 May 2024 09:50:34 +0000 (11:50 +0200)
committerOleg Drokin <green@whamcloud.com>
Mon, 10 Jun 2024 06:10:13 +0000 (06:10 +0000)
To control operations on dynamic nodemaps, we need to know if the
current nodemap configuration is in the process of being loaded.
Only once it is fully loaded the nodemap_mgs() function returns true.
So change semantic of global variable nodemap_config_loaded, to be:
* 0: not loaded yet
* 1: successfully loaded
* -1: loading in progress

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: If5e52e924415f644d0134f4093c2405df0887f87
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55001
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_nodemap.h
lustre/mgc/mgc_request_server.c
lustre/ptlrpc/nodemap_internal.h
lustre/ptlrpc/nodemap_storage.c

index e421c3b..0df134b 100644 (file)
@@ -224,6 +224,7 @@ struct nodemap_config {
 
 struct nodemap_config *nodemap_config_alloc(void);
 void nodemap_config_dealloc(struct nodemap_config *config);
+void nodemap_config_set_loading_mgc(bool loading);
 void nodemap_config_set_active_mgc(struct nodemap_config *config);
 
 int nodemap_process_idx_pages(struct nodemap_config *config, union lu_page *lip,
index 20d7c36..3dd2e8b 100644 (file)
@@ -404,6 +404,8 @@ again:
         * recent_nodemap should be set to NULL when the nodemap_config
         * is either destroyed or set active.
         */
+       if (new_config)
+               nodemap_config_set_loading_mgc(true);
        for (i = 0; i < nrpages && ealen > 0; i++) {
                union lu_page *ptr;
                int rc2;
@@ -424,6 +426,9 @@ again:
        }
 
 out:
+       if (new_config)
+               nodemap_config_set_loading_mgc(false);
+
        if (req) {
                ptlrpc_req_put(req);
                req = NULL;
index ea76dc5..7abd208 100644 (file)
@@ -152,6 +152,7 @@ int nm_hash_list_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd,
                    void *nodemap_list_head);
 
 bool nodemap_mgs(void);
+bool nodemap_loading(void);
 int nodemap_idx_nodemap_add(const struct lu_nodemap *nodemap);
 int nodemap_idx_nodemap_update(const struct lu_nodemap *nodemap);
 int nodemap_idx_nodemap_del(const struct lu_nodemap *nodemap);
index 2d41c89..6cc3fa2 100644 (file)
@@ -1327,9 +1327,26 @@ static void nodemap_save_all_caches(void)
 }
 
 /* tracks if config still needs to be loaded, either from disk or network */
-static bool nodemap_config_loaded;
+/*  0: not loaded yet
+ *  1: successfully loaded
+ * -1: loading in progress
+ */
+static int nodemap_config_loaded;
 static DEFINE_MUTEX(nodemap_config_loaded_lock);
 
+bool nodemap_loading(void)
+{
+       return (nodemap_config_loaded == -1);
+}
+
+void nodemap_config_set_loading_mgc(bool loading)
+{
+       mutex_lock(&nodemap_config_loaded_lock);
+       nodemap_config_loaded = loading ? -1 : 0;
+       mutex_unlock(&nodemap_config_loaded_lock);
+}
+EXPORT_SYMBOL(nodemap_config_set_loading_mgc);
+
 /**
  * Ensures that configs loaded over the wire are prioritized over those loaded
  * from disk.
@@ -1340,7 +1357,7 @@ void nodemap_config_set_active_mgc(struct nodemap_config *config)
 {
        mutex_lock(&nodemap_config_loaded_lock);
        nodemap_config_set_active(config);
-       nodemap_config_loaded = true;
+       nodemap_config_loaded = 1;
        nodemap_save_all_caches();
        mutex_unlock(&nodemap_config_loaded_lock);
 }
@@ -1379,9 +1396,9 @@ struct nm_config_file *nm_config_file_register_mgs(const struct lu_env *env,
         * loading is done, so disk config is overwritten by MGS config.
         */
        mutex_lock(&nodemap_config_loaded_lock);
+       nodemap_config_loaded = -1;
        rc = nodemap_load_entries(env, obj);
-       if (!rc)
-               nodemap_config_loaded = true;
+       nodemap_config_loaded = !rc;
        mutex_unlock(&nodemap_config_loaded_lock);
 
        if (rc) {
@@ -1415,15 +1432,15 @@ struct nm_config_file *nm_config_file_register_tgt(const struct lu_env *env,
 
        /* don't load from cache if config already loaded */
        mutex_lock(&nodemap_config_loaded_lock);
-       if (!nodemap_config_loaded) {
+       if (nodemap_config_loaded < 1) {
                config_obj = nodemap_cache_find_create(env, dev, los, 0);
-               if (IS_ERR(config_obj))
+               if (IS_ERR(config_obj)) {
                        rc = PTR_ERR(config_obj);
-               else
+               } else {
+                       nodemap_config_loaded = -1;
                        rc = nodemap_load_entries(env, config_obj);
-
-               if (!rc)
-                       nodemap_config_loaded = true;
+               }
+               nodemap_config_loaded = !rc;
        }
        mutex_unlock(&nodemap_config_loaded_lock);
        if (rc)