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

levin li levin108 at gmail.com
Wed May 30 05:49:50 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/recovery.c   |    9 +++++----
 sheep/sdnet.c      |   24 +++++++++++++-----------
 sheep/sheep_priv.h |    1 +
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 9b71d9b..9a18c00 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -389,12 +389,13 @@ static 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_move_tail(&req->request_list, &sys->request_queue);
+		list_del(&req->request_list);
+		put_vnode_info(req->vnodes);
+		queue_request(req);
 	}
-
-	process_request_event_queues();
 }
 
 static void flush_wait_obj_requests(void)
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 7fcff4b..833f7d4 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -240,10 +240,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;
-		list_add_tail(&req->request_list, &sys->request_queue);
+		put_vnode_info(req->vnodes);
+		queue_request(req);
 	}
 
 	if (!list_empty(&sys->request_queue))
@@ -264,9 +262,12 @@ void resume_wait_epoch_requests(void)
 			put_vnode_info(req->vnodes);
 			req->vnodes = get_vnode_info();
 			setup_access_to_local_objects(req);
+			list_move_tail(&req->request_list, &sys->request_queue);
+			break;
 		/* peer retries the request locally when its epoch changes. */
 		case SD_RES_NEW_NODE_VER:
-			list_move_tail(&req->request_list, &sys->request_queue);
+			put_vnode_info(req->vnodes);
+			queue_request(req);
 			break;
 		default:
 			break;
@@ -283,15 +284,16 @@ void resume_wait_obj_requests(uint64_t oid)
 			request_list) {
 		/* 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_move_tail(&req->request_list, &sys->request_queue);
-		}
+		if (req->local_oid != oid)
+			continue;
+		dprintf("retry %" PRIx64 "\n", req->local_oid);
+		list_del(&req->request_list);
+		put_vnode_info(req->vnodes);
+		queue_request(req);
 	}
-	process_request_event_queues();
 }
 
-static void queue_request(struct request *req)
+void queue_request(struct request *req)
 {
 	struct sd_req *hdr = &req->rq;
 	struct sd_rsp *rsp = &req->rp;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 2389b1e..ae83a9f 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -237,6 +237,7 @@ int get_nr_copies(struct vnode_info *vnode_info);
 
 int is_access_to_busy_objects(uint64_t oid);
 
+void queue_request(struct request *req);
 void resume_pending_requests(void);
 void resume_wait_epoch_requests(void);
 void resume_wait_obj_requests(uint64_t oid);
-- 
1.7.10




More information about the sheepdog mailing list