From 983d48a8a96c1b9759e3da4a5cb3e4c9531217ed Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Mon, 9 Sep 2019 10:39:01 +0800 Subject: [PATCH] LU-12974 lfsck: dryrun mode shouldn't repair for layout "lfsck_start -t layout --dryrun" shouldn't repair but report inconsistencies. Update sanity-lfsck.sh 18b. Test-parameters: trivial testlist=sanity-lfsck envdefinitions=ONLY=18 DDN-Bug-ID: DDN-892 Signed-off-by: Lai Siyao Change-Id: Ie1f4d0d1726e8f3f39f5a8b7be9cc149df1c1e44 Reviewed-on: https://review.whamcloud.com/36767 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Hongchao Zhang --- lustre/lfsck/lfsck_internal.h | 5 +++++ lustre/lfsck/lfsck_layout.c | 9 +++++++++ lustre/lfsck/lfsck_lib.c | 3 +++ lustre/tests/sanity-lfsck.sh | 22 ++++++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index e5b20e9..d491b2a 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -752,6 +752,11 @@ struct lfsck_instance { struct lfsck_rec_lmv_save li_rec_lmv_save[LFSCK_REC_LMV_MAX_DEPTH]; }; +static inline bool lfsck_is_dryrun(struct lfsck_instance *lfsck) +{ + return lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN; +} + struct lfsck_async_interpret_args { struct lfsck_component *laia_com; struct lfsck_tgt_descs *laia_ltds; diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index b2aad04..9f1ad92 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -2329,6 +2329,9 @@ static int lfsck_layout_recreate_parent(const struct lu_env *env, int rc = 0; ENTRY; + if (lfsck_is_dryrun(lfsck)) + GOTO(log, rc = 0); + if (unlikely(lpf == NULL)) GOTO(log, rc = -ENXIO); @@ -2729,6 +2732,9 @@ static int lfsck_layout_conflict_create(const struct lu_env *env, if (rc != 0 && rc != -ENOENT) GOTO(unlock, rc); + if (lfsck_is_dryrun(com->lc_lfsck)) + GOTO(unlock, rc = 0); + th = dt_trans_create(env, dev); if (IS_ERR(th)) GOTO(unlock, rc = PTR_ERR(th)); @@ -2808,6 +2814,9 @@ static int lfsck_layout_recreate_lovea(const struct lu_env *env, bool new_mirror = true; ENTRY; + if (lfsck_is_dryrun(lfsck)) + RETURN(0); + rc = lfsck_ibits_lock(env, lfsck, parent, &lh, MDS_INODELOCK_LAYOUT | MDS_INODELOCK_XATTR, LCK_EX); diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 4b622a7..bf69c6d 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -1426,6 +1426,9 @@ int lfsck_verify_lpf(const struct lu_env *env, struct lfsck_instance *lfsck) LASSERT(lfsck->li_master); + if (lfsck_is_dryrun(lfsck)) + RETURN(0); + if (lfsck->li_lpf_root_obj != NULL) RETURN(0); diff --git a/lustre/tests/sanity-lfsck.sh b/lustre/tests/sanity-lfsck.sh index b64280a..46642d2 100644 --- a/lustre/tests/sanity-lfsck.sh +++ b/lustre/tests/sanity-lfsck.sh @@ -2189,6 +2189,28 @@ test_18b() { cancel_lru_locks mdc cancel_lru_locks osc + # dryrun mode only check orphans, not repaie + echo "Trigger layout LFSCK --dryrun to find out orphan OST-object" + $START_LAYOUT --dryrun -o -r || + error "Fail to start layout LFSCK in dryrun mode" + wait_all_targets_blocked layout completed 2 + + local PARAMS=$($SHOW_LAYOUT | awk '/^param/ { print $2 }') + [ "$PARAMS" == "dryrun,all_targets,orphan" ] || + error "Expect 'dryrun,all_targets,orphan', got '$PARAMS'" + + local orphans=$(do_facet mds1 $LCTL get_param -n \ + mdd.$(facet_svc mds1).lfsck_layout | + awk '/^inconsistent_orphan/ { print $2 }') + [ $orphans -eq 3 ] || + error "Expect 3 found on mds1, but got: $orphans" + + # orphan parents should not be created + local subdir + for subdir in $MOUNT/.lustre/lost+found/*; do + [ ! "$(ls -A $subdir)" ] || error "$subdir not empty" + done + echo "Trigger layout LFSCK on all devices to find out orphan OST-object" $START_LAYOUT -r -o || error "(1) Fail to start LFSCK for layout!" -- 1.8.3.1