summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorGaurav Kumar Garg <ggarg@redhat.com>2015-05-08 13:08:22 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-05-09 22:25:15 -0700
commit3586581c6edf222daf836c99ce2a1a266dc741f8 (patch)
treea5eb2fb8897537add630817b69e0dda84b701094 /xlators
parentdeb76ef2a97ea51c0cbe329a1fdb636071fda90f (diff)
bitrot: Volfile generation should not proceed if node doesn't have any brick.
glusterd crashes when bitrot is enabled on a distributed volume from a node which doesn't host a brick. While generating volfile glusterd should check number of brick on that node. If node doesn't have any brick then graph generation for bitrot and scrubber should not proceed further. Change-Id: I2158113e20e93738cde2a22fd73f0ae6b22aae9e BUG: 1219784 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Reviewed-on: http://review.gluster.org/10664 Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-bitrot.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c202
2 files changed, 105 insertions, 104 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-bitrot.c b/xlators/mgmt/glusterd/src/glusterd-bitrot.c
index 456e5e788ab..08976cf6fb3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-bitrot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-bitrot.c
@@ -357,10 +357,13 @@ glusterd_should_i_stop_bitd ()
brickinfo))
continue;
stopped = _gf_false;
- break;
+ return stopped;
}
- break;
+ /* Before stoping bitrot/scrubber daemon check
+ * other volume also whether respective volume
+ * host a brick from this node or not.*/
+ continue;
}
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 3b6a8c03b43..e2bb59bb97b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -4885,44 +4885,15 @@ out:
static int
build_bitd_clusters (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
- dict_t *set_dict, unsigned int numbricks)
+ dict_t *set_dict, int brick_count, unsigned int numbricks)
{
int ret = -1;
int clusters = 0;
xlator_t *xl = NULL;
- xlator_t *trav = NULL;
- xlator_t *this = NULL;
- char transt[16] = {0,};
char *brick_hint = NULL;
- int brick_count = 0;
- glusterd_brickinfo_t *brickinfo = NULL;
char *bitrot_args[] = {"features/bit-rot",
"%s-bit-rot-%d"};
- this = THIS;
- GF_ASSERT (this);
-
- get_transport_type (volinfo, set_dict, transt, _gf_false);
- if (!strncmp (transt, "tcp,rdma", strlen ("tcp,rdma")))
- strncpy (transt, "tcp", strlen ("tcp"));
-
- cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- if (!glusterd_is_local_brick (this, volinfo, brickinfo))
- continue;
-
- xl = volgen_graph_build_client (graph, volinfo,
- brickinfo->hostname,
- brickinfo->path,
- brickinfo->brick_id,
- transt, set_dict);
- if (!xl) {
- ret = -1;
- goto out;
- }
- brick_count++;
- }
-
-
ret = volgen_link_bricks_from_list_tail (graph, volinfo, bitrot_args[0],
bitrot_args[1], brick_count,
brick_count);
@@ -4947,13 +4918,18 @@ out:
static int
build_bitd_volume_graph (volgen_graph_t *graph,
glusterd_volinfo_t *volinfo, dict_t *mod_dict,
- dict_t *set_dict, unsigned int numbricks)
+ unsigned int numbricks)
{
- volgen_graph_t cgraph = {0};
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- int ret = 0;
- int clusters = -1;
+ volgen_graph_t cgraph = {0};
+ xlator_t *this = NULL;
+ xlator_t *xl = NULL;
+ dict_t *set_dict = NULL;
+ glusterd_conf_t *priv = NULL;
+ int ret = 0;
+ int clusters = -1;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ int brick_count = 0;
+ char transt[16] = {0,};
this = THIS;
GF_ASSERT (this);
@@ -4961,11 +4937,43 @@ build_bitd_volume_graph (volgen_graph_t *graph,
priv = this->private;
GF_ASSERT (priv);
+ set_dict = dict_new ();
+ if (!set_dict) {
+ ret = -1;
+ goto out;
+ }
+
ret = prepare_bitrot_scrub_volume_options (volinfo, mod_dict, set_dict);
if (ret)
goto out;
- clusters = build_bitd_clusters (&cgraph, volinfo, set_dict, numbricks);
+ get_transport_type (volinfo, set_dict, transt, _gf_false);
+ if (!strncmp (transt, "tcp,rdma", strlen ("tcp,rdma")))
+ strncpy (transt, "tcp", strlen ("tcp"));
+
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ if (!glusterd_is_local_brick (this, volinfo, brickinfo))
+ continue;
+
+ xl = volgen_graph_build_client (&cgraph, volinfo,
+ brickinfo->hostname,
+ brickinfo->path,
+ brickinfo->brick_id,
+ transt, set_dict);
+ if (!xl) {
+ ret = -1;
+ goto out;
+ }
+ brick_count++;
+ }
+
+ if (brick_count == 0) {
+ ret = 0;
+ goto out;
+ }
+
+ clusters = build_bitd_clusters (&cgraph, volinfo, set_dict, brick_count,
+ numbricks);
if (clusters < 0) {
ret = -1;
goto out;
@@ -4976,7 +4984,11 @@ build_bitd_volume_graph (volgen_graph_t *graph,
goto out;
ret = graph_set_generic_options (this, graph, set_dict, "Bitrot");
+
out:
+ if (set_dict)
+ dict_unref (set_dict);
+
return ret;
}
@@ -4986,7 +4998,6 @@ build_bitd_graph (volgen_graph_t *graph, dict_t *mod_dict)
glusterd_volinfo_t *voliter = NULL;
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
- dict_t *set_dict = NULL;
int ret = 0;
gf_boolean_t valid_config = _gf_false;
xlator_t *iostxl = NULL;
@@ -4998,12 +5009,6 @@ build_bitd_graph (volgen_graph_t *graph, dict_t *mod_dict)
priv = this->private;
GF_ASSERT (priv);
- set_dict = dict_new ();
- if (!set_dict) {
- ret = -1;
- goto out;
- }
-
iostxl = volgen_graph_add_as (graph, "debug/io-stats", "bitd");
if (!iostxl) {
ret = -1;
@@ -5033,54 +5038,21 @@ build_bitd_graph (volgen_graph_t *graph, dict_t *mod_dict)
continue;
ret = build_bitd_volume_graph (graph, voliter,
- mod_dict, set_dict, numbricks);
- ret = dict_reset (set_dict);
- if (ret)
- goto out;
+ mod_dict, numbricks);
}
out:
- if (set_dict)
- dict_unref (set_dict);
-
return ret;
}
static int
build_scrub_clusters (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
- dict_t *set_dict)
+ dict_t *set_dict, int brick_count)
{
int ret = -1;
int clusters = 0;
xlator_t *xl = NULL;
- xlator_t *trav = NULL;
- xlator_t *this = NULL;
- char transt[16] = {0,};
- int brick_count = 0;
- glusterd_brickinfo_t *brickinfo = NULL;
char *scrub_args[] = {"features/bit-rot",
"%s-bit-rot-%d"};
- this = THIS;
- GF_ASSERT (this);
-
- get_transport_type (volinfo, set_dict, transt, _gf_false);
- if (!strncmp (transt, "tcp,rdma", strlen ("tcp,rdma")))
- strncpy (transt, "tcp", strlen ("tcp"));
-
- cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- if (!glusterd_is_local_brick (this, volinfo, brickinfo))
- continue;
-
- xl = volgen_graph_build_client (graph, volinfo,
- brickinfo->hostname,
- brickinfo->path,
- brickinfo->brick_id,
- transt, set_dict);
- if (!xl) {
- ret = -1;
- goto out;
- }
- brick_count++;
- }
ret = volgen_link_bricks_from_list_tail (graph, volinfo, scrub_args[0],
scrub_args[1], brick_count,
@@ -5102,13 +5074,18 @@ out:
static int
build_scrub_volume_graph (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
- dict_t *mod_dict, dict_t *set_dict)
-{
- volgen_graph_t cgraph = {0};
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- int ret = 0;
- int clusters = -1;
+ dict_t *mod_dict)
+{
+ volgen_graph_t cgraph = {0};
+ dict_t *set_dict = NULL;
+ xlator_t *this = NULL;
+ xlator_t *xl = NULL;
+ glusterd_conf_t *priv = NULL;
+ int ret = 0;
+ int clusters = -1;
+ int brick_count = 0;
+ char transt[16] = {0,};
+ glusterd_brickinfo_t *brickinfo = NULL;
this = THIS;
GF_ASSERT (this);
@@ -5116,11 +5093,43 @@ build_scrub_volume_graph (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
priv = this->private;
GF_ASSERT (priv);
+ set_dict = dict_new ();
+ if (!set_dict) {
+ ret = -1;
+ goto out;
+ }
+
ret = prepare_bitrot_scrub_volume_options (volinfo, mod_dict, set_dict);
if (ret)
goto out;
- clusters = build_scrub_clusters (&cgraph, volinfo, set_dict);
+ get_transport_type (volinfo, set_dict, transt, _gf_false);
+ if (!strncmp (transt, "tcp,rdma", strlen ("tcp,rdma")))
+ strncpy (transt, "tcp", strlen ("tcp"));
+
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ if (!glusterd_is_local_brick (this, volinfo, brickinfo))
+ continue;
+
+ xl = volgen_graph_build_client (&cgraph, volinfo,
+ brickinfo->hostname,
+ brickinfo->path,
+ brickinfo->brick_id,
+ transt, set_dict);
+ if (!xl) {
+ ret = -1;
+ goto out;
+ }
+ brick_count++;
+ }
+
+ if (brick_count == 0) {
+ ret = 0;
+ goto out;
+ }
+
+ clusters = build_scrub_clusters (&cgraph, volinfo, set_dict,
+ brick_count);
if (clusters < 0) {
ret = -1;
goto out;
@@ -5138,6 +5147,9 @@ build_scrub_volume_graph (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ret = graph_set_generic_options (this, graph, set_dict, "Scrubber");
out:
+ if (set_dict)
+ dict_unref (set_dict);
+
return ret;
}
@@ -5147,7 +5159,6 @@ build_scrub_graph (volgen_graph_t *graph, dict_t *mod_dict)
glusterd_volinfo_t *voliter = NULL;
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
- dict_t *set_dict = NULL;
int ret = 0;
gf_boolean_t valid_config = _gf_false;
xlator_t *iostxl = NULL;
@@ -5157,12 +5168,6 @@ build_scrub_graph (volgen_graph_t *graph, dict_t *mod_dict)
priv = this->private;
GF_ASSERT (priv);
- set_dict = dict_new ();
- if (!set_dict) {
- ret = -1;
- goto out;
- }
-
iostxl = volgen_graph_add_as (graph, "debug/io-stats", "scrub");
if (!iostxl) {
ret = -1;
@@ -5176,16 +5181,9 @@ build_scrub_graph (volgen_graph_t *graph, dict_t *mod_dict)
if (!glusterd_is_bitrot_enabled (voliter))
continue;
- ret = build_scrub_volume_graph (graph, voliter, mod_dict,
- set_dict);
- ret = dict_reset (set_dict);
- if (ret)
- goto out;
+ ret = build_scrub_volume_graph (graph, voliter, mod_dict);
}
out:
- if (set_dict)
- dict_unref (set_dict);
-
return ret;
}