[Sheepdog] [PATCH 1/6] sheep: always use the same error message for out-of-memory

Chris Webb chris at arachsys.com
Fri Nov 4 18:08:31 CET 2011


Signed-off-by: Chris Webb <chris at arachsys.com>
---
 sheep/cluster/corosync.c |   14 +++++++-------
 sheep/group.c            |   18 +++++++++---------
 sheep/sdnet.c            |    2 +-
 sheep/store.c            |    4 ++--
 sheep/vdi.c              |   16 ++++++++--------
 5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index 05bc458..8206084 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -414,7 +414,7 @@ static struct corosync_event *update_block_event(enum corosync_event_type type,
 	if (msg_len) {
 		cevent->msg = realloc(cevent->msg, msg_len);
 		if (!cevent->msg)
-			panic("oom\n");
+			panic("failed to allocate memory\n");
 		memcpy(cevent->msg, msg, msg_len);
 	} else {
 		free(cevent->msg);
@@ -434,7 +434,7 @@ static void cdrv_cpg_deliver(cpg_handle_t handle,
 
 	cevent = zalloc(sizeof(*cevent));
 	if (!cevent)
-		panic("oom\n");
+		panic("failed to allocate memory\n");
 
 	switch (cmsg->type) {
 	case COROSYNC_MSG_TYPE_JOIN_REQUEST:
@@ -459,7 +459,7 @@ static void cdrv_cpg_deliver(cpg_handle_t handle,
 		if (cmsg->msg_len) {
 			cevent->msg = zalloc(cmsg->msg_len);
 			if (!cevent->msg)
-				panic("oom\n");
+				panic("failed to allocate memory\n");
 			memcpy(cevent->msg, cmsg->msg, cmsg->msg_len);
 		} else
 			cevent->msg = NULL;
@@ -544,7 +544,7 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
 
 		cevent = zalloc(sizeof(*cevent));
 		if (!cevent)
-			panic("oom\n");
+			panic("failed to allocate memory\n");
 
 		cevent->type = COROSYNC_EVENT_TYPE_LEAVE;
 		cevent->sender = left_sheeps[i];
@@ -556,7 +556,7 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
 	for (i = 0; i < joined_list_entries; i++) {
 		cevent = zalloc(sizeof(*cevent));
 		if (!cevent)
-			panic("oom\n");
+			panic("failed to allocate memory\n");
 
 		cevent->type = COROSYNC_EVENT_TYPE_JOIN;
 		cevent->sender = joined_sheeps[i];
@@ -676,10 +676,10 @@ static int corosync_notify(void *msg, size_t msg_len, void (*block_cb)(void *))
 	if (block_cb) {
 		bm = zalloc(sizeof(*bm));
 		if (!bm)
-			panic("oom\n");
+			panic("failed to allocate memory\n");
 		bm->msg = zalloc(msg_len);
 		if (!bm->msg)
-			panic("oom\n");
+			panic("failed to allocate memory\n");
 
 		memcpy(bm->msg, msg, msg_len);
 		bm->msg_len = msg_len;
diff --git a/sheep/group.c b/sheep/group.c
index bfdadbf..a17553f 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -151,7 +151,7 @@ int get_ordered_sd_vnode_list(struct sheepdog_vnode_list_entry **entries,
 
 	cache = zalloc(sizeof(*cache));
 	if (!cache) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		*entries = NULL;
 		return SD_RES_NO_MEM;
 	}
@@ -227,7 +227,7 @@ void cluster_queue_request(struct work *work, int idx)
 
 	msg = zalloc(size);
 	if (!msg) {
-		eprintf("out of memory\n");
+		eprintf("failed to allocate memory\n");
 		return;
 	}
 
@@ -538,7 +538,7 @@ static void update_cluster_info(struct join_message *msg,
 		for (i = 0; i < nr_leave_nodes; i++) {
 			n = zalloc(sizeof(*n));
 			if (!n)
-				panic("oom\n");
+				panic("failed to allocate memory\n");
 
 			if (find_entry_list(&msg->leave_nodes[i], &sys->leave_list)
 			    || !find_entry_epoch(&msg->leave_nodes[i], le)) {
@@ -775,7 +775,7 @@ static int send_join_request(struct sheepdog_node_list_entry *ent)
 
 	msg = zalloc(sizeof(*msg) + SD_MAX_NODES * sizeof(msg->nodes[0]));
 	if (!msg)
-		panic("oom\n");
+		panic("failed to allocate memory\n");
 	msg->proto_ver = SD_SHEEP_PROTO_VER;
 
 	get_cluster_copies(&msg->nr_sobjs);
@@ -1170,7 +1170,7 @@ static void sd_join_handler(struct sheepdog_node_list_entry *joined,
 
 		w = zalloc(sizeof(*w));
 		if (!w)
-			panic("oom");
+			panic("failed to allocate memory");
 
 		cevent = &w->cev;
 		cevent->ctype = CPG_EVENT_JOIN;
@@ -1180,7 +1180,7 @@ static void sd_join_handler(struct sheepdog_node_list_entry *joined,
 		size = sizeof(struct sheepdog_node_list_entry) * nr_members;
 		w->member_list = zalloc(size);
 		if (!w->member_list)
-			panic("oom");
+			panic("failed to allocate memory");
 
 		memcpy(w->member_list, members, size);
 		w->member_list_entries = nr_members;
@@ -1190,7 +1190,7 @@ static void sd_join_handler(struct sheepdog_node_list_entry *joined,
 		size = get_join_message_size(opaque);
 		w->jm = zalloc(size);
 		if (!w->jm)
-			panic("oom\n");
+			panic("failed to allocate memory\n");
 		memcpy(w->jm, opaque, size);
 
 		list_add_tail(&cevent->cpg_event_list, &sys->cpg_event_siblings);
@@ -1203,7 +1203,7 @@ static void sd_join_handler(struct sheepdog_node_list_entry *joined,
 
 		n = zalloc(sizeof(*n));
 		if (!n)
-			panic("oom\n");
+			panic("failed to allocate memory\n");
 
 		if (find_entry_list(joined, &sys->leave_list)
 		    || !find_entry_epoch(joined, le)) {
@@ -1232,7 +1232,7 @@ static void sd_join_handler(struct sheepdog_node_list_entry *joined,
 		for (i = 0; i < nr; i++) {
 			n = zalloc(sizeof(*n));
 			if (!n)
-				panic("oom\n");
+				panic("failed to allocate memory\n");
 
 			if (find_entry_list(&jm->leave_nodes[i], &sys->leave_list)
 			    || !find_entry_epoch(&jm->leave_nodes[i], le)) {
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 21a61ac..19357a6 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -138,7 +138,7 @@ static void __done(struct work *work, int idx)
 			}
 			bmap = zalloc(sizeof(*bmap));
 			if (bmap == NULL) {
-				eprintf("out of memory\n");
+				eprintf("failed to allocate memory\n");
 				goto done;
 			}
 			dprintf("allocate a new object map\n");
diff --git a/sheep/store.c b/sheep/store.c
index 60703e8..d46668e 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -770,7 +770,7 @@ static int fix_object_consistency(struct request *req, int idx)
 
 	buf = valloc(data_length);
 	if (buf == NULL) {
-		eprintf("out of memory\n");
+		eprintf("failed to allocate memory\n");
 		goto out;
 	}
 	memset(buf, 0, data_length);
@@ -1240,7 +1240,7 @@ static int __recover_one(struct recovery_work *rw,
 	cur_entry = malloc(sizeof(*cur_entry) * SD_MAX_VNODES);
 	next_entry = malloc(sizeof(*next_entry) * SD_MAX_VNODES);
 	if (!old_entry || !cur_entry || !next_entry) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		goto err;
 	}
 
diff --git a/sheep/vdi.c b/sheep/vdi.c
index d783942..aeea7d6 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -30,7 +30,7 @@ static int create_vdi_obj(uint32_t epoch, char *name, uint32_t new_vid, uint64_t
 
 	new = zalloc(sizeof(*new));
 	if (!new) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		ret = SD_RES_NO_MEM;
 		goto out;
 	}
@@ -38,7 +38,7 @@ static int create_vdi_obj(uint32_t epoch, char *name, uint32_t new_vid, uint64_t
 	if (base_vid) {
 		base = zalloc(sizeof(*base));
 		if (!base) {
-			eprintf("oom\n");
+			eprintf("failed to allocate memory\n");
 			ret = SD_RES_NO_MEM;
 			goto out;
 		}
@@ -47,7 +47,7 @@ static int create_vdi_obj(uint32_t epoch, char *name, uint32_t new_vid, uint64_t
 	if (is_snapshot && cur_vid != base_vid) {
 		cur = zalloc(SD_INODE_HEADER_SIZE);
 		if (!cur) {
-			eprintf("oom\n");
+			eprintf("failed to allocate memory\n");
 			ret = SD_RES_NO_MEM;
 			goto out;
 		}
@@ -164,7 +164,7 @@ static int find_first_vdi(uint32_t epoch, unsigned long start, unsigned long end
 
 	inode = malloc(SD_INODE_HEADER_SIZE);
 	if (!inode) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		ret = SD_RES_NO_MEM;
 		goto out;
 	}
@@ -349,7 +349,7 @@ int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t *vid,
 
 	inode = malloc(SD_INODE_HEADER_SIZE);
 	if (!inode) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		ret = SD_RES_NO_MEM;
 		goto out;
 	}
@@ -441,7 +441,7 @@ static void delete_one(struct work *work, int idx)
 
 	inode = malloc(sizeof(*inode));
 	if (!inode) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		goto out;
 	}
 
@@ -510,7 +510,7 @@ static int fill_vdi_list(struct deletion_work *dw,
 
 	inode = malloc(SD_INODE_HEADER_SIZE);
 	if (!inode) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		goto err;
 	}
 
@@ -555,7 +555,7 @@ static uint64_t get_vdi_root(struct sheepdog_vnode_list_entry *entries,
 
 	inode = malloc(SD_INODE_HEADER_SIZE);
 	if (!inode) {
-		eprintf("oom\n");
+		eprintf("failed to allocate memory\n");
 		vid = 0;
 		goto out;
 	}
-- 
1.7.5.4




More information about the sheepdog mailing list