[Sheepdog] [PATCH 18/18] reject requests when sheepdog is not running

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Mar 11 07:48:17 CET 2010


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 collie/net.c        |   32 ++++++++++++++++++++++++++++++++
 shepherd/shepherd.c |   18 +++++++++++++-----
 2 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/collie/net.c b/collie/net.c
index 9a942c4..9c89b64 100644
--- a/collie/net.c
+++ b/collie/net.c
@@ -39,6 +39,36 @@ static void __done(struct work *work, int idx)
 static void queue_request(struct request *req)
 {
 	struct sd_req *hdr = (struct sd_req *)&req->rq;
+	struct sd_rsp *rsp = (struct sd_rsp *)&req->rp;;
+
+	if (sys->status == SD_STATUS_SHUTDOWN) {
+		rsp->result = SD_RES_SHUTDOWN;
+		req->done(req);
+		return;
+	}
+
+	if (sys->status & SD_STATUS_ERROR_MASK) {
+		rsp->result = SD_RES_SYSTEM_ERROR;
+		req->done(req);
+		return;
+	}
+
+	if (sys->status & SD_STATUS_STARTUP_MASK) {
+		/* TODO: cleanup */
+		switch (hdr->opcode) {
+		case SD_OP_STAT_CLUSTER:
+		case SD_OP_MAKE_FS:
+		case SD_OP_GET_NODE_LIST:
+		case SD_OP_SO:
+		case SD_OP_GET_EPOCH_LIST:
+		case SD_OP_READ_EPOCH:
+			break;
+		default:
+			rsp->result = SD_RES_STARTUP;
+			req->done(req);
+			return;
+		}
+	}
 
 	switch (hdr->opcode) {
 	case SD_OP_CREATE_AND_WRITE_OBJ:
@@ -75,6 +105,8 @@ static void queue_request(struct request *req)
 		break;
 	default:
 		eprintf("unknown operation %d\n", hdr->opcode);
+		rsp->result = SD_RES_SYSTEM_ERROR;
+		req->done(req);
 		return;
 	}
 
diff --git a/shepherd/shepherd.c b/shepherd/shepherd.c
index 77c1c00..c2c7db9 100644
--- a/shepherd/shepherd.c
+++ b/shepherd/shepherd.c
@@ -1297,14 +1297,22 @@ int main(int argc, char **argv)
 	if (optind >= argc)
 		usage(0);
 
-
 	node_list_entries = zalloc(SD_MAX_NODES * sizeof(struct sheepdog_node_list_entry));
-	ret = update_node_list(SD_MAX_NODES, epoch);
-	if (ret < 0)
-		return 1;
-
 	command = argv[optind++];
 
+	/* TODO: cleanup */
+	if (strcasecmp(command, "mkfs") == 0)
+		;
+	else if (strcasecmp(command, "info") == 0 && type == INFO_CLUSTER)
+		;
+	else if (strcasecmp(command, "info") == 0 && type == INFO_EPOCH)
+		;
+	else {
+		ret = update_node_list(SD_MAX_NODES, epoch);
+		if (ret < 0)
+			return 1;
+	}
+
 	if (!strcasecmp(command, "info")) {
 		char *name = NULL;
 
-- 
1.5.6.5




More information about the sheepdog mailing list