[sheepdog] [PATCH 2/3] use sd_strerror to print error reason

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Wed May 1 18:57:52 CEST 2013


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 collie/vdi.c         |  8 ++++----
 sheep/object_cache.c |  5 +++--
 sheep/ops.c          |  5 +++--
 sheep/request.c      |  4 ++--
 sheep/sockfd_cache.c |  2 +-
 sheep/store.c        | 13 ++++++++-----
 sheepfs/volume.c     |  4 ++--
 7 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/collie/vdi.c b/collie/vdi.c
index c0bbf65..a527191 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -245,8 +245,8 @@ static int do_print_obj(char *sheep, uint64_t oid, struct sd_rsp *rsp,
 		fprintf(stderr, "The node list has changed: please try again\n");
 		break;
 	default:
-		fprintf(stderr, "%s: hit an unexpected error (%d)\n",
-		       sheep, rsp->result);
+		fprintf(stderr, "%s: hit an unexpected error (%s)\n",
+			sheep, sd_strerror(rsp->result));
 		break;
 	}
 
@@ -282,8 +282,8 @@ static int get_data_oid(char *sheep, uint64_t oid, struct sd_rsp *rsp,
 		fprintf(stderr, "The node list has changed: please try again\n");
 		break;
 	default:
-		fprintf(stderr, "%s: hit an unexpected error (%d)\n",
-		       sheep, rsp->result);
+		fprintf(stderr, "%s: hit an unexpected error (%s)\n",
+			sheep, sd_strerror(rsp->result));
 		break;
 	}
 
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index ed6570f..3aa7fd6 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -407,7 +407,8 @@ static int write_cache_object(struct object_cache_entry *entry, void *buf,
 
 	ret = exec_local_req(&hdr, buf);
 	if (ret != SD_RES_SUCCESS) {
-		sd_eprintf("failed to write object %" PRIx64 ", %x", oid, ret);
+		sd_eprintf("failed to write object %" PRIx64 ", %s", oid,
+			   sd_strerror(ret));
 		return ret;
 	}
 out:
@@ -463,7 +464,7 @@ static int push_cache_object(uint32_t vid, uint32_t idx, uint64_t bmap,
 
 	ret = exec_local_req(&hdr, buf);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to push object %x", ret);
+		sd_eprintf("failed to push object %s", sd_strerror(ret));
 out:
 	free(buf);
 	return ret;
diff --git a/sheep/ops.c b/sheep/ops.c
index cff800e..2d897f9 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -1363,8 +1363,9 @@ void do_process_work(struct work *work)
 		ret = req->op->process_work(req);
 
 	if (ret != SD_RES_SUCCESS) {
-		sd_dprintf("failed: %x, %" PRIx64" , %u, %"PRIx32,
-			   req->rq.opcode, req->rq.obj.oid, req->rq.epoch, ret);
+		sd_dprintf("failed: %x, %" PRIx64" , %u, %s",
+			   req->rq.opcode, req->rq.obj.oid, req->rq.epoch,
+			   sd_strerror(ret));
 	}
 
 	req->rp.result = ret;
diff --git a/sheep/request.c b/sheep/request.c
index 85d62c9..e99f6f2 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -64,7 +64,7 @@ static void io_op_done(struct work *work)
 	case SD_RES_NETWORK_ERROR:
 		break;
 	default:
-		sd_dprintf("unhandled error %x", req->rp.result);
+		sd_dprintf("unhandled error %s", sd_strerror(req->rp.result));
 		break;
 	}
 
@@ -134,7 +134,7 @@ static void gateway_op_done(struct work *work)
 	case SD_RES_SUCCESS:
 		break;
 	default:
-		sd_dprintf("unhandled error %x", req->rp.result);
+		sd_dprintf("unhandled error %s", sd_strerror(req->rp.result));
 		break;
 	}
 
diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
index d3aa1e6..70d804c 100644
--- a/sheep/sockfd_cache.c
+++ b/sheep/sockfd_cache.c
@@ -529,7 +529,7 @@ int sheep_exec_req(const struct node_id *nid, struct sd_req *hdr, void *buf)
 	}
 	ret = rsp->result;
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed %x", ret);
+		sd_eprintf("failed %s", sd_strerror(ret));
 
 	sheep_put_sockfd(nid, sfd);
 	return ret;
diff --git a/sheep/store.c b/sheep/store.c
index 3f4cf41..38ba963 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -421,7 +421,8 @@ forward_write:
 
 	ret = exec_local_req(&hdr, data);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to write object %" PRIx64 ", %x", oid, ret);
+		sd_eprintf("failed to write object %" PRIx64 ", %s", oid,
+			   sd_strerror(ret));
 
 	return ret;
 }
@@ -441,7 +442,8 @@ int read_backend_object(uint64_t oid, char *data, unsigned int datalen,
 
 	ret = exec_local_req(&hdr, data);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to read object %" PRIx64 ", %x", oid, ret);
+		sd_eprintf("failed to read object %" PRIx64 ", %s", oid,
+			   sd_strerror(ret));
 
 	untrim_zero_sectors(data, rsp->obj.offset, rsp->data_length, datalen);
 
@@ -460,8 +462,8 @@ int read_object(uint64_t oid, char *data, unsigned int datalen,
 	if (sys->enable_object_cache && object_is_cached(oid)) {
 		ret = object_cache_read(oid, data, datalen, offset);
 		if (ret != SD_RES_SUCCESS) {
-			sd_eprintf("try forward read %"PRIx64" %"PRIx32, oid,
-				   ret);
+			sd_eprintf("try forward read %"PRIx64" %s", oid,
+				   sd_strerror(ret));
 			goto forward_read;
 		}
 		return ret;
@@ -482,7 +484,8 @@ int remove_object(uint64_t oid)
 
 	ret = exec_local_req(&hdr, NULL);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to remove object %" PRIx64 ", %x", oid, ret);
+		sd_eprintf("failed to remove object %" PRIx64 ", %s", oid,
+			   sd_strerror(ret));
 
 	return ret;
 }
diff --git a/sheepfs/volume.c b/sheepfs/volume.c
index 5f55030..ae1f520 100644
--- a/sheepfs/volume.c
+++ b/sheepfs/volume.c
@@ -203,9 +203,9 @@ static int volume_rw_object(char *buf, uint64_t oid, size_t size,
 	put_socket_fd(vdi, sock_idx);
 
 	if (ret || rsp->result != SD_RES_SUCCESS) {
-		sheepfs_pr("failed to %s object %" PRIx64 " ret %d, res %u\n",
+		sheepfs_pr("failed to %s object %" PRIx64 " ret %d, res %s\n",
 			   rw == VOLUME_READ ? "read" : "write",
-			   oid, ret, rsp->result);
+			   oid, ret, sd_strerror(rsp->result));
 		return -1;
 	}
 
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list