[sheepdog] [PATCH 1/2] dog: check the result of dog_exec_req() correctly

MORITA Kazutaka morita.kazutaka at gmail.com
Thu Aug 22 03:25:54 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

dog_exec_req doesn't return a result code after the commit 5940548.
We have to check rsp->result instead of its return value.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 dog/common.c    |    5 +++--
 dog/farm/farm.c |    2 +-
 dog/vdi.c       |    4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/dog/common.c b/dog/common.c
index 14d3b1d..b01117d 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -197,12 +197,13 @@ int dog_exec_req(const uint8_t *addr, int port, struct sd_req *hdr,
 int send_light_req(struct sd_req *hdr, const uint8_t *addr, int port)
 {
 	int ret = dog_exec_req(addr, port, hdr, NULL);
+	struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
 
 	if (ret == -1)
 		return -1;
 
-	if (ret != SD_RES_SUCCESS) {
-		sd_err("Response's result: %s", sd_strerror(ret));
+	if (rsp->result != SD_RES_SUCCESS) {
+		sd_err("Response's result: %s", sd_strerror(rsp->result));
 		return -1;
 	}
 
diff --git a/dog/farm/farm.c b/dog/farm/farm.c
index ee47855..84f219e 100644
--- a/dog/farm/farm.c
+++ b/dog/farm/farm.c
@@ -187,7 +187,7 @@ static int notify_vdi_add(uint32_t vdi_id, uint32_t nr_copies)
 
 	ret = dog_exec_req(sdhost, sdport, &hdr, buf);
 
-	if (ret)
+	if (ret < 0)
 		sd_err("Fail to notify vdi add event(%"PRIx32", %d)", vdi_id,
 		       nr_copies);
 
diff --git a/dog/vdi.c b/dog/vdi.c
index 6101141..84c9c1f 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -1458,7 +1458,7 @@ static void vdi_hash_check_work(struct work *work)
 	if (ret < 0)
 		exit(EXIT_SYSFAIL);
 
-	switch (ret) {
+	switch (rsp->result) {
 	case SD_RES_SUCCESS:
 		vcw->object_found = true;
 		memcpy(vcw->hash, rsp->hash.digest, sizeof(vcw->hash));
@@ -1470,7 +1470,7 @@ static void vdi_hash_check_work(struct work *work)
 	default:
 		sd_err("failed to read %" PRIx64 " from %s, %s", info->oid,
 		       addr_to_str(vcw->vnode->nid.addr, vcw->vnode->nid.port),
-		       sd_strerror(ret));
+		       sd_strerror(rsp->result));
 		exit(EXIT_FAILURE);
 	}
 }
-- 
1.7.9.5




More information about the sheepdog mailing list