diff options
author | David Teigland <teigland@redhat.com> | 2007-05-18 10:00:32 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-07-09 03:22:36 -0400 |
commit | d7db923ea4990edb5583bf54af868ba687a1bc84 (patch) | |
tree | 3efa0db00a3a6400f43a65aef2726fa813f9dfa2 /fs/dlm/user.c | |
parent | 3ae1acf93a21512512f8a78430fcde5992dd208e (diff) |
[DLM] dlm_device interface changes [3/6]
Change the user/kernel device interface used by libdlm:
- Add ability for userspace to check the version of the interface. libdlm
can now adapt to different versions of the kernel interface.
- Increase the size of the flags passed in a lock request so all possible
flags can be used from userspace.
- Add an opaque "xid" value for each lock. This "transaction id" will be
used later to associate locks with each other during deadlock detection.
- Add a "timeout" value for each lock. This is used along with the
DLM_LKF_TIMEOUT flag.
Also, remove a fragment of unused code in device_read().
This patch requires updating libdlm which is backward compatible with
older kernels.
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/dlm/user.c')
-rw-r--r-- | fs/dlm/user.c | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/fs/dlm/user.c b/fs/dlm/user.c index c7612da5b617..37aad3fe8949 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c | |||
@@ -33,16 +33,17 @@ static const struct file_operations device_fops; | |||
33 | struct dlm_lock_params32 { | 33 | struct dlm_lock_params32 { |
34 | __u8 mode; | 34 | __u8 mode; |
35 | __u8 namelen; | 35 | __u8 namelen; |
36 | __u16 flags; | 36 | __u16 unused; |
37 | __u32 flags; | ||
37 | __u32 lkid; | 38 | __u32 lkid; |
38 | __u32 parent; | 39 | __u32 parent; |
39 | 40 | __u64 xid; | |
41 | __u64 timeout; | ||
40 | __u32 castparam; | 42 | __u32 castparam; |
41 | __u32 castaddr; | 43 | __u32 castaddr; |
42 | __u32 bastparam; | 44 | __u32 bastparam; |
43 | __u32 bastaddr; | 45 | __u32 bastaddr; |
44 | __u32 lksb; | 46 | __u32 lksb; |
45 | |||
46 | char lvb[DLM_USER_LVB_LEN]; | 47 | char lvb[DLM_USER_LVB_LEN]; |
47 | char name[0]; | 48 | char name[0]; |
48 | }; | 49 | }; |
@@ -68,6 +69,7 @@ struct dlm_lksb32 { | |||
68 | }; | 69 | }; |
69 | 70 | ||
70 | struct dlm_lock_result32 { | 71 | struct dlm_lock_result32 { |
72 | __u32 version[3]; | ||
71 | __u32 length; | 73 | __u32 length; |
72 | __u32 user_astaddr; | 74 | __u32 user_astaddr; |
73 | __u32 user_astparam; | 75 | __u32 user_astparam; |
@@ -102,6 +104,8 @@ static void compat_input(struct dlm_write_request *kb, | |||
102 | kb->i.lock.flags = kb32->i.lock.flags; | 104 | kb->i.lock.flags = kb32->i.lock.flags; |
103 | kb->i.lock.lkid = kb32->i.lock.lkid; | 105 | kb->i.lock.lkid = kb32->i.lock.lkid; |
104 | kb->i.lock.parent = kb32->i.lock.parent; | 106 | kb->i.lock.parent = kb32->i.lock.parent; |
107 | kb->i.lock.xid = kb32->i.lock.xid; | ||
108 | kb->i.lock.timeout = kb32->i.lock.timeout; | ||
105 | kb->i.lock.castparam = (void *)(long)kb32->i.lock.castparam; | 109 | kb->i.lock.castparam = (void *)(long)kb32->i.lock.castparam; |
106 | kb->i.lock.castaddr = (void *)(long)kb32->i.lock.castaddr; | 110 | kb->i.lock.castaddr = (void *)(long)kb32->i.lock.castaddr; |
107 | kb->i.lock.bastparam = (void *)(long)kb32->i.lock.bastparam; | 111 | kb->i.lock.bastparam = (void *)(long)kb32->i.lock.bastparam; |
@@ -115,6 +119,10 @@ static void compat_input(struct dlm_write_request *kb, | |||
115 | static void compat_output(struct dlm_lock_result *res, | 119 | static void compat_output(struct dlm_lock_result *res, |
116 | struct dlm_lock_result32 *res32) | 120 | struct dlm_lock_result32 *res32) |
117 | { | 121 | { |
122 | res32->version[0] = res->version[0]; | ||
123 | res32->version[1] = res->version[1]; | ||
124 | res32->version[2] = res->version[2]; | ||
125 | |||
118 | res32->user_astaddr = (__u32)(long)res->user_astaddr; | 126 | res32->user_astaddr = (__u32)(long)res->user_astaddr; |
119 | res32->user_astparam = (__u32)(long)res->user_astparam; | 127 | res32->user_astparam = (__u32)(long)res->user_astparam; |
120 | res32->user_lksb = (__u32)(long)res->user_lksb; | 128 | res32->user_lksb = (__u32)(long)res->user_lksb; |
@@ -252,16 +260,18 @@ static int device_user_lock(struct dlm_user_proc *proc, | |||
252 | ua->castaddr = params->castaddr; | 260 | ua->castaddr = params->castaddr; |
253 | ua->bastparam = params->bastparam; | 261 | ua->bastparam = params->bastparam; |
254 | ua->bastaddr = params->bastaddr; | 262 | ua->bastaddr = params->bastaddr; |
263 | ua->xid = params->xid; | ||
255 | 264 | ||
256 | if (params->flags & DLM_LKF_CONVERT) | 265 | if (params->flags & DLM_LKF_CONVERT) |
257 | error = dlm_user_convert(ls, ua, | 266 | error = dlm_user_convert(ls, ua, |
258 | params->mode, params->flags, | 267 | params->mode, params->flags, |
259 | params->lkid, params->lvb); | 268 | params->lkid, params->lvb, |
269 | (unsigned long) params->timeout); | ||
260 | else { | 270 | else { |
261 | error = dlm_user_request(ls, ua, | 271 | error = dlm_user_request(ls, ua, |
262 | params->mode, params->flags, | 272 | params->mode, params->flags, |
263 | params->name, params->namelen, | 273 | params->name, params->namelen, |
264 | params->parent); | 274 | (unsigned long) params->timeout); |
265 | if (!error) | 275 | if (!error) |
266 | error = ua->lksb.sb_lkid; | 276 | error = ua->lksb.sb_lkid; |
267 | } | 277 | } |
@@ -641,6 +651,9 @@ static int copy_result_to_user(struct dlm_user_args *ua, int compat, int type, | |||
641 | int struct_len; | 651 | int struct_len; |
642 | 652 | ||
643 | memset(&result, 0, sizeof(struct dlm_lock_result)); | 653 | memset(&result, 0, sizeof(struct dlm_lock_result)); |
654 | result.version[0] = DLM_DEVICE_VERSION_MAJOR; | ||
655 | result.version[1] = DLM_DEVICE_VERSION_MINOR; | ||
656 | result.version[2] = DLM_DEVICE_VERSION_PATCH; | ||
644 | memcpy(&result.lksb, &ua->lksb, sizeof(struct dlm_lksb)); | 657 | memcpy(&result.lksb, &ua->lksb, sizeof(struct dlm_lksb)); |
645 | result.user_lksb = ua->user_lksb; | 658 | result.user_lksb = ua->user_lksb; |
646 | 659 | ||
@@ -699,6 +712,20 @@ static int copy_result_to_user(struct dlm_user_args *ua, int compat, int type, | |||
699 | return error; | 712 | return error; |
700 | } | 713 | } |
701 | 714 | ||
715 | static int copy_version_to_user(char __user *buf, size_t count) | ||
716 | { | ||
717 | struct dlm_device_version ver; | ||
718 | |||
719 | memset(&ver, 0, sizeof(struct dlm_device_version)); | ||
720 | ver.version[0] = DLM_DEVICE_VERSION_MAJOR; | ||
721 | ver.version[1] = DLM_DEVICE_VERSION_MINOR; | ||
722 | ver.version[2] = DLM_DEVICE_VERSION_PATCH; | ||
723 | |||
724 | if (copy_to_user(buf, &ver, sizeof(struct dlm_device_version))) | ||
725 | return -EFAULT; | ||
726 | return sizeof(struct dlm_device_version); | ||
727 | } | ||
728 | |||
702 | /* a read returns a single ast described in a struct dlm_lock_result */ | 729 | /* a read returns a single ast described in a struct dlm_lock_result */ |
703 | 730 | ||
704 | static ssize_t device_read(struct file *file, char __user *buf, size_t count, | 731 | static ssize_t device_read(struct file *file, char __user *buf, size_t count, |
@@ -710,6 +737,16 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count, | |||
710 | DECLARE_WAITQUEUE(wait, current); | 737 | DECLARE_WAITQUEUE(wait, current); |
711 | int error, type=0, bmode=0, removed = 0; | 738 | int error, type=0, bmode=0, removed = 0; |
712 | 739 | ||
740 | if (count == sizeof(struct dlm_device_version)) { | ||
741 | error = copy_version_to_user(buf, count); | ||
742 | return error; | ||
743 | } | ||
744 | |||
745 | if (!proc) { | ||
746 | log_print("non-version read from control device %zu", count); | ||
747 | return -EINVAL; | ||
748 | } | ||
749 | |||
713 | #ifdef CONFIG_COMPAT | 750 | #ifdef CONFIG_COMPAT |
714 | if (count < sizeof(struct dlm_lock_result32)) | 751 | if (count < sizeof(struct dlm_lock_result32)) |
715 | #else | 752 | #else |
@@ -747,11 +784,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count, | |||
747 | } | 784 | } |
748 | } | 785 | } |
749 | 786 | ||
750 | if (list_empty(&proc->asts)) { | ||
751 | spin_unlock(&proc->asts_spin); | ||
752 | return -EAGAIN; | ||
753 | } | ||
754 | |||
755 | /* there may be both completion and blocking asts to return for | 787 | /* there may be both completion and blocking asts to return for |
756 | the lkb, don't remove lkb from asts list unless no asts remain */ | 788 | the lkb, don't remove lkb from asts list unless no asts remain */ |
757 | 789 | ||
@@ -823,6 +855,7 @@ static const struct file_operations device_fops = { | |||
823 | static const struct file_operations ctl_device_fops = { | 855 | static const struct file_operations ctl_device_fops = { |
824 | .open = ctl_device_open, | 856 | .open = ctl_device_open, |
825 | .release = ctl_device_close, | 857 | .release = ctl_device_close, |
858 | .read = device_read, | ||
826 | .write = device_write, | 859 | .write = device_write, |
827 | .owner = THIS_MODULE, | 860 | .owner = THIS_MODULE, |
828 | }; | 861 | }; |