diff options
author | M. Mohan Kumar <mohan@in.ibm.com> | 2012-11-29 21:46:07 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2012-11-29 09:39:25 -0800 |
commit | ca796eba11a3f965bfbaa9bbffb5ef00c9bbb7ad (patch) | |
tree | 26dfc9d8d2c5f0aa2cd2cfe5d590f4930bd4a7ba /cli/src/cli-cmd-parser.c | |
parent | b7840704c2095ad64f56da8d37fbae26db3a81ac (diff) |
BD Backend: Volume creation support
A new parameter type is added to volume create command. To use BD xlator
one has to specify following argument in addition to normal volume
create
device vg brick:<VG-NAME>
for example,
$ gluster volume create lv_volume device vg host:/vg1
Changes from previous version
* New type 'backend' added to volinfo structure to differentiate between
posix and bd xlator
* Most of the volume related commands are updated to handle BD xlator,
like add-brick, heal-brick etc refuse to work when volume is BD xlator
type
* Only one VG (ie brick) can be specified for BD xlator during volume
creation
* volume info shows VG info if its of type BD xlator
BUG: 805138
Change-Id: I0ff90aca04840c71f364fabb0ab43ce33f9278ce
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Reviewed-on: http://review.gluster.org/3717
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 4181e6c8162..f7ee29a10c7 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -159,13 +159,21 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options int32_t index = 0; char *bricks = NULL; int32_t brick_count = 0; - char *opwords[] = { "replica", "stripe", "transport", NULL }; + char *opwords[] = { "replica", "stripe", "transport", +#ifdef HAVE_BD_XLATOR + "device", +#endif + NULL }; + char *invalid_volnames[] = {"volume", "type", "subvolumes", "option", "end-volume", "all", NULL}; char *w = NULL; int op_count = 0; int32_t replica_count = 1; int32_t stripe_count = 1; +#ifdef HAVE_BD_XLATOR + char *dev_type = NULL; +#endif GF_ASSERT (words); GF_ASSERT (options); @@ -300,7 +308,26 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options goto out; } index += 2; - } else { + } +#ifdef HAVE_BD_XLATOR + else if ((strcmp (w, "device")) == 0) { + if (dev_type) { + cli_err ("'device' option given more" + " than one time"); + goto out; + } + if ((strcasecmp (words[index+1], "vg") == 0)) { + dev_type = gf_strdup ("vg"); + } else { + gf_log ("", GF_LOG_ERROR, "incorrect" + " device type specified"); + ret = -1; + goto out; + } + index += 2; + } +#endif + else { GF_ASSERT (!"opword mismatch"); ret = -1; goto out; @@ -336,6 +363,19 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options goto out; } + /* BD xlator does not support multiple bricks */ +#ifdef HAVE_BD_XLATOR + if (brick_count > 1 && dev_type) { + cli_err ("Block Device backend volume does not support multiple" + " bricks"); + gf_log ("", GF_LOG_ERROR, + "Block Device backend volumer does not support multiple" + " bricks"); + ret = -1; + goto out; + } +#endif + if (brick_count % sub_count) { if (type == GF_CLUSTER_TYPE_STRIPE) cli_err ("number of bricks is not a multiple of " @@ -369,6 +409,14 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options if (ret) goto out; +#ifdef HAVE_BD_XLATOR + if (dev_type) { + ret = dict_set_dynstr (dict, "device", dev_type); + if (ret) + goto out; + } +#endif + ret = dict_set_int32 (dict, "count", brick_count); if (ret) goto out; |