[sheepdog] [PATCH stable-0.7 1/3] dog: check the result of dog_exec_req() correctly

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Thu Aug 22 10:18:59 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>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 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 1969927..df121fd 100644
--- a/dog/farm/farm.c
+++ b/dog/farm/farm.c
@@ -188,7 +188,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 370ad7b..fbda08d 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.10.4




More information about the sheepdog mailing list