[sheepdog] [PATCH 2/2] sheep: use default copy number when vdi state is not available
MORITA Kazutaka
morita.kazutaka at gmail.com
Wed Aug 28 08:30:53 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Currently, screen_object_list() drops an object from the recovery list
when its copy number is not available. This can happen, e.g., when we
lost all the inode replicas temporary. To fix the problem, this patch
makes get_vdi_copy_number() return the default copy number when sheep
doesn't have the vdi state.
This patch is necessary to pass test/functional/074.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
sheep/gateway.c | 18 +++++++++---------
sheep/plain_store.c | 6 +-----
sheep/recovery.c | 6 +-----
sheep/vdi.c | 4 ++--
4 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/sheep/gateway.c b/sheep/gateway.c
index af7ba2a..35858e6 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -41,13 +41,13 @@ int gateway_read_obj(struct request *req)
goto out;
}
- nr_copies = get_req_copy_number(req);
-
- if (nr_copies == 0) {
- sd_debug("there is no living nodes");
+ 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,
nr_copies, obj_vnodes);
for (i = 0; i < nr_copies; i++) {
@@ -266,6 +266,11 @@ 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);
@@ -273,11 +278,6 @@ static int gateway_forward_request(struct request *req)
nr_to_send = init_target_nodes(req, oid, target_nodes);
write_info_init(&wi, nr_to_send);
- if (nr_to_send == 0) {
- sd_debug("there is no living nodes");
- return SD_RES_HALT;
- }
-
for (i = 0; i < nr_to_send; i++) {
struct sockfd *sfd;
const struct node_id *nid;
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index e35a7e7..7ed2d51 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -391,10 +391,6 @@ static bool oid_stale(uint64_t oid)
vinfo = get_vnode_info();
nr_copies = get_obj_copy_number(oid, vinfo->nr_zones);
- if (!nr_copies) {
- ret = false;
- goto out;
- }
oid_to_vnodes(vinfo->vnodes, vinfo->nr_vnodes, oid,
nr_copies, obj_vnodes);
@@ -405,7 +401,7 @@ static bool oid_stale(uint64_t oid)
break;
}
}
-out:
+
put_vnode_info(vinfo);
return ret;
}
diff --git a/sheep/recovery.c b/sheep/recovery.c
index c63f416..6faaeab 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -715,11 +715,7 @@ static void screen_object_list(struct recovery_list_work *rlw,
continue;
nr_objs = get_obj_copy_number(oids[i], rw->cur_vinfo->nr_zones);
- if (!nr_objs) {
- sd_err("ERROR: can not find copy number for object %"
- PRIx64, oids[i]);
- continue;
- }
+
oid_to_vnodes(rw->cur_vinfo->vnodes, rw->cur_vinfo->nr_vnodes,
oids[i], nr_objs, vnodes);
for (j = 0; j < nr_objs; j++) {
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 4a180cb..d5df668 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -76,8 +76,8 @@ int get_vdi_copy_number(uint32_t vid)
sd_unlock(&vdi_state_lock);
if (!entry) {
- sd_err("No VDI copy entry for %" PRIx32 " found", vid);
- return 0;
+ sd_alert("No VDI copy entry for %" PRIx32 " found", vid);
+ return SD_DEFAULT_COPIES;
}
return entry->nr_copies;
--
1.7.9.5
More information about the sheepdog
mailing list