diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2012-11-19 17:21:49 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-02-06 23:39:52 -0800 |
commit | 7a9e27073789bdc0164cc6428aee5088a8faa2fb (patch) | |
tree | 765cfcbc78081fbc618b4d83139587e106a89ea8 | |
parent | 0b7cdbf50dea9ee77bc8f71526a1566945672c19 (diff) |
glusterd: synctaskize 'volume create' operation
.. and also move brickpath validation to volume create stage
Change-Id: Ia028677932ca5f6aa05dcf624f47033b62e7b212
BUG: 862834
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/4213
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
-rwxr-xr-x | tests/bugs/bug-862834.t | 46 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 48 |
2 files changed, 52 insertions, 42 deletions
diff --git a/tests/bugs/bug-862834.t b/tests/bugs/bug-862834.t new file mode 100755 index 00000000000..33aaea1a8b1 --- /dev/null +++ b/tests/bugs/bug-862834.t @@ -0,0 +1,46 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +V1="patchy2" +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; + +function check_brick() +{ + vol=$1; + num=$2 + $CLI volume info $V0 | grep "Brick$num" | awk '{print $2}'; +} + +function volinfo_field() +{ + local vol=$1; + local field=$2; + + $CLI volume info $vol | grep "^$field: " | sed 's/.*: //'; +} + +function brick_count() +{ + local vol=$1; + + $CLI volume info $vol | egrep "^Brick[0-9]+: " | wc -l; +} + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '2' brick_count $V0 + + +EXPECT "$H0:$B0/${V0}1" check_brick $V0 '1'; +EXPECT "$H0:$B0/${V0}2" check_brick $V0 '2'; + +TEST ! $CLI volume create $V1 $H0:$B0/${V1}0 $H0:$B0/${V0}1; + +cleanup; diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index 3734bf7f82a..60f671efd92 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -36,14 +36,9 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) int32_t ret = -1; gf_cli_req cli_req = {{0,}}; dict_t *dict = NULL; - glusterd_brickinfo_t *brickinfo = NULL; - char *brick = NULL; char *bricks = NULL; char *volname = NULL; int brick_count = 0; - char *tmpptr = NULL; - int i = 0; - char *brick_list = NULL; void *cli_rsp = NULL; char err_str[2048] = {0,}; gf_cli_rsp rsp = {0,}; @@ -52,15 +47,12 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) char *trans_type = NULL; uuid_t volume_id = {0,}; uuid_t tmp_uuid = {0}; - glusterd_volinfo_t tmpvolinfo = {{0},}; int32_t type = 0; char *username = NULL; char *password = NULL; GF_ASSERT (req); - INIT_LIST_HEAD (&tmpvolinfo.bricks); - this = THIS; GF_ASSERT(this); @@ -153,31 +145,6 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) } free_ptr = NULL; - if (bricks) { - brick_list = gf_strdup (bricks); - free_ptr = brick_list; - } - - while ( i < brick_count) { - i++; - brick= strtok_r (brick_list, " \n", &tmpptr); - brick_list = tmpptr; - ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo); - if (ret) { - snprintf (err_str, sizeof (err_str), "Failed to create " - "brickinfo for brick %s", brick); - goto out; - } - - ret = glusterd_new_brick_validate (brick, brickinfo, err_str, - sizeof (err_str)); - if (ret) - goto out; - - list_add_tail (&brickinfo->brick_list, &tmpvolinfo.bricks); - brickinfo = NULL; - } - /* generate internal username and password */ uuid_generate (tmp_uuid); @@ -198,8 +165,7 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) goto out; } - ret = glusterd_op_begin (req, GD_OP_CREATE_VOLUME, dict, err_str, - sizeof (err_str)); + ret = glusterd_op_begin_synctask (req, GD_OP_CREATE_VOLUME, dict); out: if (ret) { @@ -217,13 +183,6 @@ out: GF_FREE(free_ptr); - glusterd_volume_brickinfos_delete (&tmpvolinfo); - if (brickinfo) - glusterd_brickinfo_delete (brickinfo); - - glusterd_friend_sm (); - glusterd_op_sm (); - return ret; } @@ -746,6 +705,11 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr) if (ret) goto out; + ret = glusterd_new_brick_validate (brick, brick_info, msg, + sizeof (msg)); + if (ret) + goto out; + ret = glusterd_resolve_brick (brick_info); if (ret) { gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK, |