diff options
Diffstat (limited to 'xlators/cluster/afr/src/afr-read-txn.c')
| -rw-r--r-- | xlators/cluster/afr/src/afr-read-txn.c | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c index 1cd5c2eee3b..6fc2c75145c 100644 --- a/xlators/cluster/afr/src/afr-read-txn.c +++ b/xlators/cluster/afr/src/afr-read-txn.c @@ -30,27 +30,6 @@ afr_pending_read_decrement(afr_private_t *priv, int child_index) GF_ATOMIC_DEC(priv->pending_reads[child_index]); } -static gf_boolean_t -afr_ta_dict_contains_pending_xattr(dict_t *dict, afr_private_t *priv, int child) -{ - int *pending = NULL; - int ret = 0; - int i = 0; - - ret = dict_get_ptr(dict, priv->pending_key[child], (void *)&pending); - if (ret == 0) { - for (i = 0; i < AFR_NUM_CHANGE_LOGS; i++) { - /* Not doing a ntoh32(pending) as we just want to check - * if it is non-zero or not. */ - if (pending[i]) { - return _gf_true; - } - } - } - - return _gf_false; -} - void afr_read_txn_wind(call_frame_t *frame, xlator_t *this, int subvol) { @@ -114,7 +93,7 @@ afr_ta_read_txn(void *opaque) call_frame_t *frame = NULL; xlator_t *this = NULL; int read_subvol = -1; - int up_child = AFR_CHILD_UNKNOWN; + int query_child = AFR_CHILD_UNKNOWN; int possible_bad_child = AFR_CHILD_UNKNOWN; int ret = 0; int op_errno = ENOMEM; @@ -134,18 +113,18 @@ afr_ta_read_txn(void *opaque) this = frame->this; local = frame->local; priv = this->private; + query_child = local->read_txn_query_child; - if (local->child_up[AFR_CHILD_ZERO]) { - up_child = AFR_CHILD_ZERO; + if (query_child == AFR_CHILD_ZERO) { possible_bad_child = AFR_CHILD_ONE; - } else if (local->child_up[AFR_CHILD_ONE]) { - up_child = AFR_CHILD_ONE; + } else if (query_child == AFR_CHILD_ONE) { possible_bad_child = AFR_CHILD_ZERO; + } else { + /*read_txn_query_child is AFR_CHILD_UNKNOWN*/ + goto out; } - GF_ASSERT(up_child != AFR_CHILD_UNKNOWN); - - /* Query the up_child to see if it blames the down one. */ + /* Ask the query_child to see if it blames the possibly bad one. */ xdata_req = dict_new(); if (!xdata_req) goto out; @@ -159,30 +138,33 @@ afr_ta_read_txn(void *opaque) goto out; if (local->fd) { - ret = syncop_fxattrop(priv->children[up_child], local->fd, + ret = syncop_fxattrop(priv->children[query_child], local->fd, GF_XATTROP_ADD_ARRAY, xdata_req, NULL, &xdata_rsp, NULL); } else { - ret = syncop_xattrop(priv->children[up_child], &local->loc, + ret = syncop_xattrop(priv->children[query_child], &local->loc, GF_XATTROP_ADD_ARRAY, xdata_req, NULL, &xdata_rsp, NULL); } if (ret || !xdata_rsp) { gf_msg(this->name, GF_LOG_ERROR, -ret, AFR_MSG_THIN_ARB, "Failed xattrop for gfid %s on %s", - uuid_utoa(local->inode->gfid), priv->children[up_child]->name); + uuid_utoa(local->inode->gfid), + priv->children[query_child]->name); op_errno = -ret; goto out; } if (afr_ta_dict_contains_pending_xattr(xdata_rsp, priv, possible_bad_child)) { - read_subvol = up_child; + read_subvol = query_child; goto out; } dict_unref(xdata_rsp); - /* Query thin-arbiter to see if it blames any data brick. */ - ret = afr_fill_ta_loc(this, &loc); + xdata_rsp = NULL; + + /* It doesn't. So query thin-arbiter to see if it blames any data brick. */ + ret = afr_fill_ta_loc(this, &loc, _gf_true); if (ret) { gf_msg(this->name, GF_LOG_ERROR, -ret, AFR_MSG_THIN_ARB, "Failed to populate thin-arbiter loc for: %s.", loc.name); @@ -211,8 +193,8 @@ afr_ta_read_txn(void *opaque) goto unlock; } - if (!afr_ta_dict_contains_pending_xattr(xdata_rsp, priv, up_child)) { - read_subvol = up_child; + if (!afr_ta_dict_contains_pending_xattr(xdata_rsp, priv, query_child)) { + read_subvol = query_child; } else { gf_msg(this->name, GF_LOG_ERROR, EIO, AFR_MSG_THIN_ARB, "Failing read for gfid %s since good brick %s is down", @@ -290,7 +272,7 @@ afr_read_txn_refresh_done(call_frame_t *frame, xlator_t *this, int err) int read_subvol = -1; inode_t *inode = NULL; int ret = -1; - int spb_choice = -1; + int spb_subvol = -1; local = frame->local; inode = local->inode; @@ -321,9 +303,9 @@ afr_read_txn_refresh_done(call_frame_t *frame, xlator_t *this, int err) local->read_attempted[read_subvol] = 1; readfn: if (read_subvol == -1) { - ret = afr_inode_split_brain_choice_get(inode, this, &spb_choice); - if ((ret == 0) && spb_choice >= 0) - read_subvol = spb_choice; + ret = afr_split_brain_read_subvol_get(inode, this, frame, &spb_subvol); + if ((ret == 0) && spb_subvol >= 0) + read_subvol = spb_subvol; } if (read_subvol == -1) { @@ -431,7 +413,7 @@ afr_read_txn(call_frame_t *frame, xlator_t *this, inode_t *inode, local->is_read_txn = _gf_true; local->transaction.type = type; - if (priv->quorum_count && !afr_has_quorum(local->child_up, this)) { + if (priv->quorum_count && !afr_has_quorum(local->child_up, this, NULL)) { local->op_ret = -1; local->op_errno = afr_quorum_errno(priv); goto read; @@ -450,6 +432,11 @@ afr_read_txn(call_frame_t *frame, xlator_t *this, inode_t *inode, if (priv->thin_arbiter_count && AFR_COUNT(local->child_up, priv->child_count) != priv->child_count) { + if (local->child_up[0]) { + local->read_txn_query_child = AFR_CHILD_ZERO; + } else if (local->child_up[1]) { + local->read_txn_query_child = AFR_CHILD_ONE; + } afr_ta_read_txn_synctask(frame, this); return 0; } |
