Whamcloud - gitweb
LU-6109 lfsck: check FID validity before locating object
[fs/lustre-release.git] / lustre / lfsck / lfsck_engine.c
index 4d232d9..8eb6f02 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2013, 2014, Intel Corporation.
  */
 /*
  * lustre/lfsck/lfsck_engine.c
@@ -39,7 +39,7 @@
 
 #include "lfsck_internal.h"
 
-static int lfsck_unpack_ent(struct lu_dirent *ent, __u64 *cookie, __u16 *type)
+int lfsck_unpack_ent(struct lu_dirent *ent, __u64 *cookie, __u16 *type)
 {
        struct luda_type        *lt;
        int                      align = sizeof(*lt) - 1;
@@ -93,19 +93,6 @@ static void lfsck_di_dir_put(const struct lu_env *env, struct lfsck_instance *lf
        iops->put(env, di);
 }
 
-static void lfsck_close_dir(const struct lu_env *env,
-                           struct lfsck_instance *lfsck)
-{
-       struct dt_object        *dir_obj  = lfsck->li_obj_dir;
-       const struct dt_it_ops  *dir_iops = &dir_obj->do_index_ops->dio_it;
-       struct dt_it            *dir_di   = lfsck->li_di_dir;
-
-       lfsck_di_dir_put(env, lfsck);
-       dir_iops->fini(env, dir_di);
-       lfsck->li_obj_dir = NULL;
-       lfsck_object_put(env, dir_obj);
-}
-
 static int lfsck_update_lma(const struct lu_env *env,
                            struct lfsck_instance *lfsck, struct dt_object *obj)
 {
@@ -234,7 +221,7 @@ static int lfsck_needs_scan_dir(const struct lu_env *env,
                fld_range_set_mdt(range);
                rc = fld_local_lookup(env, ss->ss_server_fld,
                                      fid_seq(fid), range);
-               if (rc != 0 || range->lsr_index != idx) {
+               if (rc != 0 || range->lsr_index != idx)
                        /* Current FID should NOT be for the input parameter
                         * @obj, because the lfsck_master_oit_engine() has
                         * filtered out agent object. So current FID is for
@@ -242,10 +229,7 @@ static int lfsck_needs_scan_dir(const struct lu_env *env,
                         * So the ancestor is a remote directory. The input
                         * parameter @obj is local directory, and should be
                         * scanned under such case. */
-                       LASSERT(depth > 0);
-
                        return 1;
-               }
 
                /* normal FID on this target (locally) must be for the
                 * client-side visiable object. */
@@ -298,6 +282,77 @@ out:
        return rc;
 }
 
+static int lfsck_load_stripe_lmv(const struct lu_env *env,
+                                struct lfsck_instance *lfsck,
+                                struct dt_object *obj)
+{
+       struct lmv_mds_md_v1    *lmv    = &lfsck_env_info(env)->lti_lmv;
+       struct lfsck_lmv        *llmv;
+       int                      rc;
+       ENTRY;
+
+       LASSERT(lfsck->li_obj_dir == NULL);
+       LASSERT(lfsck->li_lmv == NULL);
+
+       rc = lfsck_read_stripe_lmv(env, obj, lmv);
+       if (rc == -ENODATA) {
+               lfsck->li_obj_dir = lfsck_object_get(obj);
+
+               RETURN(0);
+       }
+
+       if (rc < 0)
+               RETURN(rc);
+
+       OBD_ALLOC_PTR(llmv);
+       if (llmv == NULL)
+               RETURN(-ENOMEM);
+
+       if (lmv->lmv_magic == LMV_MAGIC) {
+               struct lfsck_slave_lmv_rec      *lslr;
+               __u32                            stripes;
+
+               llmv->ll_lmv_master = 1;
+               if (lmv->lmv_stripe_count < 1)
+                       stripes = LFSCK_LMV_DEF_STRIPES;
+               else if (lmv->lmv_stripe_count > LFSCK_LMV_MAX_STRIPES)
+                       stripes = LFSCK_LMV_MAX_STRIPES;
+               else
+                       stripes = lmv->lmv_stripe_count;
+
+               OBD_ALLOC_LARGE(lslr, sizeof(*lslr) * stripes);
+               if (lslr == NULL) {
+                       OBD_FREE_PTR(llmv);
+
+                       RETURN(-ENOMEM);
+               }
+
+               /* Find the object against the bottom device. */
+               obj = lfsck_object_find_by_dev(env, lfsck->li_bottom,
+                                              lfsck_dto2fid(obj));
+               if (IS_ERR(obj)) {
+                       OBD_FREE_LARGE(lslr, sizeof(*lslr) * stripes);
+                       OBD_FREE_PTR(llmv);
+
+                       RETURN(PTR_ERR(obj));
+               }
+
+               llmv->ll_stripes_allocated = stripes;
+               llmv->ll_hash_type = LMV_HASH_TYPE_UNKNOWN;
+               llmv->ll_lslr = lslr;
+               lfsck->li_obj_dir = obj;
+       } else {
+               llmv->ll_lmv_slave = 1;
+               lfsck->li_obj_dir = lfsck_object_get(obj);
+       }
+
+       llmv->ll_lmv = *lmv;
+       atomic_set(&llmv->ll_ref, 1);
+       lfsck->li_lmv = llmv;
+
+       RETURN(0);
+}
+
 /* LFSCK wrap functions */
 
 static void lfsck_fail(const struct lu_env *env, struct lfsck_instance *lfsck,
@@ -310,6 +365,98 @@ static void lfsck_fail(const struct lu_env *env, struct lfsck_instance *lfsck,
        }
 }
 
