Commit 2040144a authored by Andriy Skulysh's avatar Andriy Skulysh Committed by Oleg Drokin
Browse files

LU-10949 mdt: lost reference on mdt_md_root

mdt_remote_object_lock_try() drops object
reference in case of an error but if the
request was sent to a server it is decreased
again via failed_lock_cleanup()

Add ldlm_created_callback. It is called after
lock creation, so we can safely add a reference
to l_ast_data and drop it only in BL AST handler.

Lustre-commit: b2368774

Cray-bug-id: LUS-7013
Signed-off-by: default avatarLai Siyao <>
Signed-off-by: default avatarAndriy Skulysh <>
Reviewed-by: default avatarAlexandr Boyko <>
Reviewed-by: default avatarVitaly Fertman <>
Reviewed-by: default avatarMike Pershin <>
Reviewed-by: default avatarLai Siyao <>
Reviewed-by: default avatarOleg Drokin <>
Change-Id: I49c946278f379390634642370d15c7fe89441d86

Tested-by: default avatarjenkins <>
Tested-by: default avatarMaloo <>
parent dcbb023c
......@@ -592,6 +592,9 @@ typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, __u64 flags,
/** Type for glimpse callback function of a lock. */
typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);
/** Type for created callback function of a lock. */
typedef void (*ldlm_created_callback)(struct ldlm_lock *lock);
/** Work list for sending GL ASTs to multiple locks. */
struct ldlm_glimpse_work {
struct ldlm_lock *gl_lock; /* lock to glimpse */
......@@ -1197,6 +1200,7 @@ struct ldlm_enqueue_info {
void *ei_cb_local_bl; /** blocking local lock callback */
void *ei_cb_cp; /** lock completion callback */
void *ei_cb_gl; /** lock glimpse callback */
ldlm_created_callback ei_cb_created; /** lock created callback */
void *ei_cbdata; /** Data to be passed into callbacks. */
void *ei_namespace; /** lock namespace **/
u64 ei_inodebits; /** lock inode bits **/
......@@ -944,6 +944,10 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
lvb_len, lvb_type);
if (IS_ERR(lock))
if (einfo->ei_cb_created)
/* for the local lock, add the reference */
ldlm_lock_addref_internal(lock, einfo->ei_mode);
ldlm_lock2handle(lock, lockh);
......@@ -3115,6 +3115,11 @@ int mdt_check_resent_lock(struct mdt_thread_info *info,
return 1;
static void mdt_remote_object_lock_created_cb(struct ldlm_lock *lock)
mdt_object_get(NULL, lock->l_ast_data);
int mdt_remote_object_lock_try(struct mdt_thread_info *mti,
struct mdt_object *o, const struct lu_fid *fid,
struct lustre_handle *lh, enum ldlm_mode mode,
......@@ -3143,8 +3148,8 @@ int mdt_remote_object_lock_try(struct mdt_thread_info *mti,
* if we cache lock, couple lock with mdt_object, so that object
* can be easily found in lock ASTs.
mdt_object_get(mti->mti_env, o);
einfo->ei_cbdata = o;
einfo->ei_cb_created = mdt_remote_object_lock_created_cb;
memset(policy, 0, sizeof(*policy));
......@@ -3153,8 +3158,6 @@ int mdt_remote_object_lock_try(struct mdt_thread_info *mti,
rc = mo_object_lock(mti->mti_env, mdt_object_child(o), lh, einfo,
if (rc < 0 && cache)
mdt_object_put(mti->mti_env, o);
/* Return successfully acquired bits to a caller */
if (rc == 0) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment