[sheepdog] [PATCH] sheep: set cluster_op_running to false after block request finishes

Liu Yuan namei.unix at gmail.com
Wed May 29 15:06:07 CEST 2013


On 05/29/2013 06:20 PM, MORITA Kazutaka wrote:
> From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> 
> There is a race problem that sd_block_handler() can be executed before
> sd_notify_handler() of the previous block request.  This leads to
> segmentation fault.  For example,
> 
>  1. There are two requests in pending_block_list.
> 
>  2. sd_block_handler() of the first block request is called.
>     cluster_op_running is set to true.
> 
>  3. cluster_op_done of the first block request is called and
>     cluster_op_running is set to false.
> 
>  4. sd_block_handler() of the second block request is tried to be
>     called.  However, the first one is still in the pending_block_list
>     and sd_block_handler() is called against the first request again.
> 
> To fix this problem, this patch sets cluster_op_running to false after
> the request is removed from the pending_block_list in
> sd_notify_handler().
> 
> Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> ---
>  sheep/group.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/sheep/group.c b/sheep/group.c
> index fe45ff9..b9399ee 100644
> --- a/sheep/group.c
> +++ b/sheep/group.c
> @@ -272,8 +272,6 @@ static void cluster_op_done(struct work *work)
>  	struct vdi_op_message *msg;
>  	size_t size;
>  
> -	cluster_op_running = false;
> -
>  	sd_dprintf("%s (%p)", op_name(req->op), req);
>  
>  	msg = prepare_cluster_msg(req, &size);
> @@ -976,6 +974,9 @@ void sd_notify_handler(const struct sd_node *sender, void *data,
>  
>  		put_request(req);
>  	}
> +
> +	if (has_process_work(op))
> +		cluster_op_running = false;
>  }
>  
>  enum cluster_join_result sd_check_join_cb(const struct sd_node *joining,
> 

Applied, thanks.

Yuan



More information about the sheepdog mailing list