Skip to content

Commit

Permalink
fs: dlm: drop rxbuf manipulation in dlm_recover_master_copy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexander Aring authored and teigland committed Aug 10, 2023
1 parent 561c67d commit b9d2f6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 7 additions & 3 deletions fs/dlm/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -5384,7 +5384,8 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
back the rcom_lock struct we got but with the remid field filled in. */

/* needs at least dlm_rcom + rcom_lock */
int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc,
__le32 *rl_remid, __le32 *rl_result)
{
struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf;
struct dlm_rsb *r;
Expand All @@ -5393,6 +5394,9 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
int from_nodeid = le32_to_cpu(rc->rc_header.h_nodeid);
int error;

/* init rl_remid with rcom lock rl_remid */
*rl_remid = rl->rl_remid;

if (rl->rl_parent_lkid) {
error = -EOPNOTSUPP;
goto out;
Expand Down Expand Up @@ -5448,7 +5452,7 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
out_remid:
/* this is the new value returned to the lock holder for
saving in its process-copy lkb */
rl->rl_remid = cpu_to_le32(lkb->lkb_id);
*rl_remid = cpu_to_le32(lkb->lkb_id);

lkb->lkb_recover_seq = ls->ls_recover_seq;

Expand All @@ -5459,7 +5463,7 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
if (error && error != -EEXIST)
log_rinfo(ls, "dlm_recover_master_copy remote %d %x error %d",
from_nodeid, remid, error);
rl->rl_result = cpu_to_le32(error);
*rl_result = cpu_to_le32(error);
return error;
}

Expand Down
3 changes: 2 additions & 1 deletion fs/dlm/lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ void dlm_purge_mstcpy_locks(struct dlm_rsb *r);
void dlm_recover_grant(struct dlm_ls *ls);
int dlm_recover_waiters_post(struct dlm_ls *ls);
void dlm_recover_waiters_pre(struct dlm_ls *ls);
int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc);
int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc,
__le32 *rl_remid, __le32 *rl_result);
int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc,
uint64_t seq);

Expand Down
12 changes: 8 additions & 4 deletions fs/dlm/rcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,21 +472,25 @@ int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, uint64_t seq)
static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in,
uint64_t seq)
{
__le32 rl_remid, rl_result;
struct rcom_lock *rl;
struct dlm_rcom *rc;
struct dlm_mhandle *mh;
int error, nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid);

dlm_recover_master_copy(ls, rc_in);
dlm_recover_master_copy(ls, rc_in, &rl_remid, &rl_result);

error = create_rcom(ls, nodeid, DLM_RCOM_LOCK_REPLY,
sizeof(struct rcom_lock), &rc, &mh, seq);
if (error)
return;

/* We send back the same rcom_lock struct we received, but
dlm_recover_master_copy() has filled in rl_remid and rl_result */

memcpy(rc->rc_buf, rc_in->rc_buf, sizeof(struct rcom_lock));
rl = (struct rcom_lock *)rc->rc_buf;
/* set rl_remid and rl_result from dlm_recover_master_copy() */
rl->rl_remid = rl_remid;
rl->rl_result = rl_result;

rc->rc_id = rc_in->rc_id;
rc->rc_seq_reply = rc_in->rc_seq;

Expand Down

0 comments on commit b9d2f6a

Please sign in to comment.