[Sheepdog] [PATCH 1/2] sheep: avoid extra log reading if system status is not okay

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Sep 23 14:11:24 CEST 2011


At Fri, 23 Sep 2011 14:36:10 +0800,
Liu Yuan wrote:
> 
> From: Liu Yuan <tailai.ly at taobao.com>
> 
> When we query the cluster info, we don't have to do extra log reading
> if system status is not okay. This patch fixes it.

For debug or manual cluster recovery, isn't it helpful to show the
epoch histories when the node is waiting for other's joining?

Thanks,

Kazutaka

> 
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
>  sheep/group.c |   43 +++++++++++++++++++++----------------------
>  1 files changed, 21 insertions(+), 22 deletions(-)
> 
> diff --git a/sheep/group.c b/sheep/group.c
> index 9d05fdd..1d02971 100644
> --- a/sheep/group.c
> +++ b/sheep/group.c
> @@ -294,30 +294,29 @@ void cluster_queue_request(struct work *work, int idx)
>  			      (struct sd_node_rsp *)rsp, req->data);
>  		break;
>  	case SD_OP_STAT_CLUSTER:
> -		max_logs = rsp->data_length / sizeof(*log);
> -		epoch = get_latest_epoch();
> -		rsp->data_length = 0;
> -		for (i = 0; i < max_logs; i++) {
> -			if (epoch <= 0)
> -				break;
> -
> -			log = (struct epoch_log *)req->data + i;
> -			log->epoch = epoch;
> -			log->ctime = get_cluster_ctime();
> -			log->nr_nodes = epoch_log_read(epoch, (char *)log->nodes,
> -						       sizeof(log->nodes));
> -			if (log->nr_nodes == -1)
> -				log->nr_nodes = epoch_log_read_remote(epoch,
> -								      (char *)log->nodes,
> -								      sizeof(log->nodes));
> -
> -			rsp->data_length += sizeof(*log);
> -			log->nr_nodes /= sizeof(log->nodes[0]);
> -			epoch--;
> -		}
> -
>  		switch (sys->status) {
>  		case SD_STATUS_OK:
> +			max_logs = rsp->data_length / sizeof(*log);
> +			epoch = get_latest_epoch();
> +			rsp->data_length = 0;
> +			for (i = 0; i < max_logs; i++) {
> +				if (epoch <= 0)
> +					break;
> +
> +				log = (struct epoch_log *)req->data + i;
> +				log->epoch = epoch;
> +				log->ctime = get_cluster_ctime();
> +				log->nr_nodes = epoch_log_read(epoch, (char *)log->nodes,
> +						sizeof(log->nodes));
> +				if (log->nr_nodes == -1)
> +					log->nr_nodes = epoch_log_read_remote(epoch,
> +							(char *)log->nodes,
> +							sizeof(log->nodes));
> +
> +				rsp->data_length += sizeof(*log);
> +				log->nr_nodes /= sizeof(log->nodes[0]);
> +				epoch--;
> +			}
>  			ret = SD_RES_SUCCESS;
>  			break;
>  		case SD_STATUS_WAIT_FOR_FORMAT:
> -- 
> 1.7.6.1
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list