Commit b09b533b authored by Mikhail Pershin's avatar Mikhail Pershin Committed by Oleg Drokin
Browse files

LU-13599 mdt: fix mti_big_lmm buffer usage

The mti_big_lmm buffer can be used just as temporary buffer
in some cases. It should drop mti_big_lmm_used flag after
that to avoid assertion in mdt_big_attr_get().

This fix is extracted from bigger patch of LU-11025 in
master branch.

Lustre-change: https://review.whamcloud.com/37284
Lustre-commit: a336d7c7

Signed-off-by: default avatarMikhail Pershin <mpershin@whamcloud.com>
Change-Id: I3718d6c413ef1d5f8242e548868602ef6476006e
Reviewed-on: https://review.whamcloud.com/39521

Tested-by: default avatarjenkins <devops@whamcloud.com>
Tested-by: default avatarMaloo <maloo@whamcloud.com>
Reviewed-by: default avatarStephane Thiell <sthiell@stanford.edu>
Reviewed-by: default avatarAndreas Dilger <adilger@whamcloud.com>
Reviewed-by: default avatarLai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: default avatarOleg Drokin <green@whamcloud.com>
parent 3f3c839f
......@@ -921,8 +921,8 @@ int mdt_big_xattr_get(struct mdt_thread_info *info, struct mdt_object *o,
RETURN(rc);
}
int mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
struct md_attr *ma, const char *name)
int __mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
struct md_attr *ma, const char *name)
{
struct md_object *next = mdt_object_child(o);
struct lu_buf *buf = &info->mti_buf;
......@@ -998,6 +998,40 @@ got:
return rc;
}
int mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
struct md_attr *ma, const char *name)
{
int rc;
if (!info->mti_big_lmm) {
OBD_ALLOC(info->mti_big_lmm, PAGE_SIZE);
if (!info->mti_big_lmm)
return -ENOMEM;
info->mti_big_lmmsize = PAGE_SIZE;
}
if (strcmp(name, XATTR_NAME_LOV) == 0) {
ma->ma_lmm = info->mti_big_lmm;
ma->ma_lmm_size = info->mti_big_lmmsize;
ma->ma_valid &= ~MA_LOV;
} else if (strcmp(name, XATTR_NAME_LMV) == 0) {
ma->ma_lmv = info->mti_big_lmm;
ma->ma_lmv_size = info->mti_big_lmmsize;
ma->ma_valid &= ~MA_LMV;
} else {
LBUG();
}
LASSERT(!info->mti_big_lmm_used);
rc = __mdt_stripe_get(info, o, ma, name);
/* since big_lmm is always used here, clear 'used' flag to avoid
* assertion in mdt_big_xattr_get().
*/
info->mti_big_lmm_used = 0;
return rc;
}
int mdt_attr_get_pfid(struct mdt_thread_info *info, struct mdt_object *o,
struct lu_fid *pfid)
{
......@@ -1082,19 +1116,19 @@ int mdt_attr_get_complex(struct mdt_thread_info *info,
}
if (need & MA_LOV && (S_ISREG(mode) || S_ISDIR(mode))) {
rc = mdt_stripe_get(info, o, ma, XATTR_NAME_LOV);
rc = __mdt_stripe_get(info, o, ma, XATTR_NAME_LOV);
if (rc)
GOTO(out, rc);
}
if (need & MA_LMV && S_ISDIR(mode)) {
rc = mdt_stripe_get(info, o, ma, XATTR_NAME_LMV);
rc = __mdt_stripe_get(info, o, ma, XATTR_NAME_LMV);
if (rc != 0)
GOTO(out, rc);
}
if (need & MA_LMV_DEF && S_ISDIR(mode)) {
rc = mdt_stripe_get(info, o, ma, XATTR_NAME_DEFAULT_LMV);
rc = __mdt_stripe_get(info, o, ma, XATTR_NAME_DEFAULT_LMV);
if (rc != 0)
GOTO(out, rc);
}
......
......@@ -835,6 +835,8 @@ int mdt_attr_get_complex(struct mdt_thread_info *info,
struct mdt_object *o, struct md_attr *ma);
int mdt_big_xattr_get(struct mdt_thread_info *info, struct mdt_object *o,
const char *name);
int __mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
struct md_attr *ma, const char *name);
int mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
struct md_attr *ma, const char *name);
int mdt_attr_get_pfid(struct mdt_thread_info *info, struct mdt_object *o,
......
......@@ -1739,9 +1739,6 @@ static int mdt_migrate_object_lock(struct mdt_thread_info *info,
if (S_ISDIR(lu_object_attr(&obj->mot_obj))) {
struct md_attr *ma = &info->mti_attr;
ma->ma_lmv = info->mti_big_lmm;
ma->ma_lmv_size = info->mti_big_lmmsize;
ma->ma_valid = 0;
rc = mdt_stripe_get(info, obj, ma, XATTR_NAME_LMV);
if (rc) {
mdt_object_unlock(info, obj, lh, rc);
......@@ -2011,16 +2008,6 @@ static int mdt_reint_migrate(struct mdt_thread_info *info,
if (IS_ERR(pobj))
GOTO(unlock_rename, rc = PTR_ERR(pobj));
if (unlikely(!info->mti_big_lmm)) {
info->mti_big_lmmsize = lmv_mds_md_size(64, LMV_MAGIC);
OBD_ALLOC(info->mti_big_lmm, info->mti_big_lmmsize);
if (!info->mti_big_lmm)
GOTO(put_parent, rc = -ENOMEM);
}
ma->ma_lmv = info->mti_big_lmm;
ma->ma_lmv_size = info->mti_big_lmmsize;
ma->ma_valid = 0;
rc = mdt_stripe_get(info, pobj, ma, XATTR_NAME_LMV);
if (rc)
GOTO(put_parent, rc);
......@@ -2056,9 +2043,6 @@ static int mdt_reint_migrate(struct mdt_thread_info *info,
/* TODO: DoM migration is not supported yet */
if (S_ISREG(lu_object_attr(&sobj->mot_obj))) {
ma->ma_lmm = info->mti_big_lmm;
ma->ma_lmm_size = info->mti_big_lmmsize;
ma->ma_valid = 0;
rc = mdt_stripe_get(info, sobj, ma, XATTR_NAME_LOV);
if (rc)
GOTO(put_source, rc);
......@@ -2226,10 +2210,6 @@ static int mdt_rename_determine_lock_order(struct mdt_thread_info *info,
return 0;
/* check whether sobj and tobj are sibling stripes */
ma->ma_need = MA_LMV;
ma->ma_valid = 0;
ma->ma_lmv = (union lmv_mds_md *)info->mti_xattr_buf;
ma->ma_lmv_size = sizeof(info->mti_xattr_buf);
rc = mdt_stripe_get(info, sobj, ma, XATTR_NAME_LMV);
if (rc)
return rc;
......
......@@ -345,14 +345,6 @@ static int mdt_dir_layout_shrink(struct mdt_thread_info *info)
mdt->mdt_enable_remote_dir_gid != -1)
RETURN(-EPERM);
/* mti_big_lmm is used to save LMV, but it may be uninitialized. */
if (unlikely(!info->mti_big_lmm)) {
info->mti_big_lmmsize = lmv_mds_md_size(64, LMV_MAGIC);
OBD_ALLOC(info->mti_big_lmm, info->mti_big_lmmsize);
if (!info->mti_big_lmm)
RETURN(-ENOMEM);
}
obj = mdt_object_find(env, mdt, rr->rr_fid1);
if (IS_ERR(obj))
RETURN(PTR_ERR(obj));
......@@ -396,9 +388,6 @@ static int mdt_dir_layout_shrink(struct mdt_thread_info *info)
if (rc)
GOTO(unlock_pobj, rc);
ma->ma_lmv = info->mti_big_lmm;
ma->ma_lmv_size = info->mti_big_lmmsize;
ma->ma_valid = 0;
rc = mdt_stripe_get(info, obj, ma, XATTR_NAME_LMV);
if (rc)
GOTO(unlock_obj, rc);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment