lock.c (eef7d739c218cb2546cf95686db77de0d76e4122) | lock.c (163a1859ec6c4c33547bf4613efabf52031566aa) |
---|---|
1/****************************************************************************** 2******************************************************************************* 3** 4** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 5** 6** This copyrighted material is made available to anyone wishing to use, 7** modify, copy, or redistribute it subject to the terms and conditions 8** of the GNU General Public License v.2. --- 4259 unchanged lines hidden (view full) --- 4268 4269static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 4270 struct dlm_rsb *r, struct dlm_rcom *rc) 4271{ 4272 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 4273 int lvblen; 4274 4275 lkb->lkb_nodeid = rc->rc_header.h_nodeid; | 1/****************************************************************************** 2******************************************************************************* 3** 4** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 5** 6** This copyrighted material is made available to anyone wishing to use, 7** modify, copy, or redistribute it subject to the terms and conditions 8** of the GNU General Public License v.2. --- 4259 unchanged lines hidden (view full) --- 4268 4269static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 4270 struct dlm_rsb *r, struct dlm_rcom *rc) 4271{ 4272 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 4273 int lvblen; 4274 4275 lkb->lkb_nodeid = rc->rc_header.h_nodeid; |
4276 lkb->lkb_ownpid = rl->rl_ownpid; 4277 lkb->lkb_remid = rl->rl_lkid; 4278 lkb->lkb_exflags = rl->rl_exflags; 4279 lkb->lkb_flags = rl->rl_flags & 0x0000FFFF; | 4276 lkb->lkb_ownpid = le32_to_cpu(rl->rl_ownpid); 4277 lkb->lkb_remid = le32_to_cpu(rl->rl_lkid); 4278 lkb->lkb_exflags = le32_to_cpu(rl->rl_exflags); 4279 lkb->lkb_flags = le32_to_cpu(rl->rl_flags) & 0x0000FFFF; |
4280 lkb->lkb_flags |= DLM_IFL_MSTCPY; | 4280 lkb->lkb_flags |= DLM_IFL_MSTCPY; |
4281 lkb->lkb_lvbseq = rl->rl_lvbseq; | 4281 lkb->lkb_lvbseq = le32_to_cpu(rl->rl_lvbseq); |
4282 lkb->lkb_rqmode = rl->rl_rqmode; 4283 lkb->lkb_grmode = rl->rl_grmode; 4284 /* don't set lkb_status because add_lkb wants to itself */ 4285 4286 lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST); 4287 lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP); 4288 4289 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { --- 4 unchanged lines hidden (view full) --- 4294 sizeof(struct rcom_lock); 4295 memcpy(lkb->lkb_lvbptr, rl->rl_lvb, lvblen); 4296 } 4297 4298 /* Conversions between PR and CW (middle modes) need special handling. 4299 The real granted mode of these converting locks cannot be determined 4300 until all locks have been rebuilt on the rsb (recover_conversion) */ 4301 | 4282 lkb->lkb_rqmode = rl->rl_rqmode; 4283 lkb->lkb_grmode = rl->rl_grmode; 4284 /* don't set lkb_status because add_lkb wants to itself */ 4285 4286 lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST); 4287 lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP); 4288 4289 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { --- 4 unchanged lines hidden (view full) --- 4294 sizeof(struct rcom_lock); 4295 memcpy(lkb->lkb_lvbptr, rl->rl_lvb, lvblen); 4296 } 4297 4298 /* Conversions between PR and CW (middle modes) need special handling. 4299 The real granted mode of these converting locks cannot be determined 4300 until all locks have been rebuilt on the rsb (recover_conversion) */ 4301 |
4302 if (rl->rl_wait_type == DLM_MSG_CONVERT && middle_conversion(lkb)) { | 4302 if (rl->rl_wait_type == cpu_to_le16(DLM_MSG_CONVERT) && 4303 middle_conversion(lkb)) { |
4303 rl->rl_status = DLM_LKSTS_CONVERT; 4304 lkb->lkb_grmode = DLM_LOCK_IV; 4305 rsb_set_flag(r, RSB_RECOVER_CONVERT); 4306 } 4307 4308 return 0; 4309} 4310 --- 10 unchanged lines hidden (view full) --- 4321 struct dlm_lkb *lkb; 4322 int error; 4323 4324 if (rl->rl_parent_lkid) { 4325 error = -EOPNOTSUPP; 4326 goto out; 4327 } 4328 | 4304 rl->rl_status = DLM_LKSTS_CONVERT; 4305 lkb->lkb_grmode = DLM_LOCK_IV; 4306 rsb_set_flag(r, RSB_RECOVER_CONVERT); 4307 } 4308 4309 return 0; 4310} 4311 --- 10 unchanged lines hidden (view full) --- 4322 struct dlm_lkb *lkb; 4323 int error; 4324 4325 if (rl->rl_parent_lkid) { 4326 error = -EOPNOTSUPP; 4327 goto out; 4328 } 4329 |
4329 error = find_rsb(ls, rl->rl_name, rl->rl_namelen, R_MASTER, &r); | 4330 error = find_rsb(ls, rl->rl_name, le16_to_cpu(rl->rl_namelen), 4331 R_MASTER, &r); |
4330 if (error) 4331 goto out; 4332 4333 lock_rsb(r); 4334 | 4332 if (error) 4333 goto out; 4334 4335 lock_rsb(r); 4336 |
4335 lkb = search_remid(r, rc->rc_header.h_nodeid, rl->rl_lkid); | 4337 lkb = search_remid(r, rc->rc_header.h_nodeid, le32_to_cpu(rl->rl_lkid)); |
4336 if (lkb) { 4337 error = -EEXIST; 4338 goto out_remid; 4339 } 4340 4341 error = create_lkb(ls, &lkb); 4342 if (error) 4343 goto out_unlock; --- 6 unchanged lines hidden (view full) --- 4350 4351 attach_lkb(r, lkb); 4352 add_lkb(r, lkb, rl->rl_status); 4353 error = 0; 4354 4355 out_remid: 4356 /* this is the new value returned to the lock holder for 4357 saving in its process-copy lkb */ | 4338 if (lkb) { 4339 error = -EEXIST; 4340 goto out_remid; 4341 } 4342 4343 error = create_lkb(ls, &lkb); 4344 if (error) 4345 goto out_unlock; --- 6 unchanged lines hidden (view full) --- 4352 4353 attach_lkb(r, lkb); 4354 add_lkb(r, lkb, rl->rl_status); 4355 error = 0; 4356 4357 out_remid: 4358 /* this is the new value returned to the lock holder for 4359 saving in its process-copy lkb */ |
4358 rl->rl_remid = lkb->lkb_id; | 4360 rl->rl_remid = cpu_to_le32(lkb->lkb_id); |
4359 4360 out_unlock: 4361 unlock_rsb(r); 4362 put_rsb(r); 4363 out: 4364 if (error) | 4361 4362 out_unlock: 4363 unlock_rsb(r); 4364 put_rsb(r); 4365 out: 4366 if (error) |
4365 log_debug(ls, "recover_master_copy %d %x", error, rl->rl_lkid); 4366 rl->rl_result = error; | 4367 log_debug(ls, "recover_master_copy %d %x", error, 4368 le32_to_cpu(rl->rl_lkid)); 4369 rl->rl_result = cpu_to_le32(error); |
4367 return error; 4368} 4369 4370int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) 4371{ 4372 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 4373 struct dlm_rsb *r; 4374 struct dlm_lkb *lkb; 4375 int error; 4376 | 4370 return error; 4371} 4372 4373int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) 4374{ 4375 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 4376 struct dlm_rsb *r; 4377 struct dlm_lkb *lkb; 4378 int error; 4379 |
4377 error = find_lkb(ls, rl->rl_lkid, &lkb); | 4380 error = find_lkb(ls, le32_to_cpu(rl->rl_lkid), &lkb); |
4378 if (error) { | 4381 if (error) { |
4379 log_error(ls, "recover_process_copy no lkid %x", rl->rl_lkid); | 4382 log_error(ls, "recover_process_copy no lkid %x", 4383 le32_to_cpu(rl->rl_lkid)); |
4380 return error; 4381 } 4382 4383 DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb);); 4384 | 4384 return error; 4385 } 4386 4387 DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb);); 4388 |
4385 error = rl->rl_result; | 4389 error = le32_to_cpu(rl->rl_result); |
4386 4387 r = lkb->lkb_resource; 4388 hold_rsb(r); 4389 lock_rsb(r); 4390 4391 switch (error) { 4392 case -EBADR: 4393 /* There's a chance the new master received our lock before 4394 dlm_recover_master_reply(), this wouldn't happen if we did 4395 a barrier between recover_masters and recover_locks. */ 4396 log_debug(ls, "master copy not ready %x r %lx %s", lkb->lkb_id, 4397 (unsigned long)r, r->res_name); 4398 dlm_send_rcom_lock(r, lkb); 4399 goto out; 4400 case -EEXIST: 4401 log_debug(ls, "master copy exists %x", lkb->lkb_id); 4402 /* fall through */ 4403 case 0: | 4390 4391 r = lkb->lkb_resource; 4392 hold_rsb(r); 4393 lock_rsb(r); 4394 4395 switch (error) { 4396 case -EBADR: 4397 /* There's a chance the new master received our lock before 4398 dlm_recover_master_reply(), this wouldn't happen if we did 4399 a barrier between recover_masters and recover_locks. */ 4400 log_debug(ls, "master copy not ready %x r %lx %s", lkb->lkb_id, 4401 (unsigned long)r, r->res_name); 4402 dlm_send_rcom_lock(r, lkb); 4403 goto out; 4404 case -EEXIST: 4405 log_debug(ls, "master copy exists %x", lkb->lkb_id); 4406 /* fall through */ 4407 case 0: |
4404 lkb->lkb_remid = rl->rl_remid; | 4408 lkb->lkb_remid = le32_to_cpu(rl->rl_remid); |
4405 break; 4406 default: 4407 log_error(ls, "dlm_recover_process_copy unknown error %d %x", 4408 error, lkb->lkb_id); 4409 } 4410 4411 /* an ack for dlm_recover_locks() which waits for replies from 4412 all the locks it sends to new masters */ --- 470 unchanged lines hidden --- | 4409 break; 4410 default: 4411 log_error(ls, "dlm_recover_process_copy unknown error %d %x", 4412 error, lkb->lkb_id); 4413 } 4414 4415 /* an ack for dlm_recover_locks() which waits for replies from 4416 all the locks it sends to new masters */ --- 470 unchanged lines hidden --- |