The separate passing of epoch is rather confusing and even obsfucates the only real user of this code. Also simply the control flow in forward_read_obj_req around the call do do_local_io / do_process_work.
Signed-off-by: Christoph Hellwig <[email protected]> --- sheep/gateway.c | 18 ++++++++---------- sheep/sheep_priv.h | 1 - sheep/store.c | 17 ++++------------- 3 files changed, 12 insertions(+), 24 deletions(-) Index: sheepdog/sheep/gateway.c =================================================================== --- sheepdog.orig/sheep/gateway.c 2012-07-03 21:11:21.553691973 +0200 +++ sheepdog/sheep/gateway.c 2012-07-03 21:28:53.040352358 +0200 @@ -38,17 +38,16 @@ static int forward_read_obj_req(struct r oid_to_vnodes(req->vnodes, oid, nr_copies, obj_vnodes); for (i = 0; i < nr_copies; i++) { v = obj_vnodes[i]; - if (vnode_is_local(v)) { - ret = do_local_io(req, fwd_hdr.epoch); - if (ret != SD_RES_SUCCESS) { - goto read_remote; - eprintf("local read fail %x\n", ret); - } + if (!vnode_is_local(v)) + continue; + ret = do_process_work(req); + if (ret == SD_RES_SUCCESS) return ret; - } + + eprintf("local read fail %x\n", ret); + break; } -read_remote: /* * Read random copy from cluster for better load balance, useful for * reading base VM's COW objects @@ -269,8 +268,7 @@ static int forward_write_obj_req(struct if (local != -1 && err_ret == SD_RES_SUCCESS) { v = obj_vnodes[local]; - ret = do_local_io(req, fwd_hdr.epoch); - + ret = do_process_work(req); if (ret != SD_RES_SUCCESS) { eprintf("fail to write local %"PRIx32"\n", ret); err_ret = ret; Index: sheepdog/sheep/sheep_priv.h =================================================================== --- sheepdog.orig/sheep/sheep_priv.h 2012-07-03 21:11:21.553691973 +0200 +++ sheepdog/sheep/sheep_priv.h 2012-07-03 21:28:53.040352358 +0200 @@ -295,7 +295,6 @@ int has_process_main(struct sd_op_templa int do_process_work(struct request *req); int do_process_main(struct sd_op_template *op, const struct sd_req *req, struct sd_rsp *rsp, void *data); -int do_local_io(struct request *req, uint32_t epoch); /* Journal */ struct jrnl_descriptor *jrnl_begin(const void *buf, size_t count, off_t offset, Index: sheepdog/sheep/store.c =================================================================== --- sheepdog.orig/sheep/store.c 2012-07-03 18:20:36.903722803 +0200 +++ sheepdog/sheep/store.c 2012-07-03 21:29:12.097018910 +0200 @@ -46,12 +46,6 @@ mode_t def_fmode = S_IRUSR | S_IWUSR | S struct store_driver *sd_store; LIST_HEAD(store_drivers); -int do_local_io(struct request *req, uint32_t epoch) -{ - req->rq.epoch = epoch; - return do_process_work(req); -} - int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes) { int fd, ret, len; @@ -91,22 +85,19 @@ err_open: void do_io_request(struct work *work) { struct request *req = container_of(work, struct request, work); - uint32_t epoch; int ret; if (req->rq.flags & SD_FLAG_CMD_RECOVERY) - epoch = req->rq.obj.tgt_epoch; - else - epoch = req->rq.epoch; + req->rq.epoch = req->rq.obj.tgt_epoch; dprintf("%x, %" PRIx64" , %u\n", - req->rq.opcode, req->rq.obj.oid, epoch); + req->rq.opcode, req->rq.obj.oid, req->rq.epoch); - ret = do_local_io(req, epoch); + ret = do_process_work(req); if (ret != SD_RES_SUCCESS) dprintf("failed: %x, %" PRIx64" , %u, %"PRIx32"\n", - req->rq.opcode, req->rq.obj.oid, epoch, ret); + req->rq.opcode, req->rq.obj.oid, req->rq.epoch, ret); req->rp.result = ret; } -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
