[Cluster-devel] cluster/cmirror/src Makefile cluster.c

jbrassow at sourceware.org jbrassow at sourceware.org
Thu Feb 21 14:45:50 UTC 2008


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	jbrassow at sourceware.org	2008-02-21 14:45:49

Modified files:
	cmirror/src    : Makefile cluster.c 

Log message:
	- couple fixes for checking error codes from openais

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror/src/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3.2.5&r2=1.3.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror/src/cluster.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.16&r2=1.1.2.17

--- cluster/cmirror/src/Attic/Makefile	2008/01/18 20:32:09	1.3.2.5
+++ cluster/cmirror/src/Attic/Makefile	2008/02/21 14:45:49	1.3.2.6
@@ -44,7 +44,6 @@
 
 all: ${TARGET}
 
-#clogd: rbtree.c link_mon.c logging.c queues.c local.c cluster.c functions.c clogd.c
 clogd: ${SOURCES}
 	${CC} ${CFLAGS} -o $@ $^ ${LDFLAGS}
 
--- cluster/cmirror/src/Attic/cluster.c	2008/02/08 14:30:10	1.1.2.16
+++ cluster/cmirror/src/Attic/cluster.c	2008/02/21 14:45:49	1.1.2.17
@@ -104,6 +104,7 @@
 	return -EBADE;
 }
 
+/* FIXME: this is here for debugging... remove */
 int cluster_send_helper(struct clog_tfr *tfr, int line, char *file, const char *function)
 {
 	int r;
@@ -121,10 +122,10 @@
 static int clog_tfr_cmp(struct clog_tfr *a, struct clog_tfr *b)
 {
 	int r = 0;
-	ENTER();
+
 	if (a->seq == b->seq)
 		r = 1;
-	EXIT("%s", r ? "[MATCH]" : "");
+
 	return r;
 }
 
@@ -132,8 +133,6 @@
 {
 	int r = 0;
 
-	ENTER("%s", RQ_TYPE(tfr->request_type));
-
 	/*
 	 * With resumes, we only handle our own.
 	 * Resume is a special case that requires
@@ -152,16 +151,15 @@
 		 * Errors from previous functions are in the tfr struct.
 		 */
 		if (printz)
-			LOG_DBG("[%s] Sending response to %u on cluster: [%s/%llu]",
-				SHORT_UUID(tfr->uuid), tfr->originator,
-				RQ_TYPE(tfr->request_type & ~DM_CLOG_RESPONSE),
-				(unsigned long long)tfr->seq);
+			LOG_PRINT("[%s] Sending response to %u on cluster: [%s/%llu]",
+				  SHORT_UUID(tfr->uuid), tfr->originator,
+				  RQ_TYPE(tfr->request_type & ~DM_CLOG_RESPONSE),
+				  (unsigned long long)tfr->seq);
 		r = cluster_send(tfr);
 		if (r)
 			LOG_ERROR("cluster_send failed: %s", strerror(-r));
 	}
 
-	EXIT();
 	return r;
 }
 
@@ -170,7 +168,6 @@
 	int r = 0;
 	struct clog_tfr *orig_tfr;
 
-	ENTER("%s", RQ_TYPE(tfr->request_type & ~DM_CLOG_RESPONSE));
 	/*
 	 * If I didn't send it, then I don't care about the response
 	 */
@@ -217,7 +214,6 @@
 		LOG_ERROR("Failed to send response to kernel");
 
 out:
-	EXIT();
 	return r;
 }
 
@@ -298,6 +294,8 @@
 		new->bitmap_size = 0;
 	}
 
+	LOG_DBG("[%s] Checkpoint prepared for %u",
+		SHORT_UUID(new->uuid), cp_requester);
 	return new;
 }
 
@@ -327,7 +325,6 @@
 	int len;
 	char buf[32];
 
