Whamcloud - gitweb
LU-11429 mdt: rename mdt_remote_permission
[fs/lustre-release.git] / lustre / lfsck / lfsck_striped_dir.c
index 25f5cb2..33c57d7 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2014, 2015, Intel Corporation.
+ * Copyright (c) 2014, 2017, Intel Corporation.
  */
 /*
  * lustre/lfsck/lfsck_striped_dir.c
@@ -839,11 +839,27 @@ out:
 int lfsck_read_stripe_lmv(const struct lu_env *env, struct dt_object *obj,
                          struct lmv_mds_md_v1 *lmv)
 {
+       struct lfsck_thread_info *info = lfsck_env_info(env);
+       struct lu_buf *buf = &info->lti_buf;
+       int size = sizeof(*lmv) + sizeof(struct lu_fid) * 2;
        int rc;
 
        dt_read_lock(env, obj, 0);
-       rc = dt_xattr_get(env, obj, lfsck_buf_get(env, lmv, sizeof(*lmv)),
-                         XATTR_NAME_LMV);
+       buf->lb_buf = lmv;
+       buf->lb_len = sizeof(*lmv);
+       rc = dt_xattr_get(env, obj, buf, XATTR_NAME_LMV);
+       if (unlikely(rc == -ERANGE)) {
+               buf = &info->lti_big_buf;
+               lu_buf_check_and_alloc(buf, size);
+               rc = dt_xattr_get(env, obj, buf, XATTR_NAME_LMV);
+               /* For the in-migration directory, its LMV EA contains
+                * not only the LMV header, but also the FIDs for both
+                * source and target. So the LMV EA size is larger. */
+               if (rc == size) {
+                       rc = sizeof(*lmv);
+                       memcpy(lmv, buf->lb_buf, rc);
+               }
+       }
        dt_read_unlock(env, obj);
        if (rc != sizeof(*lmv))
                return rc > 0 ? -EINVAL : rc;
@@ -1403,6 +1419,7 @@ static int lfsck_namespace_set_lmv_master(const struct lu_env *env,
 
        lmv3->lmv_magic = LMV_MAGIC;
        lmv3->lmv_master_mdt_index = pidx;
+       lmv3->lmv_layout_version++;
 
        if (flags & LEF_SET_LMV_ALL) {
                rc = lfsck_allow_regenerate_master_lmv(env, com, obj,
@@ -1702,6 +1719,8 @@ int lfsck_namespace_verify_stripe_slave(const struct lu_env *env,
                GOTO(out, rc);
        }
 
+       CFS_FAIL_TIMEOUT(OBD_FAIL_LFSCK_ENGINE_DELAY, cfs_fail_val);
+
        parent = lfsck_object_find_bottom(env, lfsck, pfid);
        if (IS_ERR(parent)) {
                rc = lfsck_namespace_trace_update(env, com, cfid,
@@ -1912,7 +1931,6 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
                const struct lu_fid *cfid = &lslr->lslr_fid;
                const struct lu_name *cname;
                struct linkea_data ldata = { NULL };
-               int len;
                int rc1 = 0;
                bool repair_linkea = false;
                bool repair_lmvea = false;
@@ -1927,11 +1945,12 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
                if (fid_is_zero(cfid))
                        continue;
 
-               len = snprintf(info->lti_tmpbuf, sizeof(info->lti_tmpbuf),
-                              DFID":%u", PFID(cfid), i);
-               cname = lfsck_name_get_const(env, info->lti_tmpbuf, len);
-               memcpy(lnr->lnr_name, info->lti_tmpbuf, len);
-
+               lnr->lnr_fid = *cfid;
+               lnr->lnr_namelen = snprintf(lnr->lnr_name,
+                                           lnr->lnr_size - sizeof(*lnr),
+                                           DFID":%u", PFID(cfid), i);
+               cname = lfsck_name_get_const(env, lnr->lnr_name,
+                                            lnr->lnr_namelen);
                obj = lfsck_object_find_bottom(env, lfsck, cfid);
                if (IS_ERR(obj)) {
                        if (dir == NULL) {
@@ -2162,7 +2181,7 @@ next:
                      "%d "DFID" of the striped directory "DFID" with "
                      "dangling %s/%s, rename %s/%s, llinkea %s/%s, "
                      "repair_lmvea %s/%s: rc = %d\n", lfsck_lfsck2name(lfsck),
-                     i, PFID(cfid), PFID(&lnr->lnr_fid),
+                     i, PFID(cfid), PFID(pfid),
                      create ? "yes" : "no", create_repaired ? "yes" : "no",
                      rename ? "yes" : "no", rename_repaired ? "yes" : "no",
                      repair_linkea ? "yes" : "no",