Even though SD_FLAG_CMD_DIRECT is not set, local accesses could happen
if the target object is in the local node.

Signed-off-by: MORITA Kazutaka <[email protected]>
---
 sheep/group.c      |   10 ++++++++--
 sheep/sdnet.c      |    7 +++++--
 sheep/sheep_priv.h |    2 ++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index 2826db3..28d211f 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -1342,7 +1342,10 @@ do_retry:
 
                        sys->nr_outstanding_io++;
 
-                       if (req->rq.flags & SD_FLAG_CMD_DIRECT) {
+                       if (is_access_local(req->entry, req->nr_vnodes,
+                                           ((struct sd_obj_req 
*)&req->rq)->oid, sys->nr_sobjs) ||
+                           is_access_local(req->entry, req->nr_vnodes,
+                                           ((struct sd_obj_req 
*)&req->rq)->cow_oid, sys->nr_sobjs)) {
                                int ret = check_epoch(req);
                                if (ret != SD_RES_SUCCESS) {
                                        req->rp.result = ret;
@@ -1350,7 +1353,10 @@ do_retry:
                                        list_add_tail(&req->r_wlist, 
&failed_req_list);
                                        continue;
                                }
-                       } else if (req->rq.opcode == SD_OP_READ_OBJ) {
+                       }
+
+                       if (!(req->rq.flags & SD_FLAG_CMD_DIRECT) &&
+                           req->rq.opcode == SD_OP_READ_OBJ) {
                                struct sd_obj_req *hdr = (struct sd_obj_req 
*)&req->rq;
                                uint32_t vdi_id = oid_to_vid(hdr->oid);
                                struct data_object_bmap *bmap;
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index d37e75f..1b1b7cc 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -51,11 +51,14 @@ void resume_pending_requests(void)
                start_cpg_event_work();
 }
 
-static int is_access_local(struct sheepdog_vnode_list_entry *e, int nr_nodes,
-                          uint64_t oid, int copies)
+int is_access_local(struct sheepdog_vnode_list_entry *e, int nr_nodes,
+                   uint64_t oid, int copies)
 {
        int i, n;
 
+       if (oid == 0)
+               return 0;
+
        for (i = 0; i < copies; i++) {
                n = obj_to_sheep(e, nr_nodes, oid, i);
 
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 13a5ce2..82840de 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -166,6 +166,8 @@ void setup_ordered_sd_vnode_list(struct request *req);
 void get_ordered_sd_vnode_list(struct sheepdog_vnode_list_entry *entries,
                               int *nr_vnodes, int *nr_nodes);
 int is_access_to_busy_objects(uint64_t oid);
+int is_access_local(struct sheepdog_vnode_list_entry *e, int nr_nodes,
+                   uint64_t oid, int copies);
 
 void resume_pending_requests(void);
 
-- 
1.5.6.5

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to