-	ENTER();
 	LOG_DBG("Sending checkpointed data to %u", cp->requester);
 
 	len = snprintf((char *)(name.value), SA_MAX_NAME_LENGTH, "bitmaps_%s_%u",
@@ -355,12 +352,12 @@
 
 	if (rv == SA_AIS_ERR_EXIST) {
 		LOG_DBG("export_checkpoint: checkpoint already exists");
-		EXIT();
 		return -EEXIST;
 	}
 
 	if (rv != SA_AIS_OK) {
-		EXIT();
+		LOG_ERROR("[%s] Failed to open checkpoint for %u",
+			  SHORT_UUID(cp->uuid), cp->requester);
 		return -EIO; /* FIXME: better error */
 	}
 
@@ -382,13 +379,13 @@
 
 	if (rv == SA_AIS_ERR_EXIST) {
 		LOG_DBG("export_checkpoint: sync checkpoint section already exists");
-		EXIT();
+		saCkptCheckpointClose(h);
 		return -EEXIST;
 	}
 
 	if (rv != SA_AIS_OK) {
 		LOG_ERROR("export_checkpoint: sync checkpoint section creation failed");
-		EXIT();
+		saCkptCheckpointClose(h);
 		return -EIO; /* FIXME: better error */
 	}
 
@@ -410,13 +407,13 @@
 
 	if (rv == SA_AIS_ERR_EXIST) {
 		LOG_DBG("export_checkpoint: clean checkpoint section already exists");
-		EXIT();
+		saCkptCheckpointClose(h);
 		return -EEXIST;
 	}
 
 	if (rv != SA_AIS_OK) {
 		LOG_ERROR("export_checkpoint: clean checkpoint section creation failed");
-		EXIT();
+		saCkptCheckpointClose(h);
 		return -EIO; /* FIXME: better error */
 	}
 
@@ -439,13 +436,13 @@
 
 	if (rv == SA_AIS_ERR_EXIST) {
 		LOG_DBG("export_checkpoint: RR checkpoint section already exists");
-		EXIT();
+		saCkptCheckpointClose(h);
 		return -EEXIST;
 	}
 
 	if (rv != SA_AIS_OK) {
 		LOG_ERROR("export_checkpoint: RR checkpoint section creation failed");
-		EXIT();
+		saCkptCheckpointClose(h);
 		return -EIO; /* FIXME: better error */
 	}
 
@@ -474,10 +471,27 @@
 	}
 	queue_add(tfr, free_queue);
 
-	EXIT();
+	LOG_DBG("[%s] Checkpoint ready, notification sent to %u",
+		SHORT_UUID(cp->uuid), cp->requester);
+
 	return 0;
 }
 
