[sheepdog] [PATCH stable-0.7] dog: forbid invalid copy policy option of cluster and vdi

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Mon Jan 6 05:33:23 CET 2014


"dog vdi create" and "dog cluster format" of stable-0.7 don't treat a
command line option for copy policy like "3:1" as an invalid
thing. This would be confusing for users who want to use the feature
of erasure coding. This patch lets dog command cause error when such
an option is passed.

Below is an example of error messages:

$ dog cluster format -c 3:1
copy number 3:1 is invalid
If you want to use the erasure coding feature, please use sheepdog 0.8 or later
$ dog vdi create test 1G -c 3:X
copy number 3:X is invalid
If you want to use the erasure coding feature, please use sheepdog 0.8 or later

Cc: Marcin Miroslaw <marcin at mejor.pl>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 dog/cluster.c |    7 ++++++-
 dog/vdi.c     |    7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dog/cluster.c b/dog/cluster.c
index e3ac33a..2430765 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -503,7 +503,12 @@ static int cluster_parser(int ch, char *opt)
 		break;
 	case 'c':
 		copies = strtol(opt, &p, 10);
-		if (opt == p || copies < 1) {
+		if (*p != '\0') {
+			sd_err("copy number %s is invalid", opt);
+			sd_err("If you want to use the erasure coding feature,"
+			       " please use sheepdog 0.8 or later");
+			exit(EXIT_FAILURE);
+		} else if (opt == p || copies < 1) {
 			sd_err("There must be at least one copy of data");
 			exit(EXIT_FAILURE);
 		} else if (copies > SD_MAX_COPIES) {
diff --git a/dog/vdi.c b/dog/vdi.c
index f4fbc67..85def26 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -2235,7 +2235,12 @@ static int vdi_parser(int ch, char *opt)
 		break;
 	case 'c':
 		nr_copies = strtol(opt, &p, 10);
-		if (opt == p || nr_copies < 0 || nr_copies > SD_MAX_COPIES) {
+		if (*p != '\0') {
+			sd_err("copy number %s is invalid", opt);
+			sd_err("If you want to use the erasure coding feature,"
+			       " please use sheepdog 0.8 or later");
+			exit(EXIT_FAILURE);
+		} if (opt == p || nr_copies < 0 || nr_copies > SD_MAX_COPIES) {
 			sd_err("Invalid copies number, must be "
 			       "an integer between 0 and %d", SD_MAX_COPIES);
 			exit(EXIT_FAILURE);
-- 
1.7.10.4




More information about the sheepdog mailing list