[sheepdog] [PATCH 3/3] sheep: fix finish_object_list()

Liu Yuan namei.unix at gmail.com
Sun Jun 3 08:47:25 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

When prepare_object_list() gets an empty list, we should directly call
finish_recovery() or oid = 0 will be recovered. Though this does no harm
just wasting cpu cycles, we should avoid it completely.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/recovery.c |   33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index c3d1d4d..591c5d1 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -353,6 +353,21 @@ static inline void run_next_rw(struct recovery_work *rw)
 	dprintf("recovery work is superseded\n");
 }
 
+static inline void finish_recovery(struct recovery_work *rw)
+{
+	recovering_work = NULL;
+	sys->recovered_epoch = rw->epoch;
+	free_recovery_work(rw);
+
+	if (sd_store->end_recover) {
+		struct siocb iocb = { 0 };
+		iocb.epoch = sys->epoch;
+		sd_store->end_recover(&iocb);
+	}
+	dprintf("recovery complete: new epoch %"PRIu32"\n",
+		sys->recovered_epoch);
+}
+
 static void recover_object_main(struct work *work)
 {
 	struct recovery_work *rw = container_of(work, struct recovery_work,
@@ -378,22 +393,12 @@ static void recover_object_main(struct work *work)
 	resume_wait_obj_requests(rw->oids[rw->done++]);
 
 	if (rw->done < rw->count) {
-		/* Requeue the work */
+		/* Try recover next object */
 		queue_work(sys->recovery_wqueue, &rw->work);
 		return;
 	}
 
-	recovering_work = NULL;
-	sys->recovered_epoch = rw->epoch;
-	free_recovery_work(rw);
-
-	if (sd_store->end_recover) {
-		struct siocb iocb = { 0 };
-		iocb.epoch = sys->epoch;
-		sd_store->end_recover(&iocb);
-	}
-	dprintf("recovery complete: new epoch %"PRIu32"\n",
-		sys->recovered_epoch);
+	finish_recovery(rw);
 }
 
 static void finish_object_list(struct work *work)
@@ -405,6 +410,10 @@ static void finish_object_list(struct work *work)
 		run_next_rw(rw);
 		return;
 	}
+	if (!rw->count) {
+		finish_recovery(rw);
+		return;
+	}
 	/*
 	 * We have got the object list to be recovered locally, most of
 	 * objects are actually already being there, so let's resume
-- 
1.7.10.2




More information about the sheepdog mailing list