[Sheepdog] [PATCH v4 05/12] sheep: export some structures for trace use

Liu Yuan namei.unix at gmail.com
Tue Apr 10 09:02:00 CEST 2012


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


Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep.c |    3 +++
 sheep/work.c  |   31 +++----------------------------
 sheep/work.h  |   30 ++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index b2c03b8..fd98044 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -226,6 +226,9 @@ int main(int argc, char **argv)
 	    !sys->flush_wqueue)
 		exit(1);
 
+	ret = init_signal();
+	if (ret)
+		exit(1);
 	vprintf(SDOG_NOTICE, "sheepdog daemon (version %s) started\n", PACKAGE_VERSION);
 
 	while (!sys_stat_shutdown() || sys->nr_outstanding_reqs != 0)
diff --git a/sheep/work.c b/sheep/work.c
index 789272e..ec9678d 100644
--- a/sheep/work.c
+++ b/sheep/work.c
@@ -32,40 +32,14 @@
 #include "event.h"
 
 static int efd;
-static LIST_HEAD(worker_info_list);
-
-struct work_queue {
-	int wq_state;
-	int nr_active;
-	struct list_head pending_list;
-	struct list_head blocked_list;
-};
+int total_nr_workers;
+LIST_HEAD(worker_info_list);
 
 enum wq_state {
 	WQ_BLOCKED = (1U << 0),
 	WQ_DEAD = (1U << 1),
 };
 
-struct worker_info {
-	struct list_head worker_info_siblings;
-
-	int nr_threads;
-
-	pthread_mutex_t finished_lock;
-	struct list_head finished_list;
-
-	/* wokers sleep on this and signaled by tgtd */
-	pthread_cond_t pending_cond;
-	/* locked by tgtd and workers */
-	pthread_mutex_t pending_lock;
-	/* protected by pending_lock */
-	struct work_queue q;
-
-	pthread_mutex_t startup_lock;
-
-	pthread_t worker_thread[0];
-};
-
 static void work_queue_set_blocked(struct work_queue *q)
 {
 	q->wq_state |= WQ_BLOCKED;
@@ -289,6 +263,7 @@ struct work_queue *init_work_queue(int nr)
 
 	list_add(&wi->worker_info_siblings, &worker_info_list);
 
+	total_nr_workers += nr;
 	return &wi->q;
 destroy_threads:
 
diff --git a/sheep/work.h b/sheep/work.h
index 9ef9936..3598ad9 100644
--- a/sheep/work.h
+++ b/sheep/work.h
@@ -18,6 +18,36 @@ struct work {
 	enum work_attr attr;
 };
 
+struct work_queue {
+        int wq_state;
+        int nr_active;
+        struct list_head pending_list;
+        struct list_head blocked_list;
+};
+
+struct worker_info {
+	struct list_head worker_info_siblings;
+
+	int nr_threads;
+
+	pthread_mutex_t finished_lock;
+	struct list_head finished_list;
+
+	/* wokers sleep on this and signaled by tgtd */
+	pthread_cond_t pending_cond;
+	/* locked by tgtd and workers */
+	pthread_mutex_t pending_lock;
+	/* protected by pending_lock */
+	struct work_queue q;
+
+	pthread_mutex_t startup_lock;
+
+	pthread_t worker_thread[0];
+};
+
+extern struct list_head worker_info_list;
+extern int total_nr_workers;
+
 struct work_queue *init_work_queue(int nr);
 void queue_work(struct work_queue *q, struct work *work);
 
-- 
1.7.8.2




More information about the sheepdog mailing list