OBD_FREE_PTR(info);
}
-struct lu_context_key cmm_thread_key = {
+static struct lu_context_key cmm_thread_key = {
.lct_tags = LCT_MD_THREAD,
.lct_init = cmm_key_init,
.lct_fini = cmm_key_fini
};
+struct cmm_thread_info *cmm_env_info(const struct lu_env *env)
+{
+ struct cmm_thread_info *info;
+
+ info = lu_context_key_get(&env->le_ctx, &cmm_thread_key);
+ LASSERT(info != NULL);
+ return info;
+}
+
static int cmm_type_init(struct lu_device_type *t)
{
return lu_context_key_register(&cmm_thread_key);
struct cmm_thread_info {
struct md_attr cmi_ma;
+ struct lu_buf cmi_buf;
};
static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
return (o ? lu2md(lu_object_next(&o->cmo_obj.mo_lu)) : NULL);
}
+struct cmm_thread_info *cmm_env_info(const struct lu_env *env);
/* cmm_object.c */
struct lu_object *cmm_object_alloc(const struct lu_env *env,
const struct lu_object_header *hdr,
#include "cmm_internal.h"
#include "mdc_internal.h"
-extern struct lu_context_key cmm_thread_key;
-
static int cmm_fld_lookup(struct cmm_device *cm,
const struct lu_fid *fid, mdsno_t *mds,
const struct lu_env *env)
if (IS_ERR(mo_s))
RETURN(PTR_ERR(mo_s));
- cmi = lu_context_key_get(&env->le_ctx, &cmm_thread_key);
+ cmi = cmm_env_info(env);
LASSERT(cmi);
tmp_ma = &cmi->cmi_ma;
tmp_ma->ma_need = MA_INODE;
int rc;
ENTRY;
- cmi = lu_context_key_get(&env->le_ctx, &cmm_thread_key);
+ cmi = cmm_env_info(env);
rc = __cmm_mode_get(env, md_obj2dev(mo), fid, &cmi->cmi_ma);
if (rc)
RETURN(rc);
ENTRY;
/* check the SGID attr */
- cmi = lu_context_key_get(&env->le_ctx, &cmm_thread_key);
+ cmi = cmm_env_info(env);
LASSERT(cmi);
tmp_ma = &cmi->cmi_ma;
tmp_ma->ma_need = MA_INODE;
RETURN(rc);
}
+static struct lu_buf *cmm_buf_get(const struct lu_env *env, void *area,
+ ssize_t len)
+{
+ struct lu_buf *buf;
+
+ buf = &cmm_env_info(env)->cmi_buf;
+ buf->lb_buf = area;
+ buf->lb_len = len;
+ return buf;
+}
+
int cml_try_to_split(const struct lu_env *env, struct md_object *mo)
{
struct cmm_device *cmm = cmm_obj2dev(md2cmm_obj(mo));
struct md_attr *ma;
+ struct lu_buf *buf;
int rc = 0;
ENTRY;
if (rc)
GOTO(cleanup, ma);
+ buf = cmm_buf_get(env, ma->ma_lmv, ma->ma_lmv_size);
/* step4: set mea to the master object */
- rc = mo_xattr_set(env, md_object_next(mo), ma->ma_lmv,
- ma->ma_lmv_size, MDS_LMV_MD_NAME, 0);
-
+ rc = mo_xattr_set(env, md_object_next(mo), buf, MDS_LMV_MD_NAME, 0);
if (rc == -ERESTART)
CWARN("Dir"DFID" has been split \n",
PFID(lu_object_fid(&mo->mo_lu)));