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/lock.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/lock.c')
-rw-r--r-- | fs/dlm/lock.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index ab986dfbe6d3..ad3797a37942 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -1098,6 +1098,8 @@ void dlm_scan_timeout(struct dlm_ls *ls) | |||
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | if (do_cancel) { | 1100 | if (do_cancel) { |
1101 | log_debug("timeout cancel %x node %d %s", lkb->lkb_id, | ||
1102 | lkb->lkb_nodeid, r->res_name); | ||
1101 | lkb->lkb_flags &= ~DLM_IFL_WATCH_TIMEWARN; | 1103 | lkb->lkb_flags &= ~DLM_IFL_WATCH_TIMEWARN; |
1102 | lkb->lkb_flags |= DLM_IFL_TIMEOUT_CANCEL; | 1104 | lkb->lkb_flags |= DLM_IFL_TIMEOUT_CANCEL; |
1103 | del_timeout(lkb); | 1105 | del_timeout(lkb); |
@@ -1864,7 +1866,7 @@ static void confirm_master(struct dlm_rsb *r, int error) | |||
1864 | } | 1866 | } |
1865 | 1867 | ||
1866 | static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, | 1868 | static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, |
1867 | int namelen, uint32_t parent_lkid, void *ast, | 1869 | int namelen, unsigned long timeout_cs, void *ast, |
1868 | void *astarg, void *bast, struct dlm_args *args) | 1870 | void *astarg, void *bast, struct dlm_args *args) |
1869 | { | 1871 | { |
1870 | int rv = -EINVAL; | 1872 | int rv = -EINVAL; |
@@ -1907,10 +1909,6 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, | |||
1907 | if (flags & DLM_LKF_VALBLK && !lksb->sb_lvbptr) | 1909 | if (flags & DLM_LKF_VALBLK && !lksb->sb_lvbptr) |
1908 | goto out; | 1910 | goto out; |
1909 | 1911 | ||
1910 | /* parent/child locks not yet supported */ | ||
1911 | if (parent_lkid) | ||
1912 | goto out; | ||
1913 | |||
1914 | if (flags & DLM_LKF_CONVERT && !lksb->sb_lkid) | 1912 | if (flags & DLM_LKF_CONVERT && !lksb->sb_lkid) |
1915 | goto out; | 1913 | goto out; |
1916 | 1914 | ||
@@ -1922,6 +1920,7 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, | |||
1922 | args->astaddr = ast; | 1920 | args->astaddr = ast; |
1923 | args->astparam = (long) astarg; | 1921 | args->astparam = (long) astarg; |
1924 | args->bastaddr = bast; | 1922 | args->bastaddr = bast; |
1923 | args->timeout = timeout_cs; | ||
1925 | args->mode = mode; | 1924 | args->mode = mode; |
1926 | args->lksb = lksb; | 1925 | args->lksb = lksb; |
1927 | rv = 0; | 1926 | rv = 0; |
@@ -1976,6 +1975,7 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
1976 | lkb->lkb_lksb = args->lksb; | 1975 | lkb->lkb_lksb = args->lksb; |
1977 | lkb->lkb_lvbptr = args->lksb->sb_lvbptr; | 1976 | lkb->lkb_lvbptr = args->lksb->sb_lvbptr; |
1978 | lkb->lkb_ownpid = (int) current->pid; | 1977 | lkb->lkb_ownpid = (int) current->pid; |
1978 | lkb->lkb_timeout_cs = args->timeout; | ||
1979 | rv = 0; | 1979 | rv = 0; |
1980 | out: | 1980 | out: |
1981 | return rv; | 1981 | return rv; |
@@ -2423,7 +2423,7 @@ int dlm_lock(dlm_lockspace_t *lockspace, | |||
2423 | if (error) | 2423 | if (error) |
2424 | goto out; | 2424 | goto out; |
2425 | 2425 | ||
2426 | error = set_lock_args(mode, lksb, flags, namelen, parent_lkid, ast, | 2426 | error = set_lock_args(mode, lksb, flags, namelen, 0, ast, |
2427 | astarg, bast, &args); | 2427 | astarg, bast, &args); |
2428 | if (error) | 2428 | if (error) |
2429 | goto out_put; | 2429 | goto out_put; |
@@ -4175,7 +4175,7 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4175 | 4175 | ||
4176 | int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, | 4176 | int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, |
4177 | int mode, uint32_t flags, void *name, unsigned int namelen, | 4177 | int mode, uint32_t flags, void *name, unsigned int namelen, |
4178 | uint32_t parent_lkid) | 4178 | unsigned long timeout_cs) |
4179 | { | 4179 | { |
4180 | struct dlm_lkb *lkb; | 4180 | struct dlm_lkb *lkb; |
4181 | struct dlm_args args; | 4181 | struct dlm_args args; |
@@ -4203,7 +4203,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, | |||
4203 | When DLM_IFL_USER is set, the dlm knows that this is a userspace | 4203 | When DLM_IFL_USER is set, the dlm knows that this is a userspace |
4204 | lock and that lkb_astparam is the dlm_user_args structure. */ | 4204 | lock and that lkb_astparam is the dlm_user_args structure. */ |
4205 | 4205 | ||
4206 | error = set_lock_args(mode, &ua->lksb, flags, namelen, parent_lkid, | 4206 | error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, |
4207 | DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args); | 4207 | DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args); |
4208 | lkb->lkb_flags |= DLM_IFL_USER; | 4208 | lkb->lkb_flags |= DLM_IFL_USER; |
4209 | ua->old_mode = DLM_LOCK_IV; | 4209 | ua->old_mode = DLM_LOCK_IV; |
@@ -4240,7 +4240,8 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, | |||
4240 | } | 4240 | } |
4241 | 4241 | ||
4242 | int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | 4242 | int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, |
4243 | int mode, uint32_t flags, uint32_t lkid, char *lvb_in) | 4243 | int mode, uint32_t flags, uint32_t lkid, char *lvb_in, |
4244 | unsigned long timeout_cs) | ||
4244 | { | 4245 | { |
4245 | struct dlm_lkb *lkb; | 4246 | struct dlm_lkb *lkb; |
4246 | struct dlm_args args; | 4247 | struct dlm_args args; |
@@ -4268,6 +4269,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
4268 | if (lvb_in && ua->lksb.sb_lvbptr) | 4269 | if (lvb_in && ua->lksb.sb_lvbptr) |
4269 | memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN); | 4270 | memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN); |
4270 | 4271 | ||
4272 | ua->xid = ua_tmp->xid; | ||
4271 | ua->castparam = ua_tmp->castparam; | 4273 | ua->castparam = ua_tmp->castparam; |
4272 | ua->castaddr = ua_tmp->castaddr; | 4274 | ua->castaddr = ua_tmp->castaddr; |
4273 | ua->bastparam = ua_tmp->bastparam; | 4275 | ua->bastparam = ua_tmp->bastparam; |
@@ -4275,8 +4277,8 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
4275 | ua->user_lksb = ua_tmp->user_lksb; | 4277 | ua->user_lksb = ua_tmp->user_lksb; |
4276 | ua->old_mode = lkb->lkb_grmode; | 4278 | ua->old_mode = lkb->lkb_grmode; |
4277 | 4279 | ||
4278 | error = set_lock_args(mode, &ua->lksb, flags, 0, 0, DLM_FAKE_USER_AST, | 4280 | error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs, |
4279 | ua, DLM_FAKE_USER_AST, &args); | 4281 | DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args); |
4280 | if (error) | 4282 | if (error) |
4281 | goto out_put; | 4283 | goto out_put; |
4282 | 4284 | ||