+void ckpt_print (char *str, SaCkptCheckpointHandleT handle)
+{
+	SaCkptCheckpointDescriptorT descriptor;
+	SaAisErrorT rv;
+
+retry_statusget:
+	rv = saCkptCheckpointStatusGet (handle, &descriptor);
+	if (rv == SA_AIS_ERR_TRY_AGAIN)
+		goto retry_statusget;
+	
+	LOG_DBG("printing [%s] sections [%d] result [%d]",
+		str, descriptor.numberOfSections, rv);
+}
+
+
 static int import_checkpoint(struct clog_cpg *entry, int no_read)
 {
 	int rtn = 0;
@@ -490,8 +504,6 @@
 	char *bitmap = NULL;
 	int len;
 
-	ENTER();
-
 	bitmap = malloc(1024*1024);
 	if (!bitmap)
 		return -ENOMEM;
@@ -511,10 +523,11 @@
 
 	if (rv != SA_AIS_OK) {
 		LOG_ERROR("Failed to open checkpoint");
-		EXIT();
 		return -EIO; /* FIXME: better error */
 	}
 
+	ckpt_print ("Before unlink", h);
+
 	saCkptCheckpointUnlink(ckpt_handle, &name);
 
 	if (no_read) {
@@ -522,8 +535,10 @@
 		goto no_read;
 	}
 
+	ckpt_print ("After unlink", h);
+
 init_retry:
-	rv = saCkptSectionIterationInitialize(h, SA_CKPT_SECTIONS_ANY, 0, &itr);
+	rv = saCkptSectionIterationInitialize(h, SA_CKPT_SECTIONS_ANY, SA_TIME_END, &itr);
 	if (rv == SA_AIS_ERR_TRY_AGAIN) {
 		LOG_ERROR("import_checkpoint: sync create retry");
 		sleep(1);
@@ -532,7 +547,6 @@
 
 	if (rv != SA_AIS_OK) {
 		LOG_ERROR("import_checkpoint: sync checkpoint section creation failed");
-		EXIT();
 		return -EIO; /* FIXME: better error */
 	}
 
@@ -541,8 +555,10 @@
 		rv = saCkptSectionIterationNext(itr, &desc);
 		if (rv == SA_AIS_OK)
 			len++;
-		else
+		else if (rv != SA_AIS_ERR_TRY_AGAIN) {
+			LOG_ERROR("saCkptSectionIterationNext failure: %d", rv);
 			break;
+		}
 	}
 	saCkptSectionIterationFinalize(itr);
 	if (len != 3) {
@@ -550,7 +566,7 @@
 		sleep(1);
 		goto init_retry;
 	}
-	saCkptSectionIterationInitialize(h, SA_CKPT_SECTIONS_ANY, 0, &itr);
+	saCkptSectionIterationInitialize(h, SA_CKPT_SECTIONS_ANY, SA_TIME_END, &itr);
 
 	while (1) {
 		rv = saCkptSectionIterationNext(itr, &desc);
@@ -620,8 +636,18 @@
 no_read:
 	saCkptCheckpointClose(h);
 
+	/*
+	LOG_PRINT("Testing if chkpoint exists after unlink/close");
+	rv = saCkptCheckpointOpen(ckpt_handle, &name, NULL,
+				  SA_CKPT_CHECKPOINT_READ, 0, &h);
+	if (rv != SA_AIS_OK) {
+		LOG_PRINT("Checkpoint was not removed!!!");
+		saCkptCheckpointClose(h);
+	} else
+		LOG_PRINT("   rv == %d", rv);
+	*/
+
 	free(bitmap);
-	EXIT();
 	return rtn;
 }
 
@@ -631,7 +657,6 @@
 	struct clog_cpg *entry, *tmp;
 	struct checkpoint_data *cp;
 
-	ENTER();
 	list_for_each_entry_safe(entry, tmp, &clog_cpg_list, list) {
 		r = cpg_dispatch(entry->handle, CPG_DISPATCH_ALL);
 		if (r != SA_AIS_OK)
@@ -666,7 +691,6 @@
 			}
 		}
 	}
-	EXIT();
 	return (r == SA_AIS_OK) ? 0 : -1;  /* FIXME: good error number? */
 }
 
@@ -681,8 +705,6 @@
 	struct clog_tfr *startup_tfr = NULL;
 	struct clog_cpg *match;
 
-	ENTER();
-
 	if (msg_len != (sizeof(*tfr) + tfr->data_size))
 		LOG_ERROR("Badly sized message recieved from cluster.");
 
@@ -835,7 +857,6 @@
 		if (response)
 			sprintf(debugging[idx] + len, ", RSPR=%u", nodeid);
 	}
