diff options
| author | Kevin Vigor <kvigor@fb.com> | 2017-01-05 12:21:20 -0800 |
|---|---|---|
| committer | Kevin Vigor <kvigor@fb.com> | 2017-01-05 12:21:20 -0800 |
| commit | c27aa58e72cf528583c585691e65abdb765535e5 (patch) | |
| tree | fae75e5b924ac4fb80a3d4ed42203638732fbb52 /xlators/cluster/afr/src | |
| parent | 63403742f53ec59a6acbe26ff4c39bab1b0842ed (diff) | |
| parent | cb8bc3396d16e777d9a2683886fefd43e747e8a3 (diff) | |
Merge remote-tracking branch 'origin/release-3.8' into merge-3.8-again
Change-Id: I844adf2aef161a44d446f8cd9b7ebcb224ee618a
Signed-off-by: Kevin Vigor <kvigor@fb.com>
Diffstat (limited to 'xlators/cluster/afr/src')
| -rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 12 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 4 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal.h | 2 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-transaction.c | 103 |
4 files changed, 88 insertions, 33 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 6431432690d..747577c9380 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -936,7 +936,7 @@ afr_replies_interpret (call_frame_t *frame, xlator_t *this, inode_t *inode, for (i = 0; i < priv->child_count; i++) { if (start_heal && priv->child_up[i] && - (!data_readable[i] || !metadata_readable[i])) { + (data_accused[i] || metadata_accused[i])) { *start_heal = _gf_true; break; } @@ -1026,7 +1026,10 @@ afr_inode_refresh_done (call_frame_t *frame, xlator_t *this) } heal_local->refreshinode = inode_ref (local->refreshinode); heal_local->heal_frame = heal_frame; - afr_throttled_selfheal (heal_frame, this); + if (!afr_throttled_selfheal (heal_frame, this)) { + AFR_STACK_DESTROY (heal_frame); + goto refresh_done; + } } refresh_done: @@ -5170,7 +5173,6 @@ out: int afr_transaction_local_init (afr_local_t *local, xlator_t *this) { - int child_up_count = 0; int ret = -ENOMEM; afr_private_t *priv = NULL; @@ -5189,10 +5191,6 @@ afr_transaction_local_init (afr_local_t *local, xlator_t *this) } ret = -ENOMEM; - child_up_count = AFR_COUNT (local->child_up, priv->child_count); - if (priv->optimistic_change_log && child_up_count == priv->child_count) - local->optimistic_change_log = 1; - local->pre_op_compat = priv->pre_op_compat; local->transaction.eager_lock = diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 58db6d1e497..faee8dbb89b 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -1985,7 +1985,7 @@ afr_heal_synctask (xlator_t *this, afr_local_t *local) afr_refresh_heal_done (ret, heal_frame, heal_frame); } -void +gf_boolean_t afr_throttled_selfheal (call_frame_t *frame, xlator_t *this) { gf_boolean_t can_heal = _gf_true; @@ -2013,6 +2013,8 @@ afr_throttled_selfheal (call_frame_t *frame, xlator_t *this) gf_msg_debug (this->name, 0, "Max number of heals are " "pending, background self-heal rejected."); } + + return can_heal; } int diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h index ec5337e60b2..1705c967f60 100644 --- a/xlators/cluster/afr/src/afr-self-heal.h +++ b/xlators/cluster/afr/src/afr-self-heal.h @@ -85,7 +85,7 @@ int afr_selfheal (xlator_t *this, uuid_t gfid); -void +gf_boolean_t afr_throttled_selfheal (call_frame_t *frame, xlator_t *this); int diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 848387fc0db..4d0ed943a81 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -1132,19 +1132,21 @@ void afr_changelog_populate_xdata (call_frame_t *frame, afr_xattrop_type_t op, dict_t **xdata, dict_t **newloc_xdata) { - dict_t *xdata1 = NULL; - dict_t *xdata2 = NULL; - afr_local_t *local = NULL; - afr_private_t *priv = NULL; - int ret = 0; - const char *name = NULL; + int i = 0; + int ret = 0; + char *key = NULL; + const char *name = NULL; + dict_t *xdata1 = NULL; + dict_t *xdata2 = NULL; + xlator_t *this = NULL; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + gf_boolean_t need_entry_key_set = _gf_true; local = frame->local; - priv = THIS->private; + this = THIS; + priv = this->private; - /*Populate xdata for POST_OP only.*/ - if (op == AFR_TRANSACTION_PRE_OP) - goto out; if (local->transaction.type == AFR_DATA_TRANSACTION || local->transaction.type == AFR_METADATA_TRANSACTION) goto out; @@ -1155,26 +1157,63 @@ afr_changelog_populate_xdata (call_frame_t *frame, afr_xattrop_type_t op, xdata1 = dict_new(); if (!xdata1) goto out; + name = local->loc.name; if (local->op == GF_FOP_LINK) name = local->newloc.name; - ret = dict_set_str (xdata1, GF_XATTROP_ENTRY_IN_KEY, (char *)name); - if (ret) - gf_msg (THIS->name, GF_LOG_ERROR, 0, AFR_MSG_DICT_SET_FAILED, - "%s/%s: Could not set xattrop-entry key during post-op", - uuid_utoa (local->loc.pargfid), local->loc.name); - if (local->transaction.type == AFR_ENTRY_RENAME_TRANSACTION) { - xdata2 = dict_new(); - if (!xdata2) - goto out; - ret = dict_set_str (xdata2, GF_XATTROP_ENTRY_IN_KEY, - (char *)local->newloc.name); + + switch (op) { + case AFR_TRANSACTION_PRE_OP: + key = GF_XATTROP_ENTRY_IN_KEY; + break; + case AFR_TRANSACTION_POST_OP: + if (afr_txn_nothing_failed (frame, this)) { + key = GF_XATTROP_ENTRY_OUT_KEY; + for (i = 0; i < priv->child_count; i++) { + if (!local->transaction.failed_subvols[i]) + continue; + need_entry_key_set = _gf_false; + break; + } + /* If the transaction itself did not fail and there + * are no failed subvolumes, check whether the fop + * failed due to a symmetric error. If it did, do + * not set the ENTRY_OUT xattr which would end up + * deleting a name index which was created possibly by + * an earlier entry txn that may have failed on some + * of the sub-volumes. + */ + if (local->op_ret) + need_entry_key_set = _gf_false; + } else { + key = GF_XATTROP_ENTRY_IN_KEY; + } + break; + } + + if (need_entry_key_set) { + ret = dict_set_str (xdata1, key, (char *)name); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, AFR_MSG_DICT_SET_FAILED, - "%s/%s: Could not set xattrop-entry key during" - " post-op", uuid_utoa (local->newloc.pargfid), - local->newloc.name); + "%s/%s: Could not set %s key during xattrop", + uuid_utoa (local->loc.pargfid), local->loc.name, + key); + if (local->transaction.type == AFR_ENTRY_RENAME_TRANSACTION) { + xdata2 = dict_new (); + if (!xdata2) + goto out; + + ret = dict_set_str (xdata2, key, + (char *)local->newloc.name); + if (ret) + gf_msg (THIS->name, GF_LOG_ERROR, 0, + AFR_MSG_DICT_SET_FAILED, + "%s/%s: Could not set %s key during " + "xattrop", + uuid_utoa (local->newloc.pargfid), + local->newloc.name, key); + } } *xdata = xdata1; @@ -1286,6 +1325,20 @@ afr_changelog_do (call_frame_t *frame, xlator_t *this, dict_t *xattr, return 0; } +static void +afr_init_optimistic_changelog_for_txn (xlator_t *this, afr_local_t *local) +{ + int locked_count = 0; + afr_private_t *priv = NULL; + + priv = this->private; + + locked_count = AFR_COUNT (local->transaction.pre_op, priv->child_count); + if (priv->optimistic_change_log && locked_count == priv->child_count) + local->optimistic_change_log = 1; + + return; +} int afr_changelog_pre_op (call_frame_t *frame, xlator_t *this) @@ -1317,6 +1370,8 @@ afr_changelog_pre_op (call_frame_t *frame, xlator_t *this) } } + afr_init_optimistic_changelog_for_txn (this, local); + /* This condition should not be met with present code, as * transaction.done will be called if locks are not acquired on even a * single node. |
