[sheepdog] [PATCH] collie: don't fetch node list if not use

Liu Yuan namei.unix at gmail.com
Wed Aug 29 13:14:18 CEST 2012


On 08/29/2012 05:08 PM, levin li wrote:
> From: levin li <xingke.lwp at taobao.com>
> 
> 
> Signed-off-by: levin li <xingke.lwp at taobao.com>
> ---
>  collie/cluster.c |    5 +----
>  collie/common.c  |    3 ---
>  collie/node.c    |    4 ++--
>  collie/vdi.c     |   27 +++++++++++++--------------
>  4 files changed, 16 insertions(+), 23 deletions(-)
> 
> diff --git a/collie/cluster.c b/collie/cluster.c
> index fe2393f..8b28eab 100644
> --- a/collie/cluster.c
> +++ b/collie/cluster.c
> @@ -99,7 +99,6 @@ static int cluster_format(int argc, char **argv)
>  	if (cluster_cmd_data.quorum)
>  		hdr.flags |= SD_FLAG_QUORUM;
>  
> -	hdr.epoch = sd_epoch;
>  	hdr.ctime = (uint64_t) tv.tv_sec << 32 | tv.tv_usec * 1000;
>  
>  	if (strlen(cluster_cmd_data.name))
> @@ -159,7 +158,6 @@ again:
>  		goto error;
>  
>  	sd_init_req(&hdr, SD_OP_STAT_CLUSTER);
> -	hdr.epoch = sd_epoch;
>  	hdr.data_length = log_length;
>  
>  	rlen = hdr.data_length;
> @@ -222,7 +220,6 @@ static int cluster_shutdown(int argc, char **argv)
>  	struct sd_req hdr;
>  
>  	sd_init_req(&hdr, SD_OP_SHUTDOWN);
> -	hdr.epoch = sd_epoch;
>  
>  	ret = send_light_req(&hdr, sdhost, sdport);
>  	if (ret) {
> @@ -500,7 +497,7 @@ static struct subcommand cluster_cmd[] = {
>  	{"format", NULL, "bcmaph", "create a Sheepdog store",
>  	 NULL, 0, cluster_format, cluster_options},
>  	{"shutdown", NULL, "aph", "stop Sheepdog",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST, cluster_shutdown, cluster_options},
> +	 NULL, 0, cluster_shutdown, cluster_options},
>  	{"snapshot", NULL, "aRlph", "snapshot/restore the cluster",
>  	 NULL, 0, cluster_snapshot, cluster_options},
>  	{"recover", NULL, "afph",
> diff --git a/collie/common.c b/collie/common.c
> index ce8dcf7..8bfab30 100644
> --- a/collie/common.c
> +++ b/collie/common.c
> @@ -57,7 +57,6 @@ int sd_read_object(uint64_t oid, void *data, unsigned int datalen,
>  	}
>  
>  	sd_init_req(&hdr, SD_OP_READ_OBJ);
> -	hdr.epoch = sd_epoch;
>  	hdr.data_length = rlen;
>  
>  	hdr.obj.oid = oid;
> @@ -99,7 +98,6 @@ int sd_write_object(uint64_t oid, uint64_t cow_oid, void *data, unsigned int dat
>  	else
>  		sd_init_req(&hdr, SD_OP_WRITE_OBJ);
>  
> -	hdr.epoch = sd_epoch;
>  	hdr.data_length = wlen;
>  	hdr.flags = flags | SD_FLAG_CMD_WRITE;
>  
> @@ -149,7 +147,6 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
>  
>  	sd_init_req(&req, SD_OP_GET_VDI_COPIES);
>  	req.data_length = rlen;
> -	req.epoch = sd_epoch;
>  
>  	ret = exec_req(fd, &req, (char *)vc, &wlen, &rlen);
>  	if (ret < 0) {
> diff --git a/collie/node.c b/collie/node.c
> index 63bb27a..e86e4da 100644
> --- a/collie/node.c
> +++ b/collie/node.c
> @@ -211,7 +211,7 @@ static int node_kill(int argc, char **argv)
>  
>  static struct subcommand node_cmd[] = {
>  	{"kill", "<node id>", "aprh", "kill node", NULL,
> -	 SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG, node_kill},
> +	 SUBCMD_FLAG_NEED_THIRD_ARG, node_kill},
>  	{"list", NULL, "aprh", "list nodes", NULL,
>  	 SUBCMD_FLAG_NEED_NODELIST, node_list},
>  	{"info", NULL, "aprh", "show information about each node", NULL,
> @@ -219,7 +219,7 @@ static struct subcommand node_cmd[] = {
>  	{"recovery", NULL, "aprh", "show nodes in recovery", NULL,
>  	 SUBCMD_FLAG_NEED_NODELIST, node_recovery},
>  	{"cache", "<cache size>", "aprh", "specify max cache size", NULL,
> -	 SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG, node_cache},
> +	 SUBCMD_FLAG_NEED_THIRD_ARG, node_cache},
>  	{NULL,},
>  };
>  
> diff --git a/collie/vdi.c b/collie/vdi.c
> index 7e2f5b0..2e01091 100644
> --- a/collie/vdi.c
> +++ b/collie/vdi.c
> @@ -724,7 +724,6 @@ static int vdi_delete(int argc, char **argv)
>  	wlen = sizeof(vdiname);
>  
>  	sd_init_req(&hdr, SD_OP_DEL_VDI);
> -	hdr.epoch = sd_epoch;
>  	hdr.flags = SD_FLAG_CMD_WRITE;
>  	hdr.data_length = wlen;
>  	hdr.vdi.snapid = vdi_cmd_data.snapshot_id;
> @@ -1527,23 +1526,23 @@ static struct subcommand vdi_cmd[] = {
>  	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_check, vdi_options},
>  	{"create", "<vdiname> <size>", "Pcaph", "create an image",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_create, vdi_options},
>  	{"snapshot", "<vdiname>", "saph", "create a snapshot",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_snapshot, vdi_options},
>  	{"clone", "<src vdi> <dst vdi>", "sPcaph", "clone an image",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_clone, vdi_options},
>  	{"delete", "<vdiname>", "saph", "delete an image",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_delete, vdi_options},
>  	{"list", "[vdiname]", "aprh", "list images",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST, vdi_list, vdi_options},
> +	 NULL, 0, vdi_list, vdi_options},
>  	{"tree", NULL, "aph", "show images in tree view format",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST, vdi_tree, vdi_options},
> +	 NULL, 0, vdi_tree, vdi_options},
>  	{"graph", NULL, "aph", "show images in Graphviz dot format",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST, vdi_graph, vdi_options},
> +	 NULL, 0, vdi_graph, vdi_options},
>  	{"object", "<vdiname>", "isaph", "show object information in the image",
>  	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_object, vdi_options},
> @@ -1551,22 +1550,22 @@ static struct subcommand vdi_cmd[] = {
>  	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_track, vdi_options},
>  	{"setattr", "<vdiname> <key> [value]", "dxaph", "set a VDI attribute",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_setattr, vdi_options},
>  	{"getattr", "<vdiname> <key>", "aph", "get a VDI attribute",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_getattr, vdi_options},
>  	{"resize", "<vdiname> <new size>", "aph", "resize an image",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_resize, vdi_options},
>  	{"read", "<vdiname> [<offset> [<len>]]", "saph", "read data from an image",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_read, vdi_options},
>  	{"write", "<vdiname> [<offset> [<len>]]", "apCh", "write data to an image",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_write, vdi_options},
>  	{"flush", "<vdiname>", "aph", "flush data to cluster",
> -	 NULL, SUBCMD_FLAG_NEED_NODELIST|SUBCMD_FLAG_NEED_THIRD_ARG,
> +	 NULL, SUBCMD_FLAG_NEED_THIRD_ARG,
>  	 vdi_flush, vdi_options},
>  	{NULL,},
>  };
> 

Applied, thanks.

Yuan



More information about the sheepdog mailing list