[Sheepdog] [PATCH 10/10] collie: fix cow read
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Tue Jan 26 05:34:56 CET 2010
Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
collie/store.c | 15 +++++++++++----
lib/net.c | 3 ++-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/collie/store.c b/collie/store.c
index 05070a9..d242e8d 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -136,10 +136,10 @@ static int get_obj_list(struct request *req)
}
static int read_from_one(struct cluster_info *cluster, uint64_t oid,
- unsigned *rlen, void *buf, uint64_t offset)
+ unsigned *ori_rlen, void *buf, uint64_t offset)
{
int i, n, nr, fd, ret;
- unsigned wlen;
+ unsigned wlen, rlen;
char name[128];
struct sheepdog_node_list_entry *e;
struct sd_obj_req hdr;
@@ -156,6 +156,10 @@ again:
e[n].addr[12], e[n].addr[13],
e[n].addr[14], e[n].addr[15]);
+ /* FIXME: do like store_queue_request_local() */
+ if (e[n].id == cluster->this_node.id)
+ continue;
+
fd = connect_to(name, e[n].port);
if (fd < 0)
continue;
@@ -165,11 +169,13 @@ again:
hdr.oid = oid;
hdr.epoch = cluster->epoch;
+ rlen = *ori_rlen;
+ wlen = 0;
hdr.flags = 0;
- hdr.data_length = *rlen;
+ hdr.data_length = rlen;
hdr.offset = offset;
- ret = exec_req(fd, (struct sd_req *)&hdr, buf, &wlen, rlen);
+ ret = exec_req(fd, (struct sd_req *)&hdr, buf, &wlen, &rlen);
close(fd);
@@ -178,6 +184,7 @@ again:
switch (rsp->result) {
case SD_RES_SUCCESS:
+ *ori_rlen = rlen;
return 0;
case SD_RES_OLD_NODE_VER:
case SD_RES_NEW_NODE_VER:
diff --git a/lib/net.c b/lib/net.c
index cc625f0..7bca7b2 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -295,7 +295,8 @@ int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int *wlen)
ret = do_write(sockfd, &msg, sizeof(*hdr) + *wlen);
if (ret) {
- eprintf("failed to send a req, %m\n");
+ eprintf("failed to send a req, %x %d, %m\n", hdr->opcode,
+ *wlen);
ret = -1;
}
--
1.5.6.5
More information about the sheepdog
mailing list