#include "ldlm_internal.h"
#ifdef HAVE_SERVER_SUPPORT
+
/**
* Determine if the lock is compatible with all locks on the queue.
*
ENTRY;
- LASSERT(lock->l_granted_mode != lock->l_req_mode);
+ LASSERT(!ldlm_is_granted(lock));
check_res_locked(res);
if (intention == LDLM_PROCESS_RESCAN) {
/* Just return if there are no conflicting bits */
if ((lock->l_policy_data.l_inodebits.bits & to_drop) == 0) {
- LDLM_WARN(lock, "try to drop unset bits %#llx/%#llx\n",
+ LDLM_WARN(lock, "try to drop unset bits %#llx/%#llx",
lock->l_policy_data.l_inodebits.bits, to_drop);
/* nothing to do */
RETURN(0);
ldlm_lock2handle(lock, &lockh);
lock_res_and_lock(lock);
- /* check if all bits are cancelled */
+ /* check if all bits are blocked */
if (!(lock->l_policy_data.l_inodebits.bits & ~drop_bits)) {
unlock_res_and_lock(lock);
/* return error to continue with cancel */
GOTO(exit, rc = -EINVAL);
}
+ /* check if no common bits, consider this as successful convert */
+ if (!(lock->l_policy_data.l_inodebits.bits & drop_bits)) {
+ unlock_res_and_lock(lock);
+ GOTO(exit, rc = 0);
+ }
+
/* check if there is race with cancel */
if (ldlm_is_canceling(lock) || ldlm_is_cancel(lock)) {
unlock_res_and_lock(lock);
rc = ldlm_cli_convert(lock, &flags);
if (rc) {
lock_res_and_lock(lock);
- ldlm_clear_converting(lock);
- ldlm_set_cbpending(lock);
- ldlm_set_bl_ast(lock);
+ if (ldlm_is_converting(lock)) {
+ ldlm_clear_converting(lock);
+ ldlm_set_cbpending(lock);
+ ldlm_set_bl_ast(lock);
+ }
unlock_res_and_lock(lock);
GOTO(exit, rc);
}