-	EXIT();
 }
 
 static void cpg_config_callback(cpg_handle_t handle, struct cpg_name *gname,
@@ -849,8 +870,6 @@
 	struct clog_cpg *match, *tmp;
 	uint32_t lowest = 0xDEAD;
 
-	ENTER();
-
 	memberz = member_list_entries;
 
 	LOG_DBG("****** CPG config callback **[%s]**",
@@ -990,21 +1009,20 @@
 
 out:
 	if (lowest != match->lowest_id)
-		LOG_DBG("[%s]  Server change %u -> %u (%u %s)",
-			SHORT_UUID(match->name.value),
-			lowest, match->lowest_id,
-			(joined_list_entries) ? joined_list[0].nodeid : left_list[0].nodeid,
-			(joined_list_entries && (member_list_entries == 1)) ? 
-			"is first to join" : (joined_list_entries) ? "joined" : "left");
+		LOG_PRINT("[%s]  Server change %u -> %u (%u %s)",
+			  SHORT_UUID(match->name.value),
+			  lowest, match->lowest_id,
+			  (joined_list_entries) ? joined_list[0].nodeid : left_list[0].nodeid,
+			  (joined_list_entries && (member_list_entries == 1)) ? 
+			  "is first to join" : (joined_list_entries) ? "joined" : "left");
 	else
-		LOG_DBG("[%s]  Server unchanged at %u (%u %s)",
-			SHORT_UUID(match->name.value), lowest,
-			(joined_list_entries) ? joined_list[0].nodeid : left_list[0].nodeid,
-			(joined_list_entries) ? "joined" : "left");
+		LOG_PRINT("[%s]  Server unchanged at %u (%u %s)",
+			  SHORT_UUID(match->name.value), lowest,
+			  (joined_list_entries) ? joined_list[0].nodeid : left_list[0].nodeid,
+			  (joined_list_entries) ? "joined" : "left");
 
 	if (joined_list_entries && (joined_list[0].nodeid == my_cluster_id))
 		doit = 25;
-	EXIT();
 }
 
 cpg_callbacks_t cpg_callbacks = {
@@ -1019,8 +1037,6 @@
 	struct clog_cpg *new;
 	struct clog_cpg *tmp, *tmp2;
 
-	ENTER();
-
 	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);
@@ -1030,7 +1046,6 @@
 	new = malloc(sizeof(*new));
 	if (!new) {
 		LOG_ERROR("Unable to allocate memory for clog_cpg");
-		EXIT();
 		return -ENOMEM;
 	}
 	memset(new, 0, sizeof(*new));
@@ -1041,7 +1056,6 @@
 	if (!new->startup_queue) {
 		free(new);
 		LOG_ERROR("Unable to allocate memory for clog_cpg");
-		EXIT();
 		return -ENOMEM;
 	}
 	INIT_LIST_HEAD(&(new->startup_queue->list));
@@ -1056,14 +1070,12 @@
 	r = cpg_initialize(&new->handle, &cpg_callbacks);
 	if (r != SA_AIS_OK) {
 		LOG_ERROR("cpg_initialize failed:  Cannot join cluster");
-		EXIT();
 		return -EPERM;
 	}
 
 	r = cpg_join(new->handle, &new->name);
 	if (r != SA_AIS_OK) {
 		LOG_ERROR("cpg_join failed:  Cannot join cluster");
-		EXIT();
 		return -EPERM;
 	}
 
@@ -1075,7 +1087,6 @@
 	cpg_fd_get(new->handle, &r);
 	links_register(r, "cluster", do_cluster_work, NULL);
 
-	EXIT();
 	return 0;
 }
 
@@ -1084,7 +1095,6 @@
 	int r;
 	struct clog_cpg *del, *tmp;
 
-	ENTER();
 	list_for_each_entry_safe(del, tmp, &clog_cpg_list, list)
 		if (!strncmp(del->name.value, str, CPG_MAX_NAME_LENGTH)) {
 			r = cpg_leave(del->handle, &del->name);
@@ -1093,7 +1103,6 @@
 			break;
 		}
 
-	EXIT();
 	return 0;
 }
 
@@ -1101,8 +1110,6 @@
 {
 	SaAisErrorT rv;
 
-	ENTER();
-
 	{
 		int i;
 		for(i = 0; i < DEBUGGING_HISTORY; i++)
@@ -1112,12 +1119,9 @@
 	INIT_LIST_HEAD(&clog_cpg_list);
 	rv = saCkptInitialize(&ckpt_handle, &callbacks, &version);
 
-	if (rv != SA_AIS_OK) {
-		EXIT("saCkptInitialize failure");
+	if (rv != SA_AIS_OK)
 		return EXIT_CLUSTER_CKPT_INIT;
-	}
 
-	EXIT();
 	return 0;
 }
 




More information about the Cluster-devel mailing list