From: Fan Yong Date: Sun, 23 Mar 2014 00:11:34 +0000 (+0800) Subject: LU-4919 lfsck: record the first failure position X-Git-Tag: 2.5.59~103 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=bc3ca96bdeae44d400724b3db886468ba5245f9b;ds=sidebyside LU-4919 lfsck: record the first failure position The layout LFSCK should set lfsck_layout::ll_pos_first_inconsistent, then we can know where the first object to be fixed or failed to be checked, which can save some effort when switch LFSCK from dryrun to repair mode. Signed-off-by: Fan Yong Change-Id: Icd8f4bce6b75c07b1daeac36062b6736bb66c7fc Reviewed-on: http://review.whamcloud.com/9985 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index 4f84c3b..45a1691 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -230,7 +230,8 @@ struct lfsck_layout { /* Position for the last LFSCK checkpoint. */ __u64 ll_pos_last_checkpoint; - /* Position for the first should be updated object. */ + /* Position for the first object to be fixed or + * failed to be checked in the phase1. */ __u64 ll_pos_first_inconsistent; /* How many objects have been checked. */ diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index c808808..bd5c1fb 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -1153,6 +1153,17 @@ out: return rc; } +static void lfsck_layout_record_failure(const struct lu_env *env, + struct lfsck_instance *lfsck, + struct lfsck_layout *lo) +{ + lo->ll_objs_failed_phase1++; + if (unlikely(lo->ll_pos_first_inconsistent == 0)) + lo->ll_pos_first_inconsistent = + lfsck->li_obj_oit->do_index_ops->dio_it.store(env, + lfsck->li_di_oit); +} + static int lfsck_layout_master_async_interpret(const struct lu_env *env, struct ptlrpc_request *req, void *args, int rc) @@ -3299,13 +3310,18 @@ out: lo->ll_objs_skipped++; rc = 0; } else { - lo->ll_objs_failed_phase1++; + lfsck_layout_record_failure(env, lfsck, lo); } } else if (rc > 0) { LASSERTF(type > LLIT_NONE && type <= LLIT_MAX, "unknown type = %d\n", type); lo->ll_objs_repaired[type - 1]++; + if (bk->lb_param & LPF_DRYRUN && + unlikely(lo->ll_pos_first_inconsistent == 0)) + lo->ll_pos_first_inconsistent = + lfsck->li_obj_oit->do_index_ops->dio_it.store(env, + lfsck->li_di_oit); } up_write(&com->lc_sem); @@ -4062,14 +4078,7 @@ static void lfsck_layout_fail(const struct lu_env *env, down_write(&com->lc_sem); if (new_checked) com->lc_new_checked++; - lo->ll_objs_failed_phase1++; - if (lo->ll_pos_first_inconsistent == 0) { - struct lfsck_instance *lfsck = com->lc_lfsck; - - lo->ll_pos_first_inconsistent = - lfsck->li_obj_oit->do_index_ops->dio_it.store(env, - lfsck->li_di_oit); - } + lfsck_layout_record_failure(env, com->lc_lfsck, lo); up_write(&com->lc_sem); } @@ -4408,7 +4417,7 @@ next: down_write(&com->lc_sem); com->lc_new_checked++; if (rc < 0) - lo->ll_objs_failed_phase1++; + lfsck_layout_record_failure(env, lfsck, lo); up_write(&com->lc_sem); if (cobj != NULL && !IS_ERR(cobj)) @@ -4555,7 +4564,7 @@ out: down_write(&com->lc_sem); com->lc_new_checked++; if (rc < 0) - lo->ll_objs_failed_phase1++; + lfsck_layout_record_failure(env, lfsck, lo); up_write(&com->lc_sem); } buf->lb_len = buflen;