Whamcloud - gitweb
LU-2868 lfsck: finish otable iteration if no more objects
authorFan Yong <yong.fan@whamcloud.com>
Fri, 8 Feb 2013 05:46:30 +0000 (13:46 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 20 Mar 2013 21:01:13 +0000 (17:01 -0400)
If there are no objects to be scanned just at the LFSCK beginning,
then the LFSCK should mark the otable-based iteration as finished
to avoid to access non-initialized data via dt_it_ops::rec().

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I67e880ccfa13e867c4ca7f1858d67909ba0415b3
Reviewed-on: http://review.whamcloud.com/5622
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/mdd/mdd_lfsck.c
lustre/osd-ldiskfs/osd_scrub.c

index 02ea968..bca6ce1 100644 (file)
@@ -2118,12 +2118,17 @@ static int object_is_client_visible(const struct lu_env *env,
                else if (IS_ERR(obj))
                        return PTR_ERR(obj);
 
-               /* XXX: need more processing for remote object in the future. */
-               if (!mdd_object_exists(obj) || mdd_object_remote(obj)) {
+               if (!mdd_object_exists(obj)) {
                        mdd_object_put(env, obj);
                        return 0;
                }
 
+               /* Currently, only client visible directory can be remote. */
+               if (mdd_object_remote(obj)) {
+                       mdd_object_put(env, obj);
+                       return 1;
+               }
+
                depth++;
        }
        return 0;
@@ -2213,12 +2218,19 @@ static int mdd_lfsck_prep(struct lu_env *env, struct md_lfsck *lfsck)
        /* Init otable-based iterator. */
        if (pos == NULL) {
                rc = iops->load(env, lfsck->ml_di_oit, 0);
-               GOTO(out, rc = (rc >= 0 ? 0 : rc));
+               if (rc > 0) {
+                       lfsck->ml_oit_over = 1;
+                       rc = 0;
+               }
+
+               GOTO(out, rc);
        }
 
        rc = iops->load(env, lfsck->ml_di_oit, pos->lp_oit_cookie);
        if (rc < 0)
                GOTO(out, rc);
+       else if (rc > 0)
+               lfsck->ml_oit_over = 1;
 
        if (fid_is_zero(&pos->lp_dir_parent))
                GOTO(out, rc = 0);
index 858aa07..3736410 100644 (file)
@@ -1873,6 +1873,13 @@ static int osd_otable_it_rec(const struct lu_env *env, const struct dt_it *di,
        struct osd_otable_cache *ooc = &it->ooi_cache;
 
        *(struct lu_fid *)rec = ooc->ooc_cache[ooc->ooc_consumer_idx].oic_fid;
+
+       /* Filter out Invald FID already. */
+       LASSERTF(fid_is_sane((struct lu_fid *)rec),
+                "Invalid FID "DFID", p_idx = %d, c_idx = %d\n",
+                PFID((struct lu_fid *)rec),
+                ooc->ooc_producer_idx, ooc->ooc_consumer_idx);
+
        return 0;
 }