The lu_env maybe used in different target than it initialized.
So we should refill it by tags to over come the issue while
MDT & OST work in same node.
Signed-off-by: Yang Sheng <ys@whamcloud.com>
Change-Id: Ie7706dc9df2dd6fdbbac801fb266a87d9ed22026
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55808
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
int lu_env_refill(struct lu_env *env);
int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags, __u32 stags);
-static inline void *lu_env_info(const struct lu_env *env,
- const struct lu_context_key *key)
+static inline void *__lu_env_info(const struct lu_env *env,
+ const struct lu_context_key *key, int tags)
{
void *info;
info = lu_context_key_get(&env->le_ctx, key);
if (!info) {
- if (!lu_env_refill((struct lu_env *)env))
+ int rc;
+
+ if (tags)
+ rc = lu_env_refill_by_tags((struct lu_env *)env,
+ key->lct_tags, 0);
+ else
+ rc = lu_env_refill((struct lu_env *)env);
+ if (!rc)
info = lu_context_key_get(&env->le_ctx, key);
}
LASSERT(info);
return info;
}
+#define lu_env_info(env, key) __lu_env_info(env, key, 0)
+#define lu_env_info_get(env, key) __lu_env_info(env, key, 1)
+
struct lu_env *lu_env_find(void);
int lu_env_add(struct lu_env *env);
int lu_env_add_task(struct lu_env *env, struct task_struct *task);
static inline struct mdt_thread_info *mdt_th_info(const struct lu_env *env)
{
- return lu_env_info(env, &mdt_thread_key);
+ return lu_env_info_get(env, &mdt_thread_key);
}
struct cdt_req_progress {
RETURN(-ENOENT);
LASSERT(env);
- info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- if (!info) {
- rc = lu_env_refill_by_tags((struct lu_env *)env,
- LCT_MD_THREAD, 0);
- if (rc)
- GOTO(out_env, rc);
- info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- if (!info)
- GOTO(out_env, rc = -ENOMEM);
- }
+ info = mdt_th_info(env);
+ if (!info)
+ GOTO(out_env, rc = -ENOMEM);
fid = &info->mti_tmp_fid2;
fid_extract_from_res_name(fid, &res->lr_name);
GOTO(out, rc);
}
- info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- if (!info) {
- rc = lu_env_refill_by_tags(env, LCT_MD_THREAD, 0);
- if (rc)
- GOTO(out, rc);
- info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- if (!info)
- GOTO(out, rc = -ENOMEM);
- }
+ info = mdt_th_info(env);
+ if (!info)
+ GOTO(out, rc = -ENOMEM);
/* DOM LVB is used by glimpse and IO completion when
* DoM bits is always alone.
static inline struct ofd_thread_info *ofd_info(const struct lu_env *env)
{
- return lu_env_info(env, &ofd_thread_key);
+ return lu_env_info_get(env, &ofd_thread_key);
}
static inline struct ofd_thread_info *ofd_info_init(const struct lu_env *env,