summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c144
1 files changed, 144 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 0de71a49a..fc326757d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -3172,6 +3172,38 @@ glusterd_generate_brick_volfile (glusterd_volinfo_t *volinfo,
return ret;
}
+static int
+glusterd_generate_snap_brick_volfile (glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *brickinfo,
+ glusterd_volinfo_t *snap_volinfo)
+{
+ volgen_graph_t graph = {0,};
+ char filename[PATH_MAX] = {0,};
+ int ret = -1;
+ char path[PATH_MAX] = {0,};
+ char brick[PATH_MAX] = {0,};
+ glusterd_conf_t *priv = NULL;
+
+ priv = THIS->private;
+ GF_ASSERT (volinfo);
+ GF_ASSERT (brickinfo);
+
+ GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, brick);
+ GLUSTERD_GET_SNAP_DIR (path, volinfo, snap_volinfo->volname, priv);
+
+ snprintf (filename, PATH_MAX, "%s/%s.%s.%s.vol",
+ path, snap_volinfo->volname,
+ brickinfo->hostname,
+ brick);
+
+ ret = build_server_graph (&graph, snap_volinfo, NULL, brickinfo);
+ if (!ret)
+ ret = volgen_write_volfile (&graph, filename);
+
+ volgen_graph_free (&graph);
+
+ return ret;
+}
static void
@@ -3241,6 +3273,31 @@ out:
return ret;
}
+int
+generate_snap_brick_volfiles (glusterd_volinfo_t *volinfo,
+ glusterd_volinfo_t *snap_volinfo)
+{
+ glusterd_brickinfo_t *brickinfo = NULL;
+ int ret = -1;
+
+ list_for_each_entry (brickinfo, &snap_volinfo->bricks, brick_list) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Found a brick - %s:%s", brickinfo->hostname,
+ brickinfo->path);
+
+ ret = glusterd_generate_snap_brick_volfile (volinfo, brickinfo,
+ snap_volinfo);
+ if (ret)
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
static int
generate_single_transport_client_volfile (glusterd_volinfo_t *volinfo,
char *filepath, dict_t *dict)
@@ -3323,6 +3380,93 @@ out:
}
int
+generate_snap_client_volfiles (glusterd_volinfo_t *actual_volinfo,
+ glusterd_volinfo_t *snap_volinfo,
+ glusterd_client_type_t client_type)
+{
+ char filepath[PATH_MAX] = {0,};
+ int ret = -1;
+ char *types[] = {NULL, NULL, NULL};
+ int i = 0;
+ dict_t *dict = NULL;
+ gf_transport_type type = GF_TRANSPORT_TCP;
+ char path[PATH_MAX] = {0, };
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ conf = this->private;
+ GF_ASSERT (conf);
+
+ if (!actual_volinfo) {
+ gf_log (this->name, GF_LOG_ERROR, "actual volinfo is NULL."
+ "Unable to generate the client volfiles for snap");
+ goto out;
+ }
+
+ if (!snap_volinfo) {
+ gf_log (this->name, GF_LOG_ERROR, "snap volinfo is NULL. Unable"
+ "to generate the client volfiles for snap (volume: %s)",
+ actual_volinfo->volname);
+ goto out;
+ }
+
+ enumerate_transport_reqs (actual_volinfo->transport_type, types);
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+ for (i = 0; types[i]; i++) {
+ memset (filepath, 0, sizeof (filepath));
+ ret = dict_set_str (dict, "client-transport-type", types[i]);
+ if (ret)
+ goto out;
+ type = transport_str_to_type (types[i]);
+
+ ret = dict_set_uint32 (dict, "trusted-client", client_type);
+ if (ret)
+ goto out;
+
+ GLUSTERD_GET_SNAP_DIR (path, actual_volinfo,
+ snap_volinfo->volname,conf);
+ if (client_type == GF_CLIENT_TRUSTED) {
+ if ((actual_volinfo->transport_type ==
+ GF_TRANSPORT_BOTH_TCP_RDMA) &&
+ type == GF_TRANSPORT_RDMA) {
+ snprintf (filepath, PATH_MAX,
+ "%s/trusted-%s.rdma-fuse.vol",
+ path, snap_volinfo->volname);
+ } else {
+ snprintf (filepath, PATH_MAX,
+ "%s/trusted-%s-fuse.vol",
+ path, snap_volinfo->volname);
+ }
+ } else {
+ if ((actual_volinfo->transport_type ==
+ GF_TRANSPORT_BOTH_TCP_RDMA) &&
+ (type == GF_TRANSPORT_RDMA)) {
+ snprintf (filepath, PATH_MAX, "%s/%s.rdma-fuse.vol",
+ path, snap_volinfo->volname);
+ } else {
+ snprintf (filepath, PATH_MAX, "%s/%s-fuse.vol",
+ path, snap_volinfo->volname);
+ }
+ }
+
+ ret = generate_single_transport_client_volfile (snap_volinfo,
+ filepath,
+ dict);
+ if (ret)
+ goto out;
+ }
+
+out:
+ if (dict)
+ dict_unref (dict);
+ return ret;
+}
+
+int
glusterd_create_rb_volfiles (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo)
{