Patchwork [BUG:1888] mgmt/glusterd: Add the new volume only after all ops succeed

login
register
Submitter Pranith K
Date 2011-03-27 14:21:29
Message ID <20110327142129.GA18761@dev.gluster.com>
Download mbox | patch
Permalink /patch/6601/
State Accepted
Headers show

Comments

Pranith K - 2011-03-27 14:21:29
- Print errors to the user when any of the op fails in create volume
- Add the volume to the list only after all the ops succeed

Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
---
 xlators/mgmt/glusterd/src/glusterd-op-sm.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

Patch

diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index ca8f554..462671a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2234,22 +2234,27 @@  glusterd_op_create_volume (dict_t *dict, char **op_errstr)
                 brick = strtok_r (NULL, " \n", &saveptr);
                 i++;
         }
-        list_add_tail (&volinfo->vol_list, &priv->volumes);
-        volinfo->defrag_status = 0;
 
         ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT);
-
-        if (ret)
+        if (ret) {
+                *op_errstr = gf_strdup ("Failed to store the Volume information");
                 goto out;
+        }
 
         ret = glusterd_create_volfiles_and_notify_services (volinfo);
-        if (ret)
+        if (ret) {
+                *op_errstr = gf_strdup ("Failed to create volume files");
                 goto out;
+        }
 
         ret = glusterd_volume_compute_cksum (volinfo);
-        if (ret)
+        if (ret) {
+                *op_errstr = gf_strdup ("Failed to compute checksum of volume");
                 goto out;
+        }
 
+        volinfo->defrag_status = 0;
+        list_add_tail (&volinfo->vol_list, &priv->volumes);
 out:
         if (free_ptr)
                 GF_FREE(free_ptr);