diff options
author | Vijay Bellur <vijay@gluster.com> | 2010-08-16 11:47:04 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-08-17 02:23:46 -0700 |
commit | 9eccb80f42328cff1e652b12e01a3b02898f5edf (patch) | |
tree | 2ff06dece9fdc947df5453c02c6e7d5302ef5e9b /xlators/mgmt/glusterd | |
parent | 3af126d594c8e0710ba6a3fb4024224eb7f8e4b4 (diff) |
glusterd: Fixes for add brick
Signed-off-by: Vijay Bellur <vijay@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1374 ()
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1374
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 21 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 54 |
2 files changed, 63 insertions, 12 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 0843bc25aa1..eb609e5ccb6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -892,9 +892,25 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req) goto out; list_add_tail (&brickinfo->brick_list, &volinfo->bricks); + brick = strtok_r (NULL, "\n", &saveptr); + i++; + } + + brick_list = gf_strdup (bricks); + i = 1; + + if (count) + brick = strtok_r (brick_list+1, " \n", &saveptr); + + while (i <= count) { + + ret = glusterd_brickinfo_get (brick, volinfo, &brickinfo); + if (ret) + goto out; + ret = glusterd_resolve_brick (brickinfo); - if ((!uuid_compare (brickinfo->uuid, priv->uuid)) && + if (!ret && (!uuid_compare (brickinfo->uuid, priv->uuid)) && (GLUSTERD_STATUS_STARTED == volinfo->status)) { ret = glusterd_volume_create_generate_volfiles (volinfo); @@ -914,9 +930,8 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req) glfs_started = _gf_true; mybrick++; } - - brick = strtok_r (NULL, " \n", &saveptr); i++; + brick = strtok_r (NULL, "\n", &saveptr); } if (!glfs_started) { diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 16d3f59099d..cb1aa160aa9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -994,23 +994,58 @@ int32_t glusterd_store_update_volume (glusterd_volinfo_t *volinfo) { int32_t ret = -1; + char buf[1024] = {0,}; + glusterd_brickinfo_t *brickinfo = NULL; + glusterd_brickinfo_t *tmp = NULL; - ret = glusterd_store_delete_volume (volinfo); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to delete " - "volume: %s", volinfo->volname); - goto out; + list_for_each_entry (tmp, &volinfo->bricks, brick_list) { + ret = glusterd_store_delete_brick (volinfo, tmp); + //if (ret) + // goto out; } - ret = glusterd_store_create_volume (volinfo); + ret = glusterd_store_handle_truncate (volinfo->shandle); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to create " - "volume: %s", volinfo->volname); + snprintf (buf, sizeof (buf), "%d", volinfo->type); + ret = glusterd_store_save_value (volinfo->shandle, + GLUSTERD_STORE_KEY_VOL_TYPE, buf); + if (ret) goto out; + + snprintf (buf, sizeof (buf), "%d", volinfo->brick_count); + ret = glusterd_store_save_value (volinfo->shandle, + GLUSTERD_STORE_KEY_VOL_COUNT, buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%d", volinfo->status); + ret = glusterd_store_save_value (volinfo->shandle, + GLUSTERD_STORE_KEY_VOL_STATUS, buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%d", volinfo->port); + ret = glusterd_store_save_value (volinfo->shandle, + GLUSTERD_STORE_KEY_VOL_PORT, buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%d", volinfo->sub_count); + ret = glusterd_store_save_value (volinfo->shandle, + GLUSTERD_STORE_KEY_VOL_SUB_COUNT, buf); + if (ret) + goto out; + + list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + ret = glusterd_store_create_brick (volinfo, brickinfo); + if (ret) + goto out; } + ret = 0; + + out: gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); @@ -1131,6 +1166,7 @@ glusterd_store_update_peerinfo (glusterd_peerinfo_t *peerinfo) ret = glusterd_store_handle_new (filepath, &peerinfo->shandle); if (ret) goto out; + ret = glusterd_store_handle_truncate (peerinfo->shandle); } else { ret = glusterd_store_handle_truncate (peerinfo->shandle); if (ret) |