From cffd726304667ea3d84b4b3c1a9b66565e5a5566 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Tue, 27 Sep 2016 23:12:12 +0800 Subject: [PATCH] LU-8929 lfsck: dumper gets current position properly 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 Change-Id: I672258baa9d0b0aa8ec12249c13b2b147a274ab4 Reviewed-on: https://review.whamcloud.com/24869 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/lfsck/lfsck_layout.c | 26 +++++++++++----------- lustre/lfsck/lfsck_namespace.c | 49 ++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index 1df9822..8ce6086 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -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; diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index 1cb3963..88a9ab2 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -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() - -- 1.8.3.1