summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr.c
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2012-06-24 16:17:21 +0200
committerAnand Avati <avati@redhat.com>2012-07-03 14:07:10 -0700
commit9781fea0dbde3faeeeb52451965de5d891e79bf2 (patch)
tree3fb0dd327d2fc6e2a3873da71af8efffd5e54d50 /xlators/cluster/afr/src/afr.c
parentfe4777660a0a92da6da582103690fa0c2e5c7496 (diff)
cluster/afr: add a new option to select read-subvol by index
read subvolume is a nice option to set prefred read child if you have a replication over 2 datacenter. if you have 2 datacenter and have a distributed replication where one set of servers are in datacenter one and the other (the replicated) are in the other datacenter read-subvolume it not very handy since it goes over name and the subvolume name is different for each replication pair. i added a new option called read-subvolume-index which take the number of the subvolume to choose. 0 fo first , 1 for second and so on subvolume in every replication. this option can now be used in the --xlator-option mount option to choose the prefered read child for all replication at once. For Example on all clients in datacenter one you can use --xlator-option=volumename-replication-*.read-subvolume-index=0 to prefer read from the servers in datacenter one. when you expand or shrink the volume no changes are needed to the client config since the wildcard will set this option automatic on reconfigure. Change-Id: I3b47432f77037c380ff4a6296636c6f8fc953db9 BUG: 837420 Original-author: domwo <glusterfs@wollina.de> Signed-off-by: domwo <glusterfs@wollina.de> Signed-off-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-on: http://review.gluster.com/3615 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr.c')
-rw-r--r--xlators/cluster/afr/src/afr.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index ebb9f1ee904..cd84c357da8 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -107,6 +107,7 @@ reconfigure (xlator_t *this, dict_t *options)
{
afr_private_t *priv = NULL;
xlator_t *read_subvol = NULL;
+ int read_subvol_index = -1;
int ret = -1;
int index = -1;
char *qtype = NULL;
@@ -162,6 +163,18 @@ reconfigure (xlator_t *this, dict_t *options)
priv->read_child = index;
}
+ GF_OPTION_RECONF ("read-subvolume-index",read_subvol_index, options,int32,out);
+
+ if (read_subvol_index >-1) {
+ index=read_subvol_index;
+ if (index >= priv->child_count) {
+ gf_log (this->name, GF_LOG_ERROR, "%d not a subvolume-index",
+ index);
+ goto out;
+ }
+ priv->read_child = index;
+ }
+
GF_OPTION_RECONF ("eager-lock", priv->eager_lock, options, bool, out);
GF_OPTION_RECONF ("quorum-type", qtype, options, str, out);
GF_OPTION_RECONF ("quorum-count", priv->quorum_count, options,
@@ -199,6 +212,7 @@ init (xlator_t *this)
int ret = -1;
GF_UNUSED int op_errno = 0;
xlator_t *read_subvol = NULL;
+ int read_subvol_index = -1;
xlator_t *fav_child = NULL;
char *qtype = NULL;
@@ -241,6 +255,15 @@ init (xlator_t *this)
goto out;
}
}
+ GF_OPTION_INIT ("read-subvolume-index",read_subvol_index,int32,out);
+ if (read_subvol_index > -1) {
+ if (read_subvol_index >= priv->child_count) {
+ gf_log (this->name, GF_LOG_ERROR, "%d not a subvolume-index",
+ read_subvol_index);
+ goto out;
+ }
+ priv->read_child = read_subvol_index;
+ }
GF_OPTION_INIT ("choose-local", priv->choose_local, bool, out);
GF_OPTION_INIT ("read-hash-mode", priv->hash_mode, uint32, out);
@@ -502,6 +525,10 @@ struct volume_options options[] = {
{ .key = {"read-subvolume" },
.type = GF_OPTION_TYPE_XLATOR
},
+ { .key = {"read-subvolume-index" },
+ .type = GF_OPTION_TYPE_INT,
+ .default_value = "-1",
+ },
{ .key = {"read-hash-mode" },
.type = GF_OPTION_TYPE_INT,
.min = 0,