[sheepdog] [PATCH v1] lib/work: remove startup_lock

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Thu Sep 11 04:24:28 CEST 2014


At Wed, 10 Sep 2014 19:31:30 +0800,
Bingpeng Zhu wrote:
> 
> The startup_lock is garbage code now. The code of worker threads
> is imported from tgt and the corresponding code in tgt is removed
> in the following commit:
> https://github.com/fujita/tgt/commit/c57e3ba1ae043eff558b4534e5bfe0c7865f6c1e
> We should follow it.
> 
> Signed-off-by: Bingpeng Zhu <bingpeng.zbp at alibaba-inc.com>
> ---
>  lib/work.c |   10 ----------
>  1 files changed, 0 insertions(+), 10 deletions(-)

Applied, thanks.
Hitoshi

> 
> diff --git a/lib/work.c b/lib/work.c
> index eba59c4..7e2cd79 100644
> --- a/lib/work.c
> +++ b/lib/work.c
> @@ -47,7 +47,6 @@ struct wq_info {
>  	struct list_node list;
>  
>  	struct sd_mutex finished_lock;
> -	struct sd_mutex startup_lock;
>  
>  	/* workers sleep on this and signaled by work producer */
>  	struct sd_cond pending_cond;
> @@ -247,18 +246,15 @@ static int create_worker_threads(struct wq_info *wi, size_t nr_threads)
>  	pthread_t thread;
>  	int ret;
>  
> -	sd_mutex_lock(&wi->startup_lock);
>  	while (wi->nr_threads < nr_threads) {
>  		ret = pthread_create(&thread, NULL, worker_routine, wi);
>  		if (ret != 0) {
>  			sd_err("failed to create worker thread: %m");
> -			sd_mutex_unlock(&wi->startup_lock);
>  			return -1;
>  		}
>  		wi->nr_threads++;
>  		sd_debug("create thread %s %zu", wi->name, wi->nr_threads);
>  	}
> -	sd_mutex_unlock(&wi->startup_lock);
>  
>  	return 0;
>  }
> @@ -314,10 +310,6 @@ static void *worker_routine(void *arg)
>  
>  	set_thread_name(wi->name, (wi->tc != WQ_ORDERED));
>  
> -	sd_mutex_lock(&wi->startup_lock);
> -	/* started this thread */
> -	sd_mutex_unlock(&wi->startup_lock);
> -
>  	trace_set_tid_map(tid);
>  	while (true) {
>  
> @@ -414,7 +406,6 @@ struct work_queue *create_work_queue(const char *name,
>  
>  	sd_init_mutex(&wi->finished_lock);
>  	sd_init_mutex(&wi->pending_lock);
> -	sd_init_mutex(&wi->startup_lock);
>  
>  	ret = create_worker_threads(wi, 1);
>  	if (ret < 0)
> @@ -424,7 +415,6 @@ struct work_queue *create_work_queue(const char *name,
>  
>  	return &wi->q;
>  destroy_threads:
> -	sd_mutex_unlock(&wi->startup_lock);
>  	sd_destroy_cond(&wi->pending_cond);
>  	sd_destroy_mutex(&wi->pending_lock);
>  	sd_destroy_mutex(&wi->finished_lock);
> -- 
> 1.7.1
> 
> 
> 
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list