[sheepdog] [PATCH RFC 05/11] sheep: read objects only from live nodes

Yunkai Zhang yunkai.me at gmail.com
Wed Aug 8 23:14:17 CEST 2012


From: Yunkai Zhang <qiushu.zyk at taobao.com>

Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
 sheep/gateway.c    | 5 +++++
 sheep/sheep_priv.h | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/sheep/gateway.c b/sheep/gateway.c
index bdbd08c..edd8dcb 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -67,6 +67,11 @@ int gateway_read_obj(struct request *req)
 		if (vnode_is_local(v))
 			continue;
 
+		if (sys->disable_recovery && vnode_has_left(req->vinfo, v)) {
+			ret = SD_RES_NETWORK_ERROR;
+			continue;
+		}
+
 		sfd = sheep_get_sockfd(&v->nid);
 		if (!sfd) {
 			ret = SD_RES_NETWORK_ERROR;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 1bf52da..b530f71 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -346,6 +346,11 @@ static inline int vnode_is_local(struct sd_vnode *v)
 	return is_myself(v->nid.addr, v->nid.port);
 }
 
+static inline int vnode_has_left(struct vnode_info *vinfo, struct sd_vnode *v)
+{
+	return vinfo->nodes[v->node_idx].left;
+}
+
 /* gateway operations */
 int gateway_read_obj(struct request *req);
 int gateway_write_obj(struct request *req);
-- 
1.7.11.2




More information about the sheepdog mailing list