diff options
author | Xavier Hernandez <xhernandez@datalab.es> | 2015-01-07 12:29:48 +0100 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-05-09 17:29:46 -0700 |
commit | b46e65db722c14985db62a1679e0388d217b713b (patch) | |
tree | fac847af8f529505bf364ed54df25658552fbae3 | |
parent | 73b61d709712692b48a1c9b18b4547410fb9078c (diff) |
ec: Fix failures with missing files
When a file does not exist on a brick but it does on others, there
could be problems trying to access it because there was some loc_t
structures with null 'pargfid' but 'name' was set. This forced
inode resolution based on <pargfid>/name instead of <gfid> which
would be the correct one. To solve this problem, 'name' is always
set to NULL when 'pargfid' is not present.
Another problem was caused by an incorrect management of errors
while doing incremental locking. The only allowed error during an
incremental locking was ENOTCONN, but missing files on a brick can
be returned as ESTALE. This caused an EIO on the operation.
This patch doesn't care of errors during an incremental locking. At
the end of the operation it will check if there are enough successfully
locked bricks to continue or not.
Change-Id: I9360ebf8d819d219cea2d173c09bd37679a6f15a
BUG: 1176062
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/9407
Tested-by: NetBSD Build System
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
-rwxr-xr-x | run-tests.sh | 1 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-common.c | 19 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-common.h | 4 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-heal.c | 64 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-helpers.c | 55 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-locks.c | 305 |
6 files changed, 165 insertions, 283 deletions
diff --git a/run-tests.sh b/run-tests.sh index 40fcad8b2a6..0c9e61ceb26 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -208,6 +208,7 @@ function is_bad_test () ./tests/basic/tier/tier.t \ ./tests/basic/ec/ec-4-1.t \ ./tests/basic/ec/ec.t \ + ./tests/basic/ec/self-heal.t \ ./tests/basic/quota-nfs.t \ ./tests/basic/ec/ec-6-2.t \ ./tests/bugs/quota/bug-1035576.t \ diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c index 383c460bb32..393d9142797 100644 --- a/xlators/cluster/ec/src/ec-common.c +++ b/xlators/cluster/ec/src/ec-common.c @@ -267,21 +267,6 @@ int32_t ec_check_complete(ec_fop_data_t * fop, ec_resume_f resume) return error; } -void ec_wait_winds(ec_fop_data_t * fop) -{ - LOCK(&fop->lock); - - if (fop->winds > 0) - { - fop->jobs++; - fop->refs++; - - fop->flags |= EC_FLAG_WAITING_WINDS; - } - - UNLOCK(&fop->lock); -} - void ec_resume(ec_fop_data_t * fop, int32_t error) { ec_resume_f resume = NULL; @@ -357,10 +342,6 @@ void ec_complete(ec_fop_data_t * fop) resume = 1; } - else if ((fop->flags & EC_FLAG_WAITING_WINDS) != 0) - { - resume = 1; - } } UNLOCK(&fop->lock); diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h index 04f85a43f16..9e0aaa0f079 100644 --- a/xlators/cluster/ec/src/ec-common.h +++ b/xlators/cluster/ec/src/ec-common.h @@ -29,8 +29,6 @@ typedef enum { #define EC_FLAG_UPDATE_FD 0x0004 #define EC_FLAG_UPDATE_FD_INODE 0x0008 -#define EC_FLAG_WAITING_WINDS 0x0010 - #define EC_SELFHEAL_BIT 62 #define EC_MINIMUM_ONE -1 @@ -99,8 +97,6 @@ void ec_dispatch_inc(ec_fop_data_t * fop); void ec_dispatch_min(ec_fop_data_t * fop); void ec_dispatch_one(ec_fop_data_t * fop); -void ec_wait_winds(ec_fop_data_t * fop); - void ec_sleep(ec_fop_data_t *fop); void ec_resume(ec_fop_data_t * fop, int32_t error); void ec_resume_parent(ec_fop_data_t * fop, int32_t error); diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c index 315de8765ad..ceddfeb6ac7 100644 --- a/xlators/cluster/ec/src/ec-heal.c +++ b/xlators/cluster/ec/src/ec-heal.c @@ -486,16 +486,6 @@ ec_heal_init (ec_fop_data_t * fop) ec_heal_t * heal = NULL; int32_t error = 0; - inode = fop->loc[0].inode; - if (inode == NULL) - { - gf_log(fop->xl->name, GF_LOG_WARNING, "Unable to start inode healing " - "because there is not enough " - "information"); - - return ENODATA; - } - heal = GF_MALLOC(sizeof(ec_heal_t), ec_mt_ec_heal_t); if (heal == NULL) { @@ -509,6 +499,16 @@ ec_heal_init (ec_fop_data_t * fop) goto out; } + inode = heal->loc.inode; + if (inode == NULL) { + gf_log(fop->xl->name, GF_LOG_WARNING, "Unable to start inode healing " + "because there is not enough " + "information"); + + error = ENODATA; + goto out; + } + LOCK_INIT(&heal->lock); heal->xl = fop->xl; @@ -532,26 +532,20 @@ ec_heal_init (ec_fop_data_t * fop) gf_log("ec", GF_LOG_INFO, "Healing '%s', gfid %s", heal->loc.path, uuid_utoa(heal->loc.gfid)); } else { - error = EEXIST; - } - - list_add_tail(&heal->list, &ctx->heal); - heal = NULL; - -unlock: - UNLOCK(&inode->lock); - - if (error == EEXIST) { LOCK(&fop->lock); fop->jobs++; fop->refs++; UNLOCK(&fop->lock); - - error = 0; } + list_add_tail(&heal->list, &ctx->heal); + heal = NULL; + +unlock: + UNLOCK(&inode->lock); + out: GF_FREE(heal); @@ -563,6 +557,7 @@ void ec_heal_entrylk(ec_heal_t * heal, entrylk_cmd cmd) loc_t loc; if (ec_loc_parent(heal->xl, &heal->loc, &loc) != 0) { + gf_log("ec", GF_LOG_NOTICE, "ec_loc_parent() failed"); ec_fop_set_error(heal->fop, EIO); return; @@ -1164,10 +1159,11 @@ void ec_heal_dispatch(ec_heal_t *heal) LOCK(&inode->lock); - /* A heal object not belonging to any list means that it has not been fully - * executed. It got its information from a previous heal that was executing - * when this heal started. */ - if (!list_empty(&heal->list)) { + /* done == 0 means that self-heal is still running (it shouldn't happen) + * done == 1 means that self-heal has just completed + * done == 2 means that self-heal has completed and reported */ + if (heal->done == 1) { + heal->done = 2; list_del_init(&heal->list); ctx = __ec_inode_get(inode, heal->xl); if (ctx != NULL) { @@ -1182,6 +1178,11 @@ void ec_heal_dispatch(ec_heal_t *heal) if (!next->partial) { break; } + + /* Setting 'done' to 2 avoids executing all heal logic and + * directly reports the result to the caller. */ + next->done = 2; + list_move_tail(&next->list, &list); } if (list_empty(&ctx->heal)) { @@ -1241,10 +1242,6 @@ void ec_heal_dispatch(ec_heal_t *heal) heal->good = cbk->uintptr[1]; heal->fixed = cbk->uintptr[2]; - /* Setting 'done' to 1 avoids executing all heal logic and directly - * reports the result to the caller. */ - heal->done = 1; - ec_resume(heal->fop, error); } @@ -1304,11 +1301,14 @@ ec_manager_heal (ec_fop_data_t * fop, int32_t state) } case EC_STATE_DISPATCH: - if (heal->done) { + if (heal->done != 0) { + gf_log("ec", GF_LOG_NOTICE, "heal already done"); return EC_STATE_HEAL_DISPATCH; } + gf_log("ec", GF_LOG_NOTICE, "heal before entrylk"); ec_heal_entrylk(heal, ENTRYLK_LOCK); + gf_log("ec", GF_LOG_NOTICE, "heal after entrylk"); return EC_STATE_HEAL_ENTRY_LOOKUP; @@ -1403,7 +1403,7 @@ ec_manager_heal (ec_fop_data_t * fop, int32_t state) return EC_STATE_HEAL_DISPATCH; case EC_STATE_HEAL_DATA_LOCK: - if (heal->done) + if (heal->done != 0) { return EC_STATE_HEAL_POST_INODELK_LOCK; } diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c index 2b497efd166..8ce3087d5a6 100644 --- a/xlators/cluster/ec/src/ec-helpers.c +++ b/xlators/cluster/ec/src/ec-helpers.c @@ -332,7 +332,7 @@ int32_t ec_loc_gfid_check(xlator_t * xl, uuid_t dst, uuid_t src) return 1; } -int32_t ec_loc_setup_inode(xlator_t *xl, loc_t *loc) +int32_t ec_loc_setup_inode(xlator_t *xl, inode_table_t *table, loc_t *loc) { int32_t ret = -1; @@ -340,11 +340,11 @@ int32_t ec_loc_setup_inode(xlator_t *xl, loc_t *loc) if (!ec_loc_gfid_check(xl, loc->gfid, loc->inode->gfid)) { goto out; } - } else if (loc->parent != NULL) { + } else if (table != NULL) { if (!gf_uuid_is_null(loc->gfid)) { - loc->inode = inode_find(loc->parent->table, loc->gfid); + loc->inode = inode_find(table, loc->gfid); } else if (loc->path && strchr (loc->path, '/')) { - loc->inode = inode_resolve(loc->parent->table, (char *)loc->path); + loc->inode = inode_resolve(table, (char *)loc->path); } } @@ -354,7 +354,7 @@ out: return ret; } -int32_t ec_loc_setup_parent(xlator_t *xl, loc_t *loc) +int32_t ec_loc_setup_parent(xlator_t *xl, inode_table_t *table, loc_t *loc) { char *path, *parent; int32_t ret = -1; @@ -363,9 +363,9 @@ int32_t ec_loc_setup_parent(xlator_t *xl, loc_t *loc) if (!ec_loc_gfid_check(xl, loc->pargfid, loc->parent->gfid)) { goto out; } - } else if (loc->inode != NULL) { + } else if (table != NULL) { if (!gf_uuid_is_null(loc->pargfid)) { - loc->parent = inode_find(loc->inode->table, loc->pargfid); + loc->parent = inode_find(table, loc->pargfid); } else if (loc->path && strchr (loc->path, '/')) { path = gf_strdup(loc->path); if (path == NULL) { @@ -375,11 +375,20 @@ int32_t ec_loc_setup_parent(xlator_t *xl, loc_t *loc) goto out; } parent = dirname(path); - loc->parent = inode_resolve(loc->inode->table, parent); + loc->parent = inode_resolve(table, parent); + if (loc->parent != NULL) { + gf_uuid_copy(loc->pargfid, loc->parent->gfid); + } GF_FREE(path); } } + /* If 'pargfid' has not been determined, clear 'name' to avoid resolutions + based on <gfid:pargfid>/name. */ + if (gf_uuid_is_null(loc->pargfid)) { + loc->name = NULL; + } + ret = 0; out: @@ -431,13 +440,17 @@ out: int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent) { + inode_table_t *table = NULL; char *str = NULL; int32_t ret = -1; memset(parent, 0, sizeof(loc_t)); if (loc->parent != NULL) { + table = loc->parent->table; parent->inode = inode_ref(loc->parent); + } else if (loc->inode != NULL) { + table = loc->inode->table; } if (!gf_uuid_is_null(loc->pargfid)) { gf_uuid_copy(parent->gfid, loc->pargfid); @@ -460,8 +473,8 @@ int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent) } if ((ec_loc_setup_path(xl, parent) != 0) || - (ec_loc_setup_inode(xl, parent) != 0) || - (ec_loc_setup_parent(xl, parent) != 0)) { + (ec_loc_setup_inode(xl, table, parent) != 0) || + (ec_loc_setup_parent(xl, table, parent) != 0)) { goto out; } @@ -488,14 +501,22 @@ out: int32_t ec_loc_update(xlator_t *xl, loc_t *loc, inode_t *inode, struct iatt *iatt) { + inode_table_t *table = NULL; int32_t ret = -1; - if ((inode != NULL) && (loc->inode != inode)) { - if (loc->inode != NULL) { - inode_unref(loc->inode); + if (inode != NULL) { + table = inode->table; + if (loc->inode != inode) { + if (loc->inode != NULL) { + inode_unref(loc->inode); + } + loc->inode = inode_ref(inode); + gf_uuid_copy(loc->gfid, inode->gfid); } - loc->inode = inode_ref(inode); - gf_uuid_copy(loc->gfid, inode->gfid); + } else if (loc->inode != NULL) { + table = loc->inode->table; + } else if (loc->parent != NULL) { + table = loc->parent->table; } if (iatt != NULL) { @@ -505,8 +526,8 @@ int32_t ec_loc_update(xlator_t *xl, loc_t *loc, inode_t *inode, } if ((ec_loc_setup_path(xl, loc) != 0) || - (ec_loc_setup_inode(xl, loc) != 0) || - (ec_loc_setup_parent(xl, loc) != 0)) { + (ec_loc_setup_inode(xl, table, loc) != 0) || + (ec_loc_setup_parent(xl, table, loc) != 0)) { goto out; } diff --git a/xlators/cluster/ec/src/ec-locks.c b/xlators/cluster/ec/src/ec-locks.c index 2e301631b3f..10572037932 100644 --- a/xlators/cluster/ec/src/ec-locks.c +++ b/xlators/cluster/ec/src/ec-locks.c @@ -21,57 +21,52 @@ #define EC_LOCK_MODE_INC 1 #define EC_LOCK_MODE_ALL 2 -int32_t ec_lock_check(ec_fop_data_t * fop, ec_cbk_data_t ** cbk, - uintptr_t * mask) +int32_t ec_lock_check(ec_fop_data_t *fop, uintptr_t *mask) { - ec_t * ec = fop->xl->private; - ec_cbk_data_t * ans = NULL; + ec_t *ec = fop->xl->private; + ec_cbk_data_t *ans = NULL; + ec_cbk_data_t *cbk = NULL; uintptr_t locked = 0, notlocked = 0; int32_t error = -1; - list_for_each_entry(ans, &fop->cbk_list, list) - { - if (ans->op_ret >= 0) - { - if (locked != 0) - { + list_for_each_entry(ans, &fop->cbk_list, list) { + if (ans->op_ret >= 0) { + if (locked != 0) { error = EIO; } locked |= ans->mask; - *cbk = ans; - } - else if (ans->op_errno == EAGAIN) - { + cbk = ans; + } else { notlocked |= ans->mask; } } - if (error == -1) - { - if (ec_bits_count(locked | notlocked) >= ec->fragments) - { - if (notlocked == 0) - { - fop->answer = *cbk; + if (error == -1) { + if (ec_bits_count(locked | notlocked) >= ec->fragments) { + if (ec_bits_count (locked) >= ec->fragments) { + if (fop->answer == NULL) { + fop->answer = cbk; + } ec_update_bad(fop, locked); error = 0; - } - else - { - if (fop->uint32 == EC_LOCK_MODE_NONE) - { + } else { + switch (fop->uint32) { + case EC_LOCK_MODE_NONE: error = EAGAIN; - } - else - { + break; + + case EC_LOCK_MODE_ALL: fop->uint32 = EC_LOCK_MODE_INC; + break; + + default: + error = EIO; + break; } } - } - else - { + } else { error = EIO; } } @@ -81,28 +76,6 @@ int32_t ec_lock_check(ec_fop_data_t * fop, ec_cbk_data_t ** cbk, return error; } -uintptr_t ec_lock_handler(ec_fop_data_t * fop, ec_cbk_data_t * cbk, - ec_combine_f combine) -{ - uintptr_t mask = 0; - - if (fop->uint32 == EC_LOCK_MODE_INC) - { - if (cbk->op_ret < 0) - { - if (cbk->op_errno != ENOTCONN) - { - mask = fop->mask & ~fop->remaining & ~cbk->mask; - fop->remaining = 0; - } - } - } - - ec_combine(cbk, combine); - - return mask; -} - int32_t ec_lock_unlocked(call_frame_t * frame, void * cookie, xlator_t * this, int32_t op_ret, int32_t op_errno, dict_t * xdata) @@ -150,8 +123,6 @@ int32_t ec_entrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, op_errno); if (cbk != NULL) { - uintptr_t mask; - if (xdata != NULL) { cbk->xdata = dict_ref(xdata); @@ -164,13 +135,7 @@ int32_t ec_entrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } } - mask = ec_lock_handler(fop, cbk, NULL); - if (mask != 0) - { - ec_entrylk(fop->req_frame, fop->xl, mask, 1, ec_lock_unlocked, - NULL, fop->str[0], &fop->loc[0], fop->str[1], - ENTRYLK_UNLOCK, fop->entrylk_type, fop->xdata); - } + ec_combine(cbk, NULL); } out: @@ -213,45 +178,41 @@ int32_t ec_manager_entrylk(ec_fop_data_t * fop, int32_t state) return EC_STATE_PREPARE_ANSWER; case EC_STATE_PREPARE_ANSWER: - cbk = fop->answer; - if ((cbk == NULL) || - ((cbk->op_ret < 0) && (cbk->op_errno == EAGAIN))) - { + if (fop->entrylk_cmd != ENTRYLK_UNLOCK) { uintptr_t mask; - fop->error = ec_lock_check(fop, &cbk, &mask); - if (fop->error != 0) - { - if (mask != 0) - { - if (fop->id == GF_FOP_ENTRYLK) - { - ec_entrylk(fop->req_frame, fop->xl, mask, 1, + fop->error = ec_lock_check(fop, &mask); + if (fop->error != 0) { + if (mask != 0) { + if (fop->id == GF_FOP_ENTRYLK) { + ec_entrylk(fop->frame, fop->xl, mask, 1, ec_lock_unlocked, NULL, fop->str[0], &fop->loc[0], fop->str[1], ENTRYLK_UNLOCK, fop->entrylk_type, fop->xdata); - } - else - { - ec_fentrylk(fop->req_frame, fop->xl, mask, 1, + } else { + ec_fentrylk(fop->frame, fop->xl, mask, 1, ec_lock_unlocked, NULL, fop->str[0], fop->fd, fop->str[1], ENTRYLK_UNLOCK, fop->entrylk_type, fop->xdata); } } - if (fop->error > 0) - { - return EC_STATE_REPORT; - } - - fop->error = 0; + if (fop->error < 0) { + fop->error = 0; - fop->entrylk_cmd = ENTRYLK_LOCK; + fop->entrylk_cmd = ENTRYLK_LOCK; - ec_dispatch_inc(fop); + ec_dispatch_inc(fop); - return EC_STATE_PREPARE_ANSWER; + return EC_STATE_PREPARE_ANSWER; + } + } + } else { + cbk = fop->answer; + if (cbk == NULL) { + ec_fop_set_error(fop, EIO); + } else if (cbk->op_ret < 0) { + ec_fop_set_error(fop, cbk->op_errno); } } @@ -279,8 +240,6 @@ int32_t ec_manager_entrylk(ec_fop_data_t * fop, int32_t state) } } - ec_wait_winds(fop); - return EC_STATE_END; case -EC_STATE_INIT: @@ -306,8 +265,6 @@ int32_t ec_manager_entrylk(ec_fop_data_t * fop, int32_t state) } } - ec_wait_winds(fop); - return EC_STATE_END; default: @@ -422,8 +379,6 @@ int32_t ec_fentrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, op_errno); if (cbk != NULL) { - uintptr_t mask; - if (xdata != NULL) { cbk->xdata = dict_ref(xdata); @@ -436,13 +391,7 @@ int32_t ec_fentrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } } - mask = ec_lock_handler(fop, cbk, NULL); - if (mask != 0) - { - ec_fentrylk(fop->req_frame, fop->xl, mask, 1, ec_lock_unlocked, - NULL, fop->str[0], fop->fd, fop->str[1], - ENTRYLK_UNLOCK, fop->entrylk_type, fop->xdata); - } + ec_combine(cbk, NULL); } out: @@ -572,8 +521,6 @@ int32_t ec_inodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, op_errno); if (cbk != NULL) { - uintptr_t mask; - if (xdata != NULL) { cbk->xdata = dict_ref(xdata); @@ -586,23 +533,7 @@ int32_t ec_inodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } } - mask = ec_lock_handler(fop, cbk, NULL); - if (mask != 0) - { - ec_t * ec = fop->xl->private; - struct gf_flock flock; - - 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; - - ec_inodelk(fop->req_frame, fop->xl, mask, 1, ec_lock_unlocked, - NULL, fop->str[0], &fop->loc[0], F_SETLK, &flock, - fop->xdata); - } + ec_combine(cbk, NULL); } out: @@ -649,18 +580,13 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state) return EC_STATE_PREPARE_ANSWER; case EC_STATE_PREPARE_ANSWER: - cbk = fop->answer; - if ((cbk == NULL) || - ((cbk->op_ret < 0) && (cbk->op_errno == EAGAIN))) - { + if (fop->flock.l_type != F_UNLCK) { uintptr_t mask; - fop->error = ec_lock_check(fop, &cbk, &mask); - if (fop->error != 0) - { - if (mask != 0) - { - ec_t * ec = fop->xl->private; + fop->error = ec_lock_check(fop, &mask); + if (fop->error != 0) { + if (mask != 0) { + ec_t *ec = fop->xl->private; struct gf_flock flock; flock.l_type = F_UNLCK; @@ -670,32 +596,33 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state) flock.l_pid = 0; flock.l_owner.len = 0; - if (fop->id == GF_FOP_INODELK) - { - ec_inodelk(fop->req_frame, fop->xl, mask, 1, + if (fop->id == GF_FOP_INODELK) { + ec_inodelk(fop->frame, fop->xl, mask, 1, ec_lock_unlocked, NULL, fop->str[0], &fop->loc[0], F_SETLK, &flock, fop->xdata); - } - else - { - ec_finodelk(fop->req_frame, fop->xl, mask, 1, + } else { + ec_finodelk(fop->frame, fop->xl, mask, 1, ec_lock_unlocked, NULL, fop->str[0], fop->fd, F_SETLK, &flock, fop->xdata); } } - if (fop->error > 0) - { - return EC_STATE_REPORT; - } + if (fop->error < 0) { + fop->error = 0; - fop->error = 0; + fop->int32 = F_SETLKW; - fop->int32 = F_SETLKW; + ec_dispatch_inc(fop); - ec_dispatch_inc(fop); - - return EC_STATE_PREPARE_ANSWER; + return EC_STATE_PREPARE_ANSWER; + } + } + } else { + cbk = fop->answer; + if (cbk == NULL) { + ec_fop_set_error(fop, EIO); + } else if (cbk->op_ret < 0) { + ec_fop_set_error(fop, cbk->op_errno); } } @@ -723,8 +650,6 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state) } } - ec_wait_winds(fop); - return EC_STATE_END; case -EC_STATE_INIT: @@ -750,8 +675,6 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state) } } - ec_wait_winds(fop); - return EC_STATE_END; default: @@ -869,8 +792,6 @@ int32_t ec_finodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, op_errno); if (cbk != NULL) { - uintptr_t mask; - if (xdata != NULL) { cbk->xdata = dict_ref(xdata); @@ -883,23 +804,7 @@ int32_t ec_finodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } } - mask = ec_lock_handler(fop, cbk, NULL); - if (mask != 0) - { - ec_t * ec = fop->xl->private; - struct gf_flock flock; - - 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; - - ec_finodelk(fop->req_frame, fop->xl, mask, 1, ec_lock_unlocked, - NULL, fop->str[0], fop->fd, F_SETLK, &flock, - fop->xdata); - } + ec_combine(cbk, NULL); } out: @@ -1047,8 +952,6 @@ int32_t ec_lk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, op_errno); if (cbk != NULL) { - uintptr_t mask; - if (op_ret >= 0) { if (flock != NULL) @@ -1078,22 +981,7 @@ int32_t ec_lk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } } - mask = ec_lock_handler(fop, cbk, ec_combine_lk); - if (mask != 0) - { - ec_t * ec = fop->xl->private; - struct gf_flock flock; - - 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; - - ec_lk(fop->req_frame, fop->xl, mask, 1, ec_lock_lk_unlocked, NULL, - fop->fd, F_SETLK, &flock, fop->xdata); - } + ec_combine(cbk, ec_combine_lk); } out: @@ -1139,18 +1027,13 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state) return EC_STATE_PREPARE_ANSWER; case EC_STATE_PREPARE_ANSWER: - cbk = fop->answer; - if ((cbk == NULL) || - ((cbk->op_ret < 0) && (cbk->op_errno == EAGAIN))) - { + if (fop->flock.l_type != F_UNLCK) { uintptr_t mask; - fop->error = ec_lock_check(fop, &cbk, &mask); - if (fop->error != 0) - { - if (mask != 0) - { - ec_t * ec = fop->xl->private; + fop->error = ec_lock_check(fop, &mask); + if (fop->error != 0) { + if (mask != 0) { + ec_t *ec = fop->xl->private; struct gf_flock flock; flock.l_type = F_UNLCK; @@ -1160,22 +1043,26 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state) flock.l_pid = 0; flock.l_owner.len = 0; - ec_lk(fop->req_frame, fop->xl, mask, 1, + ec_lk(fop->frame, fop->xl, mask, 1, ec_lock_lk_unlocked, NULL, fop->fd, F_SETLK, &flock, fop->xdata); } - if (fop->error > 0) - { - return EC_STATE_REPORT; - } - - fop->error = 0; + if (fop->error < 0) { + fop->error = 0; - fop->int32 = F_SETLKW; + fop->int32 = F_SETLKW; - ec_dispatch_inc(fop); + ec_dispatch_inc(fop); - return EC_STATE_PREPARE_ANSWER; + return EC_STATE_PREPARE_ANSWER; + } + } + } else { + cbk = fop->answer; + if (cbk == NULL) { + ec_fop_set_error(fop, EIO); + } else if (cbk->op_ret < 0) { + ec_fop_set_error(fop, cbk->op_errno); } } @@ -1192,8 +1079,6 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state) cbk->op_errno, &cbk->flock, cbk->xdata); } - ec_wait_winds(fop); - return EC_STATE_END; case -EC_STATE_INIT: @@ -1208,8 +1093,6 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state) NULL, NULL); } - ec_wait_winds(fop); - return EC_STATE_END; default: |