From 05cfe91c2714a77f5ad3de4a7e58e20b6df17b83 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Wed, 21 Feb 2018 03:25:55 +0800 Subject: [PATCH] LU-9437 lfsck: handle LMV EA for migrating directory 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 Change-Id: Ic43853fb5ca058042fafa0f6c81fa99d4b8d8897 Reviewed-on: https://review.whamcloud.com/31266 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: John L. Hammond --- lustre/lfsck/lfsck_striped_dir.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lustre/lfsck/lfsck_striped_dir.c b/lustre/lfsck/lfsck_striped_dir.c index 7457f2f..a336d77 100644 --- a/lustre/lfsck/lfsck_striped_dir.c +++ b/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; -- 1.8.3.1