Whamcloud - gitweb
LU-8498 nodemap: new zfs index files not properly initialized 39/21939/8
authorKit Westneat <kit.westneat@gmail.com>
Tue, 16 Aug 2016 03:50:07 +0000 (23:50 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 8 Sep 2016 02:05:51 +0000 (02:05 +0000)
Calling index ->next on a new zfs returns a non-zero RC, but ldiskfs
indexes start with a blank record. This change modifies the config
load code to always write the default nodemap to an empty index file.

Signed-off-by: Kit Westneat <kit.westneat@gmail.com>
Change-Id: I30a365f65463979889f09f7ad5ffcdacc83fa868
Reviewed-on: http://review.whamcloud.com/21939
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ptlrpc/nodemap_storage.c

index c94d4ec..fb12f09 100644 (file)
@@ -779,20 +779,30 @@ static int nodemap_load_entries(const struct lu_env *env,
                GOTO(out, rc = PTR_ERR(it));
 
        rc = iops->load(env, it, hash);
                GOTO(out, rc = PTR_ERR(it));
 
        rc = iops->load(env, it, hash);
+       if (rc < 0)
+               GOTO(out_iops_fini, rc);
+
+       /* rc == 0 means we need to advance to record */
        if (rc == 0) {
                rc = iops->next(env, it);
        if (rc == 0) {
                rc = iops->next(env, it);
-               if (rc != 0)
-                       GOTO(out_iops, rc = 0);
+
+               if (rc < 0)
+                       GOTO(out_iops_put, rc);
+               /* rc > 0 is eof, will be checked in while below */
+       } else {
+               /* rc == 1, we found initial record and can process below */
+               rc = 0;
        }
 
        new_config = nodemap_config_alloc();
        if (IS_ERR(new_config)) {
                rc = PTR_ERR(new_config);
                new_config = NULL;
        }
 
        new_config = nodemap_config_alloc();
        if (IS_ERR(new_config)) {
                rc = PTR_ERR(new_config);
                new_config = NULL;
-               GOTO(out_lock, rc);
+               GOTO(out_iops_put, rc);
        }
 
        }
 
-       do {
+       /* rc > 0 is eof, check initial iops->next here as well */
+       while (rc == 0) {
                struct nodemap_key *key;
                union nodemap_rec rec;
 
                struct nodemap_key *key;
                union nodemap_rec rec;
 
@@ -800,11 +810,11 @@ static int nodemap_load_entries(const struct lu_env *env,
                rc = iops->rec(env, it, (struct dt_rec *)&rec, 0);
                if (rc != -ESTALE) {
                        if (rc != 0)
                rc = iops->rec(env, it, (struct dt_rec *)&rec, 0);
                if (rc != -ESTALE) {
                        if (rc != 0)
-                               GOTO(out_lock, rc);
+                               GOTO(out_nodemap_config, rc);
                        rc = nodemap_process_keyrec(new_config, key, &rec,
                                                    &recent_nodemap);
                        if (rc < 0)
                        rc = nodemap_process_keyrec(new_config, key, &rec,
                                                    &recent_nodemap);
                        if (rc < 0)
-                               GOTO(out_lock, rc);
+                               GOTO(out_nodemap_config, rc);
                        if (rc == NODEMAP_GLOBAL_IDX)
                                loaded_global_idx = true;
                }
                        if (rc == NODEMAP_GLOBAL_IDX)
                                loaded_global_idx = true;
                }
@@ -812,19 +822,20 @@ static int nodemap_load_entries(const struct lu_env *env,
                do
                        rc = iops->next(env, it);
                while (rc == -ESTALE);
                do
                        rc = iops->next(env, it);
                while (rc == -ESTALE);
-       } while (rc == 0);
+       }
 
        if (rc > 0)
                rc = 0;
 
 
        if (rc > 0)
                rc = 0;
 
-out_lock:
+out_nodemap_config:
        if (rc != 0)
                nodemap_config_dealloc(new_config);
        else
                /* creating new default needs to be done outside dt read lock */
                activate_nodemap = true;
        if (rc != 0)
                nodemap_config_dealloc(new_config);
        else
                /* creating new default needs to be done outside dt read lock */
                activate_nodemap = true;
-out_iops:
+out_iops_put:
        iops->put(env, it);
        iops->put(env, it);
+out_iops_fini:
        iops->fini(env, it);
 out:
        dt_read_unlock(env, nodemap_idx);
        iops->fini(env, it);
 out:
        dt_read_unlock(env, nodemap_idx);