summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr-common.c1
-rw-r--r--xlators/cluster/afr/src/afr-read-txn.c10
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c11
-rw-r--r--xlators/cluster/afr/src/afr.c11
-rw-r--r--xlators/cluster/afr/src/afr.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c4
6 files changed, 36 insertions, 2 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index c31fcba6c3b..a28cbf4a2a9 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -3561,6 +3561,7 @@ afr_priv_dump (xlator_t *this)
gf_proc_dump_write("read_child", "%d", priv->read_child);
gf_proc_dump_write("favorite_child", "%d", priv->favorite_child);
gf_proc_dump_write("wait_count", "%u", priv->wait_count);
+ gf_proc_dump_write("quorum-reads", "%d", priv->quorum_reads);
return 0;
}
diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c
index 29a926dbd97..ec67a20e624 100644
--- a/xlators/cluster/afr/src/afr-read-txn.c
+++ b/xlators/cluster/afr/src/afr-read-txn.c
@@ -195,6 +195,15 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode,
local->readfn = readfn;
local->inode = inode_ref (inode);
+ if (priv->quorum_reads &&
+ priv->quorum_count && !afr_has_quorum (priv->child_up, this)) {
+ local->op_ret = -1;
+ local->op_errno = ENOTCONN;
+ read_subvol = -1;
+ goto read;
+ }
+
+
local->transaction.type = type;
ret = afr_inode_read_subvol_type_get (inode, this, local->readable,
&event_generation, type);
@@ -232,6 +241,7 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode,
local->read_attempted[read_subvol] = 1;
+read:
local->readfn (frame, this, read_subvol);
return 0;
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 3cb073ecfc3..afa11bba7ab 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -28,6 +28,13 @@ int
afr_changelog_do (call_frame_t *frame, xlator_t *this, dict_t *xattr,
afr_changelog_resume_t changelog_resume);
+static int32_t
+afr_quorum_errno (afr_private_t *priv)
+{
+ if (priv->quorum_reads)
+ return ENOTCONN;
+ return EROFS;
+}
int
__afr_txn_write_fop (call_frame_t *frame, xlator_t *this)
@@ -558,7 +565,7 @@ afr_handle_quorum (call_frame_t *frame)
}
local->op_ret = -1;
- local->op_errno = EROFS;
+ local->op_errno = afr_quorum_errno (priv);
}
int
@@ -992,7 +999,7 @@ afr_changelog_pre_op (call_frame_t *frame, xlator_t *this)
* quorum number of nodes.
*/
if (priv->quorum_count && !afr_has_fop_quorum (frame)) {
- op_errno = EROFS;
+ op_errno = afr_quorum_errno (priv);
goto err;
}
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index bf7ba3fb0ac..f435767f5e4 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -211,6 +211,9 @@ reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("heal-timeout", priv->shd.timeout, options,
int32, out);
+ GF_OPTION_RECONF ("quorum-reads", priv->quorum_reads, options,
+ bool, out);
+
priv->did_discovery = _gf_false;
ret = 0;
@@ -359,6 +362,8 @@ init (xlator_t *this)
GF_OPTION_INIT ("iam-self-heal-daemon", priv->shd.iamshd, bool, out);
GF_OPTION_INIT ("heal-timeout", priv->shd.timeout, int32, out);
+ GF_OPTION_INIT ("quorum-reads", priv->quorum_reads, bool, out);
+
priv->wait_count = 1;
priv->child_up = GF_CALLOC (sizeof (unsigned char), child_count,
@@ -724,6 +729,12 @@ struct volume_options options[] = {
"this many bricks or present. Other quorum types "
"will OVERWRITE this value.",
},
+ { .key = {"quorum-reads"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "no",
+ .description = "If quorum-reads is \"true\" only allow reads if "
+ "quorum is met when quorum is enabled.",
+ },
{ .key = {"node-uuid"},
.type = GF_OPTION_TYPE_STR,
.description = "Local glusterd uuid string, used in starting "
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 8156eaa995e..dff70e89bb3 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -97,6 +97,7 @@ typedef struct _afr_private {
gf_boolean_t pre_op_compat; /* on/off */
uint32_t post_op_delay_secs;
unsigned int quorum_count;
+ gf_boolean_t quorum_reads;
char vol_uuid[UUID_SIZE + 1];
int32_t *last_event;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index e9473658176..e35a607cfc2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -1655,6 +1655,10 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.op_version = GD_OP_VERSION_3_7_0,
.validate_fn = validate_disperse_heal_enable_disable
},
+ { .key = "cluster.quorum-reads",
+ .voltype = "cluster/replicate",
+ .op_version = GD_OP_VERSION_3_7_0,
+ },
{ .key = NULL
}
};