Skip to content

Commit b9d2f6a

Browse files
Alexander Aringteigland
authored andcommitted
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 <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 561c67d commit b9d2f6a

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

fs/dlm/lock.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,7 +5384,8 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
53845384
back the rcom_lock struct we got but with the remid field filled in. */
53855385

53865386
/* 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)
53885389
{
53895390
struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf;
53905391
struct dlm_rsb *r;
@@ -5393,6 +5394,9 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
53935394
int from_nodeid = le32_to_cpu(rc->rc_header.h_nodeid);
53945395
int error;
53955396

5397+
/* init rl_remid with rcom lock rl_remid */
5398+
*rl_remid = rl->rl_remid;
5399+
53965400
if (rl->rl_parent_lkid) {
53975401
error = -EOPNOTSUPP;
53985402
goto out;
@@ -5448,7 +5452,7 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
54485452
out_remid:
54495453
/* this is the new value returned to the lock holder for
54505454
saving in its process-copy lkb */
5451-
rl->rl_remid = cpu_to_le32(lkb->lkb_id);
5455+
*rl_remid = cpu_to_le32(lkb->lkb_id);
54525456

54535457
lkb->lkb_recover_seq = ls->ls_recover_seq;
54545458

@@ -5459,7 +5463,7 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
54595463
if (error && error != -EEXIST)
54605464
log_rinfo(ls, "dlm_recover_master_copy remote %d %x error %d",
54615465
from_nodeid, remid, error);
5462-
rl->rl_result = cpu_to_le32(error);
5466+
*rl_result = cpu_to_le32(error);
54635467
return error;
54645468
}
54655469

fs/dlm/lock.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ void dlm_purge_mstcpy_locks(struct dlm_rsb *r);
3636
void dlm_recover_grant(struct dlm_ls *ls);
3737
int dlm_recover_waiters_post(struct dlm_ls *ls);
3838
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);
4041
int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc,
4142
uint64_t seq);
4243

fs/dlm/rcom.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,21 +472,25 @@ int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, uint64_t seq)
472472
static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in,
473473
uint64_t seq)
474474
{
475+
__le32 rl_remid, rl_result;
476+
struct rcom_lock *rl;
475477
struct dlm_rcom *rc;
476478
struct dlm_mhandle *mh;
477479
int error, nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid);
478480

479-
dlm_recover_master_copy(ls, rc_in);
481+
dlm_recover_master_copy(ls, rc_in, &rl_remid, &rl_result);
480482

481483
error = create_rcom(ls, nodeid, DLM_RCOM_LOCK_REPLY,
482484
sizeof(struct rcom_lock), &rc, &mh, seq);
483485
if (error)
484486
return;
485487

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-
489488
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+
490494
rc->rc_id = rc_in->rc_id;
491495
rc->rc_seq_reply = rc_in->rc_seq;
492496

0 commit comments

Comments
 (0)