Whamcloud - gitweb
LU-4788 lfsck: enable verification for remote object
[fs/lustre-release.git] / lustre / lfsck / lfsck_layout.c
index 884d0e1..bbb2ce9 100644 (file)
@@ -291,9 +291,9 @@ lfsck_layout_assistant_sync_failures_interpret(const struct lu_env *env,
  * fixing for the fake orphan.
  *
  * To avoid above trouble, when layout LFSCK finishes the first-stage scanning,
- * it will scan the bitmap for the ever failed OTs, and notify them that it has
- * ever missed some OST-object verification and should skip orphan handling for
- * all MDTs that are in layout LFSCK.
+ * it will scan the bitmap for the ever failed OSTs, and notify them that they
+ * have ever missed some OST-object verification and should skip the handling
+ * for orphan OST-objects on all MDTs that are in the layout LFSCK.
  *
  * \param[in] env      pointer to the thread context
  * \param[in] com      pointer to the lfsck component
@@ -821,7 +821,6 @@ static int lfsck_layout_load_bitmap(const struct lu_env *env,
        struct dt_object                *obj    = com->lc_obj;
        struct lfsck_assistant_data     *lad    = com->lc_data;
        struct lfsck_layout             *lo     = com->lc_file_ram;
-       const struct dt_body_operations *dbo    = obj->do_body_ops;
        cfs_bitmap_t                    *bitmap = lad->lad_bitmap;
        loff_t                           pos    = com->lc_file_size;
        ssize_t                          size;
@@ -862,9 +861,7 @@ static int lfsck_layout_load_bitmap(const struct lu_env *env,
        }
 
        size = (lo->ll_bitmap_size + 7) >> 3;
-       rc = dbo->dbo_read(env, obj,
-                          lfsck_buf_get(env, bitmap->data, size), &pos,
-                          BYPASS_CAPA);
+       rc = dt_read(env, obj, lfsck_buf_get(env, bitmap->data, size), &pos);
        if (rc == 0) {
                RETURN(-ENOENT);
        } else if (rc != size) {
@@ -904,14 +901,12 @@ static int lfsck_layout_load(const struct lu_env *env,
                             struct lfsck_component *com)
 {
        struct lfsck_layout             *lo     = com->lc_file_ram;
-       const struct dt_body_operations *dbo    = com->lc_obj->do_body_ops;
        ssize_t                          size   = com->lc_file_size;
        loff_t                           pos    = 0;
        int                              rc;
 
-       rc = dbo->dbo_read(env, com->lc_obj,
-                          lfsck_buf_get(env, com->lc_file_disk, size), &pos,
-                          BYPASS_CAPA);
+       rc = dt_read(env, com->lc_obj,
+                    lfsck_buf_get(env, com->lc_file_disk, size), &pos);
        if (rc == 0) {
                return -ENOENT;
        } else if (rc < 0) {
@@ -1044,14 +1039,14 @@ static int fid_is_for_ostobj(const struct lu_env *env, struct dt_device *dt,
                             struct dt_object *obj, const struct lu_fid *fid)
 {
        struct seq_server_site  *ss     = lu_site2seq(dt->dd_lu_dev.ld_site);
-       struct lu_seq_range      range  = { 0 };
+       struct lu_seq_range     *range  = &lfsck_env_info(env)->lti_range;
        struct lustre_mdt_attrs *lma;
        int                      rc;
 
-       fld_range_set_any(&range);
-       rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(fid), &range);
+       fld_range_set_any(range);
+       rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(fid), range);
        if (rc == 0) {
-               if (fld_range_is_ost(&range))
+               if (fld_range_is_ost(range))
                        return 1;
 
                return 0;
@@ -1403,7 +1398,6 @@ static int lfsck_layout_double_scan_result(const struct lu_env *env,
        lo->ll_objs_checked_phase2 += com->lc_new_checked;
 
        if (rc > 0) {
-               com->lc_journal = 0;
                if (lo->ll_flags & LF_INCOMPLETE) {
                        lo->ll_status = LS_PARTIAL;
                } else {
@@ -2133,7 +2127,6 @@ static int lfsck_layout_conflict_create(const struct lu_env *env,
        struct lfsck_thread_info *info          = lfsck_env_info(env);
        struct lu_fid            *cfid2         = &info->lti_fid2;
        struct ost_id            *oi            = &info->lti_oi;
-       char                     *infix         = info->lti_tmpbuf;
        struct lov_mds_md_v1     *lmm           = ea_buf->lb_buf;
        struct dt_device         *dev           = com->lc_lfsck->li_bottom;
        struct thandle           *th            = NULL;
@@ -2165,10 +2158,11 @@ static int lfsck_layout_conflict_create(const struct lu_env *env,
                lfsck_ibits_unlock(&lh, LCK_EX);
 
                fid_zero(&rec->lor_fid);
-               snprintf(infix, LFSCK_TMPBUF_LEN, "-"DFID"-%x",
-                        PFID(lu_object_fid(&parent->do_lu)), ea_off);
+               snprintf(info->lti_tmpbuf, sizeof(info->lti_tmpbuf),
+                        "-"DFID"-%x", PFID(lu_object_fid(&parent->do_lu)),
+                        ea_off);
                rc = lfsck_layout_recreate_parent(env, com, ltd, rec, cfid,
-                                                 infix, "C", ea_off);
+                                               info->lti_tmpbuf, "C", ea_off);
 
                RETURN(rc);
        }
@@ -2582,8 +2576,7 @@ static int lfsck_layout_scan_orphan(const struct lu_env *env,
               "scanning for OST%04x\n",
               lfsck_lfsck2name(lfsck), ltd->ltd_index);
 
-       if (lad->lad_incomplete &&
-           cfs_bitmap_check(lad->lad_bitmap, ltd->ltd_index)) {
+       if (cfs_bitmap_check(lad->lad_bitmap, ltd->ltd_index)) {
                CDEBUG(D_LFSCK, "%s: layout LFSCK assistant skip the orphan "
                       "scanning for OST%04x\n",
                       lfsck_lfsck2name(lfsck), ltd->ltd_index);
@@ -3352,6 +3345,9 @@ static int lfsck_layout_assistant_handler_p2(const struct lu_env *env,
        int                              rc     = 0;
        ENTRY;
 
+       CDEBUG(D_LFSCK, "%s: layout LFSCK phase2 scan start\n",
+              lfsck_lfsck2name(lfsck));
+
        spin_lock(&ltds->ltd_lock);
        while (!list_empty(&lad->lad_ost_phase2_list)) {
                ltd = list_entry(lad->lad_ost_phase2_list.next,
@@ -3377,6 +3373,9 @@ static int lfsck_layout_assistant_handler_p2(const struct lu_env *env,
                rc = 0;
        spin_unlock(&ltds->ltd_lock);
 
+       CDEBUG(D_LFSCK, "%s: layout LFSCK phase2 scan stop: rc = %d\n",
+              lfsck_lfsck2name(lfsck), rc);
+
        RETURN(rc);
 }
 
@@ -3733,22 +3732,22 @@ static int lfsck_layout_slave_check_pairs(const struct lu_env *env,
        struct obd_export        *exp    = NULL;
        struct ptlrpc_request    *req    = NULL;
        struct lfsck_request     *lr;
-       struct lu_seq_range       range  = { 0 };
+       struct lu_seq_range      *range  = &lfsck_env_info(env)->lti_range;
        int                       rc     = 0;
        ENTRY;
 
        if (unlikely(fid_is_idif(pfid)))
                RETURN(1);
 
-       fld_range_set_any(&range);
-       rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(pfid), &range);
+       fld_range_set_any(range);
+       rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(pfid), range);
        if (rc != 0)
                RETURN(rc == -ENOENT ? 1 : rc);
 
-       if (unlikely(!fld_range_is_mdt(&range)))
+       if (unlikely(!fld_range_is_mdt(range)))
                RETURN(1);
 
-       exp = lustre_find_lwp_by_index(obd->obd_name, range.lsr_index);
+       exp = lustre_find_lwp_by_index(obd->obd_name, range->lsr_index);
        if (unlikely(exp == NULL))
                RETURN(1);
 
@@ -3979,7 +3978,7 @@ static int lfsck_layout_prep(const struct lu_env *env,
        if (lo->ll_status == LS_COMPLETED ||
            lo->ll_status == LS_PARTIAL ||
            /* To handle orphan, must scan from the beginning. */
-           (start != NULL && start->ls_flags & LPF_ORPHAN)) {
+           (start != NULL && start->ls_flags & LPF_OST_ORPHAN)) {
                int rc;
 
                rc = lfsck_layout_reset(env, com, false);
@@ -4060,7 +4059,7 @@ static int lfsck_layout_slave_prep(const struct lu_env *env,
                return 0;
 
        rc = lfsck_layout_llst_add(llsd, lsp->lsp_index);
-       if (rc == 0 && start != NULL && start->ls_flags & LPF_ORPHAN) {
+       if (rc == 0 && start != NULL && start->ls_flags & LPF_OST_ORPHAN) {
                LASSERT(!llsd->llsd_rbtree_valid);
 
                write_lock(&llsd->llsd_rb_lock);
@@ -5275,7 +5274,7 @@ static int lfsck_layout_slave_join(const struct lu_env *env,
        int                               rc    = 0;
        ENTRY;
 
-       if (start == NULL || !(start->ls_flags & LPF_ORPHAN))
+       if (start == NULL || !(start->ls_flags & LPF_OST_ORPHAN))
                RETURN(0);
 
        if (!lsp->lsp_index_valid)
@@ -5507,7 +5506,7 @@ static int lfsck_fid_match_idx(const struct lu_env *env,
 {
        struct seq_server_site  *ss;
        struct lu_server_fld    *sf;
-       struct lu_seq_range      range  = { 0 };
+       struct lu_seq_range     *range = &lfsck_env_info(env)->lti_range;
        int                      rc;
 
        /* All abnormal cases will be returned to MDT0. */
@@ -5525,15 +5524,15 @@ static int lfsck_fid_match_idx(const struct lu_env *env,
        sf = ss->ss_server_fld;
        LASSERT(sf != NULL);
 
-       fld_range_set_any(&range);
-       rc = fld_server_lookup(env, sf, fid_seq(fid), &range);
+       fld_range_set_any(range);
+       rc = fld_server_lookup(env, sf, fid_seq(fid), range);
        if (rc != 0)
                return rc;
 
-       if (!fld_range_is_mdt(&range))
+       if (!fld_range_is_mdt(range))
                return -EINVAL;
 
-       if (range.lsr_index == idx)
+       if (range->lsr_index == idx)
                return 1;
 
        return 0;