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)
+{
+ void *info;
+ info = lu_context_key_get(&env->le_ctx, key);
+ if (!info) {
+ if (!lu_env_refill((struct lu_env *)env))
+ info = lu_context_key_get(&env->le_ctx, key);
+ }
+ LASSERT(info);
+ return info;
+}
+
struct lu_env *lu_env_find(void);
int lu_env_add(struct lu_env *env);
void lu_env_remove(struct lu_env *env);
(void)handler(req);
lu_context_exit(&thread->t_env->le_ctx);
+ req->rq_svc_thread->t_env->le_ses = NULL;
+
/* don't reset timer for final stage */
if (!exp_finished(req->rq_export)) {
time_t to = obd_timeout;
struct mdd_thread_info *mdd_env_info(const struct lu_env *env)
{
- struct mdd_thread_info *info;
-
- lu_env_refill((struct lu_env *)env);
- info = lu_context_key_get(&env->le_ctx, &mdd_thread_key);
- LASSERT(info != NULL);
- return info;
+ return lu_env_info(env, &mdd_thread_key);
}
struct lu_buf *mdd_buf_get(const struct lu_env *env, void *area, ssize_t len)
static inline struct mdt_thread_info *mdt_th_info(const struct lu_env *env)
{
- struct mdt_thread_info *mti;
-
- lu_env_refill((void *)env);
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(mti);
- return mti;
+ return lu_env_info(env, &mdt_thread_key);
}
struct cdt_req_progress {
static inline struct mgs_thread_info *mgs_env_info(const struct lu_env *env)
{
- struct mgs_thread_info *info;
- int rc;
-
- info = lu_context_key_get(&env->le_ctx, &mgs_thread_key);
- if (info == NULL) {
- rc = lu_env_refill((struct lu_env *)env);
- if (rc != 0)
- return ERR_PTR(rc);
- info = lu_context_key_get(&env->le_ctx, &mgs_thread_key);
- }
- LASSERT(info != NULL);
- return info;
+ return lu_env_info(env, &mgs_thread_key);
}
extern const struct lu_device_operations mgs_lu_ops;
static inline struct ofd_thread_info *ofd_info(const struct lu_env *env)
{
- struct ofd_thread_info *info;
-
- lu_env_refill((void *)env);
- info = lu_context_key_get(&env->le_ctx, &ofd_thread_key);
- LASSERT(info);
- return info;
+ return lu_env_info(env, &ofd_thread_key);
}
static inline struct ofd_thread_info *ofd_info_init(const struct lu_env *env,
static inline struct osp_thread_info *osp_env_info(const struct lu_env *env)
{
- struct osp_thread_info *info;
-
- info = lu_context_key_get(&env->le_ctx, &osp_thread_key);
- if (info == NULL) {
- lu_env_refill((struct lu_env *)env);
- info = lu_context_key_get(&env->le_ctx, &osp_thread_key);
- }
- LASSERT(info);
- return info;
+ return lu_env_info(env, &osp_thread_key);
}
struct osp_txn_info {
static inline
struct lquota_thread_info *lquota_info(const struct lu_env *env)
{
- struct lquota_thread_info *info;
-
- info = lu_context_key_get(&env->le_ctx, &lquota_thread_key);
- if (info == NULL) {
- lu_env_refill((struct lu_env *)env);
- info = lu_context_key_get(&env->le_ctx, &lquota_thread_key);
- }
- LASSERT(info);
- return info;
+ return lu_env_info(env, &lquota_thread_key);
}
#define req_is_acq(flags) ((flags & QUOTA_DQACQ_FL_ACQ) != 0)
static inline
struct qmt_thread_info *qmt_info(const struct lu_env *env)
{
- struct qmt_thread_info *info;
-
- info = lu_context_key_get(&env->le_ctx, &qmt_thread_key);
- if (info == NULL) {
- lu_env_refill((struct lu_env *)env);
- info = lu_context_key_get(&env->le_ctx, &qmt_thread_key);
- }
- LASSERT(info);
- return info;
+ return lu_env_info(env, &qmt_thread_key);
}
/* helper routine to convert a lu_device into a qmt_device */
static inline
struct qsd_thread_info *qsd_info(const struct lu_env *env)
{
- struct qsd_thread_info *info;
-
- info = lu_context_key_get(&env->le_ctx, &qsd_thread_key);
- if (info == NULL) {
- lu_env_refill((struct lu_env *)env);
- info = lu_context_key_get(&env->le_ctx, &qsd_thread_key);
- }
- LASSERT(info);
- return info;
+ return lu_env_info(env, &qsd_thread_key);
}
/* helper function to check whether a given quota type is enabled */