[sheepdog] [PATCH] use queue_request when resume waiting requests

levin li levin108 at gmail.com
Wed May 30 10:28:43 CEST 2012


From: levin li <xingke.lwp at taobao.com>

When a waiting requests due to epoch inconsistency or object in recovery
is resumed, we should check it again to determine whether the current
condition can fulfill its need to make it run, so we call queue_request
to reinitialize and check the request again.

Signed-off-by: levin li <xingke.lwp at taobao.com>
---
 sheep/sdnet.c |   38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index dc39de5..c23ea31 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -20,6 +20,7 @@
 
 #include "sheep_priv.h"
 
+static void queue_request(struct request *req);
 
 static int is_access_local(struct request *req, uint64_t oid)
 {
@@ -292,10 +293,8 @@ void resume_pending_requests(void)
 
 	list_for_each_entry_safe(req, n, &pending_list, request_list) {
 		list_del(&req->request_list);
-
-		if (check_request(req) < 0)
-			continue;
-		process_io_request(req);
+		put_vnode_info(req->vnodes);
+		queue_request(req);
 	}
 }
 
@@ -313,10 +312,14 @@ void resume_wait_epoch_requests(void)
 			put_vnode_info(req->vnodes);
 			req->vnodes = get_vnode_info();
 			setup_access_to_local_objects(req);
+			list_del(&req->request_list);
+			process_io_request(req);
+			break;
 		/* peer retries the request locally when its epoch changes. */
 		case SD_RES_NEW_NODE_VER:
 			list_del(&req->request_list);
-			process_io_request(req);
+			put_vnode_info(req->vnodes);
+			queue_request(req);
 			break;
 		default:
 			break;
@@ -330,11 +333,13 @@ void resume_wait_recovery_requests(void)
 
 	list_for_each_entry_safe(req, t, &sys->wait_rw_queue,
 				 request_list) {
+		if (req->rp.result != SD_RES_OBJ_RECOVERING)
+			continue;
+
 		dprintf("resume wait oid %" PRIx64 "\n", req->local_oid);
-		if (req->rp.result == SD_RES_OBJ_RECOVERING) {
-			list_del(&req->request_list);
-			process_io_request(req);
-		}
+		list_del(&req->request_list);
+		put_vnode_info(req->vnodes);
+		queue_request(req);
 	}
 }
 
@@ -344,13 +349,15 @@ void resume_wait_obj_requests(uint64_t oid)
 
 	list_for_each_entry_safe(req, t, &sys->wait_obj_queue,
 			request_list) {
+		if (req->local_oid != oid)
+			continue;
+
 		/* the object requested by a pending request has been
 		 * recovered, notify the pending request. */
-		if (req->local_oid == oid) {
-			dprintf("retry %" PRIx64 "\n", req->local_oid);
-			list_del(&req->request_list);
-			process_io_request(req);
-		}
+		dprintf("retry %" PRIx64 "\n", req->local_oid);
+		list_del(&req->request_list);
+		put_vnode_info(req->vnodes);
+		queue_request(req);
 	}
 }
 
@@ -360,7 +367,8 @@ void flush_wait_obj_requests(void)
 
 	list_for_each_entry_safe(req, n, &sys->wait_obj_queue, request_list) {
 		list_del(&req->request_list);
-		process_io_request(req);
+		put_vnode_info(req->vnodes);
+		queue_request(req);
 	}
 }
 
-- 
1.7.10




More information about the sheepdog mailing list