From ad40feaee4f58399da8a048fa5342700b8aebc6c Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Wed, 8 Apr 2015 21:32:10 +0800 Subject: [PATCH] LU-6350 lfsck: lock object based on prediction for bad linkEA 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 Change-Id: I16b317305894a07bb372f5ca5e5f22052ff7cd66 Reviewed-on: http://review.whamcloud.com/14008 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/lfsck/lfsck_internal.h | 1 + lustre/lfsck/lfsck_lib.c | 1 + lustre/lfsck/lfsck_namespace.c | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index 21163e8..7945769 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -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 diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 3905d85..d301bac 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -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); diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index d1b66a8..55b668b 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -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; } -- 1.8.3.1