Whamcloud - gitweb
LU-6350 lfsck: lock object based on prediction for bad linkEA 08/14008/8
authorFan Yong <fan.yong@intel.com>
Wed, 8 Apr 2015 13:32:10 +0000 (21:32 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 1 May 2015 03:21:39 +0000 (03:21 +0000)
Originally, when the namespace LFSCK verifies the object's linkEA,
it will check the linkEA without related ldlm/dt lock firstly. If
finds bad linkEA (or lost linkEA), it will acquire the ldlm/dt lock
on the object, then re-check the object; if still some inconsistent,
it will repair the inconsistency with the lock.

For the system that contains many inconsistent objects, such double
check mechanism is some inefficient. Be as improvement, the LFSCK can
make some prediction, for example: if the former object contains bad
linkEA, then when verifies current object, the namespace LFSCK will
acquire the ldlm/dt lock on the object in advance; if the prediction
is wrong, it will NOT take ldlm/dt lock in advance for next object.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I16b317305894a07bb372f5ca5e5f22052ff7cd66
Reviewed-on: http://review.whamcloud.com/14008
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lfsck/lfsck_internal.h
lustre/lfsck/lfsck_lib.c
lustre/lfsck/lfsck_namespace.c

index 21163e8..7945769 100644 (file)
@@ -813,6 +813,7 @@ struct lfsck_assistant_data {
                                                 lad_in_double_scan:1,
                                                 lad_exit:1,
                                                 lad_incomplete:1;
+       bool                                     lad_advance_lock;
 };
 
 #define LFSCK_TMPBUF_LEN       64
index 3905d85..d301bac 100644 (file)
@@ -2400,6 +2400,7 @@ int lfsck_start_assistant(const struct lu_env *env, struct lfsck_component *com,
        lad->lad_to_double_scan = 0;
        lad->lad_in_double_scan = 0;
        lad->lad_exit = 0;
+       lad->lad_advance_lock = false;
        thread_set_flags(athread, 0);
 
        lta = lfsck_thread_args_init(lfsck, com, lsp);
index d1b66a8..55b668b 100644 (file)
@@ -5009,6 +5009,7 @@ static int lfsck_namespace_assistant_handler_p1(const struct lu_env *env,
        struct lfsck_instance      *lfsck    = com->lc_lfsck;
        struct lfsck_bookmark      *bk       = &lfsck->li_bookmark_ram;
        struct lfsck_namespace     *ns       = com->lc_file_ram;
+       struct lfsck_assistant_data *lad     = com->lc_data;
        struct linkea_data          ldata    = { NULL };
        const struct lu_name       *cname;
        struct thandle             *handle   = NULL;
@@ -5026,6 +5027,7 @@ static int lfsck_namespace_assistant_handler_p1(const struct lu_env *env,
        bool                        newdata;
        bool                        log      = false;
        bool                        bad_hash = false;
+       bool                        bad_linkea = false;
        int                         idx      = 0;
        int                         count    = 0;
        int                         rc       = 0;
@@ -5160,7 +5162,7 @@ dangling:
                GOTO(out, rc);
        }
 
-       if (!(bk->lb_param & LPF_DRYRUN) && repaired) {
+       if (!(bk->lb_param & LPF_DRYRUN) && lad->lad_advance_lock) {
 
 again:
                rc = lfsck_ibits_lock(env, lfsck, obj, &lh,
@@ -5299,6 +5301,7 @@ nodata:
                if (rc != 0)
                        GOTO(stop, rc);
 
+               bad_linkea = true;
                if (!remove && newdata)
                        ns->ln_flags |= LF_UPGRADE;
                else if (remove || !(ns->ln_flags & LF_UPGRADE))
@@ -5513,6 +5516,8 @@ trace:
        if (dir != NULL && !IS_ERR(dir))
                lfsck_object_put(env, dir);
 
+       lad->lad_advance_lock = bad_linkea;
+
        return rc;
 }