All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCHv4 dlm/next 15/20] fs: dlm: add union in dlm header for lockspace id
Date: Mon, 11 Jan 2021 13:03:05 -0500	[thread overview]
Message-ID: <20210111180310.122451-16-aahringo@redhat.com> (raw)
In-Reply-To: <20210111180310.122451-1-aahringo@redhat.com>

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>
---
 fs/dlm/dlm_internal.h | 5 ++++-
 fs/dlm/lock.c         | 8 ++++----
 fs/dlm/midcomms.c     | 1 -
 fs/dlm/rcom.c         | 4 ++--
 fs/dlm/util.c         | 6 ++++--
 5 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index 04fe9f525ac7..917de7367a32 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -377,7 +377,10 @@ static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
 
 struct dlm_header {
 	uint32_t		h_version;
-	uint32_t		h_lockspace;
+	union {
+		/* for DLM_MSG and DLM_RCOM */
+		uint32_t	h_lockspace;
+	} u;
 	uint32_t		h_nodeid;	/* nodeid of sender */
 	uint16_t		h_length;
 	uint8_t			h_cmd;		/* DLM_MSG, DLM_RCOM */
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index b3fd823009f4..daa5747c8556 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -3544,7 +3544,7 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
 	ms = (struct dlm_message *) mb;
 
 	ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
-	ms->m_header.h_lockspace = ls->ls_global_id;
+	ms->m_header.u.h_lockspace = ls->ls_global_id;
 	ms->m_header.h_nodeid = dlm_our_nodeid();
 	ms->m_header.h_length = mb_len;
 	ms->m_header.h_cmd = DLM_MSG;
@@ -5038,16 +5038,16 @@ void dlm_receive_buffer(union dlm_packet *p, int nodeid)
 
 	if (hd->h_nodeid != nodeid) {
 		log_print("invalid h_nodeid %d from %d lockspace %x",
-			  hd->h_nodeid, nodeid, hd->h_lockspace);
+			  hd->h_nodeid, nodeid, hd->u.h_lockspace);
 		return;
 	}
 
-	ls = dlm_find_lockspace_global(hd->h_lockspace);
+	ls = dlm_find_lockspace_global(hd->u.h_lockspace);
 	if (!ls) {
 		if (dlm_config.ci_log_debug) {
 			printk_ratelimited(KERN_DEBUG "dlm: invalid lockspace "
 				"%u from %d cmd %d type %d\n",
-				hd->h_lockspace, nodeid, hd->h_cmd, type);
+				hd->u.h_lockspace, nodeid, hd->h_cmd, type);
 		}
 
 		if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS)
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index 45dd3d7d857f..71a1f0c910b3 100644
--- a/fs/dlm/midcomms.c
+++ b/fs/dlm/midcomms.c
@@ -149,4 +149,3 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len)
 
 	return ret;
 }
-
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c
index 7a7d4a8e4706..06f7a5f1d99d 100644
--- a/fs/dlm/rcom.c
+++ b/fs/dlm/rcom.c
@@ -49,7 +49,7 @@ static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len,
 	rc = (struct dlm_rcom *) mb;
 
 	rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
-	rc->rc_header.h_lockspace = ls->ls_global_id;
+	rc->rc_header.u.h_lockspace = ls->ls_global_id;
 	rc->rc_header.h_nodeid = dlm_our_nodeid();
 	rc->rc_header.h_length = mb_len;
 	rc->rc_header.h_cmd = DLM_RCOM;
@@ -476,7 +476,7 @@ int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
 	rc = (struct dlm_rcom *) mb;
 
 	rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
-	rc->rc_header.h_lockspace = rc_in->rc_header.h_lockspace;
+	rc->rc_header.u.h_lockspace = rc_in->rc_header.u.h_lockspace;
 	rc->rc_header.h_nodeid = dlm_our_nodeid();
 	rc->rc_header.h_length = mb_len;
 	rc->rc_header.h_cmd = DLM_RCOM;
diff --git a/fs/dlm/util.c b/fs/dlm/util.c
index 74a8c5bfe9b5..58acbcc2081a 100644
--- a/fs/dlm/util.c
+++ b/fs/dlm/util.c
@@ -23,7 +23,8 @@
 void header_out(struct dlm_header *hd)
 {
 	hd->h_version		= cpu_to_le32(hd->h_version);
-	hd->h_lockspace		= cpu_to_le32(hd->h_lockspace);
+	/* does it for others u32 in union as well */
+	hd->u.h_lockspace	= cpu_to_le32(hd->u.h_lockspace);
 	hd->h_nodeid		= cpu_to_le32(hd->h_nodeid);
 	hd->h_length		= cpu_to_le16(hd->h_length);
 }
@@ -31,7 +32,8 @@ void header_out(struct dlm_header *hd)
 void header_in(struct dlm_header *hd)
 {
 	hd->h_version		= le32_to_cpu(hd->h_version);
-	hd->h_lockspace		= le32_to_cpu(hd->h_lockspace);
+	/* does it for others u32 in union as well */
+	hd->u.h_lockspace	= le32_to_cpu(hd->u.h_lockspace);
 	hd->h_nodeid		= le32_to_cpu(hd->h_nodeid);
 	hd->h_length		= le16_to_cpu(hd->h_length);
 }
-- 
2.26.2



  parent reply	other threads:[~2021-01-11 18:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 18:02 [Cluster-devel] [PATCHv4 dlm/next 00/20] fs: dlm: introduce dlm re-transmission layer Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 01/20] fs: dlm: set connected bit after accept Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 02/20] fs: dlm: set subclass for othercon sock_mutex Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 03/20] fs: dlm: add errno handling to check callback Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 04/20] fs: dlm: add check if dlm is currently running Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 05/20] fs: dlm: change allocation limits Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 06/20] fs: dlm: public header in out utility Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 07/20] fs: dlm: use GFP_ZERO for page buffer Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 08/20] fs: dlm: simplify writequeue handling Alexander Aring
2021-01-11 18:02 ` [Cluster-devel] [PATCHv4 dlm/next 09/20] fs: dlm: add more midcomms hooks Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 10/20] fs: dlm: make buffer handling per msg Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 11/20] fs: dlm: make new buffer handling softirq ready Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 12/20] fs: dlm: add functionality to re-transmit a message Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 13/20] fs: dlm: move out some hash functionality Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 14/20] fs: dlm: remove unaligned memory access handling Alexander Aring
2021-01-11 18:03 ` Alexander Aring [this message]
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 16/20] fs: dlm: add per node receive flush Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 17/20] fs: dlm: add reliable connection if reconnect Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 18/20] fs: dlm: don't allow half transmitted messages Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 19/20] fs: dlm: remove obsolete code and comment Alexander Aring
2021-01-11 18:03 ` [Cluster-devel] [PATCHv4 dlm/next 20/20] fs: dlm: check for invalid namelen Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111180310.122451-16-aahringo@redhat.com \
    --to=aahringo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.