Whamcloud - gitweb
LU-12974 lfsck: dryrun mode shouldn't repair for layout 67/36767/5
authorLai Siyao <lai.siyao@whamcloud.com>
Mon, 9 Sep 2019 02:39:01 +0000 (10:39 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 14 May 2020 05:40:02 +0000 (05:40 +0000)
"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 <lai.siyao@whamcloud.com>
Change-Id: Ie1f4d0d1726e8f3f39f5a8b7be9cc149df1c1e44
Reviewed-on: https://review.whamcloud.com/36767
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
lustre/lfsck/lfsck_internal.h
lustre/lfsck/lfsck_layout.c
lustre/lfsck/lfsck_lib.c
lustre/tests/sanity-lfsck.sh

index e5b20e9..d491b2a 100644 (file)
@@ -752,6 +752,11 @@ struct lfsck_instance {
        struct lfsck_rec_lmv_save li_rec_lmv_save[LFSCK_REC_LMV_MAX_DEPTH];
 };
 
        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;
 struct lfsck_async_interpret_args {
        struct lfsck_component          *laia_com;
        struct lfsck_tgt_descs          *laia_ltds;
index b2aad04..9f1ad92 100644 (file)
@@ -2329,6 +2329,9 @@ static int lfsck_layout_recreate_parent(const struct lu_env *env,
        int                              rc     = 0;
        ENTRY;
 
        int                              rc     = 0;
        ENTRY;
 
+       if (lfsck_is_dryrun(lfsck))
+               GOTO(log, rc = 0);
+
        if (unlikely(lpf == NULL))
                GOTO(log, rc = -ENXIO);
 
        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 (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));
        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;
 
        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);
        rc = lfsck_ibits_lock(env, lfsck, parent, &lh,
                              MDS_INODELOCK_LAYOUT | MDS_INODELOCK_XATTR,
                              LCK_EX);
index 4b622a7..bf69c6d 100644 (file)
@@ -1426,6 +1426,9 @@ int lfsck_verify_lpf(const struct lu_env *env, struct lfsck_instance *lfsck)
 
        LASSERT(lfsck->li_master);
 
 
        LASSERT(lfsck->li_master);
 
+       if (lfsck_is_dryrun(lfsck))
+               RETURN(0);
+
        if (lfsck->li_lpf_root_obj != NULL)
                RETURN(0);
 
        if (lfsck->li_lpf_root_obj != NULL)
                RETURN(0);
 
index b64280a..46642d2 100644 (file)
@@ -2189,6 +2189,28 @@ test_18b() {
        cancel_lru_locks mdc
        cancel_lru_locks osc
 
        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!"
 
        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!"