[sheepdog] [PATCH v4 6/6] dog: add information of disks in cluster info

Liu Yuan namei.unix at gmail.com
Tue May 20 11:21:26 CEST 2014


On Tue, May 20, 2014 at 04:40:34PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai at taobao.com>
> 
> Add number of disks for every node in cluster info and
> also show type of backend and vnode mode (disk or node)
> when using '-v' option.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  dog/cluster.c | 51 ++++++++++++++++++++++++++++++++++++---------------
>  1 file changed, 36 insertions(+), 15 deletions(-)
> 
> diff --git a/dog/cluster.c b/dog/cluster.c
> index 7c5bc87..4c83b0b 100644
> --- a/dog/cluster.c
> +++ b/dog/cluster.c
> @@ -23,7 +23,6 @@ static struct sd_option cluster_options[] = {
>  	{'f', "force", false, "do not prompt for confirmation"},
>  	{'t', "strict", false,
>  	 "do not serve write request if number of nodes is not sufficient"},
> -	{'s', "backend", false, "show backend store information"},
>  	{ 0, NULL, false, NULL },
>  };
>  
> @@ -31,7 +30,6 @@ static struct cluster_cmd_data {
>  	uint8_t copies;
>  	uint8_t copy_policy;
>  	bool force;
> -	bool show_store;
>  	bool strict;
>  	char name[STORE_LEN];
>  } cluster_cmd_data;
> @@ -143,6 +141,29 @@ static int cluster_format(int argc, char **argv)
>  	return EXIT_SUCCESS;
>  }
>  
> +static void print_nodes(const struct epoch_log *logs, int epoch)
> +{
> +	int i, nr_disk;
> +	const struct sd_node *entry;
> +
> +	for (i = 0; i < logs[epoch].nr_nodes; i++) {
> +		entry = logs[epoch].nodes + i;
> +		if (logs->flags & SD_CLUSTER_FLAG_DISKMODE) {
> +			for (nr_disk = 0; nr_disk < DISK_MAX; nr_disk++) {
> +				if (entry->disks[nr_disk].disk_id == 0)
> +					break;
> +			}
> +			printf("%s%s(%d)",
> +			       (i == 0) ? "" : ", ",
> +			       addr_to_str(entry->nid.addr, entry->nid.port),
> +			       nr_disk);
> +		} else
> +			printf("%s%s",
> +			       (i == 0) ? "" : ", ",
> +			       addr_to_str(entry->nid.addr, entry->nid.port));
> +	}
> +}
> +
>  static int cluster_info(int argc, char **argv)
>  {
>  	int i, ret;
> @@ -174,7 +195,7 @@ static int cluster_info(int argc, char **argv)
>  		printf("%s\n", sd_strerror(rsp->result));
>  
>  	/* show cluster backend store */
> -	if (cluster_cmd_data.show_store) {
> +	if (verbose) {
>  		if (!raw_output)
>  			printf("Cluster store: ");
>  		if (rsp->result == SD_RES_SUCCESS) {
> @@ -195,6 +216,16 @@ static int cluster_info(int argc, char **argv)
>  			printf("%s\n", sd_strerror(rsp->result));
>  	}
>  
> +	/* show vnode mode (node or disk) for cluster */
> +	if (verbose) {

Why we need to two if check for the same 'verbose'?

Thanks
Yuan



More information about the sheepdog mailing list