Skip to contentSkip to conversation

LVM2/daemons/clogd cluster.c cluster.h functio ...

PATCH [email protected] 1 participant 1 message Jul 28, 2009

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow at sourceware.org 2009-07-28 15:55:50

Modified files:
daemons/clogd : cluster.c cluster.h functions.c functions.h

Log message:
Making adjustments to go along with the changes to the kernel. A patch to the kernel, adding the 'luid' field to dm_ulog_request, will allow us to properly identify log instances. We will now be able to definitively identify which logs are to be removed/ suspended/resumed. This replaces the old faulty behavior of assuming the logs were the same if they had the same UUID and incrementing/decrementing a reference count.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clogd/cluster.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clogd/cluster.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clogd/functions.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clogd/functions.h.diff?cvsroot=lvm2&r1=1.3&r2=1.4

daemons/clogd/cluster.c +26 -14
@@ -101,6 +101,7 @@
 	uint32_t lowest_id;
 	cpg_handle_t handle;
 	struct cpg_name name;
+	uint64_t luid;
 
 	/* Are we the first, or have we received checkpoint? */
 	int state;
@@ -147,6 +148,12 @@
 		return -ENOENT;
 	}
 
+	/*
+	 * Once the request heads for the cluster, the luid looses
+	 * all its meaning.
+	 */
+	rq->u_rq.luid = 0;
+
 	iov.iov_base = rq;
 	iov.iov_len = sizeof(struct clog_request) + rq->u_rq.data_size;
 
@@ -357,7 +364,8 @@
 	new->requester = cp_requester;
 	strncpy(new->uuid, entry->name.value, entry->name.length);
 
-	new->bitmap_size = push_state(entry->name.value, "clean_bits",
+	new->bitmap_size = push_state(entry->name.value, entry->luid,
+				      "clean_bits",
 				      &new->clean_bits, cp_requester);
 	if (new->bitmap_size <= 0) {
 		LOG_ERROR("Failed to store clean_bits to checkpoint for node %u",
@@ -366,8 +374,9 @@
 		return NULL;
 	}
 
-	new->bitmap_size = push_state(entry->name.value,
-				      "sync_bits", &new->sync_bits, cp_requester);
+	new->bitmap_size = push_state(entry->name.value, entry->luid,
+				      "sync_bits",
+				      &new->sync_bits, cp_requester);
 	if (new->bitmap_size <= 0) {
 		LOG_ERROR("Failed to store sync_bits to checkpoint for node %u",
 			  new->requester);
@@ -376,7 +385,9 @@
 		return NULL;
 	}
 
-	r = push_state(entry->name.value, "recovering_region", &new->recovering_region, cp_requester);
+	r = push_state(entry->name.value, entry->luid,
+		       "recovering_region",
+		       &new->recovering_region, cp_requester);
 	if (r <= 0) {
 		LOG_ERROR("Failed to store recovering_region to checkpoint for node %u",
 			  new->requester);
@@ -703,7 +714,7 @@
 		}
 
 		if (iov.readSize) {
-			if (pull_state(entry->name.value,
+			if (pull_state(entry->name.value, entry->luid,
 				       (char *)desc.sectionId.id, bitmap,
 				       iov.readSize)) {
 				LOG_ERROR("Error loading state");
@@ -1235,7 +1246,7 @@
 		cpg_fd_get(match->handle, &fd);
 		links_unregister(fd);
 
-		cluster_postsuspend(match->name.value);
+		cluster_postsuspend(match->name.value, match->luid);
 
 		list_for_each_entry_safe(rq, n, &match->working_list, list) {
 			list_del_init(&rq->list);
@@ -1437,7 +1448,7 @@
 	return 1;
 }
 
-int create_cluster_cpg(char *str)
+int create_cluster_cpg(char *uuid, uint64_t luid)
 {
 	int r;
 	int size;
@@ -1445,8 +1456,8 @@
 	struct clog_cpg *tmp, *tmp2;
 
 	list_for_each_entry_safe(tmp, tmp2, &clog_cpg_list, list)
-		if (!strncmp(tmp->name.value, str, CPG_MAX_NAME_LENGTH)) {
-			LOG_ERROR("Log entry already exists: %s", str);
+		if (!strncmp(tmp->name.value, uuid, CPG_MAX_NAME_LENGTH)) {
+			LOG_ERROR("Log entry already exists: %s", uuid);
 			return -EEXIST;
 		}
 
@@ -1461,10 +1472,11 @@
 	INIT_LIST_HEAD(&new->startup_list);
 	INIT_LIST_HEAD(&new->working_list);
 
-	size = ((strlen(str) + 1) > CPG_MAX_NAME_LENGTH) ?
-		CPG_MAX_NAME_LENGTH : (strlen(str) + 1);
-	strncpy(new->name.value, str, size);
+	size = ((strlen(uuid) + 1) > CPG_MAX_NAME_LENGTH) ?
+		CPG_MAX_NAME_LENGTH : (strlen(uuid) + 1);
+	strncpy(new->name.value, uuid, size);
 	new->name.length = size;
+	new->luid = luid;
 
 	/*
 	 * Ensure there are no stale checkpoints around before we join
@@ -1560,12 +1572,12 @@
 	return 0;
 }
 
-int destroy_cluster_cpg(char *str)
+int destroy_cluster_cpg(char *uuid)
 {
 	struct clog_cpg *del, *tmp;
 
 	list_for_each_entry_safe(del, tmp, &clog_cpg_list, list)
-		if (!strncmp(del->name.value, str, CPG_MAX_NAME_LENGTH))
+		if (!strncmp(del->name.value, uuid, CPG_MAX_NAME_LENGTH))
 			_destroy_cluster_cpg(del);
 
 	return 0;
daemons/clogd/cluster.h +2 -2
@@ -38,8 +38,8 @@
 void cleanup_cluster(void);
 void cluster_debug(void);
 
-int create_cluster_cpg(char *str);
-int destroy_cluster_cpg(char *str);
+int create_cluster_cpg(char *uuid, uint64_t luid);
+int destroy_cluster_cpg(char *uuid);
 
 int cluster_send(struct clog_request *rq);
 
daemons/clogd/functions.c +56 -64

361 lines not on this page · raw message

daemons/clogd/functions.h +5 -4
@@ -8,12 +8,13 @@
 #define LOG_SUSPENDED 2
 
 int local_resume(struct dm_ulog_request *rq);
-int cluster_postsuspend(char *);
+int cluster_postsuspend(char *, uint64_t);
 
 int do_request(struct clog_request *rq, int server);
-int push_state(const char *uuid, const char *which,
-	       char **buf, uint32_t debug_who);
-int pull_state(const char *uuid, const char *which, char *buf, int size);
+int push_state(const char *uuid, uint64_t luid,
+	       const char *which, char **buf, uint32_t debug_who);
+int pull_state(const char *uuid, uint64_t luid,
+	       const char *which, char *buf, int size);
 
 int log_get_state(struct dm_ulog_request *rq);
 int log_status(void);