summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijaikumar M <vmallika@redhat.com>2014-03-25 15:58:18 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-25 22:45:50 -0700
commit58dfda2a4e0ffad3a543fb47242c5cfdf0ea6bed (patch)
tree43257565469ff76d0f15277f3268a865006bb300
parentc36c95a79c2f73f35727c6f8cba0586714663fd9 (diff)
glusterd/snapshot : remove snap_volume variable from struct glusterd_snap_
Change-Id: I3c5eae3f199d97a2fe70599e2cdb4c357d20f20d Signed-off-by: Vijaikumar M <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/7197 Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Rajesh Joseph <rjoseph@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c85
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c78
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h2
4 files changed, 91 insertions, 96 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 7068a04..90f0c6c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -794,11 +794,6 @@ glusterd_list_add_snapvol (glusterd_volinfo_t *origin_vol,
GF_ASSERT (snap);
list_add_tail (&snap_vol->vol_list, &snap->volumes);
- /* TODO: As of now there is only one volume per snapshot.
- Below line should be removed once multiple volumes for
- snap driven structucture is implemented */
- snap->snap_volume = snap_vol;
-
LOCK (&origin_vol->lock);
{
list_add_order (&snap_vol->snapvol_list,
@@ -2794,7 +2789,6 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
snap_vol->is_snap_volume = _gf_true;
strcpy (snap_vol->parent_volname, origin_vol->volname);
snap_vol->snapshot = snap;
- snap->snap_volume = snap_vol;
glusterd_auth_set_username (snap_vol, username);
glusterd_auth_set_password (snap_vol, password);
@@ -3959,14 +3953,17 @@ out :
int
glusterd_get_single_snap_status (char **op_errstr, dict_t *rsp_dict,
- char *keyprefix,
- glusterd_volinfo_t *snap_volinfo)
+ char *keyprefix, glusterd_snap_t *snap)
{
- int ret = -1;
- xlator_t *this = NULL;
- char key[PATH_MAX] = "";
- glusterd_brickinfo_t *brickinfo = NULL;
- int i = 0;
+ int ret = -1;
+ xlator_t *this = NULL;
+ char key[PATH_MAX] = "";
+ char brickkey[PATH_MAX] = "";
+ glusterd_volinfo_t *snap_volinfo = NULL;
+ glusterd_volinfo_t *tmp_volinfo = NULL;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ int volcount = 0;
+ int brickcount = 0;
this = THIS;
GF_ASSERT (this);
@@ -3974,37 +3971,61 @@ glusterd_get_single_snap_status (char **op_errstr, dict_t *rsp_dict,
GF_ASSERT (op_errstr);
GF_ASSERT (rsp_dict);
GF_ASSERT (keyprefix);
- GF_ASSERT (snap_volinfo);
+ GF_ASSERT (snap);
- list_for_each_entry (brickinfo, &snap_volinfo->bricks, brick_list) {
- if (!glusterd_is_local_brick (this, snap_volinfo, brickinfo)) {
- i++;
- continue;
+ list_for_each_entry_safe (snap_volinfo, tmp_volinfo, &snap->volumes,
+ vol_list) {
+ ret = snprintf (key, sizeof (key), "%s.vol%d", keyprefix,
+ volcount);
+ if (ret < 0) {
+ goto out;
}
+ list_for_each_entry (brickinfo, &snap_volinfo->bricks,
+ brick_list) {
+ if (!glusterd_is_local_brick (this, snap_volinfo,
+ brickinfo)) {
+ brickcount++;
+ continue;
+ }
- ret = glusterd_get_single_brick_status (op_errstr, rsp_dict,
- keyprefix, i,
- snap_volinfo,
- brickinfo);
+ ret = glusterd_get_single_brick_status (op_errstr,
+ rsp_dict, key, brickcount,
+ snap_volinfo, brickinfo);
+
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Getting "
+ "single snap status failed");
+ goto out;
+ }
+ brickcount++;
+ }
+ ret = snprintf (brickkey, sizeof (brickkey), "%s.brickcount",
+ key);
+ if (ret < 0) {
+ goto out;
+ }
+ ret = dict_set_int32 (rsp_dict, brickkey, brickcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Getting single "
- "snap status failed");
+ gf_log (this->name, GF_LOG_ERROR,
+ "Could not save brick count");
goto out;
}
- i++;
+ volcount++;
}
- ret = snprintf (key, sizeof (key), "%s.brickcount", keyprefix);
+
+ ret = snprintf (key, sizeof (key), "%s.volcount", keyprefix);
if (ret < 0) {
goto out;
}
- ret = dict_set_int32 (rsp_dict, key, i);
+ ret = dict_set_int32 (rsp_dict, key, volcount);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
- "Could not save brick count");
+ "Could not save volcount");
goto out;
}
+
out :
return ret;
@@ -4068,12 +4089,8 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
temp = NULL;
- ret = snprintf (key, sizeof (key), "%s.vol0", keyprefix);
- if (ret < 0) {
- goto out;
- }
- ret = glusterd_get_single_snap_status (op_errstr, rsp_dict, key,
- snap->snap_volume);
+ ret = glusterd_get_single_snap_status (op_errstr, rsp_dict, keyprefix,
+ snap);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Could not get single snap status");
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 8dee4d4..944652b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1974,10 +1974,9 @@ out:
int32_t
-glusterd_store_retrieve_rbstate (char *volname, glusterd_snap_t *snap)
+glusterd_store_retrieve_rbstate (glusterd_volinfo_t *volinfo)
{
int32_t ret = -1;
- glusterd_volinfo_t *volinfo = NULL;
gf_store_iter_t *iter = NULL;
char *key = NULL;
char *value = NULL;
@@ -1985,19 +1984,13 @@ glusterd_store_retrieve_rbstate (char *volname, glusterd_snap_t *snap)
glusterd_conf_t *priv = NULL;
char path[PATH_MAX] = {0,};
gf_store_op_errno_t op_errno = GD_STORE_SUCCESS;
+ xlator_t *this = NULL;
- priv = THIS->private;
-
- if (snap) {
- volinfo = snap->snap_volume;
- } else {
- ret = glusterd_volinfo_find (volname, &volinfo);
- if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't get"
- "volinfo for %s.", volname);
- goto out;
- }
- }
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+ GF_ASSERT (volinfo);
GLUSTERD_GET_VOLUME_DIR(volpath, volinfo, priv);
snprintf (path, sizeof (path), "%s/%s", volpath,
@@ -2074,16 +2067,15 @@ glusterd_store_retrieve_rbstate (char *volname, glusterd_snap_t *snap)
goto out;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
return ret;
}
int32_t
-glusterd_store_retrieve_node_state (char *volname, glusterd_snap_t *snap)
+glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo)
{
int32_t ret = -1;
- glusterd_volinfo_t *volinfo = NULL;
gf_store_iter_t *iter = NULL;
char *key = NULL;
char *value = NULL;
@@ -2091,19 +2083,13 @@ glusterd_store_retrieve_node_state (char *volname, glusterd_snap_t *snap)
glusterd_conf_t *priv = NULL;
char path[PATH_MAX] = {0,};
gf_store_op_errno_t op_errno = GD_STORE_SUCCESS;
+ xlator_t *this = NULL;
- priv = THIS->private;
-
- if (snap) {
- volinfo = snap->snap_volume;
- } else {
- ret = glusterd_volinfo_find (volname, &volinfo);
- if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't get"
- "volinfo for %s.", volname);
- goto out;
- }
- }
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+ GF_ASSERT (volinfo);
GLUSTERD_GET_VOLUME_DIR(volpath, volinfo, priv);
snprintf (path, sizeof (path), "%s/%s", volpath,
@@ -2155,7 +2141,7 @@ glusterd_store_retrieve_node_state (char *volname, glusterd_snap_t *snap)
goto out;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
return ret;
}
@@ -2383,7 +2369,7 @@ out:
return ret;
}
-int32_t
+glusterd_volinfo_t*
glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
{
int32_t ret = -1;
@@ -2437,11 +2423,15 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
glusterd_list_add_snapvol (origin_volinfo, volinfo);
}
out:
- /*TODO: cleanup volinfo pointer on failure */
+ if (ret) {
+ if (volinfo)
+ glusterd_volinfo_delete (volinfo);
+ volinfo = NULL;
+ }
- gf_log ("", GF_LOG_TRACE, "Returning with %d", ret);
+ gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
- return ret;
+ return volinfo;
}
inline void
@@ -2575,38 +2565,28 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap)
if ( entry->d_type != DT_DIR )
goto next;
- ret = glusterd_store_retrieve_volume (entry->d_name, snap);
- if (ret) {
+ volinfo = glusterd_store_retrieve_volume (entry->d_name, snap);
+ if (!volinfo) {
gf_log ("", GF_LOG_ERROR, "Unable to restore "
"volume: %s", entry->d_name);
+ ret = -1;
goto out;
}
- ret = glusterd_store_retrieve_rbstate (entry->d_name, snap);
+ ret = glusterd_store_retrieve_rbstate (volinfo);
if (ret) {
/* Backward compatibility */
gf_log ("", GF_LOG_INFO, "Creating a new rbstate "
"for volume: %s.", entry->d_name);
- if (snap) {
- volinfo = snap->snap_volume;
- } else {
- ret = glusterd_volinfo_find (entry->d_name,
- &volinfo);
- }
ret = glusterd_store_create_rbstate_shandle_on_absence (volinfo);
ret = glusterd_store_perform_rbstate_store (volinfo);
}
- ret = glusterd_store_retrieve_node_state (entry->d_name, snap);
+ ret = glusterd_store_retrieve_node_state (volinfo);
if (ret) {
/* Backward compatibility */
gf_log ("", GF_LOG_INFO, "Creating a new node_state "
"for volume: %s.", entry->d_name);
- if (snap) {
- volinfo = snap->snap_volume;
- } else {
- ret = glusterd_volinfo_find (entry->d_name, &volinfo);
- }
glusterd_store_create_nodestate_sh_on_absence (volinfo);
ret = glusterd_store_perform_node_state_store (volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 7f1f494..00c551e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -4476,8 +4476,6 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
list_for_each_entry (volinfo, &conf->volumes, vol_list) {
if (volinfo->status != GLUSTERD_STATUS_STARTED)
continue;
- if (volinfo->is_snap_volume)
- continue;
start_nodesvcs = _gf_true;
gf_log (this->name, GF_LOG_DEBUG, "starting the volume %s",
volinfo->volname);
@@ -4487,15 +4485,17 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
}
list_for_each_entry (snap, &conf->snapshots, snap_list) {
- volinfo = snap->snap_volume;
- if (!volinfo) {
- gf_log (this->name, GF_LOG_WARNING, "volinfo "
- "for the snap %s is NULL",
- snap->snapname);
- continue;
- }
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- glusterd_brick_start (volinfo, brickinfo, _gf_false);
+ list_for_each_entry (volinfo, &snap->volumes, vol_list) {
+ if (volinfo->status != GLUSTERD_STATUS_STARTED)
+ continue;
+ start_nodesvcs = _gf_true;
+ gf_log (this->name, GF_LOG_DEBUG, "starting the snap "
+ "volume %s", volinfo->volname);
+ list_for_each_entry (brickinfo, &volinfo->bricks,
+ brick_list) {
+ glusterd_brick_start (volinfo, brickinfo,
+ _gf_false);
+ }
}
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index cb4196a..9920b53 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -361,8 +361,6 @@ typedef enum gd_snap_status_ {
struct glusterd_snap_ {
gf_lock_t lock;
struct list_head volumes;
- glusterd_volinfo_t *snap_volume; /*TODO: This should be replaced
- with volumes list later */
struct list_head snap_list;
char snapname[GLUSTERD_MAX_SNAP_NAME];
uuid_t snap_id;