[Sheepdog] [PATCH 1/3] collie: read objects directly in parse_objs()
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Mon Jan 31 18:46:43 CET 2011
When we send read requests without a SD_FLAG_CMD_DIRECT flag, Sheepdog
checks data consistency of the target objects before forwarding them.
However, fixing consistency could cause updating, so it is not safe
for collie to send non-direct read requests because running VMs could
update the objects at the same time.
This patch calculates the target nodes in parse_objs(), and send read
requests directly to them. This also improves performance of vdi
listing because we can avoid a redundant consistency check.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
collie/collie.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/collie/collie.c b/collie/collie.c
index 6db5a08..493d492 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -269,34 +269,50 @@ static int parse_vdi(vdi_parser_func_t func, void *data)
close(fd);
return ret;
}
+ close(fd);
for (nr = 0; nr < SD_NR_VDIS; nr++) {
struct sd_obj_req hdr;
struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&hdr;
+ uint64_t oid;
+ int n;
+ char name[128];
if (!test_bit(nr, vdi_inuse))
continue;
+ oid = vid_to_vdi_oid(nr);
+ n = obj_to_sheep(node_list_entries, nr_nodes, oid, 0);
+ addr_to_str(name, sizeof(name), node_list_entries[n].addr, 0);
+
+ fd = connect_to(name, node_list_entries[n].port);
+ if (fd < 0) {
+ printf("failed to connect %s:%d\n", name,
+ node_list_entries[n].port);
+ continue;
+ }
+
wlen = 0;
rlen = sizeof(i);
memset(&hdr, 0, sizeof(hdr));
hdr.opcode = SD_OP_READ_OBJ;
- hdr.oid = vid_to_vdi_oid(nr);
+ hdr.oid = oid;
hdr.data_length = rlen;
+ hdr.flags = SD_FLAG_CMD_DIRECT;
+ hdr.epoch = node_list_version;
ret = exec_req(fd, (struct sd_req *)&hdr, &i, &wlen, &rlen);
+ close(fd);
if (!ret && rsp->result == SD_RES_SUCCESS) {
if (i.name[0] == '\0') /* deleted */
continue;
func(i.vdi_id, i.name, i.snap_id, 0, &i, data);
} else
- printf("error %lu, %d\n", nr, ret);
+ printf("error %lu, %d, %x\n", nr, ret, rsp->result);
}
- close(fd);
-
return 0;
}
--
1.5.6.5
More information about the sheepdog
mailing list