struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
__u64 flags)
{
struct ldlm_lock *lock;
ENTRY;
LASSERT(handle);
lock = class_handle2object(handle->cookie, NULL);
if (lock == NULL)
RETURN(NULL);
if (lock->l_export != NULL && lock->l_export->exp_failed) {
CDEBUG(D_INFO, "lock export failed: lock %p, exp %p\n",
lock, lock->l_export);
LDLM_LOCK_PUT(lock);
RETURN(NULL);
}
/* It's unlikely but possible that someone marked the lock as
* destroyed after we did handle2object on it */
if ((flags == 0) && !ldlm_is_destroyed(lock)) {
lu_ref_add(&lock->l_reference, "handle", current);
RETURN(lock);
}
lock_res_and_lock(lock);
LASSERT(lock->l_resource != NULL);
lu_ref_add_atomic(&lock->l_reference, "handle", current);
if (unlikely(ldlm_is_destroyed(lock))) {
...