diff options
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-common.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 73d7e94b5cf..fff2a06f927 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -1533,3 +1533,32 @@ afr_throttled_selfheal (call_frame_t *frame, xlator_t *this) "pending, background self-heal rejected."); } } + +int +afr_choose_source_by_policy (afr_private_t *priv, unsigned char *sources, + afr_transaction_type type) +{ + int source = -1; + int i = 0; + + /* Give preference to local child to save on bandwidth */ + for (i = 0; i < priv->child_count; i++) { + if (priv->local[i] && sources[i]) { + if ((type == AFR_DATA_TRANSACTION) && + AFR_IS_ARBITER_BRICK (priv, i)) + continue; + + source = i; + goto out; + } + } + + for (i = 0; i < priv->child_count; i++) { + if (sources[i]) { + source = i; + goto out; + } + } +out: + return source; +} |