summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2015-01-07 11:14:31 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-24 07:56:32 -0700
commit84db9f8271f150fbb6024186f7f681e941731280 (patch)
treec9a3fe9dceeac5f00714362af4c7f6c706b539b2 /xlators/mgmt/glusterd/src/glusterd-volgen.c
parenta37f3ca2b286732fff18f0b0897d8bb1713c89b7 (diff)
mgmt/glusterd: generate volfile for BitD
* Implement the skeleton of bit-rot xlator. Original-Author: Raghavendra Bhat <raghavendra@redhat.com> Signed-off-by: Venky Shankar <vshankar@redhat.com> Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Signed-off-by: Anand Nekkunti <anekkunt@redhat.com> Change-Id: If33218bdc694f5f09cb7b8097c4fdb74d7a23b2d BUG: 1170075 Reviewed-on: http://review.gluster.org/9710 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index d7709750129..ea00eea432f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -848,6 +848,8 @@ _xl_link_children (xlator_t *parent, xlator_t *children, size_t child_count)
for (trav = children; --seek; trav = trav->next);
for (; child_count--; trav = trav->prev) {
ret = volgen_xlator_link (parent, trav);
+ gf_log (THIS->name, GF_LOG_DEBUG, "%s:%s", parent->name,
+ trav->name);
if (ret)
goto out;
}
@@ -4306,7 +4308,10 @@ build_quotad_graph (volgen_graph_t *graph, dict_t *mod_dict)
char *skey = NULL;
this = THIS;
+ GF_ASSERT (this);
+
priv = this->private;
+ GF_ASSERT (priv);
set_dict = dict_new ();
if (!set_dict) {
@@ -4708,6 +4713,102 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph,
}
int
+build_bitd_graph (volgen_graph_t *graph, dict_t *mod_dict)
+{
+ volgen_graph_t cgraph = {0};
+ glusterd_volinfo_t *voliter = NULL;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+ dict_t *set_dict = NULL;
+ int ret = 0;
+ xlator_t *bitd_xl = NULL;
+ xlator_t *xl = NULL;
+ xlator_t *trav = NULL;
+ xlator_t *txl = NULL;
+ char *skey = NULL;
+ char transt[16] = {0,};
+ glusterd_brickinfo_t *brickinfo = NULL;
+ char *br_args[] = {"features/bit-rot",
+ "bit-rot"};
+ int32_t count = 0;
+
+ this = THIS;
+ GF_ASSERT (this);
+
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ set_dict = dict_new ();
+ if (!set_dict) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (mod_dict)
+ dict_copy (mod_dict, set_dict);
+
+ list_for_each_entry (voliter, &priv->volumes, vol_list) {
+ if (voliter->status != GLUSTERD_STATUS_STARTED)
+ continue;
+
+ memset (transt, '\0', 16);
+
+ get_transport_type (voliter, set_dict, transt, _gf_false);
+ if (!strcmp (transt, "tcp,rdma"))
+ strcpy (transt, "tcp");
+
+
+ list_for_each_entry (brickinfo, &voliter->bricks, brick_list) {
+ if (!glusterd_is_local_brick (this, voliter, brickinfo))
+ continue;
+ /*To do: check whether bitd is enable or not if "
+ * "not then continue;
+ * Since bitd is a service running within the "
+ * trusted storage pool, it is treated as a trusted
+ * client.
+ */
+ xl = volgen_graph_build_client (graph, voliter,
+ brickinfo->hostname,
+ brickinfo->path,
+ brickinfo->brick_id, transt,
+ set_dict);
+ if (!xl) {
+ ret = -1;
+ goto out;
+ }
+
+ count++;
+ }
+ }
+
+ bitd_xl = volgen_graph_add_nolink (graph, br_args[0], br_args[1]);
+ if (!bitd_xl) {
+ ret = -1;
+ goto out;
+ }
+
+ txl = first_of (graph);
+ for (trav = txl; count; trav = trav->next)
+ count--;
+
+ for (; trav != txl; trav = trav->prev) {
+ ret = volgen_xlator_link (bitd_xl, trav);
+ if (ret)
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ if (set_dict)
+ dict_unref (set_dict);
+
+ gf_log(this->name, GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
+int
glusterd_snapdsvc_create_volfile (glusterd_volinfo_t *volinfo)
{
volgen_graph_t graph = {0,};