[sheepdog] [PATCH] sheep: clean up request judgement

Liu Yuan namei.unix at gmail.com
Thu Feb 7 08:47:33 CET 2013


From: Liu Yuan <tailai.ly at taobao.com>

Put all the judgements into bypass_object_cache() helper.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/gateway.c      |    6 ++++--
 sheep/object_cache.c |    3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/sheep/gateway.c b/sheep/gateway.c
index 04aa480..7a3d3cb 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -1,6 +1,8 @@
 /*
  * Copyright (C) 2009-2011 Nippon Telegraph and Telephone Corporation.
  *
+ * Copyright (C) 2012-2013 Taobao Inc.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version
  * 2 as published by the Free Software Foundation.
@@ -323,7 +325,7 @@ static int gateway_forward_request(struct request *req, bool all_node)
 
 int gateway_write_obj(struct request *req)
 {
-	if (is_object_cache_enabled() && !req->local && !bypass_object_cache(req))
+	if (!bypass_object_cache(req))
 		return object_cache_handle_request(req);
 
 	return gateway_forward_request(req, false);
@@ -331,7 +333,7 @@ int gateway_write_obj(struct request *req)
 
 int gateway_create_and_write_obj(struct request *req)
 {
-	if (is_object_cache_enabled() && !req->local && !bypass_object_cache(req))
+	if (!bypass_object_cache(req))
 		return object_cache_handle_request(req);
 
 	return gateway_forward_request(req, false);
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 8cf2c63..3f2cd60 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -1010,6 +1010,9 @@ bool bypass_object_cache(const struct request *req)
 {
 	uint64_t oid = req->rq.obj.oid;
 
+	if (!is_object_cache_enabled() || req->local)
+		return true;
+
 	if (req->rq.flags & SD_FLAG_CMD_DIRECT) {
 		uint32_t vid = oid_to_vid(oid);
 		struct object_cache *cache;
-- 
1.7.9.5




More information about the sheepdog mailing list