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 /xlators/mgmt/glusterd/src/glusterd-volume-ops.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 'xlators/mgmt/glusterd/src/glusterd-volume-ops.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index d42694353af..8c76c8f09e1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -12,6 +12,10 @@ #include "config.h" #endif +#ifdef HAVE_BD_XLATOR +#include <lvm2app.h> +#endif + #include "common-utils.h" #include "syscall.h" #include "cli1-xdr.h" @@ -554,6 +558,36 @@ out: return ret; } +#ifdef HAVE_BD_XLATOR +int +glusterd_is_valid_vg (const char *name) +{ + lvm_t handle = NULL; + vg_t vg = NULL; + char *vg_name = NULL; + int retval = -1; + + handle = lvm_init (NULL); + if (!handle) { + gf_log ("", GF_LOG_ERROR, "lvm_init failed"); + return -1; + } + vg_name = gf_strdup (name); + vg = lvm_vg_open (handle, basename (vg_name), "r", 0); + if (!vg) { + gf_log ("", GF_LOG_ERROR, "no such vg: %s", vg_name); + goto out; + } + retval = 0; +out: + if (vg) + lvm_vg_close (vg); + lvm_quit (handle); + GF_FREE (vg_name); + return retval; +} +#endif + /* op-sm */ int glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr) @@ -575,7 +609,9 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr) char msg[2048] = {0}; uuid_t volume_uuid; char *volume_uuid_str; - +#ifdef HAVE_BD_XLATOR + char *dev_type = NULL; +#endif this = THIS; if (!this) { gf_log ("glusterd", GF_LOG_ERROR, @@ -625,6 +661,11 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr) goto out; } + +#ifdef HAVE_BD_XLATOR + ret = dict_get_str (dict, "device", &dev_type); +#endif + ret = dict_get_str (dict, "bricks", &bricks); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to get bricks"); @@ -670,6 +711,19 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr) goto out; } +#ifdef HAVE_BD_XLATOR + if (dev_type) { + ret = glusterd_is_valid_vg (brick_info->path); + if (ret) { + snprintf (msg, sizeof(msg), "invalid vg %s", + brick_info->path); + *op_errstr = gf_strdup (msg); + goto out; + } + + break; + } else +#endif if (!uuid_compare (brick_info->uuid, MY_UUID)) { ret = glusterd_brick_create_path (brick_info->hostname, brick_info->path, @@ -1209,6 +1263,9 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) char *str = NULL; char *username = NULL; char *password = NULL; +#ifdef HAVE_BD_XLATOR + char *device = NULL; +#endif this = THIS; GF_ASSERT (this); @@ -1261,6 +1318,12 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr) goto out; } +#ifdef HAVE_BD_XLATOR + ret = dict_get_str (dict, "device", &device); + if (!ret) + volinfo->backend = GD_VOL_BK_BD; +#endif + /* replica-count 1 means, no replication, file is in one brick only */ volinfo->replica_count = 1; /* stripe-count 1 means, no striping, file is present as a whole */ |