aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dlm/lock.c')
-rw-r--r--fs/dlm/lock.c139
1 files changed, 83 insertions, 56 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index ff4a198fa677..8f250ac8b928 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -436,11 +436,15 @@ static int find_rsb(struct dlm_ls *ls, char *name, int namelen,
436{ 436{
437 struct dlm_rsb *r, *tmp; 437 struct dlm_rsb *r, *tmp;
438 uint32_t hash, bucket; 438 uint32_t hash, bucket;
439 int error = 0; 439 int error = -EINVAL;
440
441 if (namelen > DLM_RESNAME_MAXLEN)
442 goto out;
440 443
441 if (dlm_no_directory(ls)) 444 if (dlm_no_directory(ls))
442 flags |= R_CREATE; 445 flags |= R_CREATE;
443 446
447 error = 0;
444 hash = jhash(name, namelen, 0); 448 hash = jhash(name, namelen, 0);
445 bucket = hash & (ls->ls_rsbtbl_size - 1); 449 bucket = hash & (ls->ls_rsbtbl_size - 1);
446 450
@@ -1222,6 +1226,8 @@ static void set_lvb_lock_pc(struct dlm_rsb *r, struct dlm_lkb *lkb,
1222 b = dlm_lvb_operations[lkb->lkb_grmode + 1][lkb->lkb_rqmode + 1]; 1226 b = dlm_lvb_operations[lkb->lkb_grmode + 1][lkb->lkb_rqmode + 1];
1223 if (b == 1) { 1227 if (b == 1) {
1224 int len = receive_extralen(ms); 1228 int len = receive_extralen(ms);
1229 if (len > DLM_RESNAME_MAXLEN)
1230 len = DLM_RESNAME_MAXLEN;
1225 memcpy(lkb->lkb_lvbptr, ms->m_extra, len); 1231 memcpy(lkb->lkb_lvbptr, ms->m_extra, len);
1226 lkb->lkb_lvbseq = ms->m_lvbseq; 1232 lkb->lkb_lvbseq = ms->m_lvbseq;
1227 } 1233 }
@@ -1775,7 +1781,7 @@ static void grant_pending_locks(struct dlm_rsb *r)
1775 */ 1781 */
1776 1782
1777 list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) { 1783 list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) {
1778 if (lkb->lkb_bastaddr && lock_requires_bast(lkb, high, cw)) { 1784 if (lkb->lkb_bastfn && lock_requires_bast(lkb, high, cw)) {
1779 if (cw && high == DLM_LOCK_PR) 1785 if (cw && high == DLM_LOCK_PR)
1780 queue_bast(r, lkb, DLM_LOCK_CW); 1786 queue_bast(r, lkb, DLM_LOCK_CW);
1781 else 1787 else
@@ -1805,7 +1811,7 @@ static void send_bast_queue(struct dlm_rsb *r, struct list_head *head,
1805 struct dlm_lkb *gr; 1811 struct dlm_lkb *gr;
1806 1812
1807 list_for_each_entry(gr, head, lkb_statequeue) { 1813 list_for_each_entry(gr, head, lkb_statequeue) {
1808 if (gr->lkb_bastaddr && modes_require_bast(gr, lkb)) { 1814 if (gr->lkb_bastfn && modes_require_bast(gr, lkb)) {
1809 queue_bast(r, gr, lkb->lkb_rqmode); 1815 queue_bast(r, gr, lkb->lkb_rqmode);
1810 gr->lkb_highbast = lkb->lkb_rqmode; 1816 gr->lkb_highbast = lkb->lkb_rqmode;
1811 } 1817 }
@@ -1960,8 +1966,11 @@ static void confirm_master(struct dlm_rsb *r, int error)
1960} 1966}
1961 1967
1962static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, 1968static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
1963 int namelen, unsigned long timeout_cs, void *ast, 1969 int namelen, unsigned long timeout_cs,
1964 void *astarg, void *bast, struct dlm_args *args) 1970 void (*ast) (void *astparam),
1971 void *astparam,
1972 void (*bast) (void *astparam, int mode),
1973 struct dlm_args *args)
1965{ 1974{
1966 int rv = -EINVAL; 1975 int rv = -EINVAL;
1967 1976
@@ -2011,9 +2020,9 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
2011 an active lkb cannot be modified before locking the rsb */ 2020 an active lkb cannot be modified before locking the rsb */
2012 2021
2013 args->flags = flags; 2022 args->flags = flags;
2014 args->astaddr = ast; 2023 args->astfn = ast;
2015 args->astparam = (long) astarg; 2024 args->astparam = astparam;
2016 args->bastaddr = bast; 2025 args->bastfn = bast;
2017 args->timeout = timeout_cs; 2026 args->timeout = timeout_cs;
2018 args->mode = mode; 2027 args->mode = mode;
2019 args->lksb = lksb; 2028 args->lksb = lksb;
@@ -2032,7 +2041,7 @@ static int set_unlock_args(uint32_t flags, void *astarg, struct dlm_args *args)
2032 return -EINVAL; 2041 return -EINVAL;
2033 2042
2034 args->flags = flags; 2043 args->flags = flags;
2035 args->astparam = (long) astarg; 2044 args->astparam = astarg;
2036 return 0; 2045 return 0;
2037} 2046}
2038 2047
@@ -2062,9 +2071,9 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
2062 2071
2063 lkb->lkb_exflags = args->flags; 2072 lkb->lkb_exflags = args->flags;
2064 lkb->lkb_sbflags = 0; 2073 lkb->lkb_sbflags = 0;
2065 lkb->lkb_astaddr = args->astaddr; 2074 lkb->lkb_astfn = args->astfn;
2066 lkb->lkb_astparam = args->astparam; 2075 lkb->lkb_astparam = args->astparam;
2067 lkb->lkb_bastaddr = args->bastaddr; 2076 lkb->lkb_bastfn = args->bastfn;
2068 lkb->lkb_rqmode = args->mode; 2077 lkb->lkb_rqmode = args->mode;
2069 lkb->lkb_lksb = args->lksb; 2078 lkb->lkb_lksb = args->lksb;
2070 lkb->lkb_lvbptr = args->lksb->sb_lvbptr; 2079 lkb->lkb_lvbptr = args->lksb->sb_lvbptr;
@@ -2711,9 +2720,9 @@ static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb,
2711 /* m_result and m_bastmode are set from function args, 2720 /* m_result and m_bastmode are set from function args,
2712 not from lkb fields */ 2721 not from lkb fields */
2713 2722
2714 if (lkb->lkb_bastaddr) 2723 if (lkb->lkb_bastfn)
2715 ms->m_asts |= AST_BAST; 2724 ms->m_asts |= AST_BAST;
2716 if (lkb->lkb_astaddr) 2725 if (lkb->lkb_astfn)
2717 ms->m_asts |= AST_COMP; 2726 ms->m_asts |= AST_COMP;
2718 2727
2719 /* compare with switch in create_message; send_remove() doesn't 2728 /* compare with switch in create_message; send_remove() doesn't
@@ -2989,11 +2998,23 @@ static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb,
2989 if (!lkb->lkb_lvbptr) 2998 if (!lkb->lkb_lvbptr)
2990 return -ENOMEM; 2999 return -ENOMEM;
2991 len = receive_extralen(ms); 3000 len = receive_extralen(ms);
3001 if (len > DLM_RESNAME_MAXLEN)
3002 len = DLM_RESNAME_MAXLEN;
2992 memcpy(lkb->lkb_lvbptr, ms->m_extra, len); 3003 memcpy(lkb->lkb_lvbptr, ms->m_extra, len);
2993 } 3004 }
2994 return 0; 3005 return 0;
2995} 3006}
2996 3007
3008static void fake_bastfn(void *astparam, int mode)
3009{
3010 log_print("fake_bastfn should not be called");
3011}
3012
3013static void fake_astfn(void *astparam)
3014{
3015 log_print("fake_astfn should not be called");
3016}
3017
2997static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 3018static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
2998 struct dlm_message *ms) 3019 struct dlm_message *ms)
2999{ 3020{
@@ -3002,8 +3023,9 @@ static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
3002 lkb->lkb_remid = ms->m_lkid; 3023 lkb->lkb_remid = ms->m_lkid;
3003 lkb->lkb_grmode = DLM_LOCK_IV; 3024 lkb->lkb_grmode = DLM_LOCK_IV;
3004 lkb->lkb_rqmode = ms->m_rqmode; 3025 lkb->lkb_rqmode = ms->m_rqmode;
3005 lkb->lkb_bastaddr = (void *) (long) (ms->m_asts & AST_BAST); 3026
3006 lkb->lkb_astaddr = (void *) (long) (ms->m_asts & AST_COMP); 3027 lkb->lkb_bastfn = (ms->m_asts & AST_BAST) ? &fake_bastfn : NULL;
3028 lkb->lkb_astfn = (ms->m_asts & AST_COMP) ? &fake_astfn : NULL;
3007 3029
3008 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 3030 if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
3009 /* lkb was just created so there won't be an lvb yet */ 3031 /* lkb was just created so there won't be an lvb yet */
@@ -3802,7 +3824,7 @@ static void dlm_receive_message(struct dlm_ls *ls, struct dlm_message *ms,
3802 int nodeid) 3824 int nodeid)
3803{ 3825{
3804 if (dlm_locking_stopped(ls)) { 3826 if (dlm_locking_stopped(ls)) {
3805 dlm_add_requestqueue(ls, nodeid, (struct dlm_header *) ms); 3827 dlm_add_requestqueue(ls, nodeid, ms);
3806 } else { 3828 } else {
3807 dlm_wait_requestqueue(ls); 3829 dlm_wait_requestqueue(ls);
3808 _receive_message(ls, ms); 3830 _receive_message(ls, ms);
@@ -3822,21 +3844,20 @@ void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms)
3822 standard locking activity) or an RCOM (recovery message sent as part of 3844 standard locking activity) or an RCOM (recovery message sent as part of
3823 lockspace recovery). */ 3845 lockspace recovery). */
3824 3846
3825void dlm_receive_buffer(struct dlm_header *hd, int nodeid) 3847void dlm_receive_buffer(union dlm_packet *p, int nodeid)
3826{ 3848{
3827 struct dlm_message *ms = (struct dlm_message *) hd; 3849 struct dlm_header *hd = &p->header;
3828 struct dlm_rcom *rc = (struct dlm_rcom *) hd;
3829 struct dlm_ls *ls; 3850 struct dlm_ls *ls;
3830 int type = 0; 3851 int type = 0;
3831 3852
3832 switch (hd->h_cmd) { 3853 switch (hd->h_cmd) {
3833 case DLM_MSG: 3854 case DLM_MSG:
3834 dlm_message_in(ms); 3855 dlm_message_in(&p->message);
3835 type = ms->m_type; 3856 type = p->message.m_type;
3836 break; 3857 break;
3837 case DLM_RCOM: 3858 case DLM_RCOM:
3838 dlm_rcom_in(rc); 3859 dlm_rcom_in(&p->rcom);
3839 type = rc->rc_type; 3860 type = p->rcom.rc_type;
3840 break; 3861 break;
3841 default: 3862 default:
3842 log_print("invalid h_cmd %d from %u", hd->h_cmd, nodeid); 3863 log_print("invalid h_cmd %d from %u", hd->h_cmd, nodeid);
@@ -3856,7 +3877,7 @@ void dlm_receive_buffer(struct dlm_header *hd, int nodeid)
3856 hd->h_lockspace, nodeid, hd->h_cmd, type); 3877 hd->h_lockspace, nodeid, hd->h_cmd, type);
3857 3878
3858 if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS) 3879 if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS)
3859 dlm_send_ls_not_ready(nodeid, rc); 3880 dlm_send_ls_not_ready(nodeid, &p->rcom);
3860 return; 3881 return;
3861 } 3882 }
3862 3883
@@ -3865,9 +3886,9 @@ void dlm_receive_buffer(struct dlm_header *hd, int nodeid)
3865 3886
3866 down_read(&ls->ls_recv_active); 3887 down_read(&ls->ls_recv_active);
3867 if (hd->h_cmd == DLM_MSG) 3888 if (hd->h_cmd == DLM_MSG)
3868 dlm_receive_message(ls, ms, nodeid); 3889 dlm_receive_message(ls, &p->message, nodeid);
3869 else 3890 else
3870 dlm_receive_rcom(ls, rc, nodeid); 3891 dlm_receive_rcom(ls, &p->rcom, nodeid);
3871 up_read(&ls->ls_recv_active); 3892 up_read(&ls->ls_recv_active);
3872 3893
3873 dlm_put_lockspace(ls); 3894 dlm_put_lockspace(ls);
@@ -4267,32 +4288,34 @@ static struct dlm_lkb *search_remid(struct dlm_rsb *r, int nodeid,
4267 return NULL; 4288 return NULL;
4268} 4289}
4269 4290
4291/* needs at least dlm_rcom + rcom_lock */
4270static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 4292static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
4271 struct dlm_rsb *r, struct dlm_rcom *rc) 4293 struct dlm_rsb *r, struct dlm_rcom *rc)
4272{ 4294{
4273 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 4295 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf;
4274 int lvblen;
4275 4296
4276 lkb->lkb_nodeid = rc->rc_header.h_nodeid; 4297 lkb->lkb_nodeid = rc->rc_header.h_nodeid;
4277 lkb->lkb_ownpid = rl->rl_ownpid; 4298 lkb->lkb_ownpid = le32_to_cpu(rl->rl_ownpid);
4278 lkb->lkb_remid = rl->rl_lkid; 4299 lkb->lkb_remid = le32_to_cpu(rl->rl_lkid);
4279 lkb->lkb_exflags = rl->rl_exflags; 4300 lkb->lkb_exflags = le32_to_cpu(rl->rl_exflags);
4280 lkb->lkb_flags = rl->rl_flags & 0x0000FFFF; 4301 lkb->lkb_flags = le32_to_cpu(rl->rl_flags) & 0x0000FFFF;
4281 lkb->lkb_flags |= DLM_IFL_MSTCPY; 4302 lkb->lkb_flags |= DLM_IFL_MSTCPY;
4282 lkb->lkb_lvbseq = rl->rl_lvbseq; 4303 lkb->lkb_lvbseq = le32_to_cpu(rl->rl_lvbseq);
4283 lkb->lkb_rqmode = rl->rl_rqmode; 4304 lkb->lkb_rqmode = rl->rl_rqmode;
4284 lkb->lkb_grmode = rl->rl_grmode; 4305 lkb->lkb_grmode = rl->rl_grmode;
4285 /* don't set lkb_status because add_lkb wants to itself */ 4306 /* don't set lkb_status because add_lkb wants to itself */
4286 4307
4287 lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST); 4308 lkb->lkb_bastfn = (rl->rl_asts & AST_BAST) ? &fake_bastfn : NULL;
4288 lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP); 4309 lkb->lkb_astfn = (rl->rl_asts & AST_COMP) ? &fake_astfn : NULL;
4289 4310
4290 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 4311 if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
4312 int lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) -
4313 sizeof(struct rcom_lock);
4314 if (lvblen > ls->ls_lvblen)
4315 return -EINVAL;
4291 lkb->lkb_lvbptr = dlm_allocate_lvb(ls); 4316 lkb->lkb_lvbptr = dlm_allocate_lvb(ls);
4292 if (!lkb->lkb_lvbptr) 4317 if (!lkb->lkb_lvbptr)
4293 return -ENOMEM; 4318 return -ENOMEM;
4294 lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) -
4295 sizeof(struct rcom_lock);
4296 memcpy(lkb->lkb_lvbptr, rl->rl_lvb, lvblen); 4319 memcpy(lkb->lkb_lvbptr, rl->rl_lvb, lvblen);
4297 } 4320 }
4298 4321
@@ -4300,7 +4323,8 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
4300 The real granted mode of these converting locks cannot be determined 4323 The real granted mode of these converting locks cannot be determined
4301 until all locks have been rebuilt on the rsb (recover_conversion) */ 4324 until all locks have been rebuilt on the rsb (recover_conversion) */
4302 4325
4303 if (rl->rl_wait_type == DLM_MSG_CONVERT && middle_conversion(lkb)) { 4326 if (rl->rl_wait_type == cpu_to_le16(DLM_MSG_CONVERT) &&
4327 middle_conversion(lkb)) {
4304 rl->rl_status = DLM_LKSTS_CONVERT; 4328 rl->rl_status = DLM_LKSTS_CONVERT;
4305 lkb->lkb_grmode = DLM_LOCK_IV; 4329 lkb->lkb_grmode = DLM_LOCK_IV;
4306 rsb_set_flag(r, RSB_RECOVER_CONVERT); 4330 rsb_set_flag(r, RSB_RECOVER_CONVERT);
@@ -4315,6 +4339,7 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
4315 the given values and send back our lkid. We send back our lkid by sending 4339 the given values and send back our lkid. We send back our lkid by sending
4316 back the rcom_lock struct we got but with the remid field filled in. */ 4340 back the rcom_lock struct we got but with the remid field filled in. */
4317 4341
4342/* needs at least dlm_rcom + rcom_lock */
4318int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) 4343int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
4319{ 4344{
4320 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 4345 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf;
@@ -4327,13 +4352,14 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
4327 goto out; 4352 goto out;
4328 } 4353 }
4329 4354
4330 error = find_rsb(ls, rl->rl_name, rl->rl_namelen, R_MASTER, &r); 4355 error = find_rsb(ls, rl->rl_name, le16_to_cpu(rl->rl_namelen),
4356 R_MASTER, &r);
4331 if (error) 4357 if (error)
4332 goto out; 4358 goto out;
4333 4359
4334 lock_rsb(r); 4360 lock_rsb(r);
4335 4361
4336 lkb = search_remid(r, rc->rc_header.h_nodeid, rl->rl_lkid); 4362 lkb = search_remid(r, rc->rc_header.h_nodeid, le32_to_cpu(rl->rl_lkid));
4337 if (lkb) { 4363 if (lkb) {
4338 error = -EEXIST; 4364 error = -EEXIST;
4339 goto out_remid; 4365 goto out_remid;
@@ -4356,18 +4382,20 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
4356 out_remid: 4382 out_remid:
4357 /* this is the new value returned to the lock holder for 4383 /* this is the new value returned to the lock holder for
4358 saving in its process-copy lkb */ 4384 saving in its process-copy lkb */
4359 rl->rl_remid = lkb->lkb_id; 4385 rl->rl_remid = cpu_to_le32(lkb->lkb_id);
4360 4386
4361 out_unlock: 4387 out_unlock:
4362 unlock_rsb(r); 4388 unlock_rsb(r);
4363 put_rsb(r); 4389 put_rsb(r);
4364 out: 4390 out:
4365 if (error) 4391 if (error)
4366 log_debug(ls, "recover_master_copy %d %x", error, rl->rl_lkid); 4392 log_debug(ls, "recover_master_copy %d %x", error,
4367 rl->rl_result = error; 4393 le32_to_cpu(rl->rl_lkid));
4394 rl->rl_result = cpu_to_le32(error);
4368 return error; 4395 return error;
4369} 4396}
4370 4397
4398/* needs at least dlm_rcom + rcom_lock */
4371int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) 4399int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
4372{ 4400{
4373 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 4401 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf;
@@ -4375,15 +4403,16 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
4375 struct dlm_lkb *lkb; 4403 struct dlm_lkb *lkb;
4376 int error; 4404 int error;
4377 4405
4378 error = find_lkb(ls, rl->rl_lkid, &lkb); 4406 error = find_lkb(ls, le32_to_cpu(rl->rl_lkid), &lkb);
4379 if (error) { 4407 if (error) {
4380 log_error(ls, "recover_process_copy no lkid %x", rl->rl_lkid); 4408 log_error(ls, "recover_process_copy no lkid %x",
4409 le32_to_cpu(rl->rl_lkid));
4381 return error; 4410 return error;
4382 } 4411 }
4383 4412
4384 DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb);); 4413 DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb););
4385 4414
4386 error = rl->rl_result; 4415 error = le32_to_cpu(rl->rl_result);
4387 4416
4388 r = lkb->lkb_resource; 4417 r = lkb->lkb_resource;
4389 hold_rsb(r); 4418 hold_rsb(r);
@@ -4402,7 +4431,7 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
4402 log_debug(ls, "master copy exists %x", lkb->lkb_id); 4431 log_debug(ls, "master copy exists %x", lkb->lkb_id);
4403 /* fall through */ 4432 /* fall through */
4404 case 0: 4433 case 0:
4405 lkb->lkb_remid = rl->rl_remid; 4434 lkb->lkb_remid = le32_to_cpu(rl->rl_remid);
4406 break; 4435 break;
4407 default: 4436 default:
4408 log_error(ls, "dlm_recover_process_copy unknown error %d %x", 4437 log_error(ls, "dlm_recover_process_copy unknown error %d %x",
@@ -4451,7 +4480,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
4451 lock and that lkb_astparam is the dlm_user_args structure. */ 4480 lock and that lkb_astparam is the dlm_user_args structure. */
4452 4481
4453 error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, 4482 error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs,
4454 DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args); 4483 fake_astfn, ua, fake_bastfn, &args);
4455 lkb->lkb_flags |= DLM_IFL_USER; 4484 lkb->lkb_flags |= DLM_IFL_USER;
4456 ua->old_mode = DLM_LOCK_IV; 4485 ua->old_mode = DLM_LOCK_IV;
4457 4486
@@ -4504,7 +4533,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4504 /* user can change the params on its lock when it converts it, or 4533 /* user can change the params on its lock when it converts it, or
4505 add an lvb that didn't exist before */ 4534 add an lvb that didn't exist before */
4506 4535
4507 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4536 ua = lkb->lkb_ua;
4508 4537
4509 if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) { 4538 if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) {
4510 ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); 4539 ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL);
@@ -4525,7 +4554,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4525 ua->old_mode = lkb->lkb_grmode; 4554 ua->old_mode = lkb->lkb_grmode;
4526 4555
4527 error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs, 4556 error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs,
4528 DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args); 4557 fake_astfn, ua, fake_bastfn, &args);
4529 if (error) 4558 if (error)
4530 goto out_put; 4559 goto out_put;
4531 4560
@@ -4555,7 +4584,7 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4555 if (error) 4584 if (error)
4556 goto out; 4585 goto out;
4557 4586
4558 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4587 ua = lkb->lkb_ua;
4559 4588
4560 if (lvb_in && ua->lksb.sb_lvbptr) 4589 if (lvb_in && ua->lksb.sb_lvbptr)
4561 memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN); 4590 memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN);
@@ -4604,7 +4633,7 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4604 if (error) 4633 if (error)
4605 goto out; 4634 goto out;
4606 4635
4607 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4636 ua = lkb->lkb_ua;
4608 if (ua_tmp->castparam) 4637 if (ua_tmp->castparam)
4609 ua->castparam = ua_tmp->castparam; 4638 ua->castparam = ua_tmp->castparam;
4610 ua->user_lksb = ua_tmp->user_lksb; 4639 ua->user_lksb = ua_tmp->user_lksb;
@@ -4642,7 +4671,7 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid)
4642 if (error) 4671 if (error)
4643 goto out; 4672 goto out;
4644 4673
4645 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4674 ua = lkb->lkb_ua;
4646 4675
4647 error = set_unlock_args(flags, ua, &args); 4676 error = set_unlock_args(flags, ua, &args);
4648 if (error) 4677 if (error)
@@ -4681,7 +4710,6 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid)
4681 4710
4682static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) 4711static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4683{ 4712{
4684 struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam;
4685 struct dlm_args args; 4713 struct dlm_args args;
4686 int error; 4714 int error;
4687 4715
@@ -4690,7 +4718,7 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4690 list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans); 4718 list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans);
4691 mutex_unlock(&ls->ls_orphans_mutex); 4719 mutex_unlock(&ls->ls_orphans_mutex);
4692 4720
4693 set_unlock_args(0, ua, &args); 4721 set_unlock_args(0, lkb->lkb_ua, &args);
4694 4722
4695 error = cancel_lock(ls, lkb, &args); 4723 error = cancel_lock(ls, lkb, &args);
4696 if (error == -DLM_ECANCEL) 4724 if (error == -DLM_ECANCEL)
@@ -4703,11 +4731,10 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4703 4731
4704static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) 4732static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4705{ 4733{
4706 struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam;
4707 struct dlm_args args; 4734 struct dlm_args args;
4708 int error; 4735 int error;
4709 4736
4710 set_unlock_args(DLM_LKF_FORCEUNLOCK, ua, &args); 4737 set_unlock_args(DLM_LKF_FORCEUNLOCK, lkb->lkb_ua, &args);
4711 4738
4712 error = unlock_lock(ls, lkb, &args); 4739 error = unlock_lock(ls, lkb, &args);
4713 if (error == -DLM_EUNLOCK) 4740 if (error == -DLM_EUNLOCK)