Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: dlm: drop rxbuf manipulation in dlm_recover_master_copy

Currently dlm_recover_master_copy() manipulates the receive buffer of an
rcom lock message and modifies it on the fly so a later memcpy() to a
new rcom message with the same message has those new values. This patch
avoids manipulating the received rcom message by store the values for
the new rcom message in paremter assigned with call by reference. Later
when dlm_send_rcom_lock() constructs a new message and memcpy() the
receive buffer those values will be set on the new constructed message.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>

authored by

Alexander Aring and committed by
David Teigland
b9d2f6ad 561c67d8

+17 -8
+7 -3
fs/dlm/lock.c
··· 5384 5384 back the rcom_lock struct we got but with the remid field filled in. */ 5385 5385 5386 5386 /* needs at least dlm_rcom + rcom_lock */ 5387 - int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) 5387 + int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc, 5388 + __le32 *rl_remid, __le32 *rl_result) 5388 5389 { 5389 5390 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 5390 5391 struct dlm_rsb *r; ··· 5393 5392 uint32_t remid = 0; 5394 5393 int from_nodeid = le32_to_cpu(rc->rc_header.h_nodeid); 5395 5394 int error; 5395 + 5396 + /* init rl_remid with rcom lock rl_remid */ 5397 + *rl_remid = rl->rl_remid; 5396 5398 5397 5399 if (rl->rl_parent_lkid) { 5398 5400 error = -EOPNOTSUPP; ··· 5452 5448 out_remid: 5453 5449 /* this is the new value returned to the lock holder for 5454 5450 saving in its process-copy lkb */ 5455 - rl->rl_remid = cpu_to_le32(lkb->lkb_id); 5451 + *rl_remid = cpu_to_le32(lkb->lkb_id); 5456 5452 5457 5453 lkb->lkb_recover_seq = ls->ls_recover_seq; 5458 5454 ··· 5463 5459 if (error && error != -EEXIST) 5464 5460 log_rinfo(ls, "dlm_recover_master_copy remote %d %x error %d", 5465 5461 from_nodeid, remid, error); 5466 - rl->rl_result = cpu_to_le32(error); 5462 + *rl_result = cpu_to_le32(error); 5467 5463 return error; 5468 5464 } 5469 5465
+2 -1
fs/dlm/lock.h
··· 36 36 void dlm_recover_grant(struct dlm_ls *ls); 37 37 int dlm_recover_waiters_post(struct dlm_ls *ls); 38 38 void dlm_recover_waiters_pre(struct dlm_ls *ls); 39 - int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc); 39 + int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc, 40 + __le32 *rl_remid, __le32 *rl_result); 40 41 int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc, 41 42 uint64_t seq); 42 43
+8 -4
fs/dlm/rcom.c
··· 472 472 static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in, 473 473 uint64_t seq) 474 474 { 475 + __le32 rl_remid, rl_result; 476 + struct rcom_lock *rl; 475 477 struct dlm_rcom *rc; 476 478 struct dlm_mhandle *mh; 477 479 int error, nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid); 478 480 479 - dlm_recover_master_copy(ls, rc_in); 481 + dlm_recover_master_copy(ls, rc_in, &rl_remid, &rl_result); 480 482 481 483 error = create_rcom(ls, nodeid, DLM_RCOM_LOCK_REPLY, 482 484 sizeof(struct rcom_lock), &rc, &mh, seq); 483 485 if (error) 484 486 return; 485 487 486 - /* We send back the same rcom_lock struct we received, but 487 - dlm_recover_master_copy() has filled in rl_remid and rl_result */ 488 - 489 488 memcpy(rc->rc_buf, rc_in->rc_buf, sizeof(struct rcom_lock)); 489 + rl = (struct rcom_lock *)rc->rc_buf; 490 + /* set rl_remid and rl_result from dlm_recover_master_copy() */ 491 + rl->rl_remid = rl_remid; 492 + rl->rl_result = rl_result; 493 + 490 494 rc->rc_id = rc_in->rc_id; 491 495 rc->rc_seq_reply = rc_in->rc_seq; 492 496