summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-03-24 20:44:07 +0000
committerJeff Darcy <jdarcy@redhat.com>2014-03-24 20:44:07 +0000
commitefbb23837761bda6c526baca1b5ea72d227e2ae3 (patch)
tree728199c73595103d7561dd9d441bdbe1845c6331 /xlators/mgmt/glusterd/src/glusterd-utils.c
parenta58b023443b7a2ec089c45bf35bde2b0108aa19b (diff)
parent17454dfea9f3c4d47fcf0b5370a6155f639c8aeb (diff)
Merge branch 'upstream'
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 1eb03f1de..1f278ca84 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -671,6 +671,30 @@ out:
return ret;
}
+int
+glusterd_get_next_available_brickid (glusterd_volinfo_t *volinfo)
+{
+ glusterd_brickinfo_t *brickinfo = NULL;
+ char *token = NULL;
+ int brickid = 0;
+ int max_brickid = -1;
+ int ret = -1;
+
+ list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ token = strrchr (brickinfo->brick_id, '-');
+ ret = gf_string2int32 (++token, &brickid);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Unable to generate brick ID");
+ return ret;
+ }
+ if (brickid > max_brickid)
+ max_brickid = brickid;
+ }
+
+ return max_brickid + 1 ;
+}
+
int32_t
glusterd_resolve_brick (glusterd_brickinfo_t *brickinfo)
{
@@ -956,7 +980,7 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,
goto out;
}
else if (parent_st.st_dev == root_st.st_dev) {
- snprintf (msg, sizeof (msg), "The brick %s:%s is "
+ snprintf (msg, sizeof (msg), "The brick %s:%s "
"is being created in the root partition. It "
"is recommended that you don't use the "
"system's root partition for storage backend."
@@ -2134,6 +2158,13 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.brick%d.brick_id",
+ count, i);
+ ret = dict_set_str (dict, key, brickinfo->brick_id);
+ if (ret)
+ goto out;
+
i++;
}
@@ -2148,6 +2179,13 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo,
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "volume%d.client-op-version", count);
ret = dict_set_int32 (dict, key, volinfo->client_op_version);
+ if (ret)
+ goto out;
+
+ /*Add volume Capability (BD Xlator) to dict*/
+ memset (key, 0 ,sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.caps", count);
+ ret = dict_set_int32 (dict, key, volinfo->caps);
out:
GF_FREE (volume_id_str);
@@ -2801,6 +2839,7 @@ glusterd_import_new_brick (dict_t *vols, int32_t vol_count,
int ret = -1;
char *hostname = NULL;
char *path = NULL;
+ char *brick_id = NULL;
int decommissioned = 0;
glusterd_brickinfo_t *new_brickinfo = NULL;
char msg[2048] = {0};
@@ -2828,6 +2867,11 @@ glusterd_import_new_brick (dict_t *vols, int32_t vol_count,
}
memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.brick%d.brick_id",
+ vol_count, brick_count);
+ ret = dict_get_str (vols, key, &brick_id);
+
+ memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "volume%d.brick%d.decommissioned",
vol_count, brick_count);
ret = dict_get_int32 (vols, key, &decommissioned);
@@ -2843,6 +2887,8 @@ glusterd_import_new_brick (dict_t *vols, int32_t vol_count,
strcpy (new_brickinfo->path, path);
strcpy (new_brickinfo->hostname, hostname);
new_brickinfo->decommissioned = decommissioned;
+ if (brick_id)
+ strcpy (new_brickinfo->brick_id, brick_id);
//peerinfo might not be added yet
(void) glusterd_resolve_brick (new_brickinfo);
ret = 0;
@@ -2860,6 +2906,7 @@ glusterd_import_bricks (dict_t *vols, int32_t vol_count,
{
int ret = -1;
int brick_count = 1;
+ int brickid = 0;
glusterd_brickinfo_t *new_brickinfo = NULL;
GF_ASSERT (vols);
@@ -2871,6 +2918,12 @@ glusterd_import_bricks (dict_t *vols, int32_t vol_count,
&new_brickinfo);
if (ret)
goto out;
+ if (new_brickinfo->brick_id[0] == '\0')
+ /*We were probed from a peer having op-version
+ less than GD_OP_VER_PERSISTENT_AFR_XATTRS*/
+ GLUSTERD_ASSIGN_BRICKID_TO_BRICKINFO (new_brickinfo,
+ new_volinfo,
+ brickid++);
list_add_tail (&new_brickinfo->brick_list, &new_volinfo->bricks);
brick_count++;
}
@@ -3306,6 +3359,11 @@ glusterd_import_volinfo (dict_t *vols, int count,
new_volinfo->client_op_version = 1;
}
+ memset (key, 0 ,sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.caps", count);
+ /*This is not present in older glusterfs versions, so ignore ret value*/
+ ret = dict_get_int32 (vols, key, &new_volinfo->caps);
+
ret = glusterd_import_bricks (vols, count, new_volinfo);
if (ret)
goto out;