From: wangdi Date: Fri, 29 Sep 2006 05:56:39 +0000 (+0000) Subject: Branch: b_new_cmd X-Git-Tag: v1_8_0_110~486^2~774 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=780cb7c533b873035763d7de39ad3f0c9269bf9a;p=fs%2Flustre-release.git Branch: b_new_cmd some cleanup and fixes for split after landing env stuff --- diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 9ab3360..a0c2819 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -349,12 +349,21 @@ static void cmm_key_fini(const struct lu_context *ctx, 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); diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h index f5b9876..b60c86e 100644 --- a/lustre/cmm/cmm_internal.h +++ b/lustre/cmm/cmm_internal.h @@ -93,6 +93,7 @@ struct cmr_object { 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) @@ -117,6 +118,7 @@ static inline struct md_object *cmm2child_obj(struct cmm_object *o) 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, diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 799a6ee..aad8e05 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -36,8 +36,6 @@ #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) @@ -458,7 +456,7 @@ static int __cmm_mode_get(const struct lu_env *env, struct md_device *md, 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; @@ -532,7 +530,7 @@ static int cmm_is_subdir(const struct lu_env *env, struct md_object *mo, 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); @@ -779,7 +777,7 @@ static int cmr_create(const struct lu_env *env, struct md_object *mo_p, 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; diff --git a/lustre/cmm/cmm_split.c b/lustre/cmm/cmm_split.c index 3ac1c21..051e2a0 100644 --- a/lustre/cmm/cmm_split.c +++ b/lustre/cmm/cmm_split.c @@ -398,10 +398,22 @@ free_rdpg: 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; @@ -438,10 +450,9 @@ int cml_try_to_split(const struct lu_env *env, struct md_object *mo) 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)));