Skip to contentSkip to conversation

dlm_controld: handle RELEASE_RECOVER event env

PATCH New Alexander Aring 1 participant 1 message Jul 23, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dlm_controld: handle RELEASE_RECOVER event env

Newer kernels might sending an additional attribute for the leaving lockspace event "RELEASE_RECOVER" to tell other nodes from the release lockspace initator to call the recover_slot() callback in their recovery handling as a membership update triggers in-kernel recovery.

---
 dlm_controld/action.c     | 33 ++++++++++++++++++
 dlm_controld/cpg.c        | 72 ++++++++++++++++++++++++++++++++++++++-
 dlm_controld/dlm_daemon.h |  6 +++-
 dlm_controld/main.c       |  4 ++-
 4 files changed, 112 insertions(+), 3 deletions(-)
dlm_controld/action.c +33 -0
index 10f0f673..b73beea9 100644
@@ -211,6 +211,39 @@ int path_exists(const char *path)
 	return 1;
 }
 
+int set_configfs_member_release_recover(struct lockspace *ls, int id,
+					uint32_t release_recover)
+{
+	char path[PATH_MAX];
+	char buf[32];
+	int fd, rv;
+
+	memset(path, 0, PATH_MAX);
+	snprintf(path, PATH_MAX, "%s/%s/nodes/%d/release_recover",
+		 SPACES_DIR, ls->name, id);
+
+	rv = fd = open(path, O_WRONLY);
+	if (rv < 0) {
+		log_error("%s: open failed: %d", path, errno);
+		goto out;
+	}
+
+	memset(buf, 0, 32);
+	snprintf(buf, 32, "%u", release_recover);
+
+	rv = do_write(fd, buf, strlen(buf));
+	if (rv < 0) {
+		log_error("%s: write failed: %d, %s", path, errno, buf);
+		close(fd);
+		goto out;
+	}
+	close(fd);
+	rv = 0;
+
+out:
+	return rv;
+}
+
 /* The "renew" nodes are those that have left and rejoined since the last
    call to set_members().  We rmdir/mkdir for these nodes so dlm-kernel
    can notice they've left and rejoined. */
dlm_controld/cpg.c +71 -1

101 lines not on this page · raw message

dlm_controld/dlm_daemon.h +5 -1
index c902228f..95076b44 100644
@@ -247,6 +247,7 @@ enum {
 	DLM_MSG_RUN_REQUEST,
 	DLM_MSG_RUN_REPLY,
 	DLM_MSG_RUN_CANCEL,
+	DLM_MSG_RELEASE_RECOVER,
 };
 
 /* dlm_header flags */
@@ -381,6 +382,8 @@ int set_sysfs_control(char *name, int val);
 int set_sysfs_event_done(char *name, int val);
 int set_sysfs_id(char *name, uint32_t id);
 int set_sysfs_nodir(char *name, int val);
+int set_configfs_member_release_recover(struct lockspace *ls, int id,
+					uint32_t release_recover);
 int set_configfs_members(struct lockspace *ls, char *name,
 			 int new_count, int *new_members,
 			 int renew_count, int *renew_members);
@@ -405,7 +408,8 @@ void set_opt_online(char *cmd_str, int cmd_len);
 void process_lockspace_changes(void);
 void process_fencing_changes(void);
 int dlm_join_lockspace(struct lockspace *ls);
-int dlm_leave_lockspace(struct lockspace *ls);
+int dlm_leave_lockspace(struct lockspace *ls,
+			const char *release_recover_str);
 void update_flow_control_status(void);
 int set_node_info(struct lockspace *ls, int nodeid, struct dlmc_node *node);
 int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace);
dlm_controld/main.c +3 -1
index 6fb6dffe..a4beb312 100644
@@ -50,6 +50,7 @@ enum {
 	Env_DEVPATH,
 	Env_SUBSYSTEM,
 	Env_LOCKSPACE,
+	Env_RELEASE_RECOVER,
 	Env_Last, /* Flag for end of vars */
 };
 
@@ -58,6 +59,7 @@ static const char *uevent_vars[] = {
 	[Env_DEVPATH]		= "DEVPATH=",
 	[Env_SUBSYSTEM]		= "SUBSYSTEM=",
 	[Env_LOCKSPACE]		= "LOCKSPACE=",
+	[Env_RELEASE_RECOVER]	= "RELEASE_RECOVER=",
 };
 
 static void decode_uevent(const char *buf, unsigned len, const char *vars[],
@@ -769,7 +771,7 @@ static void process_uevent(int ci)
 			goto out;
 		}
 
-		dlm_leave_lockspace(ls);
+		dlm_leave_lockspace(ls, uevent_vals[Env_RELEASE_RECOVER]);
 	}
  out:
 	if (rv < 0)
Signature · 1 line
2.43.0