aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2007-03-30 16:06:16 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2007-05-01 04:11:12 -0400
commit72c2be776bd6eec5186e316e6d9dd4aab78d314d (patch)
tree378338f229887375efbb3388068a148227b72b23
parent8499137d4ef1829281e04838113b6b09a0bf1269 (diff)
[DLM] interface for purge (2/2)
Add code to accept purge commands from userland. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/dlm/lock.h2
-rw-r--r--fs/dlm/user.c28
-rw-r--r--include/linux/dlm_device.h9
3 files changed, 38 insertions, 1 deletions
diff --git a/fs/dlm/lock.h b/fs/dlm/lock.h
index 0843a3073ec3..64fc4ec40668 100644
--- a/fs/dlm/lock.h
+++ b/fs/dlm/lock.h
@@ -41,6 +41,8 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
41 uint32_t flags, uint32_t lkid, char *lvb_in); 41 uint32_t flags, uint32_t lkid, char *lvb_in);
42int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, 42int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
43 uint32_t flags, uint32_t lkid); 43 uint32_t flags, uint32_t lkid);
44int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
45 int nodeid, int pid);
44void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc); 46void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc);
45 47
46static inline int is_master(struct dlm_rsb *r) 48static inline int is_master(struct dlm_rsb *r)
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index c978c67b1eff..3e746a6ebac3 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -56,6 +56,7 @@ struct dlm_write_request32 {
56 union { 56 union {
57 struct dlm_lock_params32 lock; 57 struct dlm_lock_params32 lock;
58 struct dlm_lspace_params lspace; 58 struct dlm_lspace_params lspace;
59 struct dlm_purge_params purge;
59 } i; 60 } i;
60}; 61};
61 62
@@ -92,6 +93,9 @@ static void compat_input(struct dlm_write_request *kb,
92 kb->i.lspace.flags = kb32->i.lspace.flags; 93 kb->i.lspace.flags = kb32->i.lspace.flags;
93 kb->i.lspace.minor = kb32->i.lspace.minor; 94 kb->i.lspace.minor = kb32->i.lspace.minor;
94 strcpy(kb->i.lspace.name, kb32->i.lspace.name); 95 strcpy(kb->i.lspace.name, kb32->i.lspace.name);
96 } else if (kb->cmd == DLM_USER_PURGE) {
97 kb->i.purge.nodeid = kb32->i.purge.nodeid;
98 kb->i.purge.pid = kb32->i.purge.pid;
95 } else { 99 } else {
96 kb->i.lock.mode = kb32->i.lock.mode; 100 kb->i.lock.mode = kb32->i.lock.mode;
97 kb->i.lock.namelen = kb32->i.lock.namelen; 101 kb->i.lock.namelen = kb32->i.lock.namelen;
@@ -320,6 +324,22 @@ fail:
320 return error; 324 return error;
321} 325}
322 326
327static int device_user_purge(struct dlm_user_proc *proc,
328 struct dlm_purge_params *params)
329{
330 struct dlm_ls *ls;
331 int error;
332
333 ls = dlm_find_lockspace_local(proc->lockspace);
334 if (!ls)
335 return -ENOENT;
336
337 error = dlm_user_purge(ls, proc, params->nodeid, params->pid);
338
339 dlm_put_lockspace(ls);
340 return error;
341}
342
323static int device_create_lockspace(struct dlm_lspace_params *params) 343static int device_create_lockspace(struct dlm_lspace_params *params)
324{ 344{
325 dlm_lockspace_t *lockspace; 345 dlm_lockspace_t *lockspace;
@@ -522,6 +542,14 @@ static ssize_t device_write(struct file *file, const char __user *buf,
522 error = device_remove_lockspace(&kbuf->i.lspace); 542 error = device_remove_lockspace(&kbuf->i.lspace);
523 break; 543 break;
524 544
545 case DLM_USER_PURGE:
546 if (!proc) {
547 log_print("no locking on control device");
548 goto out_sig;
549 }
550 error = device_user_purge(proc, &kbuf->i.purge);
551 break;
552
525 default: 553 default:
526 log_print("Unknown command passed to DLM device : %d\n", 554 log_print("Unknown command passed to DLM device : %d\n",
527 kbuf->cmd); 555 kbuf->cmd);
diff --git a/include/linux/dlm_device.h b/include/linux/dlm_device.h
index 2a2dd189b9fd..c2735cab2ebf 100644
--- a/include/linux/dlm_device.h
+++ b/include/linux/dlm_device.h
@@ -19,7 +19,7 @@
19 19
20/* Version of the device interface */ 20/* Version of the device interface */
21#define DLM_DEVICE_VERSION_MAJOR 5 21#define DLM_DEVICE_VERSION_MAJOR 5
22#define DLM_DEVICE_VERSION_MINOR 0 22#define DLM_DEVICE_VERSION_MINOR 1
23#define DLM_DEVICE_VERSION_PATCH 0 23#define DLM_DEVICE_VERSION_PATCH 0
24 24
25/* struct passed to the lock write */ 25/* struct passed to the lock write */
@@ -44,6 +44,11 @@ struct dlm_lspace_params {
44 char name[0]; 44 char name[0];
45}; 45};
46 46
47struct dlm_purge_params {
48 __u32 nodeid;
49 __u32 pid;
50};
51
47struct dlm_write_request { 52struct dlm_write_request {
48 __u32 version[3]; 53 __u32 version[3];
49 __u8 cmd; 54 __u8 cmd;
@@ -53,6 +58,7 @@ struct dlm_write_request {
53 union { 58 union {
54 struct dlm_lock_params lock; 59 struct dlm_lock_params lock;
55 struct dlm_lspace_params lspace; 60 struct dlm_lspace_params lspace;
61 struct dlm_purge_params purge;
56 } i; 62 } i;
57}; 63};
58 64
@@ -76,6 +82,7 @@ struct dlm_lock_result {
76#define DLM_USER_QUERY 3 82#define DLM_USER_QUERY 3
77#define DLM_USER_CREATE_LOCKSPACE 4 83#define DLM_USER_CREATE_LOCKSPACE 4
78#define DLM_USER_REMOVE_LOCKSPACE 5 84#define DLM_USER_REMOVE_LOCKSPACE 5
85#define DLM_USER_PURGE 6
79 86
80/* Arbitrary length restriction */ 87/* Arbitrary length restriction */
81#define MAX_LS_NAME_LEN 64 88#define MAX_LS_NAME_LEN 64