summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/ec/src/ec-dir-read.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/ec/src/ec-dir-read.c')
-rw-r--r--xlators/cluster/ec/src/ec-dir-read.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c
index 3a8455101e8..7ff8df5e397 100644
--- a/xlators/cluster/ec/src/ec-dir-read.c
+++ b/xlators/cluster/ec/src/ec-dir-read.c
@@ -116,10 +116,38 @@ void ec_wind_opendir(ec_t * ec, ec_fop_data_t * fop, int32_t idx)
int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state)
{
ec_cbk_data_t * cbk;
+ ec_fd_t *ctx;
switch (state)
{
case EC_STATE_INIT:
+ LOCK(&fop->fd->lock);
+
+ ctx = __ec_fd_get(fop->fd, fop->xl);
+ if ((ctx == NULL) || !ec_loc_from_loc(fop->xl, &ctx->loc,
+ &fop->loc[0])) {
+ UNLOCK(&fop->fd->lock);
+
+ fop->error = EIO;
+
+ return EC_STATE_REPORT;
+ }
+
+ UNLOCK(&fop->fd->lock);
+
+ /* Fall through */
+
+ case EC_STATE_LOCK:
+ ec_lock_prepare_entry(fop, &fop->loc[0], 0);
+ ec_lock(fop);
+
+ return EC_STATE_GET_SIZE_AND_VERSION;
+
+ case EC_STATE_GET_SIZE_AND_VERSION:
+ ec_get_size_version(fop);
+
+ return EC_STATE_DISPATCH;
+
case EC_STATE_DISPATCH:
ec_dispatch_all(fop);
@@ -160,8 +188,10 @@ int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state)
cbk->op_errno, cbk->fd, cbk->xdata);
}
- return EC_STATE_END;
+ return EC_STATE_LOCK_REUSE;
+ case -EC_STATE_LOCK:
+ case -EC_STATE_GET_SIZE_AND_VERSION:
case -EC_STATE_DISPATCH:
case -EC_STATE_PREPARE_ANSWER:
case -EC_STATE_REPORT:
@@ -173,6 +203,18 @@ int32_t ec_manager_opendir(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:
@@ -421,6 +463,8 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
+ fop->use_fd = 1;
+
fop->size = size;
fop->offset = offset;
@@ -533,6 +577,8 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
+ fop->use_fd = 1;
+
fop->size = size;
fop->offset = offset;