summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendrabhat@gluster.com>2010-11-08 06:40:21 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-11-09 02:12:07 -0800
commit8205e939178ba2253117869024a306442b30d3d1 (patch)
treed19d66d2b8663ea69d921ee4a6a2c2b6ac776a4a /xlators/mgmt/glusterd/src/glusterd-utils.c
parente3808ac86f8ff5baebea59e610a791cef5f5f2c9 (diff)
check if the brick being added is the destination brick of replace brick
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2033 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2033
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index d5209f48d72..b6328663029 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2244,6 +2244,43 @@ glusterd_is_defrag_on (glusterd_volinfo_t *volinfo)
}
int
+glusterd_is_replace_running (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo)
+{
+ int ret = 0;
+ char *src_hostname = NULL;
+ char *brick_hostname = NULL;
+
+ if (volinfo->src_brick) {
+ src_hostname = gf_strdup (volinfo->src_brick->hostname);
+ if (!src_hostname) {
+ ret = -1;
+ goto out;
+ }
+ } else {
+ gf_log ("glusterd", GF_LOG_DEBUG,
+ "replace brick is not running");
+ goto out;
+ }
+
+ brick_hostname = gf_strdup (brickinfo->hostname);
+ if (!brick_hostname) {
+ ret = -1;
+ goto out;
+ }
+ if (!glusterd_is_local_addr (src_hostname) && !glusterd_is_local_addr (brick_hostname)) {
+ if (glusterd_is_rb_started (volinfo) || glusterd_is_rb_paused (volinfo))
+ ret = -1;
+ }
+
+out:
+ if (src_hostname)
+ GF_FREE (src_hostname);
+ if (brick_hostname)
+ GF_FREE (brick_hostname);
+ return ret;
+}
+
+int
glusterd_new_brick_validate (char *brick, glusterd_brickinfo_t *brickinfo,
char *op_errstr, size_t len)
{
@@ -2314,7 +2351,7 @@ out:
return ret;
}
-inline int
+int
glusterd_is_rb_started(glusterd_volinfo_t *volinfo)
{
gf_log ("", GF_LOG_DEBUG,
@@ -2323,7 +2360,7 @@ glusterd_is_rb_started(glusterd_volinfo_t *volinfo)
}
-inline int
+int
glusterd_is_rb_paused ( glusterd_volinfo_t *volinfo)
{
gf_log ("", GF_LOG_DEBUG,