summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorVijaikumar M <vmallika@redhat.com>2014-02-14 20:01:38 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-03 22:58:23 -0800
commitfe5927b6bd1ed795c9e85996e7c54c3abe36ceba (patch)
treed69e25c323a4b57c49af8555db75ff65c9690701 /xlators/mgmt/glusterd/src/glusterd-utils.c
parent60d4f64cea4752f76b9495bdea255b51d09820ff (diff)
glusterd/snapshot: store location for snap driven changes
Currently snapshot volfiles are stored at: <workdir>/vols/<volname>/snaps/<snapvol> With snap driven approach we need to store the volfiles at: <workdir>/snaps/<snapname>/<snapvol> Change-Id: I8efdd5db29833b2b06b64a900cbb4c9b9a5d36b6 Signed-off-by: Vijaikumar M <vmallika@redhat.com> Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/7006 Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c614
1 files changed, 103 insertions, 511 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index e7cad0b4d..63adbb75f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -444,8 +444,9 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)
LOCK_INIT (&new_volinfo->lock);
INIT_LIST_HEAD (&new_volinfo->vol_list);
+ INIT_LIST_HEAD (&new_volinfo->snapvol_list);
INIT_LIST_HEAD (&new_volinfo->bricks);
- INIT_LIST_HEAD (&new_volinfo->snaps);
+ INIT_LIST_HEAD (&new_volinfo->snap_volumes);
new_volinfo->dict = dict_new ();
if (!new_volinfo->dict) {
@@ -1176,32 +1177,64 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo)
}
int32_t
-glusterd_snap_volinfo_find (char *volname, glusterd_volinfo_t **volinfo)
+glusterd_snap_volinfo_find (char *snap_volname, glusterd_snap_t *snap,
+ glusterd_volinfo_t **volinfo)
{
- glusterd_volinfo_t *tmp_volinfo = NULL;
- int32_t ret = -1;
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+ glusterd_volinfo_t *snap_vol = 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);
+ GF_ASSERT (snap);
+ GF_ASSERT (snap_volname);
+
+ list_for_each_entry (snap_vol, &snap->volumes, vol_list) {
+ if (!strcmp (snap_vol->volname, snap_volname)) {
+ ret = 0;
+ *volinfo = snap_vol;
+ goto out;
+ }
+ }
+ gf_log (this->name, GF_LOG_WARNING, "Snap volume %s not found",
+ snap_volname);
+out:
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ return ret;
+}
+
+int32_t
+glusterd_snap_volinfo_find_from_parent_volname (char *origin_volname,
+ glusterd_snap_t *snap,
+ glusterd_volinfo_t **volinfo)
+{
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+ glusterd_volinfo_t *snap_vol = NULL;
+ glusterd_conf_t *priv = NULL;
+
+ this = THIS;
priv = this->private;
GF_ASSERT (priv);
+ GF_ASSERT (snap);
+ GF_ASSERT (origin_volname);
- 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);
+ list_for_each_entry (snap_vol, &snap->volumes, vol_list) {
+ if (!strcmp (snap_vol->parent_volname, origin_volname)) {
ret = 0;
- *volinfo = tmp_volinfo;
- break;
+ *volinfo = snap_vol;
+ goto out;
}
}
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_log (this->name, GF_LOG_DEBUG, "Snap volume not found(snap: %s, "
+ "origin-volume: %s", snap->snapname, origin_volname);
+
+out:
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -1358,29 +1391,7 @@ _mk_rundir_p (glusterd_volinfo_t *volinfo)
return ret;
}
-static int
-_mk_snap_rundir_p (glusterd_volinfo_t *volinfo, glusterd_volinfo_t *snap_volinfo)
-{
- char voldir[PATH_MAX] = {0,};
- char rundir[PATH_MAX] = {0,};
- glusterd_conf_t *priv = NULL;
- xlator_t *this = NULL;
- int ret = -1;
-
- GF_ASSERT (volinfo);
- GF_ASSERT (snap_volinfo);
-
- this = THIS;
- priv = this->private;
- GLUSTERD_GET_SNAP_DIR (voldir, volinfo, snap_volinfo->volname, priv);
- snprintf (rundir, sizeof (rundir)-1, "%s/run", voldir);
- ret = mkdir_p (rundir, 0777, _gf_true);
- if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Failed to create rundir");
- return ret;
-}
-
- int32_t
+int32_t
glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo,
gf_boolean_t wait)
@@ -1452,8 +1463,14 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
runner_argprintf (&runner, "--log-file=%s", valgrind_logfile);
}
- snprintf (volfile, PATH_MAX, "%s.%s.%s", volinfo->volname,
- brickinfo->hostname, exp_path);
+ if (volinfo->is_snap_volume) {
+ snprintf (volfile, PATH_MAX, "/snaps/%s/%s.%s.%s",
+ volinfo->snapshot->snapname, volinfo->volname,
+ brickinfo->hostname, exp_path);
+ } else {
+ snprintf (volfile, PATH_MAX, "%s.%s.%s", volinfo->volname,
+ brickinfo->hostname, exp_path);
+ }
if (volinfo->logdir) {
snprintf (logfile, PATH_MAX, "%s/%s.log",
@@ -1524,166 +1541,6 @@ out:
}
int32_t
-glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_volinfo,
- glusterd_brickinfo_t *brickinfo,
- gf_boolean_t wait)
-{
- int32_t ret = -1;
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- char pidfile[PATH_MAX+1] = {0,};
- char volfile[PATH_MAX] = {0,};
- runner_t runner = {0,};
- char exp_path[PATH_MAX] = {0,};
- char logfile[PATH_MAX] = {0,};
- int port = 0;
- int rdma_port = 0;
- char socketpath[PATH_MAX] = {0};
- char glusterd_uuid[1024] = {0,};
- char valgrind_logfile[PATH_MAX] = {0};
- char export_path[PATH_MAX] = {0,};
- char sock_filepath[PATH_MAX] = {0,};
- char snap_dir[PATH_MAX] = {0,};
- int expected_file_len = 0;
- char snap_volfile[PATH_MAX] = {0, };
-
- GF_ASSERT (volinfo);
- GF_ASSERT (brickinfo);
-
- this = THIS;
- GF_ASSERT (this);
-
- priv = this->private;
- GF_ASSERT (priv);
-
- ret = _mk_snap_rundir_p (volinfo, snap_volinfo);
- if (ret)
- goto out;
-
- expected_file_len = strlen (GLUSTERD_SOCK_DIR) + strlen ("/") +
- MD5_DIGEST_LENGTH*2 + strlen (".socket") + 1;
- GF_ASSERT (sizeof (socketpath) >= expected_file_len);
-
- GLUSTERD_GET_SNAP_DIR (snap_dir, volinfo, snap_volinfo->volname, priv);
- GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, export_path);
- snprintf (sock_filepath, PATH_MAX, "%s/run/%s-%s",
- snap_dir, brickinfo->hostname, export_path);
-
- glusterd_set_socket_filepath (sock_filepath, socketpath, sizeof (socketpath));
-
- GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo->volname,
- snap_volinfo->volname,
- brickinfo, priv);
- if (glusterd_is_service_running (pidfile, NULL))
- goto connect;
-
- _reap_brick_process (pidfile, brickinfo->path);
-
- port = brickinfo->port;
- if (!port)
- port = pmap_registry_alloc (THIS);
-
- /* Build the exp_path, before starting the glusterfsd even in
- valgrind mode. Otherwise all the glusterfsd processes start
- writing the valgrind log to the same file.
- */
- GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, exp_path);
- runinit (&runner);
-
- if (priv->valgrind) {
- /* Run bricks with valgrind */
- if (snap_volinfo->logdir) {
- snprintf (valgrind_logfile, PATH_MAX,
- "%s/valgrind-%s-%s.log",
- snap_volinfo->logdir,
- snap_volinfo->volname, exp_path);
- } else {
- snprintf (valgrind_logfile, PATH_MAX,
- "%s/bricks/valgrind-%s-%s.log",
- DEFAULT_LOG_FILE_DIRECTORY,
- snap_volinfo->volname, exp_path);
- }
-
- runner_add_args (&runner, "valgrind", "--leak-check=full",
- "--trace-children=yes", "--track-origins=yes",
- NULL);
- runner_argprintf (&runner, "--log-file=%s", valgrind_logfile);
- }
-
- snprintf (volfile, PATH_MAX, "%s/snaps/%s/%s.%s.%s",
- volinfo->volname, snap_volinfo->volname,
- snap_volinfo->volname, brickinfo->hostname, exp_path);
-
- if (snap_volinfo->logdir) {
- snprintf (logfile, PATH_MAX, "%s/%s.log",
- snap_volinfo->logdir, exp_path);
- } else {
- snprintf (logfile, PATH_MAX, "%s/bricks/%s.log",
- DEFAULT_LOG_FILE_DIRECTORY, exp_path);
- }
- if (!brickinfo->logfile)
- brickinfo->logfile = gf_strdup (logfile);
-
- snprintf (snap_volfile, sizeof (snap_volfile), "%s/vols/%s/snaps/%s/%s",
- priv->workdir, volinfo->volname, snap_volinfo->volname,
- volfile);
-
- (void) snprintf (glusterd_uuid, 1024, "*-posix.glusterd-uuid=%s",
- uuid_utoa (MY_UUID));
- runner_add_args (&runner, SBIN_DIR"/glusterfsd",
- "-s", brickinfo->hostname, "--volfile-id", volfile,
- "-p", pidfile, "-S", socketpath,
- "--brick-name", brickinfo->path,
- "-l", brickinfo->logfile,
- "--xlator-option", glusterd_uuid,
- NULL);
-
- runner_add_arg (&runner, "--brick-port");
- if (snap_volinfo->transport_type != GF_TRANSPORT_BOTH_TCP_RDMA) {
- runner_argprintf (&runner, "%d", port);
- } else {
- rdma_port = brickinfo->rdma_port;
- if (!rdma_port)
- rdma_port = pmap_registry_alloc (THIS);
- runner_argprintf (&runner, "%d,%d", port, rdma_port);
- runner_add_arg (&runner, "--xlator-option");
- runner_argprintf (&runner, "%s-server.transport.rdma.listen-port=%d",
- snap_volinfo->volname, rdma_port);
- }
-
- runner_add_arg (&runner, "--xlator-option");
- runner_argprintf (&runner, "%s-server.listen-port=%d",
- snap_volinfo->volname, port);
-
- if (snap_volinfo->memory_accounting)
- runner_add_arg (&runner, "--mem-accounting");
-
- runner_log (&runner, "", GF_LOG_DEBUG, "Starting GlusterFS");
- if (wait) {
- synclock_unlock (&priv->big_lock);
- ret = runner_run (&runner);
- synclock_lock (&priv->big_lock);
-
- } else {
- ret = runner_run_nowait (&runner);
- }
-
- if (ret)
- goto out;
-
- brickinfo->port = port;
- brickinfo->rdma_port = rdma_port;
-
-connect:
- ret = glusterd_brick_connect (snap_volinfo, brickinfo, socketpath);
- if (ret)
- goto out;
-out:
- return ret;
-}
-
-int32_t
glusterd_brick_unlink_socket_file (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo)
{
@@ -1715,52 +1572,6 @@ glusterd_brick_unlink_socket_file (glusterd_volinfo_t *volinfo,
}
int32_t
-glusterd_snap_brick_unlink_socket_file (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_volinfo,
- glusterd_brickinfo_t *brickinfo)
-{
- char path[PATH_MAX] = {0,};
- char socketpath[PATH_MAX] = {0};
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- int ret = 0;
- char sock_filepath[PATH_MAX] = {0, };
- int expected_file_len = 0;
- char export_path[PATH_MAX] = {0,};
-
- GF_ASSERT (volinfo);
- GF_ASSERT (snap_volinfo);
- GF_ASSERT (brickinfo);
-
- this = THIS;
- GF_ASSERT (this);
- priv = this->private;
- GF_ASSERT (priv);
-
- GLUSTERD_GET_SNAP_DIR (path, volinfo, snap_volinfo->volname, priv);
-
- glusterd_set_socket_filepath (sock_filepath, socketpath, sizeof (socketpath));
-
- expected_file_len = strlen (GLUSTERD_SOCK_DIR) + strlen ("/") +
- MD5_DIGEST_LENGTH*2 + strlen (".socket") + 1;
- GF_ASSERT (sizeof (socketpath) >= expected_file_len);
-
- GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, export_path);
- snprintf (sock_filepath, PATH_MAX, "%s/run/%s-%s",
- path, brickinfo->hostname, export_path);
-
- ret = unlink (socketpath);
- if (ret && (ENOENT == errno)) {
- ret = 0;
- } else {
- gf_log (this->name, GF_LOG_ERROR, "Failed to remove %s"
- " error: %s", socketpath, strerror (errno));
- }
-
- return ret;
-}
-
-int32_t
glusterd_brick_disconnect (glusterd_brickinfo_t *brickinfo)
{
rpc_clnt_t *rpc = NULL;
@@ -1822,49 +1633,6 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
}
int32_t
-glusterd_snap_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_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;
-
- GF_ASSERT (volinfo);
- GF_ASSERT (brickinfo);
- GF_ASSERT (snap_volinfo);
-
- this = THIS;
- GF_ASSERT (this);
- priv = this->private;
- GF_ASSERT (priv);
-
- if (del_brick)
- list_del_init (&brickinfo->brick_list);
-
- if (GLUSTERD_STATUS_STARTED == snap_volinfo->status) {
- (void) glusterd_brick_disconnect (brickinfo);
- GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo->volname,
- snap_volinfo->volname,
- brickinfo, priv);
- ret = glusterd_service_stop ("brick", pidfile, SIGTERM, _gf_false);
- if (ret == 0) {
- glusterd_set_brick_status (brickinfo, GF_BRICK_STOPPED);
- (void) glusterd_snap_brick_unlink_socket_file (volinfo,
- snap_volinfo,
- brickinfo);
- }
- }
-
- if (del_brick)
- glusterd_delete_snap_brick (volinfo, snap_volinfo, brickinfo);
-
- return ret;
-}
-
-int32_t
glusterd_peer_hostname_new (char *hostname, glusterd_peer_hostname_t **name)
{
glusterd_peer_hostname_t *peer_hostname = NULL;
@@ -1999,8 +1767,7 @@ glusterd_sort_and_redirect (const char *src_filepath, int dest_fd)
}
int
-glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_volinfo)
+glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo)
{
int32_t ret = -1;
glusterd_conf_t *priv = NULL;
@@ -2020,12 +1787,7 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo,
priv = THIS->private;
GF_ASSERT (priv);
- if (snap_volinfo) {
- GLUSTERD_GET_SNAP_DIR (path, volinfo, snap_volinfo->volname,
- priv);
- } else {
- GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv);
- }
+ GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv);
snprintf (cksum_path, sizeof (cksum_path), "%s/%s",
path, GLUSTERD_CKSUM_FILE);
@@ -2041,19 +1803,15 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo,
snprintf (filepath, sizeof (filepath), "%s/%s", path,
GLUSTERD_VOLUME_INFO_FILE);
- if (snap_volinfo)
- snprintf (sort_filepath, sizeof (sort_filepath),
- "/tmp/%s.XXXXXX", snap_volinfo->volname);
- else
- snprintf (sort_filepath, sizeof (sort_filepath),
- "/tmp/%s.XXXXXX", volinfo->volname);
+ snprintf (sort_filepath, sizeof (sort_filepath),
+ "/tmp/%s.XXXXXX", volinfo->volname);
sort_fd = mkstemp (sort_filepath);
if (sort_fd < 0) {
gf_log (this->name, GF_LOG_ERROR, "Could not generate temp "
"file, reason: %s for %s: %s", strerror (errno),
- (snap_volinfo)?"snap":"volume",
- (snap_volinfo)?snap_volinfo->volname:volinfo->volname);
+ (volinfo->is_snap_volume)?"snap":"volume",
+ volinfo->volname);
goto out;
} else {
unlink_sortfile = _gf_true;
@@ -2092,10 +1850,7 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
- if (snap_volinfo)
- snap_volinfo->cksum = cksum;
- else
- volinfo->cksum = cksum;
+ volinfo->cksum = cksum;
out:
if (fd > 0)
close (fd);
@@ -2811,10 +2566,8 @@ void
glusterd_do_volume_quorum_action (xlator_t *this, glusterd_volinfo_t *volinfo,
gf_boolean_t meets_quorum)
{
- int ret = -1;
glusterd_brickinfo_t *brickinfo = NULL;
- glusterd_conf_t *conf = NULL;
- glusterd_volinfo_t *parent_volinfo = NULL;
+ glusterd_conf_t *conf = NULL;
conf = this->private;
if (volinfo->status != GLUSTERD_STATUS_STARTED)
@@ -2823,33 +2576,13 @@ glusterd_do_volume_quorum_action (xlator_t *this, glusterd_volinfo_t *volinfo,
if (!glusterd_is_volume_in_server_quorum (volinfo))
meets_quorum = _gf_true;
- if (volinfo->is_snap_volume == _gf_true) {
- ret = glusterd_volinfo_find (volinfo->parent_volname, &parent_volinfo);
- if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
- "Unable to find parent volume %s for snap %s",
- volinfo->parent_volname, volinfo->volname);
- goto out;
- }
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- if (!glusterd_is_local_brick (this, volinfo, brickinfo))
- continue;
- if (meets_quorum)
- glusterd_snap_brick_start (parent_volinfo, volinfo,
- brickinfo, _gf_false);
- else
- glusterd_snap_brick_stop (parent_volinfo, volinfo,
- brickinfo, _gf_false);
- }
- } else {
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- if (!glusterd_is_local_brick (this, volinfo, brickinfo))
- continue;
- if (meets_quorum)
- glusterd_brick_start (volinfo, brickinfo, _gf_false);
- else
- glusterd_brick_stop (volinfo, brickinfo, _gf_false);
- }
+ list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ if (!glusterd_is_local_brick (this, volinfo, brickinfo))
+ continue;
+ if (meets_quorum)
+ glusterd_brick_start (volinfo, brickinfo, _gf_false);
+ else
+ glusterd_brick_stop (volinfo, brickinfo, _gf_false);
}
out:
return;
@@ -4581,58 +4314,13 @@ out:
}
int
-glusterd_snap_brick_start (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_volinfo,
- glusterd_brickinfo_t *brickinfo,
- gf_boolean_t wait)
-{
- int ret = -1;
- xlator_t *this = NULL;
- glusterd_conf_t *conf = NULL;
-
- if ((!brickinfo) || (!volinfo))
- goto out;
-
- this = THIS;
- GF_ASSERT (this);
- conf = this->private;
- GF_ASSERT (conf);
-
- if (uuid_is_null (brickinfo->uuid)) {
- ret = glusterd_resolve_brick (brickinfo);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK,
- brickinfo->hostname, brickinfo->path);
- goto out;
- }
- }
-
- if (uuid_compare (brickinfo->uuid, MY_UUID)) {
- ret = 0;
- goto out;
- }
- ret = glusterd_snap_volume_start_glusterfs (volinfo, snap_volinfo,
- brickinfo, wait);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to start brick %s:%s",
- brickinfo->hostname, brickinfo->path);
- goto out;
- }
-
-out:
- gf_log (this->name, GF_LOG_DEBUG, "returning %d ", ret);
- return ret;
-}
-
-int
glusterd_restart_bricks (glusterd_conf_t *conf)
{
+ int ret = 0;
glusterd_volinfo_t *volinfo = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
- gf_boolean_t start_nodesvcs = _gf_false;
- int ret = 0;
glusterd_snap_t *snap = NULL;
- glusterd_volinfo_t *snap_volume = NULL;
+ gf_boolean_t start_nodesvcs = _gf_false;
xlator_t *this = NULL;
this = THIS;
@@ -4651,28 +4339,19 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
}
}
- list_for_each_entry (volinfo, &conf->volumes, vol_list) {
- if (volinfo->is_snap_volume)
+ 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 (snap, &volinfo->snaps, snap_list) {
- snap_volume = snap->snap_volume;
- //GF_ASSERT (snap_volume);
- if (!snap_volume) {
- gf_log (this->name, GF_LOG_WARNING, "volinfo "
- "for the snap %s is NULL",
- snap->snap_name);
- continue;
- }
- list_for_each_entry (brickinfo, &snap_volume->bricks,
- brick_list) {
- glusterd_snap_brick_start (volinfo, snap_volume,
- brickinfo, _gf_false);
- }
+ }
+ list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ glusterd_brick_start (volinfo, brickinfo, _gf_false);
}
}
- //TODO: start consistency groups also
-
if (start_nodesvcs)
glusterd_nodesvcs_handle_graph_change (NULL);
@@ -5262,14 +4941,7 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
- if (volinfo->is_snap_volume == _gf_true) {
- /* Fetching the snap pidfile using parent volname */
- GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile,
- volinfo->parent_volname,
- volinfo->volname,
- brickinfo, priv);
- } else
- GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);
+ GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);
brick_online = glusterd_is_service_running (pidfile, &pid);
@@ -5558,60 +5230,6 @@ out:
}
int
-glusterd_snap_brick_stop (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_volinfo,
- glusterd_brickinfo_t *brickinfo,
- gf_boolean_t del_brick)
-{
- int ret = -1;
- xlator_t *this = NULL;
- glusterd_conf_t *conf = NULL;
-
- this = THIS;
- GF_ASSERT (this);
- conf = this->private;
- GF_ASSERT (conf);
-
- if ((!brickinfo) || (!volinfo) || !snap_volinfo) {
- gf_log (this->name, GF_LOG_ERROR, "input parameters NULL");
- goto out;
- }
-
- if (uuid_is_null (brickinfo->uuid)) {
- ret = glusterd_resolve_brick (brickinfo);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, FMTSTR_RESOLVE_BRICK,
- brickinfo->hostname, brickinfo->path);
- goto out;
- }
- }
-
- if (uuid_compare (brickinfo->uuid, MY_UUID)) {
- ret = 0;
- if (del_brick)
- glusterd_delete_snap_brick (volinfo, snap_volinfo,
- brickinfo);
- goto out;
- }
-
- gf_log (this->name, GF_LOG_DEBUG, "About to stop glusterfs"
- " for brick %s:%s", brickinfo->hostname,
- brickinfo->path);
- ret = glusterd_snap_volume_stop_glusterfs (volinfo, snap_volinfo,
- brickinfo, del_brick);
- if (ret) {
- gf_log (this->name, GF_LOG_CRITICAL, "Unable to stop"
- " brick: %s:%s", brickinfo->hostname,
- brickinfo->path);
- goto out;
- }
-
-out:
- gf_log (this->name, GF_LOG_TRACE, "returning %d ", ret);
- return ret;
-}
-
-int
glusterd_is_defrag_on (glusterd_volinfo_t *volinfo)
{
return (volinfo->rebal.defrag != NULL);
@@ -6229,7 +5847,7 @@ glusterd_delete_volume (glusterd_volinfo_t *volinfo)
int ret = -1;
GF_ASSERT (volinfo);
- ret = glusterd_store_delete_volume (volinfo, NULL);
+ ret = glusterd_store_delete_volume (volinfo);
if (ret)
goto out;
@@ -6260,49 +5878,6 @@ glusterd_delete_brick (glusterd_volinfo_t* volinfo,
}
int32_t
-glusterd_delete_snap_brick (glusterd_volinfo_t *volinfo,
- glusterd_volinfo_t *snap_volinfo,
- glusterd_brickinfo_t *brickinfo)
-{
- int ret = 0;
- char voldir[PATH_MAX] = {0,};
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
-
- this = THIS;
- GF_ASSERT (this);
- priv = this->private;
- GF_ASSERT (priv);
-
- GF_ASSERT (volinfo);
- GF_ASSERT (snap_volinfo);
- GF_ASSERT (brickinfo);
-
- GLUSTERD_GET_SNAP_DIR(voldir, volinfo, snap_volinfo->volname, priv);
-
- ret = glusterd_delete_snap_volfile (volinfo, snap_volinfo, brickinfo);
- if (ret)
- gf_log (this->name, GF_LOG_WARNING, "failed to delete the "
- "volfile for the brick (%s:%s), snap: %s volume: %s",
- brickinfo->hostname, brickinfo->path,
- snap_volinfo->volname, volinfo->volname);
- ret = glusterd_store_delete_brick (brickinfo, voldir);
- if (ret)
- gf_log (this->name, GF_LOG_WARNING, "failed to delete the "
- "store handle of brick (%s:%s), snap: %s volume: %s",
- brickinfo->hostname, brickinfo->path,
- snap_volinfo->volname, volinfo->volname);
- ret = glusterd_brickinfo_delete (brickinfo);
- if (ret)
- gf_log (this->name, GF_LOG_WARNING, "failed to delete the "
- "brickinfo (%s:%s), snap: %s volume: %s",
- brickinfo->hostname, brickinfo->path,
- snap_volinfo->volname, volinfo->volname);
- snap_volinfo->brick_count--;
- return ret;
-}
-
-int32_t
glusterd_delete_all_bricks (glusterd_volinfo_t* volinfo)
{
int ret = 0;
@@ -8873,3 +8448,20 @@ glusterd_is_status_tasks_op (glusterd_op_t op, dict_t *dict)
out:
return is_status_tasks;
}
+
+int
+glusterd_compare_snap_time(struct list_head *list1, struct list_head *list2)
+{
+ glusterd_snap_t *snap1 = NULL;
+ glusterd_snap_t *snap2 = NULL;
+ double diff_time = 0;
+
+ GF_ASSERT (list1);
+ GF_ASSERT (list2);
+
+ snap1 = list_entry(list1, glusterd_snap_t, snap_list);
+ snap2 = list_entry(list2, glusterd_snap_t, snap_list);
+ diff_time = difftime(snap1->time_stamp, snap2->time_stamp);
+
+ return ((int)diff_time);
+}