From: Andriy Skulysh Date: Tue, 11 Feb 2020 12:00:18 +0000 (+0200) Subject: LU-13989 ldlm: BL AST vs failed lock enqueue race X-Git-Tag: 2.13.57~100 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c1be044913dde3b935e23ac8396eb2ba434e2538 LU-13989 ldlm: BL AST vs failed lock enqueue race failed_lock_cleanup() marks the lock with LDLM_FL_LOCAL_ONLY, so cancel request isn't sent. Mark failed lock with LDLM_FL_LOCAL_ONLY only if BL AST wasn't received. Add server's lock handle to BL AST RPC. So client will be able to cancel the lock even if enqueue fails. Change-Id: I3201bc29abd877cddc334ca27a9d208cb55c5d8f HPE-bug-id: LUS-8493, LUS-8830 Signed-off-by: Andriy Skulysh Reviewed-by: Vladimir Saveliev Reviewed-by: Alexander Boyko Reviewed-by: Vitaly Fertman Reviewed-on: https://review.whamcloud.com/40046 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alexander Boyko Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index de10643..0315364 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -944,6 +944,7 @@ int ldlm_server_blocking_ast(struct ldlm_lock *lock, body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); body->lock_handle[0] = lock->l_remote_handle; + body->lock_handle[1].cookie = lock->l_handle.h_cookie; body->lock_desc = *desc; body->lock_flags |= ldlm_flags_to_wire(lock->l_flags & LDLM_FL_AST_MASK); @@ -1039,6 +1040,7 @@ int ldlm_server_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); body->lock_handle[0] = lock->l_remote_handle; + body->lock_handle[1].cookie = lock->l_handle.h_cookie; body->lock_flags = ldlm_flags_to_wire(flags); ldlm_lock2desc(lock, &body->lock_desc); if (lvb_len > 0) { @@ -2413,6 +2415,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) ldlm_lock_remove_from_lru(lock); ldlm_set_bl_ast(lock); } + if (lock->l_remote_handle.cookie == 0) + lock->l_remote_handle = dlm_req->lock_handle[1]; unlock_res_and_lock(lock); /* diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index b53a858..23abc07a 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -552,8 +552,11 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns, * bl_ast and -EINVAL reply is sent to server anyways. * b=17645 */ - lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_FAILED | + lock->l_flags |= LDLM_FL_FAILED | LDLM_FL_ATOMIC_CB | LDLM_FL_CBPENDING; + if (!(ldlm_is_bl_ast(lock) && + lock->l_remote_handle.cookie != 0)) + lock->l_flags |= LDLM_FL_LOCAL_ONLY; need_cancel = 1; } unlock_res_and_lock(lock);