diff options
author | Amar Tumballi <amar@gluster.com> | 2010-09-06 11:45:31 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-06 11:13:41 -0700 |
commit | e3a44226b3ed746260c4f3cf30d2f9f930fb7349 (patch) | |
tree | f937a9667249bd25ea1c7215e8d79d85b4031fbc /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | d38b2217393c460937505f30bd61576e7957f877 (diff) |
mgmt/glusterd: volume to have 'uuid'
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1548 (nfs should be able to get different uuid for different subvolumes)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1548
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 6e7fbd3b2c0..b18693eb25f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -319,6 +319,12 @@ glusterd_store_create_volume (glusterd_volinfo_t *volinfo) if (ret) goto out; + uuid_unparse (volinfo->volume_id, buf); + ret = glusterd_store_save_value (volinfo->shandle, + GLUSTERD_STORE_KEY_VOL_ID, buf); + if (ret) + goto out; + list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { ret = glusterd_store_create_brick (volinfo, brickinfo); if (ret) @@ -498,17 +504,8 @@ glusterd_store_save_value (glusterd_store_handle_t *handle, goto out; } - handle->write = fdopen (handle->fd, "a+"); - - if (!handle->write) { - gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %d", - handle->path, errno); - goto out; - } - snprintf (buf, sizeof (buf), "%s=%s\n", key, value); ret = write (handle->fd, buf, strlen (buf)); - //ret = fprintf (handle->write, "%s=%s\n", key, value); if (ret < 0) { gf_log ("", GF_LOG_CRITICAL, "Unable to store key: %s," @@ -524,7 +521,6 @@ out: if (handle->fd > 0) { close (handle->fd); - handle->write = NULL; handle->fd = -1; } @@ -955,6 +951,12 @@ glusterd_store_retrieve_volume (char *volname) } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TRANSPORT, strlen (GLUSTERD_STORE_KEY_VOL_TRANSPORT))) { volinfo->transport_type = atoi (value); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_ID, + strlen (GLUSTERD_STORE_KEY_VOL_ID))) { + ret = uuid_parse (value, volinfo->volume_id); + if (ret) + gf_log ("", GF_LOG_WARNING, + "failed to parse uuid"); } else { gf_log ("", GF_LOG_ERROR, "Unknown key: %s", key); @@ -1082,6 +1084,12 @@ glusterd_store_update_volume (glusterd_volinfo_t *volinfo) if (ret) goto out; + uuid_unparse (volinfo->volume_id, buf); + ret = glusterd_store_save_value (volinfo->shandle, + GLUSTERD_STORE_KEY_VOL_ID, buf); + if (ret) + goto out; + list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { ret = glusterd_store_create_brick (volinfo, brickinfo); if (ret) |