summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2013-10-24 15:05:04 +0530
committershishir gowda <sgowda@redhat.com>2013-11-15 12:48:08 +0530
commit262d9379e1dbe909e2a622a7e1806b70d3a59591 (patch)
treee3d82515f33762011e63cb082bc8c238938221b6
parentd8c95f33e2557aff81d4a7f3e22f1c784183f5aa (diff)
mgmt/glusterd: handle snap volume store and actual volume store separately
Change-Id: I8b88fe94d0f9ee1089cafdda037abcf2f7a180ca Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c49
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c23
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c10
4 files changed, 64 insertions, 21 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 39f3671..bbff2f4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1704,7 +1704,7 @@ glusterd_store_volinfo (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t a
goto out;
//checksum should be computed at the end
- ret = glusterd_volume_compute_cksum (volinfo);
+ ret = glusterd_volume_compute_cksum (volinfo, NULL);
if (ret)
goto out;
@@ -2137,7 +2137,8 @@ out:
int32_t
-glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo, char *snap_name)
+glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo,
+ glusterd_volinfo_t *snap_volinfo)
{
int32_t ret = 0;
@@ -2154,25 +2155,34 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo, char *snap_name)
char *tmpvalue = NULL;
struct pmap_registry *pmap = NULL;
gf_store_op_errno_t op_errno = GD_STORE_SUCCESS;
+ glusterd_volinfo_t *tmp_volinfo = NULL;
GF_ASSERT (volinfo);
GF_ASSERT (volinfo->volname);
priv = THIS->private;
- if (snap_name) {
- GLUSTERD_GET_SNAP_BRICK_DIR (brickdir, volinfo, snap_name,
- priv);
+ if (snap_volinfo) {
+ GLUSTERD_GET_SNAP_BRICK_DIR (brickdir, volinfo,
+ snap_volinfo->volname, priv);
} else {
GLUSTERD_GET_BRICK_DIR (brickdir, volinfo, priv);
}
- ret = gf_store_iter_new (volinfo->shandle, &tmpiter);
+ if (snap_volinfo)
+ ret = gf_store_iter_new (snap_volinfo->shandle, &tmpiter);
+ else
+ ret = gf_store_iter_new (volinfo->shandle, &tmpiter);
if (ret)
goto out;
- while (brick_count < volinfo->brick_count) {
+ if (snap_volinfo)
+ tmp_volinfo = snap_volinfo;
+ else
+ tmp_volinfo = volinfo;
+
+ while (brick_count < tmp_volinfo->brick_count) {
ret = glusterd_brickinfo_new (&brickinfo);
if (ret)
@@ -2274,7 +2284,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo, char *snap_name)
if (ret)
goto out;
- list_add_tail (&brickinfo->brick_list, &volinfo->bricks);
+ list_add_tail (&brickinfo->brick_list, &tmp_volinfo->bricks);
brick_count++;
}
@@ -2468,7 +2478,7 @@ out:
}
int32_t
-glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
+glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
{
int32_t ret = -1;
glusterd_volinfo_t *volinfo = NULL;
@@ -2480,18 +2490,24 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
char path[PATH_MAX] = {0,};
int exists = 0;
gf_store_op_errno_t op_errno = GD_STORE_SUCCESS;
+ glusterd_volinfo_t *parent_vol = NULL;
+
+ GF_ASSERT (volname);
ret = glusterd_volinfo_new (&volinfo);
if (ret)
goto out;
- strncpy (volinfo->volname, volname, GLUSTERD_MAX_VOLUME_NAME);
-
priv = THIS->private;
if (snap) {
- GLUSTERD_GET_SNAP_DIR (volpath, volinfo, snap->snap_name, priv);
+ ret = glusterd_volinfo_find (volname, &parent_vol);
+ if (ret)
+ goto out;
+ strncpy (volinfo->volname, snap->snap_name, GLUSTERD_MAX_VOLUME_NAME);
+ GLUSTERD_GET_SNAP_DIR (volpath, parent_vol, snap->snap_name, priv);
} else {
+ strncpy (volinfo->volname, volname, GLUSTERD_MAX_VOLUME_NAME);
GLUSTERD_GET_VOLUME_DIR(volpath, volinfo, priv);
}
snprintf (path, sizeof (path), "%s/%s", volpath,
@@ -2670,13 +2686,16 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
goto out;
if (snap)
- ret = glusterd_store_retrieve_bricks (volinfo, snap->snap_name);
+ ret = glusterd_store_retrieve_bricks (parent_vol, volinfo);
else
ret = glusterd_store_retrieve_bricks (volinfo, NULL);
if (ret)
goto out;
- ret = glusterd_volume_compute_cksum (volinfo);
+ if (snap)
+ ret = glusterd_volume_compute_cksum (parent_vol, volinfo);
+ else
+ ret = glusterd_volume_compute_cksum (volinfo, NULL);
if (ret)
goto out;
@@ -2684,7 +2703,9 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
if (!snap) {
list_add_tail (&volinfo->vol_list, &priv->volumes);
} else {
+ // as of now snap volume are also added to the list of volume
snap->snap_volume = volinfo;
+ list_add_tail (&volinfo->vol_list, &priv->volumes);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index fd8f5e7..771b0af 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1822,7 +1822,8 @@ glusterd_sort_and_redirect (const char *src_filepath, int dest_fd)
}
int
-glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo)
+glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo,
+ glusterd_volinfo_t *snap_volinfo)
{
int32_t ret = -1;
glusterd_conf_t *priv = NULL;
@@ -1842,7 +1843,12 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo)
priv = THIS->private;
GF_ASSERT (priv);
- GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv);
+ if (snap_volinfo) {
+ GLUSTERD_GET_SNAP_DIR (path, volinfo, snap_volinfo->volname,
+ priv);
+ } else {
+ GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv);
+ }
snprintf (cksum_path, sizeof (cksum_path), "%s/%s",
path, GLUSTERD_CKSUM_FILE);
@@ -1858,14 +1864,19 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo)
snprintf (filepath, sizeof (filepath), "%s/%s", path,
GLUSTERD_VOLUME_INFO_FILE);
- snprintf (sort_filepath, sizeof (sort_filepath), "/tmp/%s.XXXXXX",
- volinfo->volname);
+ 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);
sort_fd = mkstemp (sort_filepath);
if (sort_fd < 0) {
gf_log (this->name, GF_LOG_ERROR, "Could not generate temp "
- "file, reason: %s for volume: %s", strerror (errno),
- volinfo->volname);
+ "file, reason: %s for %s: %s", strerror (errno),
+ (snap_volinfo)?"snap":"volume",
+ (snap_volinfo)?snap_volinfo->volname:volinfo->volname);
goto out;
} else {
unlink_sortfile = _gf_true;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 4c95215..1fb55c4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -167,7 +167,8 @@ int32_t
glusterd_compare_friend_data (dict_t *vols, int32_t *status, char *hostname);
int
-glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo);
+glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo,
+ glusterd_volinfo_t *snap_volinfo);
void
glusterd_get_nodesvc_volfile (char *server, char *workdir,
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index acefc8e..c0531d3 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -1239,6 +1239,16 @@ init (xlator_t *this)
exit (1);
}
+ snprintf (storedir, PATH_MAX, "%s/%s", workdir,
+ GLUSTERD_VOL_SNAP_CG_DIR_PREFIX);
+ ret = mkdir (storedir, 0777);
+ if ((-1 == ret) && (errno != EEXIST)) {
+ gf_log (this->name, GF_LOG_CRITICAL,
+ "Unable to create cgs directory %s"
+ " ,errno = %d", storedir, errno);
+ exit (1);
+ }
+
ret = glusterd_rpcsvc_options_build (this->options);
if (ret)
goto out;