diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 70 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.c | 180 |
2 files changed, 126 insertions, 124 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 710087a554a..50d266fd634 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -145,7 +145,7 @@ afr_sh_build_pending_matrix (afr_private_t *priv, for (j = 0; j < child_count; j++) { ret = dict_get_ptr (xattr[i], priv->pending_key[j], &pending_raw); - + if (ret != 0) { /* * There is no xattr present. This means this @@ -159,7 +159,7 @@ afr_sh_build_pending_matrix (afr_private_t *priv, memcpy (pending, pending_raw, sizeof(pending)); k = afr_index_for_transaction_type (type); - + pending_matrix[i][j] = ntoh32 (pending[k]); } } @@ -198,7 +198,7 @@ afr_sh_build_pending_matrix (afr_private_t *priv, * All 'innocent' nodes are sinks. If all nodes are innocent, no self-heal is * needed. * - * A 'wise' node can be a source. If two 'wise' nodes conflict, it is + * A 'wise' node can be a source. If two 'wise' nodes conflict, it is * a split-brain. If one wise node refers to the other but the other doesn't * refer back, the referrer is a source. * @@ -250,7 +250,7 @@ afr_sh_is_wise (int32_t *array, int i, int child_count) static int -afr_sh_all_nodes_innocent (afr_node_character *characters, +afr_sh_all_nodes_innocent (afr_node_character *characters, int child_count) { int i = 0; @@ -286,7 +286,7 @@ afr_sh_wise_nodes_exist (afr_node_character *characters, int child_count) /* * The 'wisdom' of a wise node is 0 if any other wise node accuses it. - * It is 1 if no other wise node accuses it. + * It is 1 if no other wise node accuses it. * Only wise nodes with wisdom 1 are sources. * * If no nodes with wisdom 1 exist, a split-brain has occured. @@ -306,7 +306,7 @@ afr_sh_compute_wisdom (int32_t *pending_matrix[], for (j = 0; j < child_count; j++) { if ((characters[j].type == AFR_NODE_WISE) && pending_matrix[j][i]) { - + characters[i].wisdom = 0; } } @@ -316,7 +316,7 @@ afr_sh_compute_wisdom (int32_t *pending_matrix[], static int -afr_sh_wise_nodes_conflict (afr_node_character *characters, +afr_sh_wise_nodes_conflict (afr_node_character *characters, int child_count) { int i = 0; @@ -337,12 +337,12 @@ afr_sh_wise_nodes_conflict (afr_node_character *characters, static int -afr_sh_mark_wisest_as_sources (int sources[], - afr_node_character *characters, +afr_sh_mark_wisest_as_sources (int sources[], + afr_node_character *characters, int child_count) { int nsources = 0; - + int i = 0; for (i = 0; i < child_count; i++) { @@ -386,10 +386,10 @@ afr_sh_mark_if_size_differs (afr_self_heal_t *sh, int child_count) return size_differs; } - + static int afr_sh_mark_biggest_fool_as_source (afr_self_heal_t *sh, - afr_node_character *characters, + afr_node_character *characters, int child_count) { int i = 0; @@ -480,7 +480,7 @@ afr_sh_mark_sources (afr_self_heal_t *sh, int child_count, /* stores the 'characters' (innocent, fool, wise) of the nodes */ afr_node_character * - characters = GF_CALLOC (sizeof (afr_node_character), + characters = GF_CALLOC (sizeof (afr_node_character), child_count, gf_afr_mt_afr_node_character) ; @@ -488,7 +488,7 @@ afr_sh_mark_sources (afr_self_heal_t *sh, int child_count, for (i = 0; i < child_count; i++) { sources[i] = 0; } - + for (i = 0; i < child_count; i++) { if (afr_sh_is_innocent (pending_matrix[i], child_count)) { characters[i].type = AFR_NODE_INNOCENT; @@ -535,7 +535,7 @@ afr_sh_mark_sources (afr_self_heal_t *sh, int child_count, goto out; } else { - nsources = afr_sh_mark_wisest_as_sources (sources, + nsources = afr_sh_mark_wisest_as_sources (sources, characters, child_count); } @@ -691,7 +691,7 @@ afr_sh_has_data_pending (dict_t *xattr, int child_count, xlator_t *this) if (ret != 0) return 0; - + memcpy (pending, pending_raw, sizeof(pending)); j = afr_index_for_transaction_type (AFR_DATA_TRANSACTION); @@ -723,7 +723,7 @@ afr_sh_has_entry_pending (dict_t *xattr, int child_count, xlator_t *this) if (ret != 0) return 0; - + memcpy (pending, pending_raw, sizeof(pending)); j = afr_index_for_transaction_type (AFR_ENTRY_TRANSACTION); @@ -744,9 +744,9 @@ afr_sh_is_matrix_zero (int32_t *pending_matrix[], int child_count) { int i, j; - for (i = 0; i < child_count; i++) - for (j = 0; j < child_count; j++) - if (pending_matrix[i][j]) + for (i = 0; i < child_count; i++) + for (j = 0; j < child_count; j++) + if (pending_matrix[i][j]) return 0; return 1; } @@ -834,11 +834,11 @@ sh_destroy_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } call_count = afr_frame_return (frame); - + if (call_count == 0) { STACK_DESTROY (frame->root); } - + return 0; } @@ -876,13 +876,13 @@ sh_missing_entries_newentry_cbk (call_frame_t *frame, void *cookie, stbuf.ia_uid = sh->buf[sh->source].ia_uid; stbuf.ia_gid = sh->buf[sh->source].ia_gid; - + valid = GF_SET_ATTR_UID | GF_SET_ATTR_GID | GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME; - + if (op_ret == 0) { setattr_frame = copy_frame (frame); - + setattr_frame->local = GF_CALLOC (1, sizeof (afr_local_t), gf_afr_mt_afr_local_t); @@ -899,7 +899,7 @@ sh_missing_entries_newentry_cbk (call_frame_t *frame, void *cookie, &local->loc, &stbuf, valid); valid = GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME; - parent_loc = GF_CALLOC (1, sizeof (*parent_loc), + parent_loc = GF_CALLOC (1, sizeof (*parent_loc), gf_afr_mt_loc_t); afr_build_parent_loc (parent_loc, &local->loc); @@ -1504,19 +1504,21 @@ int afr_self_heal_completion_cbk (call_frame_t *bgsh_frame, xlator_t *this) { afr_private_t * priv = NULL; - afr_local_t * local = NULL; + afr_local_t * local = NULL; afr_self_heal_t * sh = NULL; char sh_type_str[256] = {0,}; priv = this->private; - local = bgsh_frame->local; + local = bgsh_frame->local; sh = &local->self_heal; - if (local->govinda_gOvinda) { - afr_set_split_brain (this, local->cont.lookup.inode, _gf_true); - } else { - afr_set_split_brain (this, local->cont.lookup.inode, _gf_false); - } + if (local->govinda_gOvinda) { + afr_set_split_brain (this, local->cont.lookup.inode, + _gf_true); + } else { + afr_set_split_brain (this, local->cont.lookup.inode, + _gf_false); + } afr_self_heal_type_str_get(sh, sh_type_str, sizeof(sh_type_str)); @@ -1601,7 +1603,7 @@ afr_self_heal (call_frame_t *frame, xlator_t *this) gf_afr_mt_dict_t); sh->sources = GF_CALLOC (sizeof (*sh->sources), priv->child_count, gf_afr_mt_int); - sh->locked_nodes = GF_CALLOC (sizeof (*sh->locked_nodes), + sh->locked_nodes = GF_CALLOC (sizeof (*sh->locked_nodes), priv->child_count, gf_afr_mt_int); diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index 02dbf717a55..3aa035c1712 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -63,18 +63,18 @@ int validate_options (xlator_t *this, dict_t *options, char **op_errstr) { - - gf_boolean_t metadata_self_heal; + + gf_boolean_t metadata_self_heal; gf_boolean_t entry_self_heal; gf_boolean_t data_self_heal; - gf_boolean_t data_change_log; - gf_boolean_t metadata_change_log; - gf_boolean_t entry_change_log; + gf_boolean_t data_change_log; + gf_boolean_t metadata_change_log; + gf_boolean_t entry_change_log; gf_boolean_t strict_readdir; gf_boolean_t optimistic_change_log; xlator_list_t * trav = NULL; - + char * read_subvol = NULL; char * self_heal = NULL; char * change_log = NULL; @@ -89,9 +89,9 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) int flag = 1; int ret = 0; int temp_ret = -1; - - + + dict_ret = dict_get_int32 (options, "background-self-heal-count", &background_count); if (dict_ret == 0) { @@ -113,13 +113,13 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) if (temp_ret < 0) { gf_log (this->name, GF_LOG_WARNING, "validation failed 'option metadata" - "-self-heal %s'.not correct.", + "-self-heal %s'.not correct.", self_heal); *op_errstr = gf_strdup ("Error, option should be boolean"); ret = -1; goto out; - } - + } + } dict_ret = dict_get_str (options, "data-self-heal", @@ -134,8 +134,8 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) "boolean"); ret = -1; goto out; - } - + } + gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring 'option data" @@ -149,14 +149,14 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) if (temp_ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Validation faled for entry-self-heal" - " (given string = %s)", + " (given string = %s)", self_heal); *op_errstr = gf_strdup ("Error, option should be " "boolean"); ret = -1; goto out; - } - + } + gf_log (this->name, GF_LOG_DEBUG, "Validated 'option entry" @@ -177,7 +177,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) ret = -1; goto out; } - + gf_log (this->name, GF_LOG_DEBUG, "Validated 'option strict" @@ -218,7 +218,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) ret = -1; goto out; } - + gf_log (this->name, GF_LOG_DEBUG, "Validated 'option data-" @@ -237,8 +237,8 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) "boolean"); ret = -1; goto out; - } - + } + gf_log (this->name, GF_LOG_DEBUG, "Validated 'option metadata-" @@ -256,7 +256,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) "boolean"); ret = -1; goto out; - } + } gf_log (this->name, GF_LOG_DEBUG, @@ -278,7 +278,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) ret = -1; goto out; } - + gf_log (this->name, GF_LOG_DEBUG, "Validated 'option optimistic-" @@ -306,9 +306,9 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr) read_ret = dict_get_str (options, "read-subvolume", &read_subvol); - if (read_ret) + if (read_ret) goto next;// No need to traverse, hence set the next option - + trav = this->children; flag = 0; while (trav) { @@ -354,7 +354,7 @@ reconfigure (xlator_t *this, dict_t *options) afr_private_t * priv = NULL; xlator_list_t * trav = NULL; - + char * read_subvol = NULL; char * self_heal = NULL; char * change_log = NULL; @@ -369,9 +369,9 @@ reconfigure (xlator_t *this, dict_t *options) int flag = 1; int ret = 0; int temp_ret = -1; - + priv = this->private; - + dict_ret = dict_get_int32 (options, "background-self-heal-count", &background_count); if (dict_ret == 0) { @@ -389,16 +389,16 @@ reconfigure (xlator_t *this, dict_t *options) if (temp_ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Reconfiguration Invalid 'option metadata" - "-self-heal %s'. Defaulting to old value.", + "-self-heal %s'. Defaulting to old value.", self_heal); ret = -1; goto out; - } - + } + priv->metadata_self_heal = metadata_self_heal; gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring 'option metadata" - "-self-heal %s'.", + "-self-heal %s'.", self_heal); } @@ -409,12 +409,12 @@ reconfigure (xlator_t *this, dict_t *options) if (temp_ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Reconfiguration Invalid 'option data" - "-self-heal %s'. Defaulting to old value.", + "-self-heal %s'. Defaulting to old value.", self_heal); ret = -1; goto out; - } - + } + priv->data_self_heal = data_self_heal; gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring 'option data" @@ -428,12 +428,12 @@ reconfigure (xlator_t *this, dict_t *options) if (temp_ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Reconfiguration Invalid 'option data" - "-self-heal %s'. Defaulting to old value.", + "-self-heal %s'. Defaulting to old value.", self_heal); ret = -1; goto out; - } - + } + priv->entry_self_heal = entry_self_heal; gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring 'option entry" @@ -453,7 +453,7 @@ reconfigure (xlator_t *this, dict_t *options) ret = -1; goto out; } - + priv->strict_readdir = strict_readdir; gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring 'option strict" @@ -472,7 +472,7 @@ reconfigure (xlator_t *this, dict_t *options) else { priv->data_self_heal_window_size = 16; } - + dict_ret = dict_get_str (options, "data-change-log", &change_log); @@ -481,12 +481,12 @@ reconfigure (xlator_t *this, dict_t *options) if (temp_ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Reconfiguration Invalid 'option data-" - "change-log %s'. Defaulting to old value.", + "change-log %s'. Defaulting to old value.", change_log); ret = -1; goto out; } - + priv->data_change_log = data_change_log; gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring 'option data-" @@ -505,8 +505,8 @@ reconfigure (xlator_t *this, dict_t *options) change_log); ret = -1; goto out; - } - + } + priv->metadata_change_log = metadata_change_log; gf_log (this->name, GF_LOG_DEBUG, "Reconfiguring 'option metadata-" @@ -520,11 +520,11 @@ reconfigure (xlator_t *this, dict_t *options) if (temp_ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Invalid 'option entry-change-log %s'. " - "Defaulting to entry-change-log as 'on'.", + "Defaulting to entry-change-log as 'on'.", change_log); ret = -1; goto out; - } + } priv->entry_change_log = entry_change_log; gf_log (this->name, GF_LOG_DEBUG, @@ -563,9 +563,9 @@ reconfigure (xlator_t *this, dict_t *options) read_ret = dict_get_str (options, "read-subvolume", &read_subvol); - if (read_ret < 0) + if (read_ret < 0) goto next;// No need to traverse, hence set the next option - + trav = this->children; flag = 0; while (trav) { @@ -575,11 +575,11 @@ reconfigure (xlator_t *this, dict_t *options) trav->xlator->name); flag = 1; - ret = -1; + ret = -1; goto out; } - + trav = trav->next; } @@ -616,7 +616,7 @@ static const char *no_lock_servers_warning_str = "You have set lock-server-count "RESPONSIBLE for inconsistent data. If you are in doubt, set it to a value " "greater than 0."; -int32_t +int32_t init (xlator_t *this) { afr_private_t * priv = NULL; @@ -650,7 +650,7 @@ init (xlator_t *this) "subvolume defined."); return -1; } - + if (!this->parents) { gf_log (this->name, GF_LOG_WARNING, "Volume is dangling."); @@ -725,10 +725,10 @@ init (xlator_t *this) if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Invalid 'option metadata-self-heal %s'. " - "Defaulting to metadata-self-heal as 'on'.", + "Defaulting to metadata-self-heal as 'on'.", self_heal); priv->metadata_self_heal = 1; - } + } } dict_ret = dict_get_str (this->options, "entry-self-heal", &self_heal); @@ -737,10 +737,10 @@ init (xlator_t *this) if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Invalid 'option entry-self-heal %s'. " - "Defaulting to entry-self-heal as 'on'.", + "Defaulting to entry-self-heal as 'on'.", self_heal); priv->entry_self_heal = 1; - } + } } /* Change log options */ @@ -757,10 +757,10 @@ init (xlator_t *this) if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Invalid 'option data-change-log %s'. " - "Defaulting to data-change-log as 'on'.", + "Defaulting to data-change-log as 'on'.", change_log); priv->data_change_log = 1; - } + } } dict_ret = dict_get_str (this->options, "metadata-change-log", @@ -774,7 +774,7 @@ init (xlator_t *this) "Defaulting to metadata-change-log as 'off'.", change_log); priv->metadata_change_log = 0; - } + } } dict_ret = dict_get_str (this->options, "entry-change-log", @@ -784,10 +784,10 @@ init (xlator_t *this) if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Invalid 'option entry-change-log %s'. " - "Defaulting to entry-change-log as 'on'.", + "Defaulting to entry-change-log as 'on'.", change_log); priv->entry_change_log = 1; - } + } } dict_ret = dict_get_str (this->options, "optimistic-change-log", @@ -797,10 +797,10 @@ init (xlator_t *this) if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Invalid 'option optimistic-change-log %s'. " - "Defaulting to optimistic-change-log as 'on'.", + "Defaulting to optimistic-change-log as 'on'.", change_log); priv->optimistic_change_log = 1; - } + } } /* Locking options */ @@ -840,14 +840,14 @@ init (xlator_t *this) priv->metadata_lock_server_count = 0; priv->entry_lock_server_count = 1; - dict_ret = dict_get_int32 (this->options, "data-lock-server-count", + dict_ret = dict_get_int32 (this->options, "data-lock-server-count", &lock_server_count); if (dict_ret == 0) { gf_log (this->name, GF_LOG_DEBUG, "Setting data lock server count to %d.", lock_server_count); - if (lock_server_count == 0) + if (lock_server_count == 0) gf_log (this->name, GF_LOG_WARNING, "%s", no_lock_servers_warning_str); @@ -856,7 +856,7 @@ init (xlator_t *this) dict_ret = dict_get_int32 (this->options, - "metadata-lock-server-count", + "metadata-lock-server-count", &lock_server_count); if (dict_ret == 0) { gf_log (this->name, GF_LOG_DEBUG, @@ -866,7 +866,7 @@ init (xlator_t *this) } - dict_ret = dict_get_int32 (this->options, "entry-lock-server-count", + dict_ret = dict_get_int32 (this->options, "entry-lock-server-count", &lock_server_count); if (dict_ret == 0) { gf_log (this->name, GF_LOG_DEBUG, @@ -921,8 +921,8 @@ init (xlator_t *this) priv->child_up = GF_CALLOC (sizeof (unsigned char), child_count, gf_afr_mt_char); if (!priv->child_up) { - gf_log (this->name, GF_LOG_ERROR, - "Out of memory."); + gf_log (this->name, GF_LOG_ERROR, + "Out of memory."); ret = -ENOMEM; goto out; } @@ -937,13 +937,13 @@ init (xlator_t *this) priv->children = GF_CALLOC (sizeof (xlator_t *), child_count, gf_afr_mt_xlator_t); if (!priv->children) { - gf_log (this->name, GF_LOG_ERROR, - "Out of memory."); + gf_log (this->name, GF_LOG_ERROR, + "Out of memory."); ret = -ENOMEM; goto out; } - priv->pending_key = GF_CALLOC (sizeof (*priv->pending_key), + priv->pending_key = GF_CALLOC (sizeof (*priv->pending_key), child_count, gf_afr_mt_char); if (!priv->pending_key) { @@ -958,11 +958,11 @@ init (xlator_t *this) while (i < child_count) { priv->children[i] = trav->xlator; - ret = gf_asprintf (&priv->pending_key[i], "%s.%s", + ret = gf_asprintf (&priv->pending_key[i], "%s.%s", AFR_XATTR_PREFIX, trav->xlator->name); if (-1 == ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_log (this->name, GF_LOG_ERROR, "asprintf failed to set pending key"); ret = -ENOMEM; goto out; @@ -1053,18 +1053,18 @@ struct xlator_cbks cbks = { struct volume_options options[] = { - { .key = {"read-subvolume" }, + { .key = {"read-subvolume" }, .type = GF_OPTION_TYPE_XLATOR }, - { .key = {"favorite-child"}, + { .key = {"favorite-child"}, .type = GF_OPTION_TYPE_XLATOR }, { .key = {"background-self-heal-count"}, .type = GF_OPTION_TYPE_INT, .min = 0 }, - { .key = {"data-self-heal"}, - .type = GF_OPTION_TYPE_BOOL + { .key = {"data-self-heal"}, + .type = GF_OPTION_TYPE_BOOL }, { .key = {"data-self-heal-algorithm"}, .type = GF_OPTION_TYPE_STR @@ -1074,33 +1074,33 @@ struct volume_options options[] = { .min = 1, .max = 1024 }, - { .key = {"metadata-self-heal"}, + { .key = {"metadata-self-heal"}, .type = GF_OPTION_TYPE_BOOL }, - { .key = {"entry-self-heal"}, - .type = GF_OPTION_TYPE_BOOL + { .key = {"entry-self-heal"}, + .type = GF_OPTION_TYPE_BOOL }, - { .key = {"data-change-log"}, - .type = GF_OPTION_TYPE_BOOL + { .key = {"data-change-log"}, + .type = GF_OPTION_TYPE_BOOL }, - { .key = {"metadata-change-log"}, + { .key = {"metadata-change-log"}, .type = GF_OPTION_TYPE_BOOL }, - { .key = {"entry-change-log"}, + { .key = {"entry-change-log"}, .type = GF_OPTION_TYPE_BOOL }, - { .key = {"optimistic-change-log"}, + { .key = {"optimistic-change-log"}, .type = GF_OPTION_TYPE_BOOL }, - { .key = {"data-lock-server-count"}, - .type = GF_OPTION_TYPE_INT, + { .key = {"data-lock-server-count"}, + .type = GF_OPTION_TYPE_INT, .min = 0 }, - { .key = {"metadata-lock-server-count"}, - .type = GF_OPTION_TYPE_INT, + { .key = {"metadata-lock-server-count"}, + .type = GF_OPTION_TYPE_INT, .min = 0 }, - { .key = {"entry-lock-server-count"}, + { .key = {"entry-lock-server-count"}, .type = GF_OPTION_TYPE_INT, .min = 0 }, |