diff options
author | Venky Shankar <vshankar@redhat.com> | 2015-03-13 22:00:22 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-24 10:26:15 -0700 |
commit | 31f841d6b35c242942b6bdcbfdc83cf548d5235a (patch) | |
tree | 450558d7e4b1788bb254b2117fef8cdc9b6f2033 /xlators/mgmt/glusterd/src/glusterd-volgen.c | |
parent | 84db9f8271f150fbb6024186f7f681e941731280 (diff) |
cli/glusterd: CLI interface for BitRot detection
* BitRot enable/disable CLI per volume
* Volfile generation for Scrubber
* Relevant glusterd infrastructure
Change-Id: I1212af63f93ecc52b22ee6da920e1664f66a1e39
BUG: 1170075
Original-Author: Raghavendra Bhat <raghavendra@redhat.com>
Original-Author: Venky Shankar <vshankar@redhat.com>
Original-Author: Gaurav Kumar Garg <ggarg@redhat.com>
Original-Author: Anand Nekkunti <anekkunt@redhat.com>
Reviewed-on: http://review.gluster.org/9986
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-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.c | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index ea00eea432f..65f446e8548 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1670,7 +1670,6 @@ static int brick_graph_add_acl (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, dict_t *set_dict, glusterd_brickinfo_t *brickinfo) { - xlator_t *xl = NULL; int ret = -1; @@ -4751,6 +4750,99 @@ build_bitd_graph (volgen_graph_t *graph, dict_t *mod_dict) if (voliter->status != GLUSTERD_STATUS_STARTED) continue; + if (!glusterd_is_bitrot_enabled (voliter)) + 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; + 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 +build_scrub_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); @@ -4787,6 +4879,10 @@ build_bitd_graph (volgen_graph_t *graph, dict_t *mod_dict) goto out; } + ret = xlator_set_option (bitd_xl, "scrubber", "true"); + if (ret) + goto out; + txl = first_of (graph); for (trav = txl; count; trav = trav->next) count--; |