Skip to content

Commit 8e2e408

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: add union in dlm header for lockspace id
This patch adds union inside the lockspace id to handle it also for another use case for a different dlm command. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 37a247d commit 8e2e408

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

fs/dlm/dlm_internal.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
380380

381381
struct dlm_header {
382382
uint32_t h_version;
383-
uint32_t h_lockspace;
383+
union {
384+
/* for DLM_MSG and DLM_RCOM */
385+
uint32_t h_lockspace;
386+
} u;
384387
uint32_t h_nodeid; /* nodeid of sender */
385388
uint16_t h_length;
386389
uint8_t h_cmd; /* DLM_MSG, DLM_RCOM */

fs/dlm/lock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,7 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
35443544
ms = (struct dlm_message *) mb;
35453545

35463546
ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
3547-
ms->m_header.h_lockspace = ls->ls_global_id;
3547+
ms->m_header.u.h_lockspace = ls->ls_global_id;
35483548
ms->m_header.h_nodeid = dlm_our_nodeid();
35493549
ms->m_header.h_length = mb_len;
35503550
ms->m_header.h_cmd = DLM_MSG;
@@ -5038,16 +5038,16 @@ void dlm_receive_buffer(union dlm_packet *p, int nodeid)
50385038

50395039
if (hd->h_nodeid != nodeid) {
50405040
log_print("invalid h_nodeid %d from %d lockspace %x",
5041-
hd->h_nodeid, nodeid, hd->h_lockspace);
5041+
hd->h_nodeid, nodeid, hd->u.h_lockspace);
50425042
return;
50435043
}
50445044

5045-
ls = dlm_find_lockspace_global(hd->h_lockspace);
5045+
ls = dlm_find_lockspace_global(hd->u.h_lockspace);
50465046
if (!ls) {
50475047
if (dlm_config.ci_log_debug) {
50485048
printk_ratelimited(KERN_DEBUG "dlm: invalid lockspace "
50495049
"%u from %d cmd %d type %d\n",
5050-
hd->h_lockspace, nodeid, hd->h_cmd, type);
5050+
hd->u.h_lockspace, nodeid, hd->h_cmd, type);
50515051
}
50525052

50535053
if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS)

fs/dlm/rcom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static void _create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len,
3535
rc = (struct dlm_rcom *) mb;
3636

3737
rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
38-
rc->rc_header.h_lockspace = ls->ls_global_id;
38+
rc->rc_header.u.h_lockspace = ls->ls_global_id;
3939
rc->rc_header.h_nodeid = dlm_our_nodeid();
4040
rc->rc_header.h_length = mb_len;
4141
rc->rc_header.h_cmd = DLM_RCOM;
@@ -508,7 +508,7 @@ int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
508508
rc = (struct dlm_rcom *) mb;
509509

510510
rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
511-
rc->rc_header.h_lockspace = rc_in->rc_header.h_lockspace;
511+
rc->rc_header.u.h_lockspace = rc_in->rc_header.u.h_lockspace;
512512
rc->rc_header.h_nodeid = dlm_our_nodeid();
513513
rc->rc_header.h_length = mb_len;
514514
rc->rc_header.h_cmd = DLM_RCOM;

fs/dlm/util.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323
void header_out(struct dlm_header *hd)
2424
{
2525
hd->h_version = cpu_to_le32(hd->h_version);
26-
hd->h_lockspace = cpu_to_le32(hd->h_lockspace);
26+
/* does it for others u32 in union as well */
27+
hd->u.h_lockspace = cpu_to_le32(hd->u.h_lockspace);
2728
hd->h_nodeid = cpu_to_le32(hd->h_nodeid);
2829
hd->h_length = cpu_to_le16(hd->h_length);
2930
}
3031

3132
void header_in(struct dlm_header *hd)
3233
{
3334
hd->h_version = le32_to_cpu(hd->h_version);
34-
hd->h_lockspace = le32_to_cpu(hd->h_lockspace);
35+
/* does it for others u32 in union as well */
36+
hd->u.h_lockspace = le32_to_cpu(hd->u.h_lockspace);
3537
hd->h_nodeid = le32_to_cpu(hd->h_nodeid);
3638
hd->h_length = le16_to_cpu(hd->h_length);
3739
}

0 commit comments

Comments
 (0)