[sheepdog] [PATCH] sheep: fix queue_gateway_request()
Liu Yuan
namei.unix at gmail.com
Sat Jun 2 18:43:57 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
- we should check if object is cached on the first place
- use goto to bypass other unnecessary checks.
- remove unnecessay lines in need_consistency_check()
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/sdnet.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 86d30d8..fa04c34 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -55,10 +55,6 @@ static int need_consistency_check(struct request *req)
/* only check consistency for data objects */
return 0;
- if (sys->enable_write_cache && object_is_cached(hdr->obj.oid))
- /* we don't check consistency for cached objects */
- return 0;
-
return 1;
}
@@ -343,19 +339,23 @@ static void queue_gateway_request(struct request *req)
req->local_oid = hdr->obj.oid;
/*
- * If we go for a cached object, we don't care if it is being recovered.
+ * If we go for a cached object, we don't care if it is being
+ * recovered. Even requests without SD_FLAG_CMD_CACHE, we can
+ * read the cached object to benefit cloned VMs, which share one
+ * base VM, to cache shared COW objects in local node.
*/
- if (req->local_oid &&
- (!sys->enable_write_cache ||
- !(req->rq.flags & SD_FLAG_CMD_CACHE) ||
- !object_is_cached(req->rq.obj.oid))) {
+ if (sys->enable_write_cache &&
+ object_is_cached(req->rq.obj.oid))
+ goto queue_work;
+
+ if (req->local_oid)
if (request_in_recovery(req))
return;
- }
if (need_consistency_check(req))
set_consistency_check(req);
+queue_work:
req->work.fn = do_gateway_request;
req->work.done = gateway_op_done;
queue_work(sys->gateway_wqueue, &req->work);
--
1.7.10.2
More information about the sheepdog
mailing list