Whamcloud - gitweb
LU-18051 ofd: Initialize the buffer for lvbo_update properly 08/55808/2
authorYang Sheng <ys@whamcloud.com>
Fri, 19 Jul 2024 14:17:00 +0000 (22:17 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Sep 2024 05:52:48 +0000 (05:52 +0000)
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>
lustre/include/lu_object.h
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lvb.c
lustre/ofd/ofd_internal.h

index 30b2244..8e3040d 100644 (file)
@@ -1154,20 +1154,30 @@ void lu_env_fini(struct lu_env *env);
 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);
index 5730842..6de73df 100644 (file)
@@ -616,7 +616,7 @@ extern struct lu_context_key mdt_thread_key;
 
 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 {
index cf5e6a9..7748bdc 100644 (file)
@@ -171,16 +171,9 @@ int mdt_dom_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock,
                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);
@@ -347,15 +340,9 @@ static int mdt_lvbo_fill(struct ldlm_lock *lock,
                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.
index a604347..8670136 100644 (file)
@@ -440,7 +440,7 @@ int ofd_intent_policy(const struct lu_env *env, struct ldlm_namespace *ns,
 
 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,