static int mgs_handle(struct ptlrpc_request *req);
static int mgs_completion_ast_config(struct ldlm_lock *lock, __u64 flags,
- void *cbdata)
+ void *cbdata)
{
- ENTRY;
+ ENTRY;
- if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
- LDLM_FL_BLOCK_CONV))) {
- struct fs_db *fsdb = (struct fs_db *)lock->l_ast_data;
- struct lustre_handle lockh;
+ if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
+ LDLM_FL_BLOCK_CONV))) {
+ struct fs_db *fsdb;
- /* clear the bit before lock put */
- clear_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags);
+ /* l_ast_data is used as a marker to avoid cancel ldlm lock
+ * twice. See LU-2317. */
+ lock_res_and_lock(lock);
+ fsdb = (struct fs_db *)lock->l_ast_data;
+ lock->l_ast_data = NULL;
+ unlock_res_and_lock(lock);
- ldlm_lock2handle(lock, &lockh);
- ldlm_lock_decref_and_cancel(&lockh, LCK_EX);
- }
+ if (fsdb != NULL) {
+ struct lustre_handle lockh;
- RETURN(ldlm_completion_ast(lock, flags, cbdata));
+ /* clear the bit before lock put */
+ clear_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags);
+
+ ldlm_lock2handle(lock, &lockh);
+ ldlm_lock_decref_and_cancel(&lockh, LCK_EX);
+ }
+ }
+
+ RETURN(ldlm_completion_ast(lock, flags, cbdata));
}
static int mgs_completion_ast_ir(struct ldlm_lock *lock, __u64 flags,