Skip to content

Commit 72c2be7

Browse files
teiglandswhiteho
authored andcommitted
[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>
1 parent 8499137 commit 72c2be7

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎fs/dlm/lock.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4141
uint32_t flags, uint32_t lkid, char *lvb_in);
4242
int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4343
uint32_t flags, uint32_t lkid);
44+
int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
45+
int nodeid, int pid);
4446
void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc);
4547

4648
static inline int is_master(struct dlm_rsb *r)

‎fs/dlm/user.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct dlm_write_request32 {
5656
union {
5757
struct dlm_lock_params32 lock;
5858
struct dlm_lspace_params lspace;
59+
struct dlm_purge_params purge;
5960
} i;
6061
};
6162

@@ -92,6 +93,9 @@ static void compat_input(struct dlm_write_request *kb,
9293
kb->i.lspace.flags = kb32->i.lspace.flags;
9394
kb->i.lspace.minor = kb32->i.lspace.minor;
9495
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;
9599
} else {
96100
kb->i.lock.mode = kb32->i.lock.mode;
97101
kb->i.lock.namelen = kb32->i.lock.namelen;
@@ -320,6 +324,22 @@ static int create_misc_device(struct dlm_ls *ls, char *name)
320324
return error;
321325
}
322326

327+
static 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+
323343
static int device_create_lockspace(struct dlm_lspace_params *params)
324344
{
325345
dlm_lockspace_t *lockspace;
@@ -522,6 +542,14 @@ static ssize_t device_write(struct file *file, const char __user *buf,
522542
error = device_remove_lockspace(&kbuf->i.lspace);
523543
break;
524544

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+
525553
default:
526554
log_print("Unknown command passed to DLM device : %d\n",
527555
kbuf->cmd);

‎include/linux/dlm_device.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/* Version of the device interface */
2121
#define DLM_DEVICE_VERSION_MAJOR 5
22-
#define DLM_DEVICE_VERSION_MINOR 0
22+
#define DLM_DEVICE_VERSION_MINOR 1
2323
#define DLM_DEVICE_VERSION_PATCH 0
2424

2525
/* struct passed to the lock write */
@@ -44,6 +44,11 @@ struct dlm_lspace_params {
4444
char name[0];
4545
};
4646

47+
struct dlm_purge_params {
48+
__u32 nodeid;
49+
__u32 pid;
50+
};
51+
4752
struct dlm_write_request {
4853
__u32 version[3];
4954
__u8 cmd;
@@ -53,6 +58,7 @@ struct dlm_write_request {
5358
union {
5459
struct dlm_lock_params lock;
5560
struct dlm_lspace_params lspace;
61+
struct dlm_purge_params purge;
5662
} i;
5763
};
5864

@@ -76,6 +82,7 @@ struct dlm_lock_result {
7682
#define DLM_USER_QUERY 3
7783
#define DLM_USER_CREATE_LOCKSPACE 4
7884
#define DLM_USER_REMOVE_LOCKSPACE 5
85+
#define DLM_USER_PURGE 6
7986

8087
/* Arbitrary length restriction */
8188
#define MAX_LS_NAME_LEN 64

0 commit comments

Comments
 (0)