[sheepdog] [PATCH v2 5/7] recovery: clear the object wait queue when new recovery work comes

levin li levin108 at gmail.com
Wed May 23 09:02:27 CEST 2012


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

When a new recovery work replaces the old one, we should
clear the waiting requests in the wait_obj_queue to make
them retry for the new work, or else, the requests in the
queue may never be waked up.

Signed-off-by: levin li <xingke.lwp at taobao.com>
---
 sheep/recovery.c   |   15 ++++++++++++++-
 sheep/sdnet.c      |    2 +-
 sheep/sheep_priv.h |    2 +-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index a2177cf..fc9d970 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -546,6 +546,17 @@ static void resume_wait_recovery_requests(void)
 	}
 }
 
+static void clear_wait_obj_requests(void)
+{
+	struct request *req, *t;
+
+	list_for_each_entry_safe(req, t, &sys->wait_obj_queue, request_list) {
+		list_del(&req->request_list);
+		list_add_tail(&req->request_list, &sys->request_queue);
+		process_request_event_queues();
+	}
+}
+
 static void do_recover_main(struct work *work)
 {
 	struct recovery_work *rw = container_of(work, struct recovery_work, work);
@@ -564,7 +575,7 @@ static void do_recover_main(struct work *work)
 	oid = rw->oids[rw->done];
 
 	if (recovered_oid)
-		resume_retry_requests(recovered_oid);
+		resume_wait_obj_requests(recovered_oid);
 
 	if (rw->retry && !next_rw) {
 		rw->retry = 0;
@@ -599,6 +610,8 @@ static void do_recover_main(struct work *work)
 		rw = next_rw;
 		next_rw = NULL;
 
+		clear_wait_obj_requests();
+
 		recovering_work = rw;
 		queue_work(sys->recovery_wqueue, &rw->work);
 	} else {
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 89b4c6c..45f2f30 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -294,7 +294,7 @@ void resume_wait_epoch_requests(void)
 	}
 }
 
-void resume_retry_requests(uint64_t oid)
+void resume_wait_obj_requests(uint64_t oid)
 {
 	struct request *req, *t;
 
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 24f4544..bf7adc5 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -266,7 +266,7 @@ int is_access_to_busy_objects(uint64_t oid);
 
 void resume_pending_requests(void);
 void resume_wait_epoch_requests(void);
-void resume_retry_requests(uint64_t oid);
+void resume_wait_obj_requests(uint64_t oid);
 
 int create_cluster(int port, int64_t zone, int nr_vnodes);
 int leave_cluster(void);
-- 
1.7.10




More information about the sheepdog mailing list