[sheepdog] [PATCH 3/3] dog: add a new option to specify the vid space

Takafumi Fujieda fujieda.takafumi at lab.ntt.co.jp
Mon Feb 2 06:58:21 CET 2015


This patch adds a new option "-s <bits>" to dog cluster format to
specify the VID space size.
"dog cluster info -v" shows the specified VID space size.

Signed-off-by: Takafumi Fujieda <fujieda.takafumi at lab.ntt.co.jp>
---
 dog/cluster.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/dog/cluster.c b/dog/cluster.c
index d4a45ec..97c5b3b 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -24,6 +24,7 @@ static struct sd_option cluster_options[] = {
 	{'f', "force", false, "do not prompt for confirmation"},
 	{'m', "multithread", false,
 	 "use multi-thread for 'cluster snapshot save'"},
+	{'s', "vid_space", true, "specify the VID space size"},
 	{'t', "strict", false,
 	 "do not serve write request if number of nodes is not sufficient"},
 	{'z', "block_size_shift", true, "specify the shift num of default"
@@ -96,6 +97,10 @@ static int cluster_format(int argc, char **argv)
 	uint32_t old_nr_vdis;
 	unsigned long *vdi_inuse = NULL;
 	size_t bmp_size;
+	if (!cluster_cmd_data.vid_space)
+		new_space = SD_VID_SPACE;
+	else
+		new_space = (uint8_t)cluster_cmd_data.vid_space;
 
 	rb_for_each_entry(n, &sd_nroot, rb) {
 		struct sd_req info_req;
@@ -177,6 +182,7 @@ static int cluster_format(int argc, char **argv)
 	hdr.cluster.copies = cluster_cmd_data.copies;
 	hdr.cluster.copy_policy = cluster_cmd_data.copy_policy;
 	hdr.cluster.block_size_shift = cluster_cmd_data.block_size_shift;
+	hdr.cluster.vid_space = new_space;
 	hdr.cluster.ctime = (uint64_t) tv.tv_sec << 32 | tv.tv_usec * 1000;
 
 	if (strlen(cluster_cmd_data.name))
@@ -281,6 +287,12 @@ retry:
 		printf("%s\n", sd_strerror(rsp->result));
 
 	if (verbose) {
+		/* show cluster vid space size */
+		if (logs->vid_space) {
+			if (!raw_output)
+				printf("Cluster VID space size: ");
+			printf("%d\n", logs->vid_space);
+		}
 		/* show cluster backend store */
 		if (!raw_output)
 			printf("Cluster store: ");
@@ -841,7 +853,7 @@ failure:
 static struct subcommand cluster_cmd[] = {
 	{"info", NULL, "aprhvT", "show cluster information",
 	 NULL, CMD_NEED_NODELIST, cluster_info, cluster_options},
-	{"format", NULL, "bctaphzTV", "create a Sheepdog store",
+	{"format", NULL, "bctaphzsTV", "create a Sheepdog store",
 	 NULL, CMD_NEED_NODELIST, cluster_format, cluster_options},
 	{"shutdown", NULL, "aphT", "stop Sheepdog",
 	 NULL, 0, cluster_shutdown, cluster_options},
@@ -865,6 +877,7 @@ static struct subcommand cluster_cmd[] = {
 static int cluster_parser(int ch, const char *opt)
 {
 	uint32_t block_size_shift;
+	uint32_t vid_space;
 	switch (ch) {
 	case 'b':
 		pstrcpy(cluster_cmd_data.name, sizeof(cluster_cmd_data.name),
@@ -889,6 +902,19 @@ static int cluster_parser(int ch, const char *opt)
 		break;
 	case 'm':
 		cluster_cmd_data.multithread = true;
+	case 's':
+		vid_space = (uint32_t)atoi(opt);
+		if (vid_space > 26) {
+			sd_err("VID space size is limited to 26 bits."
+			" Please set VID space size lower than 26");
+			exit(EXIT_FAILURE);
+		} else if (vid_space < 24) {
+			sd_err("VID space size is larger than 24 bits."
+			" Please set VID space size larger than 24");
+			exit(EXIT_FAILURE);
+		}
+		cluster_cmd_data.vid_space = vid_space;
+		break;
 	case 't':
 		cluster_cmd_data.strict = true;
 		break;
-- 
1.7.1




More information about the sheepdog mailing list