Skip to content

Commit

Permalink
[DLM] interface for purge (2/2)
Browse files Browse the repository at this point in the history
Add code to accept purge commands from userland.

Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
David Teigland authored and Steven Whitehouse committed May 1, 2007
1 parent 8499137 commit 72c2be7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions fs/dlm/lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
uint32_t flags, uint32_t lkid, char *lvb_in);
int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
uint32_t flags, uint32_t lkid);
int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
int nodeid, int pid);
void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc);

static inline int is_master(struct dlm_rsb *r)
Expand Down
28 changes: 28 additions & 0 deletions fs/dlm/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct dlm_write_request32 {
union {
struct dlm_lock_params32 lock;
struct dlm_lspace_params lspace;
struct dlm_purge_params purge;
} i;
};

Expand Down Expand Up @@ -92,6 +93,9 @@ static void compat_input(struct dlm_write_request *kb,
kb->i.lspace.flags = kb32->i.lspace.flags;
kb->i.lspace.minor = kb32->i.lspace.minor;
strcpy(kb->i.lspace.name, kb32->i.lspace.name);
} else if (kb->cmd == DLM_USER_PURGE) {
kb->i.purge.nodeid = kb32->i.purge.nodeid;
kb->i.purge.pid = kb32->i.purge.pid;
} else {
kb->i.lock.mode = kb32->i.lock.mode;
kb->i.lock.namelen = kb32->i.lock.namelen;
Expand Down Expand Up @@ -320,6 +324,22 @@ static int create_misc_device(struct dlm_ls *ls, char *name)
return error;
}

static int device_user_purge(struct dlm_user_proc *proc,
struct dlm_purge_params *params)
{
struct dlm_ls *ls;
int error;

ls = dlm_find_lockspace_local(proc->lockspace);
if (!ls)
return -ENOENT;

error = dlm_user_purge(ls, proc, params->nodeid, params->pid);

dlm_put_lockspace(ls);
return error;
}

static int device_create_lockspace(struct dlm_lspace_params *params)
{
dlm_lockspace_t *lockspace;
Expand Down Expand Up @@ -522,6 +542,14 @@ static ssize_t device_write(struct file *file, const char __user *buf,
error = device_remove_lockspace(&kbuf->i.lspace);
break;

case DLM_USER_PURGE:
if (!proc) {
log_print("no locking on control device");
goto out_sig;
}
error = device_user_purge(proc, &kbuf->i.purge);
break;

default:
log_print("Unknown command passed to DLM device : %d\n",
kbuf->cmd);
Expand Down
9 changes: 8 additions & 1 deletion include/linux/dlm_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/* Version of the device interface */
#define DLM_DEVICE_VERSION_MAJOR 5
#define DLM_DEVICE_VERSION_MINOR 0
#define DLM_DEVICE_VERSION_MINOR 1
#define DLM_DEVICE_VERSION_PATCH 0

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

struct dlm_purge_params {
__u32 nodeid;
__u32 pid;
};

struct dlm_write_request {
__u32 version[3];
__u8 cmd;
Expand All @@ -53,6 +58,7 @@ struct dlm_write_request {
union {
struct dlm_lock_params lock;
struct dlm_lspace_params lspace;
struct dlm_purge_params purge;
} i;
};

Expand All @@ -76,6 +82,7 @@ struct dlm_lock_result {
#define DLM_USER_QUERY 3
#define DLM_USER_CREATE_LOCKSPACE 4
#define DLM_USER_REMOVE_LOCKSPACE 5
#define DLM_USER_PURGE 6

/* Arbitrary length restriction */
#define MAX_LS_NAME_LEN 64
Expand Down

0 comments on commit 72c2be7

Please sign in to comment.