diff options
| author | Ravishankar N <ravishankar@redhat.com> | 2018-05-18 15:38:29 +0530 | 
|---|---|---|
| committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2018-05-25 12:57:45 +0000 | 
| commit | c6f21697a52200bbbf9af05dff2b9c3ae0a99b43 (patch) | |
| tree | 1da294370544647de8e53a6ab0b2264aaf93f855 /xlators/cluster/afr/src/afr-transaction.c | |
| parent | dbe0984d8a84e0ca0e0d42f84d856c6f1d2a5134 (diff) | |
afr: fix bug-1363721.t failure
Problem:
In the .t, when the only good brick was brought down, writes on the fd were
still succeeding on the bad bricks. The inflight split-brain check was
marking the write as failure but since the write succeeded on all the
bad bricks, afr_txn_nothing_failed() was set to true and we were
unwinding writev with success to DHT and then catching the failure in
post-op in the background.
Fix:
Don't wind the FOP phase if the write_subvol (which is populated with readable
subvols obtained in pre-op cbk) does not have at least 1 good brick which was up
when the transaction started.
Note: This fix is not related to brick muliplexing. I ran the .t
10 times with this fix and brick-mux enabled without any failures.
Change-Id: I915c9c366aa32cd342b1565827ca2d83cb02ae85
updates: bz#1581548
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
(cherry picked from commit 985a1d15db910e012ddc1dcdc2e333cc28a9968b)
Diffstat (limited to 'xlators/cluster/afr/src/afr-transaction.c')
| -rw-r--r-- | xlators/cluster/afr/src/afr-transaction.c | 38 | 
1 files changed, 38 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index b4d3062fc2b..9c0963781e3 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -167,6 +167,34 @@ afr_changelog_has_quorum (afr_local_t *local, xlator_t *this)          return _gf_false;  } + +gf_boolean_t +afr_is_write_subvol_valid (call_frame_t *frame, xlator_t *this) +{ +        int i = 0; +        afr_local_t *local = NULL; +        afr_private_t *priv  = NULL; +        uint64_t write_subvol = 0; +        unsigned char *writable = NULL; +        uint16_t datamap = 0; + +        local = frame->local; +        priv = this->private; +        writable = alloca0 (priv->child_count); + +        write_subvol = afr_write_subvol_get (frame, this); +        datamap = (write_subvol & 0x00000000ffff0000) >> 16; +        for (i = 0; i < priv->child_count; i++) { +                if (datamap & (1 << i)) +                        writable[i] = 1; + +                if (writable[i] && !local->transaction.failed_subvols[i]) +                        return _gf_true; +        } + +        return _gf_false; +} +  int  afr_transaction_fop (call_frame_t *frame, xlator_t *this)  { @@ -189,6 +217,16 @@ afr_transaction_fop (call_frame_t *frame, xlator_t *this)                  afr_transaction_resume (frame, this);                  return 0;          } + +        /* Fail if at least one writeable brick isn't up.*/ +        if (local->transaction.type == AFR_DATA_TRANSACTION && +            !afr_is_write_subvol_valid (frame, this)) { +                local->op_ret = -1; +                local->op_errno = EIO; +                afr_transaction_resume (frame, this); +                return 0; +        } +          local->call_count = call_count;          for (i = 0; i < priv->child_count; i++) {                  if (local->transaction.pre_op[i] && !failed_subvols[i]) {  | 
