Whamcloud - gitweb
LU-8929 lfsck: dumper gets current position properly 69/24869/2
authorFan Yong <fan.yong@intel.com>
Tue, 27 Sep 2016 15:12:12 +0000 (23:12 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 24 Jan 2017 05:24:11 +0000 (05:24 +0000)
It is normal that the LFSCK iteration has been done when the
dump hanlder found the status as LS_SCANNING_PHASE1, it may
because of race, or the LFSCK failed to update the status.
Under such cases, the dump handler will use the position in
the last checkpoint as the current position. It may be not
100% accurate, but not serious issue.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I672258baa9d0b0aa8ec12249c13b2b147a274ab4
Reviewed-on: https://review.whamcloud.com/24869
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lfsck/lfsck_layout.c
lustre/lfsck/lfsck_namespace.c

index 1df9822..8ce6086 100644 (file)
@@ -5218,7 +5218,6 @@ static void lfsck_layout_dump(const struct lu_env *env,
 
        if (lo->ll_status == LS_SCANNING_PHASE1) {
                __u64 pos;
-               const struct dt_it_ops *iops;
                cfs_duration_t duration = cfs_time_current() -
                                          lfsck->li_time_last_checkpoint;
                __u64 checked = lo->ll_objs_checked_phase1 +
@@ -5248,19 +5247,22 @@ static void lfsck_layout_dump(const struct lu_env *env,
                           speed,
                           new_checked);
 
-               LASSERT(lfsck->li_di_oit != NULL);
-
-               iops = &lfsck->li_obj_oit->do_index_ops->dio_it;
+               if (likely(lfsck->li_di_oit)) {
+                       const struct dt_it_ops *iops =
+                               &lfsck->li_obj_oit->do_index_ops->dio_it;
+
+                       /* The low layer otable-based iteration position may NOT
+                        * exactly match the layout-based directory traversal
+                        * cookie. Generally, it is not a serious issue. But the
+                        * caller should NOT make assumption on that. */
+                       pos = iops->store(env, lfsck->li_di_oit);
+                       if (!lfsck->li_current_oit_processed)
+                               pos--;
+               } else {
+                       pos = lo->ll_pos_last_checkpoint;
+               }
 
-               /* The low layer otable-based iteration position may NOT
-                * exactly match the layout-based directory traversal
-                * cookie. Generally, it is not a serious issue. But the
-                * caller should NOT make assumption on that. */
-               pos = iops->store(env, lfsck->li_di_oit);
-               if (!lfsck->li_current_oit_processed)
-                       pos--;
                seq_printf(m, "current_position: %llu\n", pos);
-
        } else if (lo->ll_status == LS_SCANNING_PHASE2) {
                cfs_duration_t duration = cfs_time_current() -
                                          com->lc_time_last_checkpoint;
index 1cb3963..88a9ab2 100644 (file)
@@ -4421,7 +4421,6 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
 
        if (ns->ln_status == LS_SCANNING_PHASE1) {
                struct lfsck_position pos;
-               const struct dt_it_ops *iops;
                cfs_duration_t duration = cfs_time_current() -
                                          lfsck->li_time_last_checkpoint;
                __u64 checked = ns->ln_items_checked + com->lc_new_checked;
@@ -4447,33 +4446,37 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                           speed,
                           new_checked);
 
-               LASSERT(lfsck->li_di_oit != NULL);
-
-               iops = &lfsck->li_obj_oit->do_index_ops->dio_it;
-
-               /* The low layer otable-based iteration position may NOT
-                * exactly match the namespace-based directory traversal
-                * cookie. Generally, it is not a serious issue. But the
-                * caller should NOT make assumption on that. */
-               pos.lp_oit_cookie = iops->store(env, lfsck->li_di_oit);
-               if (!lfsck->li_current_oit_processed)
-                       pos.lp_oit_cookie--;
-
-               spin_lock(&lfsck->li_lock);
-               if (lfsck->li_di_dir != NULL) {
-                       pos.lp_dir_cookie = lfsck->li_cookie_dir;
-                       if (pos.lp_dir_cookie >= MDS_DIR_END_OFF) {
+               if (likely(lfsck->li_di_oit)) {
+                       const struct dt_it_ops *iops =
+                               &lfsck->li_obj_oit->do_index_ops->dio_it;
+
+                       /* The low layer otable-based iteration position may NOT
+                        * exactly match the namespace-based directory traversal
+                        * cookie. Generally, it is not a serious issue. But the
+                        * caller should NOT make assumption on that. */
+                       pos.lp_oit_cookie = iops->store(env, lfsck->li_di_oit);
+                       if (!lfsck->li_current_oit_processed)
+                               pos.lp_oit_cookie--;
+
+                       spin_lock(&lfsck->li_lock);
+                       if (lfsck->li_di_dir) {
+                               pos.lp_dir_cookie = lfsck->li_cookie_dir;
+                               if (pos.lp_dir_cookie >= MDS_DIR_END_OFF) {
+                                       fid_zero(&pos.lp_dir_parent);
+                                       pos.lp_dir_cookie = 0;
+                               } else {
+                                       pos.lp_dir_parent =
+                                       *lfsck_dto2fid(lfsck->li_obj_dir);
+                               }
+                       } else {
                                fid_zero(&pos.lp_dir_parent);
                                pos.lp_dir_cookie = 0;
-                       } else {
-                               pos.lp_dir_parent =
-                                       *lfsck_dto2fid(lfsck->li_obj_dir);
                        }
+                       spin_unlock(&lfsck->li_lock);
                } else {
-                       fid_zero(&pos.lp_dir_parent);
-                       pos.lp_dir_cookie = 0;
+                       pos = ns->ln_pos_last_checkpoint;
                }
-               spin_unlock(&lfsck->li_lock);
+
                lfsck_pos_dump(m, &pos, "current_position");
        } else if (ns->ln_status == LS_SCANNING_PHASE2) {
                cfs_duration_t duration = cfs_time_current() -