All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [RFC PATCH dlm/next 10/16] fs: dlm: add functionality to retransmit a message
Date: Fri, 13 Nov 2020 17:58:08 -0500	[thread overview]
Message-ID: <20201113225814.461167-11-aahringo@redhat.com> (raw)
In-Reply-To: <20201113225814.461167-1-aahringo@redhat.com>

This patch introduces a irqsafe retransmit functionality for a lowcomms
message handle. It's just allocates a new buffer and transmit it again.
To avoid another connection look some refactor was done to make a new
buffer allocation with a preexisting connection pointer.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 fs/dlm/lowcomms.c | 54 +++++++++++++++++++++++++++++++++++------------
 fs/dlm/lowcomms.h |  1 +
 2 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 3c133cd2ff22..0ef1a1ffd301 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -1428,24 +1428,14 @@ static struct writequeue_entry *new_wq_entry(struct connection *con, int len,
 	return e;
 };
 
-void *dlm_lowcomms_new_buffer(int nodeid, int len, gfp_t allocation, char **ppc,
-			      void (*cb)(void *buf, void *priv), void *priv)
+static void *dlm_lowcomms_new_buffer_con(struct connection *con, int len,
+					 gfp_t allocation, char **ppc,
+					 void (*cb)(void *buf, void *priv),
+					 void *priv)
 {
 	struct writequeue_entry *e;
-	struct connection *con;
 	struct dlm_msg *msg;
 
-	if (len > LOWCOMMS_MAX_TX_BUFFER_LEN ||
-	    len < sizeof(struct dlm_header)) {
-		BUILD_BUG_ON(PAGE_SIZE < LOWCOMMS_MAX_TX_BUFFER_LEN);
-		log_print("failed to allocate a buffer of size %d", len);
-		return NULL;
-	}
-
-	con = nodeid2con(nodeid, allocation);
-	if (!con)
-		return NULL;
-
 	msg = kzalloc(sizeof(*msg), allocation);
 	if (!msg)
 		return NULL;
@@ -1465,6 +1455,25 @@ void *dlm_lowcomms_new_buffer(int nodeid, int len, gfp_t allocation, char **ppc,
 	return msg;
 }
 
+void *dlm_lowcomms_new_buffer(int nodeid, int len, gfp_t allocation, char **ppc,
+			      void (*cb)(void *buf, void *priv), void *priv)
+{
+	struct connection *con;
+
+	if (len > LOWCOMMS_MAX_TX_BUFFER_LEN ||
+	    len < sizeof(struct dlm_header)) {
+		BUILD_BUG_ON(PAGE_SIZE < LOWCOMMS_MAX_TX_BUFFER_LEN);
+		log_print("failed to allocate a buffer of size %d", len);
+		return NULL;
+	}
+
+	con = nodeid2con(nodeid, allocation);
+	if (!con)
+		return NULL;
+
+	return dlm_lowcomms_new_buffer_con(con, len, GFP_ATOMIC, ppc, cb, priv);
+}
+
 void dlm_lowcomms_commit_buffer(void *mh)
 {
 	struct dlm_msg *msg = mh;
@@ -1505,6 +1514,23 @@ void dlm_lowcomms_get_buffer(void *mh)
 	kref_get(&msg->ref);
 }
 
+/* irqsafe */
+void dlm_lowcomms_resend_buffer(void *mh)
+{
+	struct dlm_msg *msg = mh;
+	void *mh_new;
+	char *ppc;
+
+	mh_new = dlm_lowcomms_new_buffer_con(msg->entry->con, msg->len, GFP_ATOMIC,
+					     &ppc, NULL, NULL);
+	if (!mh_new)
+		return;
+
+	memcpy(ppc, msg->ppc, msg->len);
+	dlm_lowcomms_commit_buffer(mh_new);
+	dlm_lowcomms_put_buffer(mh_new);
+}
+
 /* Send a message */
 static void send_to_sock(struct connection *con)
 {
diff --git a/fs/dlm/lowcomms.h b/fs/dlm/lowcomms.h
index 6417c5fca215..30924b6f03e1 100644
--- a/fs/dlm/lowcomms.h
+++ b/fs/dlm/lowcomms.h
@@ -28,6 +28,7 @@ int dlm_lowcomms_connect_node(int nodeid);
 int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len);
 void dlm_lowcomms_put_buffer(void *mh);
 void dlm_lowcomms_get_buffer(void *mh);
+void dlm_lowcomms_resend_buffer(void *mh);
 
 #endif				/* __LOWCOMMS_DOT_H__ */
 
-- 
2.26.2



  parent reply	other threads:[~2020-11-13 22:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 22:57 [Cluster-devel] [RFC PATCH dlm/next 00/16] fs: dlm: introduce dlm retransmission layer Alexander Aring
2020-11-13 22:57 ` [Cluster-devel] [RFC PATCH dlm/next 01/16] fs: dlm: add errno handling to check callback Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 02/16] fs: dlm: add check if dlm is currently running Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 03/16] fs: dlm: add check for minimum allocation length Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 04/16] fs: dlm: public utils header utils Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 05/16] fs: dlm: use GFP_ZERO for page buffer Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 06/16] fs: dlm: simplify writequeue handling Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 07/16] fs: dlm: add more midcomms hooks Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 08/16] fs: dlm: make buffer handling per msg Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 09/16] fs: dlm: make new buffer handling softirq ready Alexander Aring
2020-11-13 22:58 ` Alexander Aring [this message]
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 11/16] fs: dlm: move out some hash functionality Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 12/16] fs: dlm: remove unaligned memory access handling Alexander Aring
2020-11-24 14:50   ` Alexander Ahring Oder Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 13/16] fs: dlm: check on minimum header size Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 14/16] fs: dlm: add union in dlm header for lockspace id Alexander Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 15/16] fs: dlm: add reliable connection if reconnect Alexander Aring
2020-11-16 18:45   ` Alexander Ahring Oder Aring
2020-11-17 18:48   ` Alexander Ahring Oder Aring
2020-11-23 22:40   ` Alexander Ahring Oder Aring
2020-11-13 22:58 ` [Cluster-devel] [RFC PATCH dlm/next 16/16] fs: dlm: don't allow half transmitted messages 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=20201113225814.461167-11-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.