dlm: canceling deadlocked lock
David Teigland
maintainerPATCH 1/1 dlm: canceling deadlocked lock
Add a function that can be used through libdlm by a system daemon to cancel another process's deadlocked lock. A completion ast with EDEADLK is returned to the process waiting for the lock.
Signed-off-by David Teigland <[email protected]>
fs/dlm/dlm_internal.h +1 -0
@@ -216,6 +216,7 @@#define DLM_IFL_ENDOFLIFE 0x00200000#define DLM_IFL_WATCH_TIMEWARN 0x00400000#define DLM_IFL_TIMEOUT_CANCEL 0x00800000 +#define DLM_IFL_DEADLOCK_CANCEL 0x01000000#define DLM_IFL_USER 0x00000001#define DLM_IFL_ORPHAN 0x00000002
fs/dlm/lock.c +53 -0
65 lines not on this page · raw message
fs/dlm/lock.h +1 -0
@@ -49,6 +49,7 @@ uint32_t flags, uint32_t lkid);int dlm_user_purge (struct dlm_ls *ls,struct dlm_user_proc *proc,int nodeid,int pid); +int dlm_user_deadlock (struct dlm_ls *ls,uint32_t flags,uint32_t lkid);void dlm_clear_proc_locks (struct dlm_ls *ls,struct dlm_user_proc *proc);static inline int is_master (struct dlm_rsb *r)
fs/dlm/user.c +25 -0
@@ -156,6 +156,7 @@return 1 ;case -DLM_ECANCEL :case -ETIMEDOUT : +case -EDEADLK :if (lkb->lkb_grmode ==DLM_LOCK_IV )return 1 ;break ;
@@ -320,6 +321,22 @@return error; } +static int device_user_deadlock (struct dlm_user_proc *proc, +struct dlm_lock_params *params) +{ +struct dlm_ls *ls; +int error; + + ls =dlm_find_lockspace_local (proc->lockspace); +if (!ls) +return -ENOENT ; + + error =dlm_user_deadlock (ls, params->flags, params->lkid); + +dlm_put_lockspace (ls); +return error; +} +static int create_misc_device (struct dlm_ls *ls,char *name) {int error, len;
@@ -545,6 +562,14 @@ error =device_user_unlock (proc, &kbuf->i.lock);break ; +case DLM_USER_DEADLOCK : +if (!proc) { +log_print ("no locking on control device" ); + goto out_sig; + } + error =device_user_deadlock (proc, &kbuf->i.lock); +break ; +case DLM_USER_CREATE_LOCKSPACE :if (proc) {log_print ("create/remove only on control device" );
include/linux/dlm_device.h +1 -0
@@ -92,6 +92,7 @@#define DLM_USER_CREATE_LOCKSPACE 4#define DLM_USER_REMOVE_LOCKSPACE 5#define DLM_USER_PURGE 6 +#define DLM_USER_DEADLOCK 7/* Arbitrary length restriction */ #define MAX_LS_NAME_LEN 64