|
@@ -300,6 +300,11 @@ static void queue_cast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rv)
|
|
|
rv = -ETIMEDOUT;
|
|
|
}
|
|
|
|
|
|
+ if (rv == -DLM_ECANCEL && (lkb->lkb_flags & DLM_IFL_DEADLOCK_CANCEL)) {
|
|
|
+ lkb->lkb_flags &= ~DLM_IFL_DEADLOCK_CANCEL;
|
|
|
+ rv = -EDEADLK;
|
|
|
+ }
|
|
|
+
|
|
|
lkb->lkb_lksb->sb_status = rv;
|
|
|
lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags;
|
|
|
|
|
@@ -4450,6 +4455,54 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
|
|
|
return error;
|
|
|
}
|
|
|
|
|
|
+int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid)
|
|
|
+{
|
|
|
+ struct dlm_lkb *lkb;
|
|
|
+ struct dlm_args args;
|
|
|
+ struct dlm_user_args *ua;
|
|
|
+ struct dlm_rsb *r;
|
|
|
+ int error;
|
|
|
+
|
|
|
+ dlm_lock_recovery(ls);
|
|
|
+
|
|
|
+ error = find_lkb(ls, lkid, &lkb);
|
|
|
+ if (error)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ ua = (struct dlm_user_args *)lkb->lkb_astparam;
|
|
|
+
|
|
|
+ error = set_unlock_args(flags, ua, &args);
|
|
|
+ if (error)
|
|
|
+ goto out_put;
|
|
|
+
|
|
|
+ /* same as cancel_lock(), but set DEADLOCK_CANCEL after lock_rsb */
|
|
|
+
|
|
|
+ r = lkb->lkb_resource;
|
|
|
+ hold_rsb(r);
|
|
|
+ lock_rsb(r);
|
|
|
+
|
|
|
+ error = validate_unlock_args(lkb, &args);
|
|
|
+ if (error)
|
|
|
+ goto out_r;
|
|
|
+ lkb->lkb_flags |= DLM_IFL_DEADLOCK_CANCEL;
|
|
|
+
|
|
|
+ error = _cancel_lock(r, lkb);
|
|
|
+ out_r:
|
|
|
+ unlock_rsb(r);
|
|
|
+ put_rsb(r);
|
|
|
+
|
|
|
+ if (error == -DLM_ECANCEL)
|
|
|
+ error = 0;
|
|
|
+ /* from validate_unlock_args() */
|
|
|
+ if (error == -EBUSY)
|
|
|
+ error = 0;
|
|
|
+ out_put:
|
|
|
+ dlm_put_lkb(lkb);
|
|
|
+ out:
|
|
|
+ dlm_unlock_recovery(ls);
|
|
|
+ return error;
|
|
|
+}
|
|
|
+
|
|
|
/* lkb's that are removed from the waiters list by revert are just left on the
|
|
|
orphans list with the granted orphan locks, to be freed by purge */
|
|
|
|