+void lfsck_close_dir(const struct lu_env *env,
+                    struct lfsck_instance *lfsck, int result)
+{
+       struct lfsck_component *com;
+       ENTRY;
+
+       if (lfsck->li_lmv != NULL) {
+               lfsck->li_lmv->ll_exit_value = result;
+               if (lfsck->li_obj_dir != NULL) {
+                       list_for_each_entry(com, &lfsck->li_list_dir,
+                                           lc_link_dir) {
+                               com->lc_ops->lfsck_close_dir(env, com);
+                       }
+               }
+
+               lfsck_lmv_put(env, lfsck->li_lmv);
+               lfsck->li_lmv = NULL;
+       }
+
+       if (lfsck->li_di_dir != NULL) {
+               const struct dt_it_ops  *dir_iops;
+               struct dt_it            *dir_di   = lfsck->li_di_dir;
+
+               LASSERT(lfsck->li_obj_dir != NULL);
+
+               dir_iops = &lfsck->li_obj_dir->do_index_ops->dio_it;
+               lfsck_di_dir_put(env, lfsck);
+               dir_iops->fini(env, dir_di);
+       }
+
+       if (lfsck->li_obj_dir != NULL) {
+               struct dt_object        *dir_obj  = lfsck->li_obj_dir;
+
+               lfsck->li_obj_dir = NULL;
+               lfsck_object_put(env, dir_obj);
+       }
+
+       EXIT;
+}
+
+int lfsck_open_dir(const struct lu_env *env,
+                  struct lfsck_instance *lfsck, __u64 cookie)
+{
+       struct dt_object        *obj    = lfsck->li_obj_dir;
+       struct dt_it            *di     = lfsck->li_di_dir;
+       struct lfsck_component  *com;
+       const struct dt_it_ops  *iops;
+       int                      rc     = 0;
+       ENTRY;
+
+       LASSERT(obj != NULL);
+       LASSERT(di == NULL);
+
+       if (unlikely(!dt_try_as_dir(env, obj)))
+               GOTO(out, rc = -ENOTDIR);
+
+       list_for_each_entry(com, &lfsck->li_list_dir, lc_link_dir) {
+               rc = com->lc_ops->lfsck_open_dir(env, com);
+               if (rc != 0)
+                       GOTO(out, rc);
+       }
+
+       iops = &obj->do_index_ops->dio_it;
+       di = iops->init(env, obj, lfsck->li_args_dir, BYPASS_CAPA);
+       if (IS_ERR(di))
+               GOTO(out, rc = PTR_ERR(di));
+
+       rc = iops->load(env, di, cookie);
+       if (rc == 0 || (rc > 0 && cookie > 0))
+               rc = iops->next(env, di);
+       else if (rc > 0)
+               rc = 0;
+
+       if (rc != 0) {
+               iops->put(env, di);
+               iops->fini(env, di);
+       } else {
+               lfsck->li_cookie_dir = iops->store(env, di);
+               spin_lock(&lfsck->li_lock);
+               lfsck->li_di_dir = di;
+               spin_unlock(&lfsck->li_lock);
+       }
+
+       GOTO(out, rc);
+
+out:
+       if (rc != 0)
+               lfsck_close_dir(env, lfsck, rc);
+
+       return rc;
+}
+
 static int lfsck_checkpoint(const struct lu_env *env,
                            struct lfsck_instance *lfsck)
 {
@@ -343,7 +490,6 @@ static int lfsck_prep(const struct lu_env *env, struct lfsck_instance *lfsck,
        struct lfsck_position  *pos     = NULL;
        const struct dt_it_ops *iops    =
                                &lfsck->li_obj_oit->do_index_ops->dio_it;
-       struct dt_it           *di;
        int                     rc;
        ENTRY;
 
@@ -394,45 +540,31 @@ static int lfsck_prep(const struct lu_env *env, struct lfsck_instance *lfsck,
            unlikely(!S_ISDIR(lfsck_object_type(obj))))
                GOTO(out, rc = 0);
 
-       if (unlikely(!dt_try_as_dir(env, obj)))
-               GOTO(out, rc = -ENOTDIR);
-
-       /* Init the namespace-based directory traverse. */
-       iops = &obj->do_index_ops->dio_it;
-       di = iops->init(env, obj, lfsck->li_args_dir, BYPASS_CAPA);
-       if (IS_ERR(di))
-               GOTO(out, rc = PTR_ERR(di));
-
-       LASSERT(pos->lp_dir_cookie < MDS_DIR_END_OFF);
+       rc = lfsck_load_stripe_lmv(env, lfsck, obj);
+       if (rc == 0) {
+               /* For the master MDT-object of a striped directory,
+                * reset the iteration from the directory beginning. */
+               if (lfsck->li_lmv != NULL && lfsck->li_lmv->ll_lmv_master)
+                       pos->lp_dir_cookie = 0;
 
-       rc = iops->load(env, di, pos->lp_dir_cookie);
-       if ((rc == 0) || (rc > 0 && pos->lp_dir_cookie > 0))
-               rc = iops->next(env, di);
-       else if (rc > 0)
-               rc = 0;
-
-       if (rc != 0) {
-               iops->put(env, di);
-               iops->fini(env, di);
-               GOTO(out, rc);
+               rc = lfsck_open_dir(env, lfsck, pos->lp_dir_cookie);
+               if (rc > 0)
+                       /* The end of the directory. */
+                       rc = 0;
        }
 
-       lfsck->li_obj_dir = lfsck_object_get(obj);
-       lfsck->li_cookie_dir = iops->store(env, di);
-       spin_lock(&lfsck->li_lock);
-       lfsck->li_di_dir = di;
-       spin_unlock(&lfsck->li_lock);
-
-       GOTO(out, rc = 0);
+       GOTO(out, rc);
 
 out:
        if (obj != NULL)
                lfsck_object_put(env, obj);
 
-       if (rc < 0) {
+       if (rc != 0) {
+               lfsck_close_dir(env, lfsck, rc);
                list_for_each_entry_safe(com, next, &lfsck->li_list_scan,
-                                        lc_link)
+                                        lc_link) {
                        com->lc_ops->lfsck_post(env, com, rc, true);
+               }
 
                return rc;
        }
@@ -456,8 +588,6 @@ static int lfsck_exec_oit(const struct lu_env *env,
                          struct lfsck_instance *lfsck, struct dt_object *obj)
 {
        struct lfsck_component *com;
-       const struct dt_it_ops *iops;
-       struct dt_it           *di;
        int                     rc;
        ENTRY;
 
@@ -473,38 +603,20 @@ static int lfsck_exec_oit(const struct lu_env *env,
        if (rc <= 0)
                GOTO(out, rc);
 
-       if (unlikely(!dt_try_as_dir(env, obj)))
-               GOTO(out, rc = -ENOTDIR);
-
-       iops = &obj->do_index_ops->dio_it;
-       di = iops->init(env, obj, lfsck->li_args_dir, BYPASS_CAPA);
-       if (IS_ERR(di))
-               GOTO(out, rc = PTR_ERR(di));
-
-       rc = iops->load(env, di, 0);
+       rc = lfsck_load_stripe_lmv(env, lfsck, obj);
        if (rc == 0)
-               rc = iops->next(env, di);
-       else if (rc > 0)
-               rc = 0;
+               rc = lfsck_open_dir(env, lfsck, 0);
 
-       if (rc != 0) {
-               iops->put(env, di);
-               iops->fini(env, di);
-               GOTO(out, rc);
-       }
-
-       lfsck->li_obj_dir = lfsck_object_get(obj);
-       lfsck->li_cookie_dir = iops->store(env, di);
-       spin_lock(&lfsck->li_lock);
-       lfsck->li_di_dir = di;
-       spin_unlock(&lfsck->li_lock);
-
-       GOTO(out, rc = 0);
+       GOTO(out, rc);
 
 out:
        if (rc < 0)
                lfsck_fail(env, lfsck, false);
-       return (rc > 0 ? 0 : rc);
+
+       if (rc != 0)
+               lfsck_close_dir(env, lfsck, rc);
+
+       return rc > 0 ? 0 : rc;
 }
 
 static int lfsck_exec_dir(const struct lu_env *env,
@@ -522,19 +634,46 @@ static int lfsck_exec_dir(const struct lu_env *env,
        return 0;
 }
 
+static int lfsck_master_dir_engine(const struct lu_env *env,
+                                  struct lfsck_instance *lfsck);
+
 static int lfsck_post(const struct lu_env *env, struct lfsck_instance *lfsck,
                      int result)
 {
        struct lfsck_component *com;
        struct lfsck_component *next;
-       int                     rc  = 0;
-       int                     rc1 = 0;
+       int                     rc  = result;
 
        lfsck_pos_fill(env, lfsck, &lfsck->li_pos_checkpoint, false);
+       lfsck_close_dir(env, lfsck, result);
+
+       while (thread_is_running(&lfsck->li_thread) && rc > 0 &&
+              !list_empty(&lfsck->li_list_lmv)) {
+               struct lfsck_lmv_unit *llu;
+
+               spin_lock(&lfsck->li_lock);
+               llu = list_entry(lfsck->li_list_lmv.next,
+                                struct lfsck_lmv_unit, llu_link);
+               list_del_init(&llu->llu_link);
+               spin_unlock(&lfsck->li_lock);
+
+               lfsck->li_lmv = &llu->llu_lmv;
+               lfsck->li_obj_dir = lfsck_object_get(llu->llu_obj);
+               rc = lfsck_open_dir(env, lfsck, 0);
+               if (rc == 0) {
+                       rc = lfsck_master_dir_engine(env, lfsck);
+                       lfsck_close_dir(env, lfsck, result);
+               }
+       }
+
+       result = rc;
+
        list_for_each_entry_safe(com, next, &lfsck->li_list_scan, lc_link) {
                rc = com->lc_ops->lfsck_post(env, com, result, false);
                if (rc != 0)
-                       rc1 = rc;
+                       CDEBUG(D_LFSCK, "%s: lfsck_post at the component %u: "
+                              "rc = %d\n", lfsck_lfsck2name(lfsck),
+                              (__u32)com->lc_type, rc);
        }
 
        lfsck->li_time_last_checkpoint = cfs_time_current();
@@ -622,24 +761,14 @@ static int lfsck_master_dir_engine(const struct lu_env *env,
        ENTRY;
 
        do {
-               if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_DELAY2) &&
-                   cfs_fail_val > 0) {
-                       struct l_wait_info lwi;
-
-                       lwi = LWI_TIMEOUT(cfs_time_seconds(cfs_fail_val),
-                                         NULL, NULL);
-                       l_wait_event(thread->t_ctl_waitq,
-                                    !thread_is_running(thread),
-                                    &lwi);
-
-                       if (unlikely(!thread_is_running(thread))) {
-                               CDEBUG(D_LFSCK, "%s: scan dir exit for engine "
-                                      "stop, parent "DFID", cookie "LPX64"\n",
-                                      lfsck_lfsck2name(lfsck),
-                                      PFID(lfsck_dto2fid(dir)),
-                                      lfsck->li_cookie_dir);
-                               RETURN(0);
-                       }
+               if (CFS_FAIL_TIMEOUT(OBD_FAIL_LFSCK_DELAY2, cfs_fail_val) &&
+                   unlikely(!thread_is_running(thread))) {
+                       CDEBUG(D_LFSCK, "%s: scan dir exit for engine stop, "
+                              "parent "DFID", cookie "LPX64"\n",
+                              lfsck_lfsck2name(lfsck),
+                              PFID(lfsck_dto2fid(dir)), lfsck->li_cookie_dir);
+
+                       RETURN(0);
                }
 
                lfsck->li_new_scanned++;
@@ -699,7 +828,7 @@ checkpoint:
        } while (rc == 0);
 
        if (rc > 0 && !lfsck->li_oit_over)
-               lfsck_close_dir(env, lfsck);
+               lfsck_close_dir(env, lfsck, rc);
 
        RETURN(rc);
 }
@@ -712,7 +841,7 @@ checkpoint:
  * registered LFSCK component(s)' API to perform related consistency
  * verification.
  *
- * It flushes related LFSCK tracing files to disk via making checkpoint
+ * It flushes related LFSCK trace files to disk via making checkpoint
  * periodically. Then if the server crashed or the LFSCK is paused, the
  * LFSCK can resume from the latest checkpoint.
  *
@@ -758,29 +887,39 @@ static int lfsck_master_oit_engine(const struct lu_env *env,
                if (unlikely(lfsck->li_oit_over))
                        RETURN(1);
 
-               if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_DELAY1) &&
-                   cfs_fail_val > 0) {
-                       struct l_wait_info lwi;
-
-                       lwi = LWI_TIMEOUT(cfs_time_seconds(cfs_fail_val),
-                                         NULL, NULL);
-                       l_wait_event(thread->t_ctl_waitq,
-                                    !thread_is_running(thread),
-                                    &lwi);
+               if (CFS_FAIL_TIMEOUT(OBD_FAIL_LFSCK_DELAY1, cfs_fail_val) &&
+                   unlikely(!thread_is_running(thread))) {
+                       CDEBUG(D_LFSCK, "%s: OIT scan exit for engine stop, "
+                              "cookie "LPU64"\n",
+                              lfsck_lfsck2name(lfsck), iops->store(env, di));
 
-                       if (unlikely(!thread_is_running(thread))) {
-                               CDEBUG(D_LFSCK, "%s: OIT scan exit for engine "
-                                      "stop, cookie "LPU64"\n",
-                                      lfsck_lfsck2name(lfsck),
-                                      iops->store(env, di));
-                               RETURN(0);
-                       }
+                       RETURN(0);
                }
 
                if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_CRASH))
                        RETURN(0);
 
                lfsck->li_current_oit_processed = 1;
+
+               if (!list_empty(&lfsck->li_list_lmv)) {
+                       struct lfsck_lmv_unit *llu;
+
+                       spin_lock(&lfsck->li_lock);
+                       llu = list_entry(lfsck->li_list_lmv.next,
+                                        struct lfsck_lmv_unit, llu_link);
+                       list_del_init(&llu->llu_link);
+                       spin_unlock(&lfsck->li_lock);
+
+                       lfsck->li_lmv = &llu->llu_lmv;
+                       lfsck->li_obj_dir = lfsck_object_get(llu->llu_obj);
+                       rc = lfsck_open_dir(env, lfsck, 0);
+                       if (rc == 0)
+                               rc = lfsck_master_dir_engine(env, lfsck);
+
+                       if (rc <= 0)
+                               RETURN(rc);
+               }
+
                lfsck->li_new_scanned++;
                lfsck->li_pos_current.lp_oit_cookie = iops->store(env, di);
                rc = iops->rec(env, di, (struct dt_rec *)fid, 0);
@@ -794,6 +933,13 @@ static int lfsck_master_oit_engine(const struct lu_env *env,
                                goto checkpoint;
                }
 
+               if (unlikely(!fid_is_sane(fid))) {
+                       CDEBUG(D_LFSCK, "%s: OIT scan find invalid FID "DFID
+                              ", skip it\n",
+                              lfsck_lfsck2name(lfsck), PFID(fid));
+                       goto checkpoint;
+               }
+
                if (fid_is_idif(fid)) {
                        __u32 idx1 = fid_idif_ost_idx(fid);
 
@@ -965,6 +1111,7 @@ int lfsck_master_engine(void *args)
        else
                rc = 1;
 
+       lfsck_pos_fill(env, lfsck, &lfsck->li_pos_checkpoint, false);
        CDEBUG(D_LFSCK, "LFSCK exit: oit_flags = %#x, dir_flags = %#x, "
               "oit_cookie = "LPU64", dir_cookie = "LPX64", parent = "DFID
               ", pid = %d, rc = %d\n", lfsck->li_args_oit, lfsck->li_args_dir,
@@ -975,9 +1122,8 @@ int lfsck_master_engine(void *args)
 
        if (!OBD_FAIL_CHECK(OBD_FAIL_LFSCK_CRASH))
                rc = lfsck_post(env, lfsck, rc);
-
-       if (lfsck->li_di_dir != NULL)
-               lfsck_close_dir(env, lfsck);
+       else
+               lfsck_close_dir(env, lfsck, rc);
 
 fini_oit:
        lfsck_di_oit_put(env, lfsck);
@@ -1131,7 +1277,7 @@ out:
 }
 
 /**
- * Notify the LFSCK event to the instatnces on remote servers.
+ * Notify the LFSCK event to the instances on remote servers.
  *
  * The LFSCK assistant thread notifies the LFSCK instances on other
  * servers (MDT/OST) about some events, such as start new scanning,
@@ -1177,8 +1323,7 @@ static int lfsck_assistant_notify_others(const struct lu_env *env,
                if (com->lc_type != LFSCK_TYPE_LAYOUT)
                        goto next;
 
-               lr->lr_valid = LSV_SPEED_LIMIT | LSV_ERROR_HANDLE | LSV_DRYRUN |
-                              LSV_ASYNC_WINDOWS | LSV_CREATE_OSTOBJ;
+               lr->lr_valid = LSV_SPEED_LIMIT | LSV_ERROR_HANDLE | LSV_DRYRUN;
                lr->lr_speed = bk->lb_speed_limit;
                lr->lr_version = bk->lb_version;
                lr->lr_param |= bk->lb_param;
@@ -1195,6 +1340,7 @@ static int lfsck_assistant_notify_others(const struct lu_env *env,
 
                        laia->laia_ltd = ltd;
                        ltd->ltd_layout_done = 0;
+                       ltd->ltd_synced_failures = 0;
                        rc = lfsck_async_request(env, ltd->ltd_exp, lr, set,
                                        lfsck_async_interpret_common,
                                        laia, LFSCK_NOTIFY);
@@ -1389,7 +1535,7 @@ again:
 
                        *gen = lad->lad_touch_gen;
                        list_move_tail(list, &lad->lad_mdt_list);
-                       if (ltd->ltd_namespace_failed)
+                       if (ltd->ltd_synced_failures)
                                continue;
 
                        atomic_inc(&ltd->ltd_ref);
@@ -1458,6 +1604,7 @@ int lfsck_assistant_engine(void *args)
        struct l_wait_info                 lwi     = { 0 };
        int                                rc      = 0;
        int                                rc1     = 0;
+       int                                rc2;
        ENTRY;
 
        CDEBUG(D_LFSCK, "%s: %s LFSCK assistant thread start\n",
@@ -1567,11 +1714,16 @@ int lfsck_assistant_engine(void *args)
                                com->lc_time_last_checkpoint +
                                cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
 
+                       CDEBUG(D_LFSCK, "%s: LFSCK assistant sync before "
+                              "the second-stage scaning\n",
+                              lfsck_lfsck2name(lfsck));
+
                        /* Flush async updates before handling orphan. */
-                       dt_sync(env, lfsck->li_next);
+                       rc2 = dt_sync(env, lfsck->li_next);
 
                        CDEBUG(D_LFSCK, "%s: LFSCK assistant phase2 "
-                              "scan start\n", lfsck_lfsck2name(lfsck));
+                              "scan start, synced: rc = %d\n",
+                              lfsck_lfsck2name(lfsck), rc2);
 
                        if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_NO_DOUBLESCAN))
                                GOTO(cleanup2, rc = 0);
@@ -1688,12 +1840,18 @@ cleanup2:
                rc = rc1;
        }
 
+       CDEBUG(D_LFSCK, "%s: LFSCK assistant sync before exit\n",
+              lfsck_lfsck2name(lfsck));
+
        /* Flush async updates before exit. */
-       dt_sync(env, lfsck->li_next);
+       rc2 = dt_sync(env, lfsck->li_next);
+
+       CDEBUG(D_LFSCK, "%s: LFSCK assistant synced before exit: rc = %d\n",
+              lfsck_lfsck2name(lfsck), rc2);
 
        /* Under force exit case, some requests may be just freed without
         * verification, those objects should be re-handled when next run.
-        * So not update the on-disk tracing file under such case. */
+        * So not update the on-disk trace file under such case. */
        if (lad->lad_in_double_scan) {
                if (!lad->lad_exit)
                        rc1 = lao->la_double_scan_result(env, com, rc);