summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2017-01-27 16:17:49 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2017-01-29 11:45:46 -0500
commitf2406fa6155267fa747d9342092ee7709a2531a9 (patch)
tree4737664d14abff7148a6132e004f7f5b2c6da1eb /xlators
parent33f8703a12dd97980c43e235546b04dffaf4afa0 (diff)
cluster/ec: Fix cthon failures observed with ec volumes
Since EC already winds one write after other there is no need to align application fcntl locks with ec blocks. Also added this locking to be done as a transaction to prevent partial upgrade/downgrade of locks happening. BUG: 1410425 Change-Id: I7ce8955c2174f62b11e5cb16140e30ff0f7c4c31 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: https://review.gluster.org/16445 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/ec/src/ec-locks.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/xlators/cluster/ec/src/ec-locks.c b/xlators/cluster/ec/src/ec-locks.c
index bd525723ddf..70b07c318e0 100644
--- a/xlators/cluster/ec/src/ec-locks.c
+++ b/xlators/cluster/ec/src/ec-locks.c
@@ -1012,10 +1012,6 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state)
switch (state)
{
case EC_STATE_INIT:
- fop->flock.l_len += ec_adjust_offset(fop->xl->private,
- &fop->flock.l_start, 1);
- fop->flock.l_len = ec_adjust_size(fop->xl->private,
- fop->flock.l_len, 1);
if ((fop->int32 == F_SETLKW) && (fop->flock.l_type != F_UNLCK))
{
fop->uint32 = EC_LOCK_MODE_ALL;
@@ -1024,6 +1020,12 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state)
/* Fall through */
+ case EC_STATE_LOCK:
+ ec_lock_prepare_fd(fop, fop->fd, EC_UPDATE_DATA | EC_QUERY_INFO);
+ ec_lock(fop);
+
+ return EC_STATE_DISPATCH;
+
case EC_STATE_DISPATCH:
ec_dispatch_all(fop);
@@ -1037,20 +1039,20 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state)
ec_fop_set_error (fop, ec_lock_check(fop, &mask));
if (fop->error != 0) {
if (mask != 0) {
- ec_t *ec = fop->xl->private;
- struct gf_flock flock;
+ struct gf_flock flock = {0};
flock.l_type = F_UNLCK;
flock.l_whence = fop->flock.l_whence;
- flock.l_start = fop->flock.l_start * ec->fragments;
- flock.l_len = fop->flock.l_len * ec->fragments;
- flock.l_pid = 0;
- flock.l_owner.len = 0;
+ flock.l_start = fop->flock.l_start;
+ flock.l_len = fop->flock.l_len;
+ flock.l_pid = fop->flock.l_pid;
+ lk_owner_copy (&flock.l_owner, &fop->flock.l_owner);
ec_lk(fop->frame, fop->xl, mask, 1,
ec_lock_lk_unlocked, NULL, fop->fd, F_SETLK,
&flock, fop->xdata);
}
+
if (fop->error < 0) {
fop->error = 0;
@@ -1078,9 +1080,10 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state)
cbk->op_errno, &cbk->flock, cbk->xdata);
}
- return EC_STATE_END;
+ return EC_STATE_LOCK_REUSE;
case -EC_STATE_INIT:
+ case -EC_STATE_LOCK:
case -EC_STATE_DISPATCH:
case -EC_STATE_REPORT:
GF_ASSERT(fop->error != 0);
@@ -1091,6 +1094,18 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state)
NULL, NULL);
}
+ return EC_STATE_LOCK_REUSE;
+
+ case -EC_STATE_LOCK_REUSE:
+ case EC_STATE_LOCK_REUSE:
+ ec_lock_reuse(fop);
+
+ return EC_STATE_UNLOCK;
+
+ case -EC_STATE_UNLOCK:
+ case EC_STATE_UNLOCK:
+ ec_unlock(fop);
+
return EC_STATE_END;
default: