[sheepdog] [PATCH stable-0.7 2/3] dog: add more result check of dog_collie_exec()
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Thu Aug 22 10:19:00 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
dog/cluster.c | 4 ++++
dog/common.c | 5 +++++
dog/farm/farm.c | 5 +++++
dog/node.c | 10 ++++++++++
dog/trace.c | 5 +++++
dog/vdi.c | 4 ++++
6 files changed, 33 insertions(+)
diff --git a/dog/cluster.c b/dog/cluster.c
index 4c7654d..e3ac33a 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -85,6 +85,10 @@ static int cluster_format(int argc, char **argv)
ret = dog_exec_req(sdhost, sdport, &hdr, &vdi_inuse);
if (ret < 0)
return EXIT_SYSFAIL;
+ if (rsp->result != SD_RES_SUCCESS) {
+ sd_err("%s", sd_strerror(rsp->result));
+ return EXIT_FAILURE;
+ }
if (!no_vdi(vdi_inuse))
confirm(FORMAT_PRINT);
diff --git a/dog/common.c b/dog/common.c
index b01117d..301b8bf 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -118,6 +118,7 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
unsigned long nr;
static struct sd_inode i;
struct sd_req req;
+ struct sd_rsp *rsp = (struct sd_rsp *)&req;
static DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
unsigned int rlen = sizeof(vdi_inuse);
@@ -127,6 +128,10 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
ret = dog_exec_req(sdhost, sdport, &req, &vdi_inuse);
if (ret < 0)
goto out;
+ if (rsp->result != SD_RES_SUCCESS) {
+ sd_err("%s", sd_strerror(rsp->result));
+ goto out;
+ }
FOR_EACH_VDI(nr, vdi_inuse) {
uint64_t oid;
diff --git a/dog/farm/farm.c b/dog/farm/farm.c
index df121fd..9d0f1f6 100644
--- a/dog/farm/farm.c
+++ b/dog/farm/farm.c
@@ -179,6 +179,7 @@ static int notify_vdi_add(uint32_t vdi_id, uint32_t nr_copies)
{
int ret = -1;
struct sd_req hdr;
+ struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
char *buf = NULL;
sd_init_req(&hdr, SD_OP_NOTIFY_VDI_ADD);
@@ -191,6 +192,10 @@ static int notify_vdi_add(uint32_t vdi_id, uint32_t nr_copies)
if (ret < 0)
sd_err("Fail to notify vdi add event(%"PRIx32", %d)", vdi_id,
nr_copies);
+ if (rsp->result != SD_RES_SUCCESS) {
+ sd_err("%s", sd_strerror(rsp->result));
+ ret = -1;
+ }
free(buf);
return ret;
diff --git a/dog/node.c b/dog/node.c
index e00058e..f6fe28b 100644
--- a/dog/node.c
+++ b/dog/node.c
@@ -111,6 +111,7 @@ static int get_recovery_state(struct recovery_state *state)
{
int ret;
struct sd_req req;
+ struct sd_rsp *rsp = (struct sd_rsp *)&req;
sd_init_req(&req, SD_OP_STAT_RECOVERY);
req.data_length = sizeof(*state);
@@ -120,6 +121,10 @@ static int get_recovery_state(struct recovery_state *state)
sd_err("Failed to execute request");
return -1;
}
+ if (rsp->result != SD_RES_SUCCESS) {
+ sd_err("%s", sd_strerror(rsp->result));
+ return -1;
+ }
return 0;
}
@@ -198,6 +203,7 @@ static int node_recovery(int argc, char **argv)
for (i = 0; i < sd_nodes_nr; i++) {
struct sd_req req;
+ struct sd_rsp *rsp = (struct sd_rsp *)&req;
struct recovery_state state;
memset(&state, 0, sizeof(state));
@@ -209,6 +215,10 @@ static int node_recovery(int argc, char **argv)
sd_nodes[i].nid.port, &req, &state);
if (ret < 0)
return EXIT_SYSFAIL;
+ if (rsp->result != SD_RES_SUCCESS) {
+ sd_err("%s", sd_strerror(rsp->result));
+ return EXIT_FAILURE;
+ }
if (state.in_recovery) {
const char *host = addr_to_str(sd_nodes[i].nid.addr,
diff --git a/dog/trace.c b/dog/trace.c
index 162a935..655c3ae 100644
--- a/dog/trace.c
+++ b/dog/trace.c
@@ -183,6 +183,7 @@ static int trace_status(int argc, char **argv)
char buf[4096]; /* must have enough space to store tracer list */
int ret;
struct sd_req hdr;
+ struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
sd_init_req(&hdr, SD_OP_TRACE_STATUS);
hdr.data_length = sizeof(buf);
@@ -190,6 +191,10 @@ static int trace_status(int argc, char **argv)
ret = dog_exec_req(sdhost, sdport, &hdr, buf);
if (ret < 0)
return EXIT_SYSFAIL;
+ switch (rsp->result) {
+ sd_err("%s", sd_strerror(rsp->result));
+ return EXIT_FAILURE;
+ }
printf("%s", buf);
diff --git a/dog/vdi.c b/dog/vdi.c
index fbda08d..11c33d6 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -319,6 +319,10 @@ static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data, unsigne
sd_nodes[i].nid.port, &hdr, buf);
if (ret < 0)
continue;
+ switch (rsp->result) {
+ sd_err("%s", sd_strerror(rsp->result));
+ continue;
+ }
untrim_zero_blocks(buf, rsp->obj.offset, rsp->data_length,
size);
--
1.7.10.4
More information about the sheepdog
mailing list