[sheepdog] [PATCH] sheep: check gateway request as early as possible

Liu Yuan namei.unix at gmail.com
Wed Aug 28 10:50:58 CEST 2013


Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/gateway.c |   10 ----------
 sheep/request.c |    6 ++++++
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/sheep/gateway.c b/sheep/gateway.c
index 35858e6..dc2cc7d 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -41,11 +41,6 @@ int gateway_read_obj(struct request *req)
 		goto out;
 	}
 
-	if (req->vinfo->nr_vnodes == 0) {
-		sd_err("there is no living nodes");
-		return SD_RES_HALT;
-	}
-
 	nr_copies = get_req_copy_number(req);
 
 	oid_to_vnodes(req->vinfo->vnodes, req->vinfo->nr_vnodes, oid,
@@ -266,11 +261,6 @@ static int gateway_forward_request(struct request *req)
 
 	sd_debug("%"PRIx64, oid);
 
-	if (req->vinfo->nr_vnodes == 0) {
-		sd_err("there is no living nodes");
-		return SD_RES_HALT;
-	}
-
 	gateway_init_fwd_hdr(&hdr, &req->rq);
 	op = get_sd_op(hdr.opcode);
 
diff --git a/sheep/request.c b/sheep/request.c
index 43c4836..53d38c7 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -303,6 +303,12 @@ static void queue_gateway_request(struct request *req)
 			return;
 
 queue_work:
+	if (req->vinfo->nr_vnodes == 0) {
+		sd_err("there is no living nodes");
+		req->rp.result = SD_RES_HALT;
+		put_request(req);
+		return;
+	}
 	req->work.fn = do_process_work;
 	req->work.done = gateway_op_done;
 	queue_work(sys->gateway_wqueue, &req->work);
-- 
1.7.9.5




More information about the sheepdog mailing list