diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 6cba5b467..d223fabb3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1155,7 +1155,6 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo) glusterd_conf_t *priv = NULL; GF_ASSERT (volname); - this = THIS; GF_ASSERT (this); @@ -1164,7 +1163,38 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo) list_for_each_entry (tmp_volinfo, &priv->volumes, vol_list) { if (!strcmp (tmp_volinfo->volname, volname)) { - gf_log (this->name, GF_LOG_DEBUG, "Volume %s found", volname); + gf_log (this->name, GF_LOG_DEBUG, "Volume %s found", + volname); + ret = 0; + *volinfo = tmp_volinfo; + break; + } + } + + gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} + +int32_t +glusterd_snap_volinfo_find (char *volname, glusterd_volinfo_t **volinfo) +{ + glusterd_volinfo_t *tmp_volinfo = NULL; + int32_t ret = -1; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + + GF_ASSERT (volname); + gf_log ("", GF_LOG_DEBUG, "Snap Volname = %s", volname); + this = THIS; + GF_ASSERT (this); + + priv = this->private; + GF_ASSERT (priv); + + list_for_each_entry (tmp_volinfo, &priv->snap_list, vol_list) { + if (!strcmp (tmp_volinfo->volname, volname)) { + gf_log (this->name, GF_LOG_DEBUG, "Snap Volume %s found", + volname); ret = 0; *volinfo = tmp_volinfo; break; @@ -1542,7 +1572,7 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo, glusterd_set_socket_filepath (sock_filepath, socketpath, sizeof (socketpath)); - GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo, + GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo->volname, snap_volinfo->volname, brickinfo, priv); if (glusterd_is_service_running (pidfile, NULL)) @@ -1760,10 +1790,10 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo, gf_boolean_t del_brick) { - xlator_t *this = NULL; - glusterd_conf_t *priv = NULL; - char pidfile[PATH_MAX] = {0,}; - int ret = 0; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + char pidfile[PATH_MAX] = {0,}; + int ret = 0; GF_ASSERT (volinfo); GF_ASSERT (brickinfo); @@ -1816,7 +1846,7 @@ glusterd_snap_volume_stop_glusterfs (glusterd_volinfo_t *volinfo, if (GLUSTERD_STATUS_STARTED == volinfo->status) { (void) glusterd_brick_disconnect (brickinfo); - GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo, + GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo->volname, snap_volinfo->volname, brickinfo, priv); ret = glusterd_service_stop ("brick", pidfile, SIGTERM, _gf_false); @@ -2159,6 +2189,15 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; + snprintf (key, sizeof (key), "volume%d.is_volume_restored", count); + ret = dict_set_int32 (dict, key, volinfo->is_volume_restored); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "Failed to set " + "is_volume_restored option for %s volume", + volinfo->volname); + goto out; + } + memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick_count", count); ret = dict_set_int32 (dict, key, volinfo->brick_count); @@ -5191,7 +5230,6 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, char key[1024] = {0}; char base_key[1024] = {0}; char pidfile[PATH_MAX] = {0}; - char exp_path[PATH_MAX] = {0}; xlator_t *this = NULL; glusterd_conf_t *priv = NULL; @@ -5226,11 +5264,10 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, if (volinfo->is_snap_volume == _gf_true) { /* Fetching the snap pidfile using parent volname */ - GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, exp_path); - snprintf (pidfile, sizeof(pidfile) - 1, - "%s/vols/%s/snaps/%s/run/%s-%s.pid", priv->workdir, - volinfo->parent_volname, volinfo->volname, - brickinfo->hostname, exp_path); + GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, + volinfo->parent_volname, + volinfo->volname, + brickinfo, priv); } else GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv); |