|
|
12a457 |
From ca2e9d2a5888ffada7af77b0b8e62f524f1e041c Mon Sep 17 00:00:00 2001
|
|
|
12a457 |
From: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
Date: Wed, 11 May 2016 18:24:40 +0530
|
|
|
12a457 |
Subject: [PATCH 163/167] glusterd: copy real_path from older brickinfo during brick import
|
|
|
12a457 |
|
|
|
12a457 |
Backport of http://review.gluster.org/#/c/14306
|
|
|
12a457 |
http://review.gluster.org/#/c/14410
|
|
|
12a457 |
http://review.gluster.org/#/c/14411
|
|
|
12a457 |
|
|
|
12a457 |
In glusterd_import_new_brick() new_brickinfo->real_path will not be populated
|
|
|
12a457 |
for the first time and hence if the underlying file system is bad for the same
|
|
|
12a457 |
brick, import will fail resulting in inconsistent configuration data.
|
|
|
12a457 |
|
|
|
12a457 |
Fix is to populate real_path from old brickinfo object.
|
|
|
12a457 |
|
|
|
12a457 |
Also there were many cases where we were unnecessarily calling realpath() and
|
|
|
12a457 |
that may cause in failure. For eg - if a remove brick is executed with a brick
|
|
|
12a457 |
whoose underlying file system has crashed, remove-brick fails since realpath()
|
|
|
12a457 |
call fails. We'd need to call realpath() here as the value is of no use.Hence
|
|
|
12a457 |
passing construct_realpath as _gf_false in glusterd_volume_brickinfo_get_by_brick ()
|
|
|
12a457 |
is a must in such cases.
|
|
|
12a457 |
|
|
|
12a457 |
Note: This is not a straight forward backport. In upstream the code is little
|
|
|
12a457 |
different as glusterd_volinfo_copy_brick_portinfo () is called differently
|
|
|
12a457 |
compared to downstream since a patch http://review.gluster.org/13578 is not been
|
|
|
12a457 |
pulled in downstream. A straight forward backport would end up in a broken
|
|
|
12a457 |
functionality and hence downstream patch introduces a new function where the
|
|
|
12a457 |
functionality is seggregated for now to make it work.
|
|
|
12a457 |
|
|
|
12a457 |
This patch also fixes BZ 1335367 & 1335359
|
|
|
12a457 |
|
|
|
12a457 |
Change-Id: I7ec93871dc9e616f5d565ad5e540b2f1cacaf9dc
|
|
|
12a457 |
BUG: 1335357
|
|
|
12a457 |
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/74663
|
|
|
12a457 |
---
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 10 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-log-ops.c | 4 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-op-sm.c | 8 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-rebalance.c | 2 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 10 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-store.c | 3 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-utils.c | 128 +++++++++++++++-----
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-utils.h | 3 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-volgen.c | 3 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 4 +-
|
|
|
12a457 |
10 files changed, 122 insertions(+), 53 deletions(-)
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
|
|
|
12a457 |
index d27ea2b..77f2edf 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
|
|
|
12a457 |
@@ -1040,7 +1040,7 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick(brick, volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
snprintf (err_str, sizeof (err_str), "Incorrect brick "
|
|
|
12a457 |
@@ -1281,7 +1281,7 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
while ( i <= count) {
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_true, NULL);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -1493,7 +1493,7 @@ glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick,
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -1709,7 +1709,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_true, NULL);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
|
|
12a457 |
GD_MSG_BRICK_NOT_FOUND,
|
|
|
12a457 |
@@ -1833,7 +1833,7 @@ glusterd_remove_brick_validate_bricks (gf1_op_commands cmd, int32_t brick_count,
|
|
|
12a457 |
ret =
|
|
|
12a457 |
glusterd_volume_brickinfo_get_by_brick(brick, volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
snprintf (msg, sizeof (msg), "Incorrect brick "
|
|
|
12a457 |
"%s for volume %s", brick, volinfo->volname);
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
|
|
|
12a457 |
index 2ded2b4..af28a63 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
|
|
|
12a457 |
@@ -151,7 +151,7 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr)
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo, NULL,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
snprintf (msg, sizeof (msg), "Incorrect brick %s "
|
|
|
12a457 |
"for volume %s", brick, volname);
|
|
|
12a457 |
@@ -211,7 +211,7 @@ glusterd_op_log_rotate (dict_t *dict)
|
|
|
12a457 |
goto cont;
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (brick, &tmpbrkinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false, NULL);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
gf_msg ("glusterd", GF_LOG_ERROR, 0,
|
|
|
12a457 |
GD_MSG_BRICK_NOT_FOUND,
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
|
|
|
12a457 |
index a3a598a..bdb67b3 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
|
|
|
12a457 |
@@ -1729,7 +1729,7 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr)
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
snprintf (msg, sizeof(msg), "No brick %s in"
|
|
|
12a457 |
" volume %s", brick, volname);
|
|
|
12a457 |
@@ -3247,7 +3247,7 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (brick,
|
|
|
12a457 |
volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -5829,7 +5829,7 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr,
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
@@ -6689,7 +6689,7 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (brickname,
|
|
|
12a457 |
volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
|
|
|
12a457 |
index ff5790b..e40757e 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
|
|
|
12a457 |
@@ -608,7 +608,7 @@ glusterd_brick_validation (dict_t *dict, char *key, data_t *value,
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (value->data, volinfo,
|
|
|
12a457 |
&brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
gf_msg (this->name, GF_LOG_ERROR, EINVAL,
|
|
|
12a457 |
GD_MSG_BRICK_NOT_FOUND,
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
|
|
|
12a457 |
index 2295729..028024c 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
|
|
|
12a457 |
@@ -299,7 +299,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo,
|
|
|
12a457 |
&src_brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
snprintf (msg, sizeof (msg), "brick: %s does not exist in "
|
|
|
12a457 |
"volume: %s", src_brick, volname);
|
|
|
12a457 |
@@ -359,7 +359,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (dst_brick, &dst_brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_true, NULL);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -545,7 +545,7 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo,
|
|
|
12a457 |
GF_ASSERT (conf);
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (new_brick, &new_brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_true, NULL);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -556,7 +556,7 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo,
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (old_brick,
|
|
|
12a457 |
volinfo, &old_brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -676,7 +676,7 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo,
|
|
|
12a457 |
&src_brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
gf_msg_debug (this->name, 0,
|
|
|
12a457 |
"Unable to get src-brickinfo");
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
12a457 |
index 4408081..0ecaa71 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
12a457 |
@@ -169,7 +169,8 @@ glusterd_store_is_valid_brickpath (char *volname, char *brick)
|
|
|
12a457 |
this = THIS;
|
|
|
12a457 |
GF_ASSERT (this);
|
|
|
12a457 |
|
|
|
12a457 |
- ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo, _gf_true);
|
|
|
12a457 |
+ ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo, _gf_false,
|
|
|
12a457 |
+ NULL);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
12a457 |
GD_MSG_BRICK_CREATION_FAIL, "Failed to create brick "
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
12a457 |
index afa5fea..0573808 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
12a457 |
@@ -1065,7 +1065,8 @@ out:
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
glusterd_brickinfo_new_from_brick (char *brick,
|
|
|
12a457 |
glusterd_brickinfo_t **brickinfo,
|
|
|
12a457 |
- gf_boolean_t construct_real_path)
|
|
|
12a457 |
+ gf_boolean_t construct_real_path,
|
|
|
12a457 |
+ char **op_errstr)
|
|
|
12a457 |
{
|
|
|
12a457 |
char *hostname = NULL;
|
|
|
12a457 |
char *path = NULL;
|
|
|
12a457 |
@@ -1113,7 +1114,25 @@ glusterd_brickinfo_new_from_brick (char *brick,
|
|
|
12a457 |
strncpy (new_brickinfo->hostname, hostname, 1024);
|
|
|
12a457 |
strncpy (new_brickinfo->path, path, 1024);
|
|
|
12a457 |
|
|
|
12a457 |
- if (construct_real_path && new_brickinfo->real_path[0] == '\0') {
|
|
|
12a457 |
+ if (construct_real_path) {
|
|
|
12a457 |
+ ret = glusterd_hostname_to_uuid (new_brickinfo->hostname,
|
|
|
12a457 |
+ new_brickinfo->uuid);
|
|
|
12a457 |
+ if (ret) {
|
|
|
12a457 |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
12a457 |
+ GD_MSG_HOSTNAME_TO_UUID_FAIL,
|
|
|
12a457 |
+ "Failed to convert hostname %s to uuid",
|
|
|
12a457 |
+ hostname);
|
|
|
12a457 |
+ if (op_errstr)
|
|
|
12a457 |
+ gf_asprintf (op_errstr, "Host %s is not in \' "
|
|
|
12a457 |
+ "Peer in Cluster\' state",
|
|
|
12a457 |
+ new_brickinfo->hostname);
|
|
|
12a457 |
+ goto out;
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+
|
|
|
12a457 |
+ if (construct_real_path &&
|
|
|
12a457 |
+ !gf_uuid_compare (new_brickinfo->uuid, MY_UUID)
|
|
|
12a457 |
+ && new_brickinfo->real_path[0] == '\0') {
|
|
|
12a457 |
if (!realpath (new_brickinfo->path, abspath)) {
|
|
|
12a457 |
/* ENOENT indicates that brick path has not been created
|
|
|
12a457 |
* which is a valid scenario */
|
|
|
12a457 |
@@ -1439,7 +1458,7 @@ glusterd_volume_brickinfo_get_by_brick (char *brick,
|
|
|
12a457 |
GF_ASSERT (volinfo);
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (brick, &tmp_brickinfo,
|
|
|
12a457 |
- construct_real_path);
|
|
|
12a457 |
+ construct_real_path, NULL);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -3056,12 +3075,8 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count,
|
|
|
12a457 |
int decommissioned = 0;
|
|
|
12a457 |
glusterd_brickinfo_t *new_brickinfo = NULL;
|
|
|
12a457 |
char msg[2048] = {0};
|
|
|
12a457 |
- xlator_t *this = NULL;
|
|
|
12a457 |
char *brick_uuid_str = NULL;
|
|
|
12a457 |
- char abspath[PATH_MAX] = {0};
|
|
|
12a457 |
|
|
|
12a457 |
- this = THIS;
|
|
|
12a457 |
- GF_ASSERT (this);
|
|
|
12a457 |
GF_ASSERT (peer_data);
|
|
|
12a457 |
GF_ASSERT (vol_count >= 0);
|
|
|
12a457 |
GF_ASSERT (brickinfo);
|
|
|
12a457 |
@@ -3122,23 +3137,7 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count,
|
|
|
12a457 |
ret = dict_get_str (peer_data, key, &brick_uuid_str);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
-
|
|
|
12a457 |
gf_uuid_parse (brick_uuid_str, new_brickinfo->uuid);
|
|
|
12a457 |
- if (!gf_uuid_compare(new_brickinfo->uuid, MY_UUID)) {
|
|
|
12a457 |
- if (new_brickinfo->real_path[0] == '\0') {
|
|
|
12a457 |
- if (!realpath (new_brickinfo->path, abspath)) {
|
|
|
12a457 |
- gf_msg (this->name, GF_LOG_CRITICAL, errno,
|
|
|
12a457 |
- GD_MSG_BRICKINFO_CREATE_FAIL,
|
|
|
12a457 |
- "realpath() failed for brick %s. The "
|
|
|
12a457 |
- "underlying file system may be in bad "
|
|
|
12a457 |
- "state", new_brickinfo->path);
|
|
|
12a457 |
- ret = -1;
|
|
|
12a457 |
- goto out;
|
|
|
12a457 |
- }
|
|
|
12a457 |
- strncpy (new_brickinfo->real_path, abspath,
|
|
|
12a457 |
- strlen(abspath));
|
|
|
12a457 |
- }
|
|
|
12a457 |
- }
|
|
|
12a457 |
|
|
|
12a457 |
*brickinfo = new_brickinfo;
|
|
|
12a457 |
out:
|
|
|
12a457 |
@@ -3153,7 +3152,7 @@ out:
|
|
|
12a457 |
* It will be "volume" for normal volumes, and snap# like
|
|
|
12a457 |
* snap1, snap2, for snapshot volumes
|
|
|
12a457 |
*/
|
|
|
12a457 |
-int32_t
|
|
|
12a457 |
+static int32_t
|
|
|
12a457 |
glusterd_import_bricks (dict_t *peer_data, int32_t vol_count,
|
|
|
12a457 |
glusterd_volinfo_t *new_volinfo, char *prefix)
|
|
|
12a457 |
{
|
|
|
12a457 |
@@ -3363,6 +3362,7 @@ glusterd_import_volinfo (dict_t *peer_data, int count,
|
|
|
12a457 |
char *parent_volname = NULL;
|
|
|
12a457 |
char *volname = NULL;
|
|
|
12a457 |
glusterd_volinfo_t *new_volinfo = NULL;
|
|
|
12a457 |
+ glusterd_volinfo_t *old_volinfo = NULL;
|
|
|
12a457 |
char *volume_id_str = NULL;
|
|
|
12a457 |
char *restored_snap = NULL;
|
|
|
12a457 |
char msg[2048] = {0};
|
|
|
12a457 |
@@ -3780,9 +3780,70 @@ glusterd_volume_disconnect_all_bricks (glusterd_volinfo_t *volinfo)
|
|
|
12a457 |
return ret;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
+/* THIS FUNCTION IS CURRENTLY DOWNSTREAM ONLY, ONCE
|
|
|
12a457 |
+ * http://review.gluster.org/13578 IS BACKPORTED THIS FUNCTIONALITY SHOULD BE
|
|
|
12a457 |
+ * MOVED TO glusterd_volinfo_copy_brick_info () WHICH WILL BE IMPORTED BY THE
|
|
|
12a457 |
+ * MENTIONED PATCH
|
|
|
12a457 |
+ */
|
|
|
12a457 |
+static int32_t
|
|
|
12a457 |
+glusterd_volinfo_copy_brick_realpathinfo (glusterd_volinfo_t *old_volinfo,
|
|
|
12a457 |
+ glusterd_volinfo_t *new_volinfo)
|
|
|
12a457 |
+{
|
|
|
12a457 |
+ glusterd_brickinfo_t *new_brickinfo = NULL;
|
|
|
12a457 |
+ glusterd_brickinfo_t *old_brickinfo = NULL;
|
|
|
12a457 |
+ glusterd_conf_t *priv = NULL;
|
|
|
12a457 |
+ int ret = -1;
|
|
|
12a457 |
+ xlator_t *this = NULL;
|
|
|
12a457 |
+ char abspath[PATH_MAX] = {0};
|
|
|
12a457 |
+
|
|
|
12a457 |
+ this = THIS;
|
|
|
12a457 |
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
|
|
|
12a457 |
+
|
|
|
12a457 |
+ GF_VALIDATE_OR_GOTO (this->name, new_volinfo, out);
|
|
|
12a457 |
+ GF_VALIDATE_OR_GOTO (this->name, old_volinfo, out);
|
|
|
12a457 |
+
|
|
|
12a457 |
+ cds_list_for_each_entry (new_brickinfo, &new_volinfo->bricks,
|
|
|
12a457 |
+ brick_list) {
|
|
|
12a457 |
+ ret = glusterd_volume_brickinfo_get (new_brickinfo->uuid,
|
|
|
12a457 |
+ new_brickinfo->hostname,
|
|
|
12a457 |
+ new_brickinfo->path,
|
|
|
12a457 |
+ old_volinfo,
|
|
|
12a457 |
+ &old_brickinfo);
|
|
|
12a457 |
+ if (ret == 0) {
|
|
|
12a457 |
+ if (old_brickinfo->real_path == '\0') {
|
|
|
12a457 |
+ if (!realpath (new_brickinfo->path, abspath)) {
|
|
|
12a457 |
+ /* Here an ENOENT should also be a
|
|
|
12a457 |
+ * failure as the brick is expected to
|
|
|
12a457 |
+ * be in existance
|
|
|
12a457 |
+ */
|
|
|
12a457 |
+ gf_msg (this->name, GF_LOG_CRITICAL,
|
|
|
12a457 |
+ errno,
|
|
|
12a457 |
+ GD_MSG_BRICKINFO_CREATE_FAIL,
|
|
|
12a457 |
+ "realpath () failed for brick "
|
|
|
12a457 |
+ "%s. The underlying filesystem "
|
|
|
12a457 |
+ "may be in bad state",
|
|
|
12a457 |
+ new_brickinfo->path);
|
|
|
12a457 |
+ ret = -1;
|
|
|
12a457 |
+ goto out;
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+ strncpy (new_brickinfo->real_path, abspath,
|
|
|
12a457 |
+ strlen(abspath));
|
|
|
12a457 |
+ } else {
|
|
|
12a457 |
+ strncpy (new_brickinfo->real_path,
|
|
|
12a457 |
+ old_brickinfo->real_path,
|
|
|
12a457 |
+ strlen (old_brickinfo->real_path));
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+
|
|
|
12a457 |
+out:
|
|
|
12a457 |
+ return ret;
|
|
|
12a457 |
+
|
|
|
12a457 |
+}
|
|
|
12a457 |
+
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
-glusterd_volinfo_copy_brick_portinfo (glusterd_volinfo_t *new_volinfo,
|
|
|
12a457 |
- glusterd_volinfo_t *old_volinfo)
|
|
|
12a457 |
+glusterd_volinfo_copy_brick_portinfo (glusterd_volinfo_t *old_volinfo,
|
|
|
12a457 |
+ glusterd_volinfo_t *new_volinfo)
|
|
|
12a457 |
{
|
|
|
12a457 |
char pidfile[PATH_MAX+1] = {0,};
|
|
|
12a457 |
glusterd_brickinfo_t *new_brickinfo = NULL;
|
|
|
12a457 |
@@ -3790,6 +3851,7 @@ glusterd_volinfo_copy_brick_portinfo (glusterd_volinfo_t *new_volinfo,
|
|
|
12a457 |
glusterd_conf_t *priv = NULL;
|
|
|
12a457 |
int ret = 0;
|
|
|
12a457 |
xlator_t *this = NULL;
|
|
|
12a457 |
+ char abspath[PATH_MAX] = {0};
|
|
|
12a457 |
|
|
|
12a457 |
GF_ASSERT (new_volinfo);
|
|
|
12a457 |
GF_ASSERT (old_volinfo);
|
|
|
12a457 |
@@ -3816,8 +3878,8 @@ glusterd_volinfo_copy_brick_portinfo (glusterd_volinfo_t *new_volinfo,
|
|
|
12a457 |
|
|
|
12a457 |
}
|
|
|
12a457 |
}
|
|
|
12a457 |
+
|
|
|
12a457 |
out:
|
|
|
12a457 |
- ret = 0;
|
|
|
12a457 |
return ret;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
@@ -4006,8 +4068,8 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count)
|
|
|
12a457 |
glusterd_volinfo_t *old_volinfo = NULL;
|
|
|
12a457 |
glusterd_volinfo_t *new_volinfo = NULL;
|
|
|
12a457 |
glusterd_svc_t *svc = NULL;
|
|
|
12a457 |
- gf_boolean_t newexportvalue;
|
|
|
12a457 |
- gf_boolean_t oldexportvalue;
|
|
|
12a457 |
+ gf_boolean_t newexportvalue = _gf_false;
|
|
|
12a457 |
+ gf_boolean_t oldexportvalue = _gf_false;
|
|
|
12a457 |
char *value = NULL;
|
|
|
12a457 |
|
|
|
12a457 |
GF_ASSERT (peer_data);
|
|
|
12a457 |
@@ -4033,6 +4095,10 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count)
|
|
|
12a457 |
|
|
|
12a457 |
(void) gd_check_and_update_rebalance_info (old_volinfo,
|
|
|
12a457 |
new_volinfo);
|
|
|
12a457 |
+
|
|
|
12a457 |
+ /* Copy real_path from the old volinfo always */
|
|
|
12a457 |
+ (void) glusterd_volinfo_copy_brick_realpathinfo (old_volinfo,
|
|
|
12a457 |
+ new_volinfo);
|
|
|
12a457 |
(void) glusterd_delete_stale_volume (old_volinfo, new_volinfo);
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
@@ -5847,7 +5913,7 @@ glusterd_new_brick_validate (char *brick, glusterd_brickinfo_t *brickinfo,
|
|
|
12a457 |
|
|
|
12a457 |
if (!brickinfo) {
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (brick, &newbrickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_true, NULL);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
is_allocated = _gf_true;
|
|
|
12a457 |
@@ -10196,7 +10262,7 @@ gd_should_i_start_rebalance (glusterd_volinfo_t *volinfo) {
|
|
|
12a457 |
ret = glusterd_volume_brickinfo_get_by_brick (brickname,
|
|
|
12a457 |
volinfo,
|
|
|
12a457 |
&brick,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_false);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
if (gf_uuid_compare (MY_UUID, brick->uuid) == 0) {
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
12a457 |
index 9f8a64f..b508b01 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
12a457 |
@@ -120,7 +120,8 @@ glusterd_brickinfo_new (glusterd_brickinfo_t **brickinfo);
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
glusterd_brickinfo_new_from_brick (char *brick,
|
|
|
12a457 |
glusterd_brickinfo_t **brickinfo,
|
|
|
12a457 |
- gf_boolean_t construct_real_path);
|
|
|
12a457 |
+ gf_boolean_t construct_real_path,
|
|
|
12a457 |
+ char **op_errstr);
|
|
|
12a457 |
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo);
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
12a457 |
index 4a29d26..8617482 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
12a457 |
@@ -4867,7 +4867,8 @@ glusterd_is_valid_volfpath (char *volname, char *brick)
|
|
|
12a457 |
this = THIS;
|
|
|
12a457 |
GF_ASSERT (this);
|
|
|
12a457 |
|
|
|
12a457 |
- ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo, _gf_true);
|
|
|
12a457 |
+ ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo, _gf_false,
|
|
|
12a457 |
+ NULL);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
12a457 |
GD_MSG_BRICKINFO_CREATE_FAIL,
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
12a457 |
index 3dc0d3f..50870cc 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
12a457 |
@@ -1227,7 +1227,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (brick, &brick_info,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_true, op_errstr);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -2300,7 +2300,7 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
while ( i <= count) {
|
|
|
12a457 |
ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo,
|
|
|
12a457 |
- _gf_true);
|
|
|
12a457 |
+ _gf_true, op_errstr);
|
|
|
12a457 |
if (ret)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
--
|
|
|
12a457 |
1.7.1
|
|
|
12a457 |
|