summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c5
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c12
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h7
5 files changed, 36 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 198f64c..5ea36dd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -3037,8 +3037,11 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
GF_ASSERT (priv);
ret = glusterd_volinfo_dup (volinfo, &snap_volume);
- strcpy (snap_volume->volname, snapname);
+ strncpy (snap_volume->volname, snapname,
+ sizeof(snap_volume->volname) - 1);
snap_volume->is_snap_volume = _gf_true;
+ strncpy (snap_volume->parent_volname, volinfo->volname,
+ sizeof(snap_volume->parent_volname) - 1);
uuid_copy (snap_volume->volume_id, snap_volid);
/* Adding snap brickinfos to the snap volinfo */
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index ca3b80c..88ac2bf 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -656,6 +656,14 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo)
if (ret)
goto out;
+ snprintf (buf, sizeof (buf), "%s", volinfo->parent_volname);
+ ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_PARENT_VOLNAME, buf);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Failed to store "
+ GLUSTERD_STORE_KEY_PARENT_VOLNAME);
+ goto out;
+ }
+
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_ID,
uuid_utoa (volinfo->volume_id));
if (ret)
@@ -2673,6 +2681,7 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
goto out;
while (!ret) {
+ gf_log ("", GF_LOG_DEBUG, "key = %s value = %s", key, value);
if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TYPE,
strlen (GLUSTERD_STORE_KEY_VOL_TYPE))) {
volinfo->type = atoi (value);
@@ -2744,6 +2753,9 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
} else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT,
strlen (GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT))) {
volinfo->snap_max_limit = (uint64_t) atoll (value);
+ } else if (!strncmp (key, GLUSTERD_STORE_KEY_PARENT_VOLNAME,
+ strlen (GLUSTERD_STORE_KEY_PARENT_VOLNAME))) {
+ strncpy (volinfo->parent_volname, value, sizeof(volinfo->parent_volname) - 1);
} else {
if (is_key_glusterd_hooks_friendly (key)) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index a5a4bfd..27472c0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -56,6 +56,7 @@ typedef enum glusterd_store_ver_ac_{
#define GLUSTERD_STORE_KEY_DEFRAG_OP "rebalance_op"
#define GLUSTERD_STORE_KEY_USERNAME "username"
#define GLUSTERD_STORE_KEY_PASSWORD "password"
+#define GLUSTERD_STORE_KEY_PARENT_VOLNAME "parent_volname"
#define GLUSTERD_STORE_KEY_VOL_OP_VERSION "op-version"
#define GLUSTERD_STORE_KEY_VOL_CLIENT_OP_VERSION "client-op-version"
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 5592af5..50d6232 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -461,6 +461,8 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)
goto out;
}
+ snprintf (new_volinfo->parent_volname, GLUSTERD_MAX_VOLUME_NAME, "N/A");
+
if (conf)
new_volinfo->snap_max_limit = conf->snap_max_limit;
else
@@ -5016,6 +5018,7 @@ 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;
@@ -5048,7 +5051,15 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
- GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);
+ 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);
+ } else
+ GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);
brick_online = glusterd_is_service_running (pidfile, &pid);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 19c05c4..648a884 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -275,6 +275,13 @@ struct glusterd_volinfo_ {
gf_lock_t lock;
char volname[GLUSTERD_MAX_VOLUME_NAME];
gf_boolean_t is_snap_volume;
+ char parent_volname[GLUSTERD_MAX_VOLUME_NAME];
+ /* In case of a snap volume
+ i.e (is_snap_volume == TRUE) this
+ field will contain the name of
+ the volume which is snapped. In
+ case of a non-snap volume, this
+ field will be initialized as N/A */
int type;
int brick_count;
uint64_t snap_count;