Whamcloud - gitweb
LU-9437 lfsck: handle LMV EA for migrating directory 66/31266/5
authorFan Yong <fan.yong@intel.com>
Tue, 20 Feb 2018 19:25:55 +0000 (03:25 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 3 Mar 2018 04:27:55 +0000 (04:27 +0000)
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. The lfsck_read_stripe_lmv() logic need to
handle such case properly.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Ic43853fb5ca058042fafa0f6c81fa99d4b8d8897
Reviewed-on: https://review.whamcloud.com/31266
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/lfsck/lfsck_striped_dir.c

index 7457f2f..a336d77 100644 (file)
@@ -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;