If the request needs checking epoch, we shouldn't add it to the
waitlist but return SD_RES_NEW_NODE_VER.  It is because the sender
node could update epoch after sending requests.

Signed-off-by: MORITA Kazutaka <[email protected]>
---
 sheep/group.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index 5d9409d..6deb4a2 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -1273,7 +1273,7 @@ int is_access_to_busy_objects(uint64_t oid)
        return 0;
 }
 
-static int __is_access_to_busy_objects(struct request *req)
+static int __is_access_to_recoverying_objects(struct request *req)
 {
        if (req->rq.flags & SD_FLAG_CMD_RECOVERY) {
                if (req->rq.opcode != SD_OP_READ_OBJ)
@@ -1281,10 +1281,21 @@ static int __is_access_to_busy_objects(struct request 
*req)
                return 0;
        }
 
-       if (is_access_to_busy_objects(req->local_oid))
+       if (is_recoverying_oid(req->local_oid))
                return 1;
 
-       if (is_recoverying_oid(req->local_oid))
+       return 0;
+}
+
+static int __is_access_to_busy_objects(struct request *req)
+{
+       if (req->rq.flags & SD_FLAG_CMD_RECOVERY) {
+               if (req->rq.opcode != SD_OP_READ_OBJ)
+                       eprintf("bug\n");
+               return 0;
+       }
+
+       if (is_access_to_busy_objects(req->local_oid))
                return 1;
 
        return 0;
@@ -1353,6 +1364,15 @@ do_retry:
                list_del(&cevent->cpg_event_list);
 
                if (is_io_request(req->rq.opcode)) {
+                       if (__is_access_to_recoverying_objects(req)) {
+                               if (req->rq.flags & SD_FLAG_CMD_DIRECT) {
+                                       req->rp.result = SD_RES_NEW_NODE_VER;
+                                       sys->nr_outstanding_io++; /* TODO: 
cleanup */
+                                       list_add_tail(&req->r_wlist, 
&failed_req_list);
+                               } else
+                                       list_add_tail(&req->r_wlist, 
&sys->req_wait_for_obj_list);
+                               continue;
+                       }
                        if (__is_access_to_busy_objects(req)) {
                                list_add_tail(&req->r_wlist, 
&sys->req_wait_for_obj_list);
                                continue;
-- 
1.5.6.5

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

Reply via email to