summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorXavier Hernandez <xhernandez@datalab.es>2015-07-21 18:05:06 +0200
committerXavier Hernandez <xhernandez@datalab.es>2015-08-08 08:36:57 -0700
commit0e0c3ec84c73bc5fcda16ed743f9d3dc0a582c03 (patch)
treee1d08f3de51dff3b6f535c768f02936b361c8423 /xlators
parent6408e0e864261479e2a1466f27baba2105aab287 (diff)
cluster/ec: Minimize usage of EIO error
>Change-Id: I82e245615419c2006a2d1b5e94ff0908d2f5e891 >BUG: 1245276 >Signed-off-by: Xavier Hernandez <xhernandez@datalab.es> >Reviewed-on: http://review.gluster.org/11741 >Tested-by: Gluster Build System <jenkins@build.gluster.com> >Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> >Tested-by: NetBSD Build System <jenkins@build.gluster.org> Change-Id: Ifd3d63f88a686a2963c5ba2e62110249f84f338d BUG: 1250864 Signed-off-by: Xavier Hernandez <xhernandez@datalab.es> Reviewed-on: http://review.gluster.org/11852 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/ec/src/ec-combine.c252
-rw-r--r--xlators/cluster/ec/src/ec-common.c177
-rw-r--r--xlators/cluster/ec/src/ec-common.h8
-rw-r--r--xlators/cluster/ec/src/ec-data.c6
-rw-r--r--xlators/cluster/ec/src/ec-dir-read.c181
-rw-r--r--xlators/cluster/ec/src/ec-dir-write.c620
-rw-r--r--xlators/cluster/ec/src/ec-generic.c423
-rw-r--r--xlators/cluster/ec/src/ec-heal.c27
-rw-r--r--xlators/cluster/ec/src/ec-helpers.c148
-rw-r--r--xlators/cluster/ec/src/ec-inode-read.c507
-rw-r--r--xlators/cluster/ec/src/ec-inode-write.c510
-rw-r--r--xlators/cluster/ec/src/ec-locks.c219
-rw-r--r--xlators/cluster/ec/src/ec-messages.h9
-rw-r--r--xlators/cluster/ec/src/ec.c4
-rw-r--r--xlators/lib/src/libxlator.c4
15 files changed, 1203 insertions, 1892 deletions
diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c
index f3905ce..4afbc5b 100644
--- a/xlators/cluster/ec/src/ec-combine.c
+++ b/xlators/cluster/ec/src/ec-combine.c
@@ -291,16 +291,14 @@ int32_t ec_dict_list(data_t ** list, int32_t * count, ec_cbk_data_t * cbk,
max = *count;
i = 0;
- for (ans = cbk; ans != NULL; ans = ans->next)
- {
- if (i >= max)
- {
+ for (ans = cbk; ans != NULL; ans = ans->next) {
+ if (i >= max) {
gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_INVALID_DICT_NUMS,
"Unexpected number of "
"dictionaries");
- return 0;
+ return -EINVAL;
}
dict = (which == EC_COMBINE_XDATA) ? ans->xdata : ans->dict;
@@ -312,46 +310,43 @@ int32_t ec_dict_list(data_t ** list, int32_t * count, ec_cbk_data_t * cbk,
*count = i;
- return 1;
+ return 0;
}
-char * ec_concat_prepare(xlator_t * xl, char ** sep, char ** post,
- const char * fmt, va_list args)
+int32_t ec_concat_prepare(xlator_t *xl, char **str, char **sep, char **post,
+ const char *fmt, va_list args)
{
- char * str, * tmp;
+ char *tmp;
int32_t len;
- len = gf_vasprintf(&str, fmt, args);
- if (len < 0)
- {
- return NULL;
+ len = gf_vasprintf(str, fmt, args);
+ if (len < 0) {
+ return -ENOMEM;
}
- tmp = strchr(str, '{');
- if (tmp == NULL)
- {
+ tmp = strchr(*str, '{');
+ if (tmp == NULL) {
goto out;
}
*tmp++ = 0;
*sep = tmp;
tmp = strchr(tmp, '}');
- if (tmp == NULL)
- {
+ if (tmp == NULL) {
goto out;
}
*tmp++ = 0;
*post = tmp;
- return str;
+ return 0;
out:
gf_msg (xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_INVALID_FORMAT,
"Invalid concat format");
- GF_FREE(str);
+ GF_FREE(*str);
- return NULL;
+ return -EINVAL;
}
int32_t ec_dict_data_concat(const char * fmt, ec_cbk_data_t * cbk,
@@ -362,21 +357,20 @@ int32_t ec_dict_data_concat(const char * fmt, ec_cbk_data_t * cbk,
dict_t * dict;
va_list args;
int32_t i, num, len, prelen, postlen, seplen, tmp;
- int32_t ret = -1;
+ int32_t err;
num = cbk->count;
- if (!ec_dict_list(data, &num, cbk, which, key))
- {
- return -1;
+ err = ec_dict_list(data, &num, cbk, which, key);
+ if (err != 0) {
+ return err;
}
va_start(args, key);
- pre = ec_concat_prepare(cbk->fop->xl, &sep, &post, fmt, args);
+ err = ec_concat_prepare(cbk->fop->xl, &pre, &sep, &post, fmt, args);
va_end(args);
- if (pre == NULL)
- {
- return -1;
+ if (err != 0) {
+ return err;
}
prelen = strlen(pre);
@@ -384,21 +378,20 @@ int32_t ec_dict_data_concat(const char * fmt, ec_cbk_data_t * cbk,
postlen = strlen(post);
len = prelen + (num - 1) * seplen + postlen + 1;
- for (i = 0; i < num; i++)
- {
+ for (i = 0; i < num; i++) {
len += data[i]->len - 1;
}
+ err = -ENOMEM;
+
str = GF_MALLOC(len, gf_common_mt_char);
- if (str == NULL)
- {
+ if (str == NULL) {
goto out;
}
memcpy(str, pre, prelen);
len = prelen;
- for (i = 0; i < num; i++)
- {
+ for (i = 0; i < num; i++) {
if (i > 0) {
memcpy(str + len, sep, seplen);
len += seplen;
@@ -410,58 +403,58 @@ int32_t ec_dict_data_concat(const char * fmt, ec_cbk_data_t * cbk,
memcpy(str + len, post, postlen + 1);
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
- if (dict_set_dynstr(dict, key, str) != 0)
- {
+ err = dict_set_dynstr(dict, key, str);
+ if (err != 0) {
goto out;
}
str = NULL;
- ret = 0;
-
out:
GF_FREE(str);
GF_FREE(pre);
- return ret;
+ return err;
}
-int32_t ec_dict_data_merge(ec_cbk_data_t * cbk, int32_t which, char * key)
+int32_t ec_dict_data_merge(ec_cbk_data_t *cbk, int32_t which, char *key)
{
- data_t * data[cbk->count];
- dict_t * dict, * lockinfo, * tmp;
- char * ptr = NULL;
+ data_t *data[cbk->count];
+ dict_t *dict, *lockinfo, *tmp = NULL;
+ char *ptr = NULL;
int32_t i, num, len;
- int32_t ret = -1;
+ int32_t err;
num = cbk->count;
- if (!ec_dict_list(data, &num, cbk, which, key))
- {
- return -1;
+ err = ec_dict_list(data, &num, cbk, which, key);
+ if (err != 0) {
+ return err;
}
lockinfo = dict_new();
- if (lockinfo == NULL)
- {
- return -1;
+ if (lockinfo == NULL) {
+ return -ENOMEM;
}
- if (dict_unserialize(data[0]->data, data[0]->len, &lockinfo) != 0)
- {
+ err = dict_unserialize(data[0]->data, data[0]->len, &lockinfo);
+ if (err != 0) {
goto out;
}
for (i = 1; i < num; i++)
{
tmp = dict_new();
- if (tmp == NULL)
- {
+ if (tmp == NULL) {
+ err = -ENOMEM;
+
goto out;
}
- if ((dict_unserialize(data[i]->data, data[i]->len, &tmp) != 0) ||
- (dict_copy(tmp, lockinfo) == NULL))
- {
- dict_unref(tmp);
+ err = dict_unserialize(data[i]->data, data[i]->len, &tmp);
+ if (err != 0) {
+ goto out;
+ }
+ if (dict_copy(tmp, lockinfo) == NULL) {
+ err = -ENOMEM;
goto out;
}
@@ -469,35 +462,40 @@ int32_t ec_dict_data_merge(ec_cbk_data_t * cbk, int32_t which, char * key)
dict_unref(tmp);
}
+ tmp = NULL;
+
len = dict_serialized_length(lockinfo);
- if (len < 0)
- {
+ if (len < 0) {
+ err = len;
+
goto out;
}
ptr = GF_MALLOC(len, gf_common_mt_char);
- if (ptr == NULL)
- {
+ if (ptr == NULL) {
+ err = -ENOMEM;
+
goto out;
}
- if (dict_serialize(lockinfo, ptr) != 0)
- {
+ err = dict_serialize(lockinfo, ptr);
+ if (err != 0) {
goto out;
}
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
- if (dict_set_dynptr(dict, key, ptr, len) != 0)
- {
+ err = dict_set_dynptr(dict, key, ptr, len);
+ if (err != 0) {
goto out;
}
ptr = NULL;
- ret = 0;
-
out:
GF_FREE(ptr);
dict_unref(lockinfo);
+ if (tmp != NULL) {
+ dict_unref(tmp);
+ }
- return ret;
+ return err;
}
int32_t ec_dict_data_uuid(ec_cbk_data_t * cbk, int32_t which, char * key)
@@ -507,27 +505,22 @@ int32_t ec_dict_data_uuid(ec_cbk_data_t * cbk, int32_t which, char * key)
data_t * data;
min = cbk;
- for (ans = cbk->next; ans != NULL; ans = ans->next)
- {
- if (ans->idx < min->idx)
- {
+ for (ans = cbk->next; ans != NULL; ans = ans->next) {
+ if (ans->idx < min->idx) {
min = ans;
}
}
- if (min != cbk)
- {
+ if (min != cbk) {
src = (which == EC_COMBINE_XDATA) ? min->xdata : min->dict;
dst = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
data = dict_get(src, key);
- if (data == NULL)
- {
- return -1;
+ if (data == NULL) {
+ return -ENOENT;
}
- if (dict_set(dst, key, data) != 0)
- {
- return -1;
+ if (dict_set(dst, key, data) != 0) {
+ return -ENOMEM;
}
}
@@ -538,44 +531,38 @@ int32_t ec_dict_data_max32(ec_cbk_data_t *cbk, int32_t which, char *key)
{
data_t * data[cbk->count];
dict_t * dict;
- int32_t i, num;
+ int32_t i, num, err;
uint32_t max, tmp;
num = cbk->count;
- if (!ec_dict_list(data, &num, cbk, which, key))
- {
- return -1;
+ err = ec_dict_list(data, &num, cbk, which, key);
+ if (err != 0) {
+ return err;
}
max = data_to_uint32(data[0]);
- for (i = 1; i < num; i++)
- {
+ for (i = 1; i < num; i++) {
tmp = data_to_uint32(data[i]);
- if (max < tmp)
- {
+ if (max < tmp) {
max = tmp;
}
}
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
- if (dict_set_uint32(dict, key, max) != 0)
- {
- return -1;
- }
-
- return 0;
+ return dict_set_uint32(dict, key, max);
}
int32_t ec_dict_data_max64(ec_cbk_data_t *cbk, int32_t which, char *key)
{
data_t *data[cbk->count];
dict_t *dict;
- int32_t i, num;
+ int32_t i, num, err;
uint64_t max, tmp;
num = cbk->count;
- if (!ec_dict_list(data, &num, cbk, which, key)) {
- return -1;
+ err = ec_dict_list(data, &num, cbk, which, key);
+ if (err != 0) {
+ return err;
}
max = data_to_uint64(data[0]);
@@ -587,11 +574,7 @@ int32_t ec_dict_data_max64(ec_cbk_data_t *cbk, int32_t which, char *key)
}
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
- if (dict_set_uint64(dict, key, max) != 0) {
- return -1;
- }
-
- return 0;
+ return dict_set_uint64(dict, key, max);
}
int32_t ec_dict_data_quota(ec_cbk_data_t *cbk, int32_t which, char *key)
@@ -601,13 +584,14 @@ int32_t ec_dict_data_quota(ec_cbk_data_t *cbk, int32_t which, char *key)
ec_t *ec = NULL;
int32_t i = 0;
int32_t num = 0;
- int32_t ret = -1;
+ int32_t err = 0;
quota_meta_t size = {0, };
quota_meta_t max_size = {0, };
num = cbk->count;
- if (!ec_dict_list(data, &num, cbk, which, key)) {
- return -1;
+ err = ec_dict_list(data, &num, cbk, which, key);
+ if (err != 0) {
+ return err;
}
if (num == 0) {
@@ -620,9 +604,9 @@ int32_t ec_dict_data_quota(ec_cbk_data_t *cbk, int32_t which, char *key)
* case, we take the maximum of all received values.
*/
for (i = 0; i < num; i++) {
- ret = quota_data_to_meta (data[i], QUOTA_SIZE_KEY, &size);
- if (ret == -1)
+ if (quota_data_to_meta (data[i], QUOTA_SIZE_KEY, &size) < 0) {
continue;
+ }
if (size.size > max_size.size)
max_size.size = size.size;
@@ -636,36 +620,29 @@ int32_t ec_dict_data_quota(ec_cbk_data_t *cbk, int32_t which, char *key)
max_size.size *= ec->fragments;
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
- if (quota_dict_set_meta (dict, key, &max_size, IA_IFDIR) != 0) {
- return -1;
- }
-
- return 0;
+ return quota_dict_set_meta (dict, key, &max_size, IA_IFDIR);
}
int32_t ec_dict_data_stime(ec_cbk_data_t * cbk, int32_t which, char * key)
{
data_t * data[cbk->count];
dict_t * dict;
- int32_t i, num;
+ int32_t i, num, err;
num = cbk->count;
- if (!ec_dict_list(data, &num, cbk, which, key))
- {
- return -1;
+ err = ec_dict_list(data, &num, cbk, which, key);
+ if (err != 0) {
+ return err;
}
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
- for (i = 1; i < num; i++)
- {
- if (gf_get_max_stime(cbk->fop->xl, dict, key, data[i]) != 0)
- {
- gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, 0,
- EC_MSG_STIME_COMBINE_FAIL,
- "STIME combination "
- "failed");
+ for (i = 1; i < num; i++) {
+ err = gf_get_max_stime(cbk->fop->xl, dict, key, data[i]);
+ if (err != 0) {
+ gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, -err,
+ EC_MSG_STIME_COMBINE_FAIL, "STIME combination failed");
- return -1;
+ return err;
}
}
@@ -733,23 +710,24 @@ int32_t ec_dict_combine(ec_cbk_data_t * cbk, int32_t which)
{
dict_t * dict;
ec_dict_combine_t data;
+ int32_t err = 0;
data.cbk = cbk;
data.which = which;
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
- if ((dict != NULL) &&
- (dict_foreach(dict, ec_dict_data_combine, &data) != 0))
- {
- gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, 0,
- EC_MSG_DICT_COMBINE_FAIL,
- "Dictionary combination "
- "failed");
-
- return 0;
+ if (dict != NULL) {
+ err = dict_foreach(dict, ec_dict_data_combine, &data);
+ if (err != 0) {
+ gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, -err,
+ EC_MSG_DICT_COMBINE_FAIL,
+ "Dictionary combination failed");
+
+ return err;
+ }
}
- return 1;
+ return 0;
}
int32_t ec_vector_compare(struct iovec * dst_vector, int32_t dst_count,
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index e67b304..b4a9868 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -240,6 +240,49 @@ void ec_fop_set_error(ec_fop_data_t * fop, int32_t error)
UNLOCK(&fop->lock);
}
+gf_boolean_t
+ec_cbk_set_error(ec_cbk_data_t *cbk, int32_t error, gf_boolean_t ro)
+{
+ if ((error != 0) && (cbk->op_ret >= 0)) {
+ /* If cbk->op_errno was 0, it means that the fop succeeded and this
+ * error has happened while processing the answer. If the operation was
+ * read-only, there's no problem (i.e. we simply return the generated
+ * error code). However if it caused a modification, we must return EIO
+ * to indicate that the operation has been partially executed. */
+ cbk->op_errno = ro ? error : EIO;
+ cbk->op_ret = -1;
+
+ ec_fop_set_error(cbk->fop, cbk->op_errno);
+ }
+
+ return (cbk->op_ret < 0);
+}
+
+ec_cbk_data_t *
+ec_fop_prepare_answer(ec_fop_data_t *fop, gf_boolean_t ro)
+{
+ ec_cbk_data_t *cbk;
+ int32_t err;
+
+ cbk = fop->answer;
+ if (cbk == NULL) {
+ ec_fop_set_error(fop, EIO);
+
+ return NULL;
+ }
+
+ if (cbk->op_ret < 0) {
+ ec_fop_set_error(fop, cbk->op_errno);
+ }
+
+ err = ec_dict_combine(cbk, EC_COMBINE_XDATA);
+ if (ec_cbk_set_error(cbk, -err, ro)) {
+ return NULL;
+ }
+
+ return cbk;
+}
+
void ec_sleep(ec_fop_data_t *fop)
{
LOCK(&fop->lock);
@@ -597,15 +640,24 @@ void ec_dispatch_one(ec_fop_data_t * fop)
}
gf_boolean_t
-ec_dispatch_one_retry(ec_fop_data_t *fop, ec_cbk_data_t *cbk)
+ec_dispatch_one_retry(ec_fop_data_t *fop, ec_cbk_data_t **cbk)
{
- if ((cbk->op_ret < 0) && ec_is_recoverable_error (cbk->op_errno)) {
- GF_ASSERT (fop->mask & (1ULL<<cbk->idx));
- fop->mask ^= (1ULL << cbk->idx);
- if (fop->mask)
- return _gf_true;
+ ec_cbk_data_t *tmp;
+
+ tmp = ec_fop_prepare_answer(fop, _gf_true);
+ if (cbk != NULL) {
+ *cbk = tmp;
+ }
+ if ((tmp != NULL) && (tmp->op_ret < 0) &&
+ ec_is_recoverable_error (tmp->op_errno)) {
+ GF_ASSERT (fop->mask & (1ULL << tmp->idx));
+ fop->mask ^= (1ULL << tmp->idx);
+ if (fop->mask) {
+ return _gf_true;
}
- return _gf_false;
+ }
+
+ return _gf_false;
}
void ec_dispatch_inc(ec_fop_data_t * fop)
@@ -658,19 +710,22 @@ void ec_dispatch_min(ec_fop_data_t * fop)
}
}
-ec_lock_t *ec_lock_allocate(xlator_t *xl, loc_t *loc)
+ec_lock_t *ec_lock_allocate(ec_fop_data_t *fop, loc_t *loc)
{
- ec_t * ec = xl->private;
+ ec_t *ec = fop->xl->private;
ec_lock_t * lock;
+ int32_t err;
if ((loc->inode == NULL) ||
(gf_uuid_is_null(loc->gfid) && gf_uuid_is_null(loc->inode->gfid)))
{
- gf_msg (xl->name, GF_LOG_ERROR, EINVAL,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_INVALID_INODE,
"Trying to lock based on an invalid "
"inode");
+ __ec_fop_set_error(fop, EINVAL);
+
return NULL;
}
@@ -680,10 +735,12 @@ ec_lock_t *ec_lock_allocate(xlator_t *xl, loc_t *loc)
lock->good_mask = -1ULL;
INIT_LIST_HEAD(&lock->waiting);
INIT_LIST_HEAD(&lock->frozen);
- if (ec_loc_from_loc(xl, &lock->loc, loc) != 0)
- {
+ err = ec_loc_from_loc(fop->xl, &lock->loc, loc);
+ if (err != 0) {
mem_put(lock);
lock = NULL;
+
+ __ec_fop_set_error(fop, -err);
}
}
@@ -759,7 +816,7 @@ void ec_lock_prepare_inode_internal(ec_fop_data_t *fop, loc_t *loc,
ctx = __ec_inode_get(loc->inode, fop->xl);
if (ctx == NULL) {
- __ec_fop_set_error(fop, EIO);
+ __ec_fop_set_error(fop, ENOMEM);
goto unlock;
}
@@ -793,10 +850,8 @@ void ec_lock_prepare_inode_internal(ec_fop_data_t *fop, loc_t *loc,
goto insert;
}
- lock = ec_lock_allocate(fop->xl, loc);
+ lock = ec_lock_allocate(fop, loc);
if (lock == NULL) {
- __ec_fop_set_error(fop, EIO);
-
goto unlock;
}
@@ -825,13 +880,15 @@ void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc,
uint32_t flags)
{
loc_t tmp, *base = NULL;
+ int32_t err;
if (fop->error != 0) {
return;
}
- if (ec_loc_parent(fop->xl, loc, &tmp) != 0) {
- ec_fop_set_error(fop, EIO);
+ err = ec_loc_parent(fop->xl, loc, &tmp);
+ if (err != 0) {
+ ec_fop_set_error(fop, -err);
return;
}
@@ -849,13 +906,15 @@ void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc,
void ec_lock_prepare_fd(ec_fop_data_t *fop, fd_t *fd, uint32_t flags)
{
loc_t loc;
+ int32_t err;
if (fop->error != 0) {
return;
}
- if (ec_loc_from_fd(fop->xl, &loc, fd) != 0) {
- ec_fop_set_error(fop, EIO);
+ err = ec_loc_from_fd(fop->xl, &loc, fd);
+ if (err != 0) {
+ ec_fop_set_error(fop, -err);
return;
}
@@ -937,13 +996,12 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
goto out;
}
- op_errno = EIO;
-
LOCK(&lock->loc.inode->lock);
- if (ec_dict_del_array(dict, EC_XATTR_VERSION, ctx->pre_version,
- EC_VERSION_SIZE) != 0) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ op_errno = -ec_dict_del_array(dict, EC_XATTR_VERSION, ctx->pre_version,
+ EC_VERSION_SIZE);
+ if (op_errno != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, op_errno,
EC_MSG_VER_XATTR_GET_FAIL,
"Unable to get version xattr");
@@ -955,8 +1013,9 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
ctx->have_version = _gf_true;
if (lock->loc.inode->ia_type == IA_IFREG) {
- if (ec_dict_del_number(dict, EC_XATTR_SIZE, &ctx->pre_size) != 0) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ op_errno = -ec_dict_del_number(dict, EC_XATTR_SIZE, &ctx->pre_size);
+ if (op_errno != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, op_errno,
EC_MSG_SIZE_XATTR_GET_FAIL, "Unable to get size xattr");
goto unlock;
@@ -965,14 +1024,23 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
ctx->have_size = _gf_true;
- if ((ec_dict_del_config(dict, EC_XATTR_CONFIG, &ctx->config) != 0) ||
- !ec_config_check(parent, &ctx->config)) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ op_errno = -ec_dict_del_config(dict, EC_XATTR_CONFIG, &ctx->config);
+ if (op_errno != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, op_errno,
EC_MSG_CONFIG_XATTR_GET_FAIL,
"Unable to get config xattr");
goto unlock;
}
+ if (!ec_config_check(parent, &ctx->config)) {
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ EC_MSG_CONFIG_XATTR_INVALID,
+ "Invalid config xattr");
+
+ op_errno = EINVAL;
+
+ goto unlock;
+ }
ctx->have_config = _gf_true;
}
@@ -1008,7 +1076,7 @@ void ec_get_size_version(ec_lock_link_t *link)
dict_t *dict = NULL;
uid_t uid;
gid_t gid;
- int32_t error = ENOMEM;
+ int32_t error = -ENOMEM;
uint64_t allzero[EC_VERSION_SIZE] = {0, 0};
lock = link->lock;
@@ -1041,16 +1109,22 @@ void ec_get_size_version(ec_lock_link_t *link)
/* Once we know that an xattrop will be needed, we try to get all available
* information in a single call. */
- if ((ec_dict_set_array(dict, EC_XATTR_VERSION, allzero,
- EC_VERSION_SIZE) != 0) ||
- (ec_dict_set_array(dict, EC_XATTR_DIRTY, allzero,
- EC_VERSION_SIZE) != 0)) {
+ error = ec_dict_set_array(dict, EC_XATTR_VERSION, allzero,
+ EC_VERSION_SIZE);
+ if (error == 0) {
+ error = ec_dict_set_array(dict, EC_XATTR_DIRTY, allzero,
+ EC_VERSION_SIZE);
+ }
+ if (error != 0) {
goto out;
}
if (lock->loc.inode->ia_type == IA_IFREG) {
- if ((ec_dict_set_number(dict, EC_XATTR_SIZE, 0) != 0) ||
- (ec_dict_set_number(dict, EC_XATTR_CONFIG, 0) != 0)) {
+ error = ec_dict_set_number(dict, EC_XATTR_SIZE, 0);
+ if (error == 0) {
+ error = ec_dict_set_number(dict, EC_XATTR_CONFIG, 0);
+ }
+ if (error != 0) {
goto out;
}
}
@@ -1066,7 +1140,8 @@ void ec_get_size_version(ec_lock_link_t *link)
* fop.
*/
if (lock->fd == NULL) {
- if (ec_loc_from_loc(fop->xl, &loc, &lock->loc) != 0) {
+ error = ec_loc_from_loc(fop->xl, &loc, &lock->loc);
+ if (error != 0) {
goto out;
}
if (gf_uuid_is_null(loc.pargfid)) {
@@ -1101,7 +1176,7 @@ out:
}
if (error != 0) {
- ec_fop_set_error(fop, error);
+ ec_fop_set_error(fop, -error);
}
}
@@ -1298,7 +1373,7 @@ int32_t ec_locked(call_frame_t *frame, void *cookie, xlator_t *this,
ec_lock_acquired(link);
ec_lock(fop->parent);
} else {
- gf_msg (this->name, GF_LOG_WARNING, 0,
+ gf_msg (this->name, GF_LOG_WARNING, op_errno,
EC_MSG_PREOP_LOCK_FAILED,
"Failed to complete preop lock");
}
@@ -1479,7 +1554,7 @@ int32_t ec_unlocked(call_frame_t *frame, void *cookie, xlator_t *this,
ec_lock_link_t *link = fop->data;
if (op_ret < 0) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
+ gf_msg (this->name, GF_LOG_WARNING, op_errno,
EC_MSG_UNLOCK_FAILED,
"entry/inode unlocking failed (%s)",
ec_fop_name(link->fop->id));
@@ -1576,6 +1651,7 @@ ec_update_size_version(ec_lock_link_t *link, uint64_t *version,
dict_t * dict;
uid_t uid;
gid_t gid;
+ int32_t err = -ENOMEM;
fop = link->fop;
@@ -1593,8 +1669,9 @@ ec_update_size_version(ec_lock_link_t *link, uint64_t *version,
/* If we don't have version information or it has been modified, we
* update it. */
if (!ctx->have_version || (version[0] != 0) || (version[1] != 0)) {
- if (ec_dict_set_array(dict, EC_XATTR_VERSION,
- version, EC_VERSION_SIZE) != 0) {
+ err = ec_dict_set_array(dict, EC_XATTR_VERSION, version,
+ EC_VERSION_SIZE);
+ if (err != 0) {
goto out;
}
}
@@ -1604,7 +1681,8 @@ ec_update_size_version(ec_lock_link_t *link, uint64_t *version,
* of the file. */
GF_ASSERT(ctx->have_size);
- if (ec_dict_set_number(dict, EC_XATTR_SIZE, size) != 0) {
+ err = ec_dict_set_number(dict, EC_XATTR_SIZE, size);
+ if (err != 0) {
goto out;
}
}
@@ -1612,8 +1690,8 @@ ec_update_size_version(ec_lock_link_t *link, uint64_t *version,
/* If we don't have dirty information or it has been modified, we update
* it. */
if ((dirty[0] != 0) || (dirty[1] != 0)) {
- if (ec_dict_set_array(dict, EC_XATTR_DIRTY, dirty,
- EC_VERSION_SIZE) != 0) {
+ err = ec_dict_set_array(dict, EC_XATTR_DIRTY, dirty, EC_VERSION_SIZE);
+ if (err != 0) {
goto out;
}
}
@@ -1653,10 +1731,9 @@ out:
dict_unref(dict);
}
- ec_fop_set_error(fop, EIO);
+ ec_fop_set_error(fop, -err);
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
- EC_MSG_SIZE_VERS_UPDATE_FAIL,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, -err, EC_MSG_SIZE_VERS_UPDATE_FAIL,
"Unable to update version and size");
}
@@ -1789,7 +1866,7 @@ void ec_unlock_timer_add(ec_lock_link_t *link)
lock->timer = gf_timer_call_after(fop->xl->ctx, delay,
ec_unlock_timer_cbk, link);
if (lock->timer == NULL) {
- gf_msg(fop->xl->name, GF_LOG_WARNING, 0,
+ gf_msg(fop->xl->name, GF_LOG_WARNING, ENOMEM,
EC_MSG_UNLOCK_DELAY_FAILED,
"Unable to delay an "
"unlock");
diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h
index 41e10e2..3978712 100644
--- a/xlators/cluster/ec/src/ec-common.h
+++ b/xlators/cluster/ec/src/ec-common.h
@@ -75,7 +75,7 @@ typedef enum {
#define EC_STATE_HEAL_POST_INODELK_UNLOCK 217
#define EC_STATE_HEAL_DISPATCH 218
-gf_boolean_t ec_dispatch_one_retry (ec_fop_data_t *fop, ec_cbk_data_t *cbk);
+gf_boolean_t ec_dispatch_one_retry (ec_fop_data_t *fop, ec_cbk_data_t **cbk);
int32_t ec_dispatch_next(ec_fop_data_t * fop, int32_t idx);
void ec_complete(ec_fop_data_t * fop);
@@ -84,6 +84,12 @@ void ec_update_bad(ec_fop_data_t * fop, uintptr_t good);
void ec_fop_set_error(ec_fop_data_t * fop, int32_t error);
+ec_cbk_data_t *
+ec_fop_prepare_answer(ec_fop_data_t *fop, gf_boolean_t ro);
+
+gf_boolean_t
+ec_cbk_set_error(ec_cbk_data_t *cbk, int32_t error, gf_boolean_t ro);
+
void ec_lock_prepare_inode(ec_fop_data_t *fop, loc_t *loc, uint32_t flags);
void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc,
uint32_t flags);
diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c
index 7656865..3dd1a34 100644
--- a/xlators/cluster/ec/src/ec-data.c
+++ b/xlators/cluster/ec/src/ec-data.c
@@ -24,7 +24,7 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this,
if (fop->xl != this)
{
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
EC_MSG_XLATOR_MISMATCH, "Mismatching xlators between request "
"and answer (req=%s, ans=%s).", fop->xl->name, this->name);
@@ -32,7 +32,7 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this,
}
if (fop->frame != frame)
{
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
EC_MSG_FRAME_MISMATCH, "Mismatching frames between request "
"and answer (req=%p, ans=%p).",
fop->frame, frame);
@@ -41,7 +41,7 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this,
}
if (fop->id != id)
{
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
EC_MSG_FOP_MISMATCH, "Mismatching fops between request "
"and answer (req=%d, ans=%d).",
fop->id, id);
diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c
index 09010d5..24de9e7 100644
--- a/xlators/cluster/ec/src/ec-dir-read.c
+++ b/xlators/cluster/ec/src/ec-dir-read.c
@@ -111,6 +111,7 @@ int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state)
{
ec_cbk_data_t * cbk;
ec_fd_t *ctx;
+ int32_t err;
switch (state)
{
@@ -118,11 +119,18 @@ int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state)
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])) != 0) {
+ if (ctx == NULL) {
UNLOCK(&fop->fd->lock);
- fop->error = EIO;
+ fop->error = ENOMEM;
+
+ return EC_STATE_REPORT;
+ }
+ err = ec_loc_from_loc(fop->xl, &ctx->loc, &fop->loc[0]);
+ if (err != 0) {
+ UNLOCK(&fop->fd->lock);
+
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -136,38 +144,20 @@ int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
+ cbk = ec_fop_prepare_answer(fop, _gf_true);
+ if (cbk != NULL) {
+ /* Save which subvolumes successfully opened the directory.
+ * If ctx->open is 0, it means that readdir cannot be
+ * processed in this directory.
+ */
+ LOCK(&fop->fd->lock);
+
+ ctx = __ec_fd_get(fop->fd, fop->xl);
+ if (ctx != NULL) {
+ ctx->open |= cbk->mask;
}
- if (cbk->op_ret >= 0) {
- /* Save which subvolumes successfully opened the directory.
- * If ctx->open is 0, it means that readdir cannot be
- * processed in this directory.
- */
- LOCK(&fop->fd->lock);
-
- ctx = __ec_fd_get(fop->fd, fop->xl);
- if (ctx != NULL) {
- ctx->open |= cbk->mask;
- }
- UNLOCK(&fop->fd->lock);
- }
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
+ UNLOCK(&fop->fd->lock);
}
return EC_STATE_REPORT;
@@ -200,7 +190,7 @@ int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -214,7 +204,7 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .opendir = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(OPENDIR) %p", frame);
@@ -225,26 +215,21 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_OPENDIR, EC_FLAG_UPDATE_FD,
target, minimum, ec_wind_opendir,
ec_manager_opendir, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -252,11 +237,9 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -268,13 +251,10 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
@@ -286,11 +266,13 @@ ec_deitransform (xlator_t *this, off_t offset)
int client_id = -1;
ec_t *ec = this->private;
char id[32] = {0};
+ int err;
client_id = gf_deitransform (this, offset);
sprintf (id, "%d", client_id);
- if (dict_get_int32 (ec->leaf_to_subvolid, id, &idx)) {
- idx = -1;
+ err = dict_get_int32 (ec->leaf_to_subvolid, id, &idx);
+ if (err < 0) {
+ idx = err;
goto out;
}
@@ -299,6 +281,7 @@ out:
gf_msg (this->name, GF_LOG_ERROR, EINVAL,
EC_MSG_INVALID_REQUEST,
"Invalid index %d in readdirp request", client_id);
+ idx = -EINVAL;
}
return idx;
}
@@ -394,17 +377,20 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state)
}
if (fop->id == GF_FOP_READDIRP) {
+ int32_t err;
+
if (fop->xdata == NULL) {
fop->xdata = dict_new();
if (fop->xdata == NULL) {
- fop->error = EIO;
+ fop->error = ENOMEM;
return EC_STATE_REPORT;
}
}
- if (dict_set_uint64(fop->xdata, EC_XATTR_SIZE, 0)) {
- fop->error = EIO;
+ err = dict_set_uint64(fop->xdata, EC_XATTR_SIZE, 0);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -419,7 +405,7 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state)
idx = ec_deitransform (fop->xl, fop->offset);
if (idx < 0) {
- fop->error = EIO;
+ fop->error = -idx;
return EC_STATE_REPORT;
}
fop->mask &= 1ULL << idx;
@@ -436,18 +422,15 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk) {
- if (ec_dispatch_one_retry (fop, cbk))
- return EC_STATE_DISPATCH;
+ if (ec_dispatch_one_retry(fop, &cbk)) {
+ return EC_STATE_DISPATCH;
+ }
- if ((cbk->op_ret > 0) && (fop->id == GF_FOP_READDIRP)) {
- ec_adjust_readdirp (fop->xl->private, cbk->idx,
- &cbk->entries);
- }
- } else {
- ec_fop_set_error(fop, EIO);
+ if ((cbk != NULL) && (cbk->op_ret > 0) &&
+ (fop->id == GF_FOP_READDIRP)) {
+ ec_adjust_readdirp (fop->xl->private, cbk->idx, &cbk->entries);
}
+
return EC_STATE_REPORT;
case EC_STATE_REPORT:
@@ -505,7 +488,7 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -519,7 +502,7 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .readdir = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(READDIR) %p", frame);
@@ -530,8 +513,7 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_READDIR, 0, target, minimum,
ec_wind_readdir, ec_manager_readdir, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -540,11 +522,9 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->size = size;
fop->offset = offset;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -552,11 +532,9 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -568,13 +546,10 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
@@ -595,7 +570,7 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .readdirp = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(READDIRP) %p", frame);
@@ -606,8 +581,7 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_READDIRP, 0, target,
minimum, ec_wind_readdirp, ec_manager_readdir,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -616,11 +590,9 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->size = size;
fop->offset = offset;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -628,11 +600,9 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -644,12 +614,9 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
diff --git a/xlators/cluster/ec/src/ec-dir-write.c b/xlators/cluster/ec/src/ec-dir-write.c
index 5fe97c8..94a1ea2 100644
--- a/xlators/cluster/ec/src/ec-dir-write.c
+++ b/xlators/cluster/ec/src/ec-dir-write.c
@@ -104,6 +104,7 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state)
ec_cbk_data_t *cbk;
ec_fd_t *ctx;
uint64_t version[2] = {0, 0};
+ int32_t err;
switch (state)
{
@@ -111,11 +112,18 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state)
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])) != 0) {
+ if (ctx == NULL) {
UNLOCK(&fop->fd->lock);
- fop->error = EIO;
+ fop->error = ENOMEM;
+
+ return EC_STATE_REPORT;
+ }
+ err = ec_loc_from_loc(fop->xl, &ctx->loc, &fop->loc[0]);
+ if (err != 0) {
+ UNLOCK(&fop->fd->lock);
+
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -124,12 +132,10 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state)
UNLOCK(&fop->fd->lock);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
fop->xdata = dict_new();
- if (fop->xdata == NULL)
- {
- fop->error = EIO;
+ if (fop->xdata == NULL) {
+ fop->error = ENOMEM;
return EC_STATE_REPORT;
}
@@ -144,22 +150,22 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state)
config.redundancy = ec->redundancy;
config.chunk_size = EC_METHOD_CHUNK_SIZE;
- if (ec_dict_set_config(fop->xdata, EC_XATTR_CONFIG,
- &config) < 0) {
- fop->error = EIO;
+ err = ec_dict_set_config(fop->xdata, EC_XATTR_CONFIG, &config);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
-
- if (ec_dict_set_array(fop->xdata, EC_XATTR_VERSION,
- version, EC_VERSION_SIZE) != 0) {
- fop->error = EIO;
+ err = ec_dict_set_array(fop->xdata, EC_XATTR_VERSION, version,
+ EC_VERSION_SIZE);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
-
- if (ec_dict_set_number(fop->xdata, EC_XATTR_SIZE, 0) != 0) {
- fop->error = EIO;
+ err = ec_dict_set_number(fop->xdata, EC_XATTR_SIZE, 0);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -183,43 +189,24 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret >= 0) {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3,
- cbk->count);
-
- if (ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
- &cbk->iatt[0]) != 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- } else {
- LOCK(&fop->fd->lock);
-
- ctx = __ec_fd_get(fop->fd, fop->xl);
- if (ctx != NULL) {
- ctx->open |= cbk->mask;
- }
-
- UNLOCK(&fop->fd->lock);
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ int32_t err;
+
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3, cbk->count);
+
+ err = ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
+ &cbk->iatt[0]);
+ if (!ec_cbk_set_error(cbk, -err, _gf_false)) {
+ LOCK(&fop->fd->lock);
+
+ ctx = __ec_fd_get(fop->fd, fop->xl);
+ if (ctx != NULL) {
+ ctx->open |= cbk->mask;
}
+
+ UNLOCK(&fop->fd->lock);
}
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
}
return EC_STATE_REPORT;
@@ -267,7 +254,7 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -282,7 +269,7 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .create = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(CREATE) %p", frame);
@@ -295,8 +282,7 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_create, ec_manager_create, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -304,21 +290,17 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->mode[0] = mode;
fop->mode[1] = umask;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -326,11 +308,9 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -342,13 +322,10 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL, NULL, NULL, NULL);
}
}
@@ -393,37 +370,19 @@ int32_t ec_manager_link(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret >= 0) {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3,
- cbk->count);
- if (cbk->iatt[0].ia_type == IA_IFREG) {
- cbk->iatt[0].ia_size = fop->locks[0].size;
- }
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ int32_t err;
- if (ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
- &cbk->iatt[0]) != 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3, cbk->count);
+
+ if (cbk->iatt[0].ia_type == IA_IFREG) {
+ cbk->iatt[0].ia_size = fop->locks[0].size;
}
- }
- else
- {
- ec_fop_set_error(fop, EIO);
+
+ err = ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
+ &cbk->iatt[0]);
+ ec_cbk_set_error(cbk, -err, _gf_false);
}
return EC_STATE_REPORT;
@@ -470,7 +429,7 @@ int32_t ec_manager_link(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -484,7 +443,7 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .link = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(LINK) %p", frame);
@@ -494,36 +453,29 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_LINK, 0, target, minimum,
ec_wind_link, ec_manager_link, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (oldloc != NULL)
- {
- if (loc_copy(&fop->loc[0], oldloc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (oldloc != NULL) {
+ if (loc_copy(&fop->loc[0], oldloc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (newloc != NULL)
- {
- if (loc_copy(&fop->loc[1], newloc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (newloc != NULL) {
+ if (loc_copy(&fop->loc[1], newloc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -535,13 +487,10 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL, NULL, NULL);
}
}
@@ -569,21 +518,24 @@ int32_t ec_manager_mkdir(ec_fop_data_t * fop, int32_t state)
{
ec_cbk_data_t * cbk;
uint64_t version[2] = {0, 0};
+ int32_t err;
+
switch (state)
{
case EC_STATE_INIT:
if (fop->xdata == NULL) {
fop->xdata = dict_new();
if (fop->xdata == NULL) {
- fop->error = EIO;
+ fop->error = ENOMEM;
return EC_STATE_REPORT;
}
}
- if (ec_dict_set_array(fop->xdata, EC_XATTR_VERSION,
- version, EC_VERSION_SIZE) != 0) {
- fop->error = EIO;
+ err = ec_dict_set_array(fop->xdata, EC_XATTR_VERSION, version,
+ EC_VERSION_SIZE);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -602,34 +554,15 @@ int32_t ec_manager_mkdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret >= 0) {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3,
- cbk->count);
-
- if (ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
- &cbk->iatt[0]) != 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ int32_t err;
+
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3, cbk->count);
+
+ err = ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
+ &cbk->iatt[0]);
+ ec_cbk_set_error(cbk, -err, _gf_false);
}
return EC_STATE_REPORT;
@@ -676,7 +609,7 @@ int32_t ec_manager_mkdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -690,7 +623,7 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .mkdir = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(MKDIR) %p", frame);
@@ -702,29 +635,24 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_PARENT, target, minimum,
ec_wind_mkdir, ec_manager_mkdir, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->mode[0] = mode;
fop->mode[1] = umask;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -736,13 +664,10 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL, NULL, NULL);
}
}
@@ -778,10 +703,12 @@ int32_t ec_manager_mknod(ec_fop_data_t * fop, int32_t state)
{
case EC_STATE_INIT:
if (S_ISREG(fop->mode[0])) {
+ int32_t err;
+
if (fop->xdata == NULL) {
fop->xdata = dict_new();
if (fop->xdata == NULL) {
- fop->error = EIO;
+ fop->error = ENOMEM;
return EC_STATE_REPORT;
}
@@ -796,22 +723,22 @@ int32_t ec_manager_mknod(ec_fop_data_t * fop, int32_t state)
config.redundancy = ec->redundancy;
config.chunk_size = EC_METHOD_CHUNK_SIZE;
- if (ec_dict_set_config(fop->xdata, EC_XATTR_CONFIG,
- &config) < 0) {
- fop->error = EIO;
+ err = ec_dict_set_config(fop->xdata, EC_XATTR_CONFIG, &config);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
-
- if (ec_dict_set_array(fop->xdata, EC_XATTR_VERSION,
- version, EC_VERSION_SIZE) != 0) {
- fop->error = EIO;
+ err = ec_dict_set_array(fop->xdata, EC_XATTR_VERSION, version,
+ EC_VERSION_SIZE);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
-
- if (ec_dict_set_number(fop->xdata, EC_XATTR_SIZE, 0) != 0) {
- fop->error = EIO;
+ err = ec_dict_set_number(fop->xdata, EC_XATTR_SIZE, 0);
+ if (err != 0) {
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -832,34 +759,15 @@ int32_t ec_manager_mknod(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret >= 0) {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3,
- cbk->count);
-
- if (ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
- &cbk->iatt[0]) != 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ int32_t err;
+
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3, cbk->count);
+
+ err = ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
+ &cbk->iatt[0]);
+ ec_cbk_set_error(cbk, -err, _gf_false);
}
return EC_STATE_REPORT;
@@ -906,7 +814,7 @@ int32_t ec_manager_mknod(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -920,7 +828,7 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .mknod = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(MKNOD) %p", frame);
@@ -932,8 +840,7 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_PARENT, target, minimum,
ec_wind_mknod, ec_manager_mknod, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -941,21 +848,17 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->dev = rdev;
fop->mode[1] = umask;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -967,13 +870,10 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL, NULL, NULL);
}
}
@@ -1022,35 +922,14 @@ int32_t ec_manager_rename(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 5,
- cbk->count);
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 5, cbk->count);
- if (cbk->iatt[0].ia_type == IA_IFREG) {
- cbk->iatt[0].ia_size = fop->locks[0].size;
- }
+ if (cbk->iatt[0].ia_type == IA_IFREG) {
+ cbk->iatt[0].ia_size = fop->locks[0].size;
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -1097,7 +976,7 @@ int32_t ec_manager_rename(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1111,7 +990,7 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .rename = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(RENAME) %p", frame);
@@ -1123,36 +1002,29 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_PARENT, target, minimum,
ec_wind_rename, ec_manager_rename, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (oldloc != NULL)
- {
- if (loc_copy(&fop->loc[0], oldloc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (oldloc != NULL) {
+ if (loc_copy(&fop->loc[0], oldloc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (newloc != NULL)
- {
- if (loc_copy(&fop->loc[1], newloc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (newloc != NULL) {
+ if (loc_copy(&fop->loc[1], newloc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1164,13 +1036,10 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL, NULL, NULL, NULL);
}
}
@@ -1213,26 +1082,7 @@ int32_t ec_manager_rmdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
- }
+ ec_fop_prepare_answer(fop, _gf_false);
return EC_STATE_REPORT;
@@ -1278,7 +1128,7 @@ int32_t ec_manager_rmdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1292,7 +1142,7 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .rmdir = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(RMDIR) %p", frame);
@@ -1304,28 +1154,23 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_PARENT, target, minimum,
ec_wind_rmdir, ec_manager_rmdir, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->int32 = xflags;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1337,13 +1182,10 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
@@ -1387,34 +1229,15 @@ int32_t ec_manager_symlink(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret >= 0) {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3,
- cbk->count);
-
- if (ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
- &cbk->iatt[0]) != 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ int32_t err;
+
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 3, cbk->count);
+
+ err = ec_loc_update(fop->xl, &fop->loc[0], cbk->inode,
+ &cbk->iatt[0]);
+ ec_cbk_set_error(cbk, -err, _gf_false);
}
return EC_STATE_REPORT;
@@ -1462,7 +1285,7 @@ int32_t ec_manager_symlink(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1477,7 +1300,7 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .symlink = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(SYMLINK) %p", frame);
@@ -1489,39 +1312,32 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_PARENT, target, minimum,
ec_wind_symlink, ec_manager_symlink, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->mode[0] = umask;
- if (linkname != NULL)
- {
+ if (linkname != NULL) {
fop->str[0] = gf_strdup(linkname);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY, "Failed to duplicate a string.");
goto out;
}
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1533,13 +1349,10 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL, NULL, NULL);
}
}
@@ -1583,26 +1396,7 @@ int32_t ec_manager_unlink(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
- }
+ ec_fop_prepare_answer(fop, _gf_false);
return EC_STATE_REPORT;
@@ -1648,7 +1442,7 @@ int32_t ec_manager_unlink(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1662,7 +1456,7 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .unlink = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(UNLINK) %p", frame);
@@ -1674,28 +1468,23 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_PARENT, target, minimum,
ec_wind_unlink, ec_manager_unlink, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->int32 = xflags;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1707,12 +1496,9 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
diff --git a/xlators/cluster/ec/src/ec-generic.c b/xlators/cluster/ec/src/ec-generic.c
index 6ffdbcf..c5ea11b 100644
--- a/xlators/cluster/ec/src/ec-generic.c
+++ b/xlators/cluster/ec/src/ec-generic.c
@@ -100,26 +100,7 @@ int32_t ec_manager_flush(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
- }
+ ec_fop_prepare_answer(fop, _gf_false);
return EC_STATE_REPORT;
@@ -165,7 +146,7 @@ int32_t ec_manager_flush(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -179,7 +160,7 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .flush = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FLUSH) %p", frame);
@@ -190,18 +171,15 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_FLUSH, EC_FLAG_UPDATE_FD,
target, minimum, ec_wind_flush,
ec_manager_flush, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->use_fd = 1;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -209,11 +187,9 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -225,13 +201,10 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL);
}
}
@@ -342,35 +315,15 @@ int32_t ec_manager_fsync(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
- cbk->count);
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
+ cbk->count);
- /* This shouldn't fail because we have the inode locked. */
- GF_ASSERT(ec_get_inode_size(fop, fop->fd->inode,
- &cbk->iatt[0].ia_size));
- cbk->iatt[1].ia_size = cbk->iatt[0].ia_size;
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
+ /* This shouldn't fail because we have the inode locked. */
+ GF_ASSERT(ec_get_inode_size(fop, fop->fd->inode,
+ &cbk->iatt[0].ia_size));
+ cbk->iatt[1].ia_size = cbk->iatt[0].ia_size;
}
return EC_STATE_REPORT;
@@ -418,7 +371,7 @@ int32_t ec_manager_fsync(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -432,7 +385,7 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .fsync = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FSYNC) %p", frame);
@@ -443,8 +396,7 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_FSYNC, EC_FLAG_UPDATE_FD,
target, minimum, ec_wind_fsync,
ec_manager_fsync, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -452,11 +404,9 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->int32 = datasync;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -464,11 +414,9 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -480,13 +428,10 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
@@ -571,26 +516,7 @@ int32_t ec_manager_fsyncdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
- }
+ ec_fop_prepare_answer(fop, _gf_false);
return EC_STATE_REPORT;
@@ -636,7 +562,7 @@ int32_t ec_manager_fsyncdir(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -650,7 +576,7 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .fsyncdir = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FSYNCDIR) %p", frame);
@@ -661,8 +587,7 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_FSYNCDIR, EC_FLAG_UPDATE_FD,
target, minimum, ec_wind_fsyncdir,
ec_manager_fsyncdir, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -670,11 +595,9 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->int32 = datasync;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -682,11 +605,9 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -698,13 +619,10 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL);
}
}
@@ -714,20 +632,17 @@ void ec_lookup_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk)
{
ec_inode_t * ctx = NULL;
uint64_t size = 0;
- int32_t have_size = 0;
+ int32_t have_size = 0, err;
- if (cbk->op_ret < 0)
- {
+ if (cbk->op_ret < 0) {
return;
}
- ec_dict_del_array(cbk->xdata, EC_XATTR_VERSION,
- cbk->version, EC_VERSION_SIZE);
-
- if (ec_loc_update(fop->xl, &fop->loc[0], cbk->inode, &cbk->iatt[0]) != 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
+ ec_dict_del_array(cbk->xdata, EC_XATTR_VERSION, cbk->version,
+ EC_VERSION_SIZE);
+ err = ec_loc_update(fop->xl, &fop->loc[0], cbk->inode, &cbk->iatt[0]);
+ if (ec_cbk_set_error(cbk, -err, _gf_true)) {
return;
}
@@ -858,6 +773,7 @@ void ec_wind_lookup(ec_t * ec, ec_fop_data_t * fop, int32_t idx)
int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state)
{
ec_cbk_data_t *cbk;
+ int32_t err;
switch (state)
{
@@ -865,11 +781,11 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state)
if (fop->xdata == NULL) {
fop->xdata = dict_new();
if (fop->xdata == NULL) {
- gf_msg (fop->xl->name, GF_LOG_ERROR, EIO,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOOKUP_REQ_PREP_FAIL, "Unable to prepare "
"lookup request");
- fop->error = EIO;
+ fop->error = ENOMEM;
return EC_STATE_REPORT;
}
@@ -877,15 +793,19 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state)
/*TODO: To be handled once we have 'syndromes' */
dict_del (fop->xdata, GF_CONTENT_KEY);
}
- if ((dict_set_uint64(fop->xdata, EC_XATTR_SIZE, 0) != 0) ||
- (dict_set_uint64(fop->xdata, EC_XATTR_VERSION, 0) != 0) ||
- (dict_set_uint64(fop->xdata, EC_XATTR_DIRTY, 0) != 0))
- {
- gf_msg (fop->xl->name, GF_LOG_ERROR, EIO,
+ err = dict_set_uint64(fop->xdata, EC_XATTR_SIZE, 0);
+ if (err == 0) {
+ err = dict_set_uint64(fop->xdata, EC_XATTR_VERSION, 0);
+ }
+ if (err == 0) {
+ err = dict_set_uint64(fop->xdata, EC_XATTR_DIRTY, 0);
+ }
+ if (err != 0) {
+ gf_msg (fop->xl->name, GF_LOG_ERROR, -err,
EC_MSG_LOOKUP_REQ_PREP_FAIL, "Unable to prepare lookup "
"request");
- fop->error = EIO;
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -910,29 +830,11 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state)
list);
}
- cbk = fop->answer;
+ cbk = ec_fop_prepare_answer(fop, _gf_true);
if (cbk != NULL) {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
- cbk->count);
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2, cbk->count);
- ec_lookup_rebuild(fop->xl->private, fop, cbk);
- }
- } else {
- ec_fop_set_error(fop, EIO);
+ ec_lookup_rebuild(fop->xl->private, fop, cbk);
}
return EC_STATE_REPORT;
@@ -966,7 +868,7 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -980,7 +882,7 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .lookup = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(LOOKUP) %p", frame);
@@ -991,26 +893,21 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_LOOKUP, 0, target, minimum,
ec_wind_lookup, ec_manager_lookup, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1022,13 +919,10 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL, NULL);
}
}
@@ -1105,11 +999,11 @@ void ec_wind_statfs(ec_t * ec, ec_fop_data_t * fop, int32_t idx)
&fop->loc[0], fop->xdata);
}
-int32_t ec_manager_statfs(ec_fop_data_t * fop, int32_t state)
+int32_t ec_manager_statfs(ec_fop_data_t *fop, int32_t state)
{
ec_cbk_data_t *cbk = NULL;
gf_boolean_t deem_statfs_enabled = _gf_false;
- int ret = 0;
+ int32_t err = 0;
switch (state)
{
@@ -1120,40 +1014,24 @@ int32_t ec_manager_statfs(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
+ cbk = ec_fop_prepare_answer(fop, _gf_true);
+ if (cbk != NULL) {
+ ec_t *ec = fop->xl->private;
+
+ if (cbk->xdata) {
+ err = dict_get_int8 (cbk->xdata, "quota-deem-statfs",
+ (int8_t *)&deem_statfs_enabled);
+ if (err != -ENOENT) {
+ ec_cbk_set_error(cbk, -err, _gf_true);
}
}
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
- ec_t * ec = fop->xl->private;
-
- if (cbk->xdata)
- ret = dict_get_int8 (cbk->xdata, "quota-deem-statfs",
- (int8_t *)&deem_statfs_enabled);
- if (ret != 0 || deem_statfs_enabled == _gf_false) {
- cbk->statvfs.f_blocks *= ec->fragments;
- cbk->statvfs.f_bfree *= ec->fragments;
- cbk->statvfs.f_bavail *= ec->fragments;
- }
+ if (err != 0 || deem_statfs_enabled == _gf_false) {
+ cbk->statvfs.f_blocks *= ec->fragments;
+ cbk->statvfs.f_bfree *= ec->fragments;
+ cbk->statvfs.f_bavail *= ec->fragments;
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -1185,7 +1063,7 @@ int32_t ec_manager_statfs(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1199,7 +1077,7 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .statfs = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(STATFS) %p", frame);
@@ -1210,26 +1088,21 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_STATFS, 0, target, minimum,
ec_wind_statfs, ec_manager_statfs, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1241,13 +1114,10 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
@@ -1358,27 +1228,12 @@ int32_t ec_manager_xattrop(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA) ||
- ((cbk->op_ret >= 0) && !ec_dict_combine(cbk,
- EC_COMBINE_DICT)))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ int32_t err;
+
+ err = ec_dict_combine(cbk, EC_COMBINE_DICT);
+ ec_cbk_set_error(cbk, -err, _gf_false);
}
return EC_STATE_REPORT;
@@ -1448,7 +1303,7 @@ int32_t ec_manager_xattrop(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1463,7 +1318,7 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .xattrop = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(XATTROP) %p", frame);
@@ -1475,28 +1330,23 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_xattrop, ec_manager_xattrop, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->xattrop_flags = optype;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xattr != NULL)
- {
+ if (xattr != NULL) {
fop->dict = dict_ref(xattr);
- if (fop->dict == NULL)
- {
+ if (fop->dict == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1504,11 +1354,9 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1520,13 +1368,10 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
@@ -1546,7 +1391,7 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .fxattrop = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FXATTROP) %p", frame);
@@ -1558,8 +1403,7 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_fxattrop, ec_manager_xattrop, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -1567,11 +1411,9 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->xattrop_flags = optype;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -1579,11 +1421,9 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xattr != NULL)
- {
+ if (xattr != NULL) {
fop->dict = dict_ref(xattr);
- if (fop->dict == NULL)
- {
+ if (fop->dict == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1591,11 +1431,9 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1607,12 +1445,9 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c
index a7c97a5..f025cab 100644
--- a/xlators/cluster/ec/src/ec-heal.c
+++ b/xlators/cluster/ec/src/ec-heal.c
@@ -1069,9 +1069,8 @@ ec_create_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name,
config.redundancy = ec->redundancy;
config.chunk_size = EC_METHOD_CHUNK_SIZE;
- if (ec_dict_set_config(xdata, EC_XATTR_CONFIG,
- &config) < 0) {
- ret = -EIO;
+ ret = ec_dict_set_config(xdata, EC_XATTR_CONFIG, &config);
+ if (ret != 0) {
goto out;
}
default:
@@ -1725,7 +1724,7 @@ ec_manager_heal_block (ec_fop_data_t *fop, int32_t state)
case -EC_STATE_REPORT:
if (fop->cbks.heal) {
fop->cbks.heal (fop->req_frame, fop, fop->xl, -1,
- EIO, 0, 0, 0, NULL);
+ fop->error, 0, 0, 0, NULL);
}
return EC_STATE_END;
@@ -1745,7 +1744,7 @@ ec_heal_block (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .heal = func };
ec_fop_data_t *fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace("ec", 0, "EC(HEAL) %p", frame);
@@ -1765,7 +1764,7 @@ out:
if (fop != NULL) {
ec_manager(fop, error);
} else {
- func(frame, NULL, this, -1, EIO, 0, 0, 0, NULL);
+ func(frame, NULL, this, -1, error, 0, 0, 0, NULL);
}
}
@@ -2350,7 +2349,7 @@ void
ec_heal_fail (ec_t *ec, ec_fop_data_t *fop)
{
if (fop->cbks.heal) {
- fop->cbks.heal (fop->req_frame, NULL, ec->xl, -1, EIO, 0, 0,
+ fop->cbks.heal (fop->req_frame, NULL, ec->xl, -1, fop->error, 0, 0,
0, NULL);
}
if (fop)
@@ -2365,6 +2364,7 @@ ec_launch_heal (ec_t *ec, ec_fop_data_t *fop)
ret = synctask_new (ec->xl->ctx->env, ec_synctask_heal_wrap,
ec_heal_done, NULL, fop);
if (ret < 0) {
+ ec_fop_set_error(fop, ENOMEM);
ec_heal_fail (ec, fop);
}
}
@@ -2418,8 +2418,9 @@ ec_heal_throttle (xlator_t *this, ec_fop_data_t *fop)
if (fop)
ec_launch_heal (ec, fop);
} else {
- gf_msg_debug (this->name, 0, "Max number of heals are pending, "
- "background self-heal rejected");
+ gf_msg_debug (this->name, 0, "Max number of heals are "
+ "pending, background self-heal rejected");
+ ec_fop_set_error(fop, EBUSY);
ec_heal_fail (ec, fop);
}
}
@@ -2431,6 +2432,7 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .heal = func };
ec_fop_data_t *fop = NULL;
+ int32_t err = EINVAL;
gf_msg_trace ("ec", 0, "EC(HEAL) %p", frame);
@@ -2445,6 +2447,9 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target,
fop = ec_fop_data_allocate (frame, this, EC_FOP_HEAL,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
NULL, NULL, callback, data);
+
+ err = ENOMEM;
+
if (fop == NULL)
goto fail;
@@ -2459,10 +2464,12 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target,
fop->xdata = dict_ref(xdata);
ec_heal_throttle (this, fop);
+
return;
+
fail:
if (fop)
ec_fop_data_release (fop);
if (func)
- func (frame, NULL, this, -1, EIO, 0, 0, 0, NULL);
+ func (frame, NULL, this, -1, err, 0, 0, 0, NULL);
}
diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c
index 372633d..88bc92d 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -163,11 +163,14 @@ int32_t ec_dict_set_array(dict_t *dict, char *key, uint64_t value[],
{
uint64_t *ptr = NULL;
int32_t vindex;
- if (value == NULL)
- return -1;
+
+ if (value == NULL) {
+ return -EINVAL;
+ }
+
ptr = GF_MALLOC(sizeof(uint64_t) * size, gf_common_mt_char);
if (ptr == NULL) {
- return -1;
+ return -ENOMEM;
}
for (vindex = 0; vindex < size; vindex++) {
ptr[vindex] = hton64(value[vindex]);
@@ -183,14 +186,19 @@ int32_t ec_dict_del_array(dict_t *dict, char *key, uint64_t value[],
int32_t len;
int32_t vindex;
int32_t old_size = 0;
+ int32_t err;
- if ((dict == NULL) || (dict_get_ptr_and_len(dict, key, &ptr, &len) != 0)) {
- return -1;
+ if (dict == NULL) {
+ return -EINVAL;
+ }
+ err = dict_get_ptr_and_len(dict, key, &ptr, &len);
+ if (err != 0) {
+ return err;
}
- if (len > (size * sizeof(uint64_t)) ||
- (len % sizeof (uint64_t)))
- return -1;
+ if (len > (size * sizeof(uint64_t)) || (len % sizeof (uint64_t))) {
+ return -EINVAL;
+ }
memset (value, 0, size * sizeof(uint64_t));
/* 3.6 version ec would have stored version in 64 bit. In that case treat
@@ -217,9 +225,8 @@ int32_t ec_dict_set_number(dict_t * dict, char * key, uint64_t value)
uint64_t * ptr;
ptr = GF_MALLOC(sizeof(value), gf_common_mt_char);
- if (ptr == NULL)
- {
- return -1;
+ if (ptr == NULL) {
+ return -ENOMEM;
}
*ptr = hton64(value);
@@ -230,12 +237,17 @@ int32_t ec_dict_set_number(dict_t * dict, char * key, uint64_t value)
int32_t ec_dict_del_number(dict_t * dict, char * key, uint64_t * value)
{
void * ptr;
- int32_t len;
+ int32_t len, err;
- if ((dict == NULL) || (dict_get_ptr_and_len(dict, key, &ptr, &len) != 0) ||
- (len != sizeof(uint64_t)))
- {
- return -1;
+ if (dict == NULL) {
+ return -EINVAL;
+ }
+ err = dict_get_ptr_and_len(dict, key, &ptr, &len);
+ if (err != 0) {
+ return err;
+ }
+ if (len != sizeof(uint64_t)) {
+ return -EINVAL;
}
*value = ntoh64(*(uint64_t *)ptr);
@@ -256,13 +268,13 @@ int32_t ec_dict_set_config(dict_t * dict, char * key, ec_config_t * config)
"Trying to store an unsupported config "
"version (%u)", config->version);
- return -1;
+ return -EINVAL;
}
ptr = GF_MALLOC(sizeof(uint64_t), gf_common_mt_char);
if (ptr == NULL)
{
- return -1;
+ return -ENOMEM;
}
data = ((uint64_t)config->version) << 56;
@@ -281,12 +293,17 @@ int32_t ec_dict_del_config(dict_t * dict, char * key, ec_config_t * config)
{
void * ptr;
uint64_t data;
- int32_t len;
+ int32_t len, err;
- if ((dict == NULL) || (dict_get_ptr_and_len(dict, key, &ptr, &len) != 0) ||
- (len != sizeof(uint64_t)))
- {
- return -1;
+ if (dict == NULL) {
+ return -EINVAL;
+ }
+ err = dict_get_ptr_and_len(dict, key, &ptr, &len);
+ if (err != 0) {
+ return err;
+ }
+ if (len != sizeof(uint64_t)) {
+ return -EINVAL;
}
data = ntoh64(*(uint64_t *)ptr);
@@ -299,7 +316,7 @@ int32_t ec_dict_del_config(dict_t * dict, char * key, ec_config_t * config)
"Found an unsupported config version (%u)",
config->version);
- return -1;
+ return -EINVAL;
}
config->algorithm = (data >> 48) & 0xff;
@@ -313,35 +330,32 @@ int32_t ec_dict_del_config(dict_t * dict, char * key, ec_config_t * config)
return 0;
}
-int32_t ec_loc_gfid_check(xlator_t * xl, uuid_t dst, uuid_t src)
+gf_boolean_t ec_loc_gfid_check(xlator_t *xl, uuid_t dst, uuid_t src)
{
- if (gf_uuid_is_null(src))
- {
- return 1;
+ if (gf_uuid_is_null(src)) {
+ return _gf_true;
}
- if (gf_uuid_is_null(dst))
- {
+ if (gf_uuid_is_null(dst)) {
gf_uuid_copy(dst, src);
- return 1;
+ return _gf_true;
}
- if (gf_uuid_compare(dst, src) != 0)
- {
+ if (gf_uuid_compare(dst, src) != 0) {
gf_msg (xl->name, GF_LOG_WARNING, 0,
EC_MSG_GFID_MISMATCH,
"Mismatching GFID's in loc");
- return 0;
+ return _gf_false;
}
- return 1;
+ return _gf_true;
}
int32_t ec_loc_setup_inode(xlator_t *xl, inode_table_t *table, loc_t *loc)
{
- int32_t ret = -1;
+ int32_t ret = -EINVAL;
if (loc->inode != NULL) {
if (!ec_loc_gfid_check(xl, loc->gfid, loc->inode->gfid)) {
@@ -364,7 +378,7 @@ out:
int32_t ec_loc_setup_parent(xlator_t *xl, inode_table_t *table, loc_t *loc)
{
char *path, *parent;
- int32_t ret = -1;
+ int32_t ret = -EINVAL;
if (loc->parent != NULL) {
if (!ec_loc_gfid_check(xl, loc->pargfid, loc->parent->gfid)) {
@@ -381,6 +395,8 @@ int32_t ec_loc_setup_parent(xlator_t *xl, inode_table_t *table, loc_t *loc)
"Unable to duplicate path '%s'",
loc->path);
+ ret = -ENOMEM;
+
goto out;
}
parent = dirname(path);
@@ -408,13 +424,16 @@ int32_t ec_loc_setup_path(xlator_t *xl, loc_t *loc)
{
uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
char *name;
- int32_t ret = -1;
+ int32_t ret = -EINVAL;
if (loc->path != NULL) {
name = strrchr(loc->path, '/');
if (name == NULL) {
- ret = 0; /*<gfid:gfid-str>*/
- goto out;
+ /* Allow gfid paths: <gfid:...> */
+ if (strncmp(loc->path, "<gfid:", 6) == 0) {
+ ret = 0;
+ }
+ goto out;
}
if (name == loc->path) {
if (name[1] == 0) {
@@ -453,7 +472,7 @@ 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;
+ int32_t ret = -ENOMEM;
memset(parent, 0, sizeof(loc_t));
@@ -487,18 +506,25 @@ 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, table, parent) != 0) ||
- (ec_loc_setup_parent(xl, table, parent) != 0)) {
+ ret = ec_loc_setup_path(xl, parent);
+ if (ret == 0) {
+ ret = ec_loc_setup_inode(xl, table, parent);
+ }
+ if (ret == 0) {
+ ret = ec_loc_setup_parent(xl, table, parent);
+ }
+ if (ret != 0) {
goto out;
}
if ((parent->inode == NULL) && (parent->path == NULL) &&
gf_uuid_is_null(parent->gfid)) {
- gf_msg (xl->name, GF_LOG_ERROR, 0,
+ gf_msg (xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_LOC_PARENT_INODE_MISSING,
"Parent inode missing for loc_t");
+ ret = -EINVAL;
+
goto out;
}
@@ -507,8 +533,7 @@ int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent)
out:
GF_FREE(str);
- if (ret != 0)
- {
+ if (ret != 0) {
loc_wipe(parent);
}
@@ -519,7 +544,7 @@ 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;
+ int32_t ret = -EINVAL;
if (inode != NULL) {
table = inode->table;
@@ -542,14 +567,17 @@ 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, table, loc) != 0) ||
- (ec_loc_setup_parent(xl, table, loc) != 0)) {
+ ret = ec_loc_setup_path(xl, loc);
+ if (ret == 0) {
+ ret = ec_loc_setup_inode(xl, table, loc);
+ }
+ if (ret == 0) {
+ ret = ec_loc_setup_parent(xl, table, loc);
+ }
+ if (ret != 0) {
goto out;
}
- ret = 0;
-
out:
return ret;
}
@@ -557,7 +585,7 @@ out:
int32_t ec_loc_from_fd(xlator_t * xl, loc_t * loc, fd_t * fd)
{
ec_fd_t * ctx;
- int32_t ret = -1;
+ int32_t ret = -ENOMEM;
memset(loc, 0, sizeof(*loc));
@@ -568,12 +596,11 @@ int32_t ec_loc_from_fd(xlator_t * xl, loc_t * loc, fd_t * fd)
}
}
- if (ec_loc_update(xl, loc, fd->inode, NULL) != 0) {
+ ret = ec_loc_update(xl, loc, fd->inode, NULL);
+ if (ret != 0) {
goto out;
}
- ret = 0;
-
out:
if (ret != 0) {
loc_wipe(loc);
@@ -584,7 +611,7 @@ out:
int32_t ec_loc_from_loc(xlator_t * xl, loc_t * dst, loc_t * src)
{
- int32_t ret = -1;
+ int32_t ret = -ENOMEM;
memset(dst, 0, sizeof(*dst));
@@ -592,12 +619,11 @@ int32_t ec_loc_from_loc(xlator_t * xl, loc_t * dst, loc_t * src)
goto out;
}
- if (ec_loc_update(xl, dst, NULL, NULL) != 0) {
+ ret = ec_loc_update(xl, dst, NULL, NULL);
+ if (ret != 0) {
goto out;
}
- ret = 0;
-
out:
if (ret != 0) {
loc_wipe(dst);
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index 2cc374b..d9a33c8 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -82,13 +82,10 @@ ec_manager_access(ec_fop_data_t *fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk) {
- if (ec_dispatch_one_retry (fop, cbk))
- return EC_STATE_DISPATCH;
- } else {
- ec_fop_set_error(fop, EIO);
+ if (ec_dispatch_one_retry(fop, NULL)) {
+ return EC_STATE_DISPATCH;
}
+
return EC_STATE_REPORT;
case EC_STATE_REPORT:
@@ -127,7 +124,7 @@ ec_manager_access(ec_fop_data_t *fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -142,7 +139,7 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .access = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(ACCESS) %p", frame);
@@ -153,29 +150,24 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_ACCESS, 0, target, minimum,
ec_wind_access, ec_manager_access, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->int32 = mask;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -188,13 +180,10 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL);
}
}
@@ -337,25 +326,12 @@ int32_t ec_manager_getxattr(ec_fop_data_t * fop, int32_t state)
case EC_STATE_PREPARE_ANSWER:
ec_handle_special_xattrs (fop);
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA) ||
- ((cbk->op_ret >= 0) && !ec_dict_combine(cbk,
- EC_COMBINE_DICT)))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
+ cbk = ec_fop_prepare_answer(fop, _gf_true);
+ if (cbk != NULL) {
+ int32_t err;
+
+ err = ec_dict_combine(cbk, EC_COMBINE_DICT);
+ if (!ec_cbk_set_error(cbk, -err, _gf_true)) {
if (cbk->xdata != NULL)
ec_filter_internal_xattrs (cbk->xdata);
@@ -363,10 +339,6 @@ int32_t ec_manager_getxattr(ec_fop_data_t * fop, int32_t state)
ec_filter_internal_xattrs (cbk->dict);
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -411,7 +383,7 @@ int32_t ec_manager_getxattr(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -480,7 +452,7 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .getxattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(GETXATTR) %p", frame);
@@ -500,27 +472,22 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_getxattr, ec_manager_getxattr, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (name != NULL)
- {
+ if (name != NULL) {
fop->str[0] = gf_strdup(name);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -528,11 +495,9 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -635,7 +600,7 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .fgetxattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FGETXATTR) %p", frame);
@@ -647,18 +612,15 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_fgetxattr, ec_manager_getxattr,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->use_fd = 1;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -667,22 +629,18 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (name != NULL)
- {
+ if (name != NULL) {
fop->str[0] = gf_strdup(name);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY, "Failed to duplicate a string.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -814,6 +772,7 @@ int32_t ec_manager_open(ec_fop_data_t * fop, int32_t state)
{
ec_cbk_data_t * cbk;
ec_fd_t * ctx;
+ int32_t err;
switch (state)
{
@@ -821,11 +780,18 @@ int32_t ec_manager_open(ec_fop_data_t * fop, int32_t state)
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])) != 0) {
+ if (ctx == NULL) {
+ UNLOCK(&fop->fd->lock);
+
+ fop->error = ENOMEM;
+
+ return EC_STATE_REPORT;
+ }
+ err = ec_loc_from_loc(fop->xl, &ctx->loc, &fop->loc[0]);
+ if (err != 0) {
UNLOCK(&fop->fd->lock);
- fop->error = EIO;
+ fop->error = -err;
return EC_STATE_REPORT;
}
@@ -851,51 +817,33 @@ int32_t ec_manager_open(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
+ cbk = ec_fop_prepare_answer(fop, _gf_true);
+ if (cbk != NULL) {
+ int32_t err;
+
+ err = ec_loc_update(fop->xl, &fop->loc[0], cbk->fd->inode,
+ NULL);
+ if (!ec_cbk_set_error(cbk, -err, _gf_true)) {
+ LOCK(&fop->fd->lock);
+
+ ctx = __ec_fd_get(fop->fd, fop->xl);
+ if (ctx != NULL) {
+ ctx->open |= cbk->mask;
}
- }
- if (cbk->op_ret >= 0) {
- if (ec_loc_update(fop->xl, &fop->loc[0], cbk->fd->inode,
- NULL) != 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- } else {
- LOCK(&fop->fd->lock);
-
- ctx = __ec_fd_get(fop->fd, fop->xl);
- if (ctx != NULL) {
- ctx->open |= cbk->mask;
- }
- UNLOCK(&fop->fd->lock);
-
- /* If O_TRUNC was specified, call ftruncate to
- effectively trunc the file with appropriate locks
- acquired. We don't use ctx->flags because self-heal
- can use the same fd with different flags. */
- if (fop->uint32 != 0) {
- ec_sleep(fop);
- ec_ftruncate(fop->req_frame, fop->xl, cbk->mask,
- fop->minimum, ec_open_truncate_cbk,
- fop, cbk->fd, 0, NULL);
- }
+ UNLOCK(&fop->fd->lock);
+
+ /* If O_TRUNC was specified, call ftruncate to
+ effectively trunc the file with appropriate locks
+ acquired. We don't use ctx->flags because self-heal
+ can use the same fd with different flags. */
+ if (fop->uint32 != 0) {
+ ec_sleep(fop);
+ ec_ftruncate(fop->req_frame, fop->xl, cbk->mask,
+ fop->minimum, ec_open_truncate_cbk,
+ fop, cbk->fd, 0, NULL);
}
}
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- }
- else
- {
- ec_fop_set_error(fop, EIO);
}
return EC_STATE_REPORT;
@@ -928,7 +876,7 @@ int32_t ec_manager_open(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -942,7 +890,7 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .open = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(OPEN) %p", frame);
@@ -953,28 +901,23 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_OPEN, EC_FLAG_UPDATE_FD,
target, minimum, ec_wind_open, ec_manager_open,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->int32 = flags;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -982,11 +925,9 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -998,13 +939,10 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
@@ -1053,8 +991,7 @@ ec_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cbk->iatt[0] = *buf;
cbk->str = gf_strdup (path);
if (!cbk->str) {
- cbk->op_ret = -1;
- cbk->op_errno = ENOMEM;
+ ec_cbk_set_error(cbk, ENOMEM, _gf_true);
}
}
ec_combine (cbk, NULL);
@@ -1094,15 +1031,12 @@ int32_t ec_manager_readlink(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk) {
- if (ec_dispatch_one_retry (fop, cbk)) {
- return EC_STATE_DISPATCH;
- } else if (cbk->op_ret >= 0) {
- ec_iatt_rebuild(fop->xl->private, &cbk->iatt[0], 1, 1);
- }
- } else {
- ec_fop_set_error(fop, EIO);
+ if (ec_dispatch_one_retry(fop, &cbk)) {
+ return EC_STATE_DISPATCH;
+ }
+
+ if ((cbk != NULL) && (cbk->op_ret >= 0)) {
+ ec_iatt_rebuild(fop->xl->private, &cbk->iatt[0], 1, 1);
}
return EC_STATE_REPORT;
@@ -1141,7 +1075,7 @@ int32_t ec_manager_readlink(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1155,7 +1089,7 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .readlink = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(READLINK) %p", frame);
@@ -1166,28 +1100,23 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_READLINK, 0, target,
minimum, ec_wind_readlink, ec_manager_readlink,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->size = size;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1199,13 +1128,10 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
@@ -1218,17 +1144,18 @@ int32_t ec_readv_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk)
struct iobuf * iobuf = NULL;
uint8_t * buff = NULL, * ptr;
size_t fsize = 0, size = 0, max = 0;
- int32_t i = 0;
+ int32_t i = 0, err = -ENOMEM;
if (cbk->op_ret < 0) {
+ err = -cbk->op_errno;
+
goto out;
}
/* This shouldn't fail because we have the inode locked. */
GF_ASSERT(ec_get_inode_size(fop, fop->fd->inode, &cbk->iatt[0].ia_size));
- if (cbk->op_ret > 0)
- {
+ if (cbk->op_ret > 0) {
struct iovec vector[1];
uint8_t * blocks[cbk->count];
uint32_t values[cbk->count];
@@ -1236,30 +1163,26 @@ int32_t ec_readv_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk)
fsize = cbk->op_ret;
size = fsize * ec->fragments;
buff = GF_MALLOC(size, gf_common_mt_char);
- if (buff == NULL)
- {
+ if (buff == NULL) {
goto out;
}
ptr = buff;
- for (i = 0, ans = cbk; ans != NULL; i++, ans = ans->next)
- {
+ for (i = 0, ans = cbk; ans != NULL; i++, ans = ans->next) {
values[i] = ans->idx;
blocks[i] = ptr;
ptr += ec_iov_copy_to(ptr, ans->vector, ans->int32, 0, fsize);
}
iobref = iobref_new();
- if (iobref == NULL)
- {
+ if (iobref == NULL) {
goto out;
}
iobuf = iobuf_get2(fop->xl->ctx->iobuf_pool, size);
- if (iobuf == NULL)
- {
+ if (iobuf == NULL) {
goto out;
}
- if (iobref_add(iobref, iobuf) != 0)
- {
+ err = iobref_add(iobref, iobuf);
+ if (err != 0) {
goto out;
}
@@ -1276,18 +1199,15 @@ int32_t ec_readv_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk)
vector[0].iov_len -= fop->head;
max = fop->offset * ec->fragments + size;
- if (max > cbk->iatt[0].ia_size)
- {
+ if (max > cbk->iatt[0].ia_size) {
max = cbk->iatt[0].ia_size;
}
max -= fop->offset * ec->fragments + fop->head;
- if (max > fop->user_size)
- {
+ if (max > fop->user_size) {
max = fop->user_size;
}
size -= fop->head;
- if (size > max)
- {
+ if (size > max) {
vector[0].iov_len -= size - max;
size = max;
}
@@ -1300,29 +1220,23 @@ int32_t ec_readv_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk)
GF_FREE(cbk->vector);
cbk->vector = iov_dup(vector, 1);
- if (cbk->vector == NULL)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
-
- return 0;
+ if (cbk->vector == NULL) {
+ return -ENOMEM;
}
}
- return 1;
+ return 0;
out:
- if (iobuf != NULL)
- {
+ if (iobuf != NULL) {
iobuf_unref(iobuf);
}
- if (iobref != NULL)
- {
+ if (iobref != NULL) {
iobref_unref(iobref);
}
GF_FREE(buff);
- return 0;
+ return err;
}
int32_t ec_combine_readv(ec_fop_data_t * fop, ec_cbk_data_t * dst,
@@ -1370,17 +1284,13 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this,
cbk = ec_cbk_data_allocate(frame, this, fop, GF_FOP_READ, idx, op_ret,
op_errno);
- if (cbk != NULL)
- {
- if (op_ret >= 0)
- {
+ if (cbk != NULL) {
+ if (op_ret >= 0) {
cbk->int32 = count;
- if (count > 0)
- {
+ if (count > 0) {
cbk->vector = iov_dup(vector, count);
- if (cbk->vector == NULL)
- {
+ if (cbk->vector == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY, "Failed to duplicate a "
"vector list.");
@@ -1389,15 +1299,12 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this,
}
cbk->int32 = count;
}
- if (stbuf != NULL)
- {
+ if (stbuf != NULL) {
cbk->iatt[0] = *stbuf;
}
- if (iobref != NULL)
- {
+ if (iobref != NULL) {
cbk->buffers = iobref_ref(iobref);
- if (cbk->buffers == NULL)
- {
+ if (cbk->buffers == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_BUF_REF_FAIL, "Failed to reference a "
"buffer.");
@@ -1406,11 +1313,9 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this,
}
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
cbk->xdata = dict_ref(xdata);
- if (cbk->xdata == NULL)
- {
+ if (cbk->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1419,18 +1324,15 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this,
}
}
- if ((op_ret > 0) && ((op_ret % ec->fragment_size) != 0))
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
+ if ((op_ret > 0) && ((op_ret % ec->fragment_size) != 0)) {
+ ec_cbk_set_error(cbk, EIO, _gf_true);
}
ec_combine(cbk, ec_combine_readv);
}
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_complete(fop);
}
@@ -1472,36 +1374,18 @@ int32_t ec_manager_readv(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 1,
- cbk->count);
+ cbk = ec_fop_prepare_answer(fop, _gf_true);
+ if (cbk != NULL) {
+ int32_t err;
- if (!ec_readv_rebuild(fop->xl->private, fop, cbk))
- {
- ec_fop_set_error(fop, EIO);
- }
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 1,
+ cbk->count);
+
+ err = ec_readv_rebuild(fop->xl->private, fop, cbk);
+ if (err != 0) {
+ ec_cbk_set_error(cbk, -err, _gf_true);
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -1547,7 +1431,7 @@ int32_t ec_manager_readv(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1561,7 +1445,7 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .readv = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(READ) %p", frame);
@@ -1572,8 +1456,7 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_READ, EC_FLAG_UPDATE_FD,
target, minimum, ec_wind_readv,
ec_manager_readv, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -1583,11 +1466,9 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->offset = offset;
fop->uint32 = flags;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -1595,11 +1476,9 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1611,13 +1490,10 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, 0, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, 0, NULL, NULL, NULL);
}
}
@@ -1723,20 +1599,9 @@ int32_t ec_manager_stat(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- } else if (cbk->iatt[0].ia_type == IA_IFREG) {
+ cbk = ec_fop_prepare_answer(fop, _gf_true);
+ if (cbk != NULL) {
+ if (cbk->iatt[0].ia_type == IA_IFREG) {
ec_iatt_rebuild(fop->xl->private, cbk->iatt, 1,
cbk->count);
@@ -1746,10 +1611,6 @@ int32_t ec_manager_stat(ec_fop_data_t * fop, int32_t state)
&cbk->iatt[0].ia_size));
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -1816,7 +1677,7 @@ int32_t ec_manager_stat(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1830,7 +1691,7 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .stat = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(STAT) %p", frame);
@@ -1841,26 +1702,21 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_STAT,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_stat, ec_manager_stat, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL, "Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1872,13 +1728,10 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
@@ -1953,7 +1806,7 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .fstat = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FSTAT) %p", frame);
@@ -1964,18 +1817,15 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_FSTAT,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_fstat, ec_manager_stat, callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->use_fd = 1;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a "
"file descriptor.");
@@ -1983,11 +1833,9 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL, "Failed to reference a "
"dictionary.");
@@ -1999,12 +1847,9 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
index ff8e89e..31ab53b 100644
--- a/xlators/cluster/ec/src/ec-inode-write.c
+++ b/xlators/cluster/ec/src/ec-inode-write.c
@@ -141,20 +141,7 @@ ec_manager_xattr (ec_fop_data_t *fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk) {
- if (!ec_dict_combine (cbk, EC_COMBINE_XDATA)) {
- if (cbk->op_ret >= 0) {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
-
- if (cbk->op_ret < 0)
- ec_fop_set_error(fop, cbk->op_errno);
- } else {
- ec_fop_set_error(fop, EIO);
- }
+ ec_fop_prepare_answer(fop, _gf_false);
return EC_STATE_REPORT;
@@ -193,7 +180,7 @@ ec_manager_xattr (ec_fop_data_t *fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -209,7 +196,7 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .removexattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(REMOVEXATTR) %p", frame);
@@ -221,27 +208,22 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_removexattr, ec_manager_xattr,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (name != NULL)
- {
+ if (name != NULL) {
fop->str[0] = gf_strdup(name);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -249,11 +231,9 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -299,7 +279,7 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .fremovexattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FREMOVEXATTR) %p", frame);
@@ -311,18 +291,15 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_fremovexattr, ec_manager_xattr,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->use_fd = 1;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -331,11 +308,9 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (name != NULL)
- {
+ if (name != NULL) {
fop->str[0] = gf_strdup(name);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -343,11 +318,9 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -412,20 +385,9 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0) {
- ec_fop_set_error(fop, cbk->op_errno);
- } else if (cbk->iatt[0].ia_type == IA_IFREG) {
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ if (cbk->iatt[0].ia_type == IA_IFREG) {
ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
cbk->count);
@@ -436,10 +398,6 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state)
cbk->iatt[1].ia_size = cbk->iatt[0].ia_size;
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -510,7 +468,7 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -526,7 +484,7 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .setattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(SETATTR) %p", frame);
@@ -538,33 +496,27 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_setattr, ec_manager_setattr, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->int32 = valid;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (stbuf != NULL)
- {
+ if (stbuf != NULL) {
fop->iatt = *stbuf;
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -577,13 +529,10 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
@@ -613,7 +562,7 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .fsetattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FSETATTR) %p", frame);
@@ -625,8 +574,7 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_fsetattr, ec_manager_setattr, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -634,11 +582,9 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->int32 = valid;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -647,15 +593,12 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (stbuf != NULL)
- {
+ if (stbuf != NULL) {
fop->iatt = *stbuf;
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -668,13 +611,10 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
@@ -703,7 +643,7 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .setxattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(SETXATTR) %p", frame);
@@ -715,29 +655,24 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_setxattr, ec_manager_xattr, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->int32 = flags;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (dict != NULL)
- {
+ if (dict != NULL) {
fop->dict = dict_ref(dict);
- if (fop->dict == NULL)
- {
+ if (fop->dict == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -746,11 +681,9 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -836,7 +769,7 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
{
ec_cbk_t callback = { .fsetxattr = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FSETXATTR) %p", frame);
@@ -848,8 +781,7 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_fsetxattr, ec_manager_xattr,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -857,11 +789,9 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
fop->int32 = flags;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -870,11 +800,9 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (dict != NULL)
- {
+ if (dict != NULL) {
fop->dict = dict_ref(dict);
- if (fop->dict == NULL)
- {
+ if (fop->dict == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -883,11 +811,9 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -915,20 +841,18 @@ int32_t ec_truncate_write(ec_fop_data_t * fop, uintptr_t mask)
struct iobref * iobref = NULL;
struct iobuf * iobuf = NULL;
struct iovec vector;
- int32_t ret = 0;
+ int32_t err = -ENOMEM;
iobref = iobref_new();
- if (iobref == NULL)
- {
+ if (iobref == NULL) {
goto out;
}
iobuf = iobuf_get(fop->xl->ctx->iobuf_pool);
- if (iobuf == NULL)
- {
+ if (iobuf == NULL) {
goto out;
}
- if (iobref_add(iobref, iobuf) != 0)
- {
+ err = iobref_add(iobref, iobuf);
+ if (err != 0) {
goto out;
}
@@ -942,19 +866,17 @@ int32_t ec_truncate_write(ec_fop_data_t * fop, uintptr_t mask)
ec_writev(fop->frame, fop->xl, mask, fop->minimum, NULL, NULL, fop->fd,
&vector, 1, fop->user_size, 0, iobref, NULL);
- ret = 1;
+ err = 0;
out:
- if (iobuf != NULL)
- {
+ if (iobuf != NULL) {
iobuf_unref(iobuf);
}
- if (iobref != NULL)
- {
+ if (iobref != NULL) {
iobref_unref(iobref);
}
- return ret;
+ return err;
}
int32_t ec_truncate_open_cbk(call_frame_t * frame, void * cookie,
@@ -962,12 +884,12 @@ int32_t ec_truncate_open_cbk(call_frame_t * frame, void * cookie,
fd_t * fd, dict_t * xdata)
{
ec_fop_data_t * fop = cookie;
+ int32_t err;
- if (op_ret >= 0)
- {
- if (!ec_truncate_write(fop->parent, fop->answer->mask))
- {
- fop->error = EIO;
+ if (op_ret >= 0) {
+ err = ec_truncate_write(fop->parent, fop->answer->mask);
+ if (err != 0) {
+ fop->error = -err;
}
}
@@ -976,22 +898,18 @@ int32_t ec_truncate_open_cbk(call_frame_t * frame, void * cookie,
int32_t ec_truncate_clean(ec_fop_data_t * fop)
{
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
fop->fd = fd_create(fop->loc[0].inode, fop->frame->root->pid);
- if (fop->fd == NULL)
- {
- return 0;
+ if (fop->fd == NULL) {
+ return -ENOMEM;
}
ec_open(fop->frame, fop->xl, fop->answer->mask, fop->minimum,
ec_truncate_open_cbk, fop, &fop->loc[0], O_RDWR, fop->fd,
NULL);
- return 1;
- }
- else
- {
+ return 0;
+ } else {
return ec_truncate_write(fop, fop->answer->mask);
}
}
@@ -1045,47 +963,28 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
- }
- }
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
- cbk->count);
-
- /* This shouldn't fail because we have the inode locked. */
- GF_ASSERT(ec_get_inode_size(fop,
- fop->locks[0].lock->loc.inode,
- &cbk->iatt[0].ia_size));
- cbk->iatt[1].ia_size = fop->user_size;
- /* This shouldn't fail because we have the inode locked. */
- GF_ASSERT(ec_set_inode_size(fop,
- fop->locks[0].lock->loc.inode,
- fop->user_size));
- if ((cbk->iatt[0].ia_size > cbk->iatt[1].ia_size) &&
- (fop->user_size != fop->offset)) {
- if (!ec_truncate_clean(fop)) {
- ec_fop_set_error(fop, EIO);
- }
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ int32_t err;
+
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
+ cbk->count);
+
+ /* This shouldn't fail because we have the inode locked. */
+ GF_ASSERT(ec_get_inode_size(fop, fop->locks[0].lock->loc.inode,
+ &cbk->iatt[0].ia_size));
+ cbk->iatt[1].ia_size = fop->user_size;
+ /* This shouldn't fail because we have the inode locked. */
+ GF_ASSERT(ec_set_inode_size(fop, fop->locks[0].lock->loc.inode,
+ fop->user_size));
+ if ((cbk->iatt[0].ia_size > cbk->iatt[1].ia_size) &&
+ (fop->user_size != fop->offset)) {
+ err = ec_truncate_clean(fop);
+ if (err != 0) {
+ ec_cbk_set_error(cbk, -err, _gf_false);
}
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -1156,7 +1055,7 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1171,7 +1070,7 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .truncate = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(TRUNCATE) %p", frame);
@@ -1183,29 +1082,24 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_truncate, ec_manager_truncate, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->offset = offset;
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -1218,13 +1112,10 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
@@ -1254,7 +1145,7 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .ftruncate = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FTRUNCATE) %p", frame);
@@ -1266,8 +1157,7 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_ftruncate, ec_manager_truncate,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -1275,11 +1165,9 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->offset = offset;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -1288,11 +1176,9 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -1305,13 +1191,10 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
@@ -1401,13 +1284,14 @@ void ec_writev_start(ec_fop_data_t *fop)
uint64_t current;
uid_t uid;
gid_t gid;
+ int32_t err = -ENOMEM;
/* This shouldn't fail because we have the inode locked. */
GF_ASSERT(ec_get_inode_size(fop, fop->fd->inode, &current));
fd = fd_anonymous(fop->fd->inode);
if (fd == NULL) {
- ec_fop_set_error(fop, EIO);
+ ec_fop_set_error(fop, ENOMEM);
return;
}
@@ -1436,7 +1320,8 @@ void ec_writev_start(ec_fop_data_t *fop)
if (iobuf == NULL) {
goto out;
}
- if (iobref_add(iobref, iobuf) != 0) {
+ err = iobref_add(iobref, iobuf);
+ if (err != 0) {
goto out;
}
@@ -1486,7 +1371,7 @@ out:
fd_unref(fd);
- ec_fop_set_error(fop, EIO);
+ ec_fop_set_error(fop, -err);
}
int32_t ec_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
@@ -1513,10 +1398,10 @@ void ec_wind_writev(ec_t * ec, ec_fop_data_t * fop, int32_t idx)
struct iobref * iobref = NULL;
struct iobuf * iobuf = NULL;
ssize_t size = 0, bufsize = 0;
+ int32_t err = -ENOMEM;
iobref = iobref_new();
- if (iobref == NULL)
- {
+ if (iobref == NULL) {
goto out;
}
@@ -1524,12 +1409,11 @@ void ec_wind_writev(ec_t * ec, ec_fop_data_t * fop, int32_t idx)
bufsize = size / ec->fragments;
iobuf = iobuf_get2(fop->xl->ctx->iobuf_pool, bufsize);
- if (iobuf == NULL)
- {
+ if (iobuf == NULL) {
goto out;
}
- if (iobref_add(iobref, iobuf) != 0)
- {
+ err = iobref_add(iobref, iobuf);
+ if (err != 0) {
goto out;
}
@@ -1551,22 +1435,20 @@ void ec_wind_writev(ec_t * ec, ec_fop_data_t * fop, int32_t idx)
return;
out:
- if (iobuf != NULL)
- {
+ if (iobuf != NULL) {
iobuf_unref(iobuf);
}
- if (iobref != NULL)
- {
+ if (iobref != NULL) {
iobref_unref(iobref);
}
- ec_writev_cbk(fop->frame, (void *)(uintptr_t)idx, fop->xl, -1, EIO, NULL,
+ ec_writev_cbk(fop->frame, (void *)(uintptr_t)idx, fop->xl, -1, -err, NULL,
NULL, NULL);
}
-int32_t ec_manager_writev(ec_fop_data_t * fop, int32_t state)
+int32_t ec_manager_writev(ec_fop_data_t *fop, int32_t state)
{
- ec_cbk_data_t * cbk;
+ ec_cbk_data_t *cbk;
switch (state)
{
@@ -1590,64 +1472,44 @@ int32_t ec_manager_writev(ec_fop_data_t * fop, int32_t state)
return EC_STATE_PREPARE_ANSWER;
case EC_STATE_PREPARE_ANSWER:
- cbk = fop->answer;
- if (cbk != NULL)
- {
- if (!ec_dict_combine(cbk, EC_COMBINE_XDATA))
- {
- if (cbk->op_ret >= 0)
- {
- cbk->op_ret = -1;
- cbk->op_errno = EIO;
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
+ if (cbk != NULL) {
+ ec_t *ec = fop->xl->private;
+ size_t size;
+
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
+ cbk->count);
+
+ /* This shouldn't fail because we have the inode locked. */
+ GF_ASSERT(ec_get_inode_size(fop, fop->fd->inode,
+ &cbk->iatt[0].ia_size));
+ cbk->iatt[1].ia_size = cbk->iatt[0].ia_size;
+ size = fop->offset + fop->head + fop->user_size;
+ if (size > cbk->iatt[0].ia_size) {
+ /* Only update inode size if this is a top level fop.
+ * Otherwise this is an internal write and the top
+ * level fop should take care of the real inode size.
+ */
+ if (fop->parent == NULL) {
+ /* This shouldn't fail because we have the inode
+ * locked. */
+ GF_ASSERT(ec_set_inode_size(fop, fop->fd->inode,
+ size));
}
+ cbk->iatt[1].ia_size = size;
}
- if (cbk->op_ret < 0)
- {
- ec_fop_set_error(fop, cbk->op_errno);
- }
- else
- {
- ec_t * ec = fop->xl->private;
- size_t size;
-
- ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
- cbk->count);
-
- /* This shouldn't fail because we have the inode locked. */
- GF_ASSERT(ec_get_inode_size(fop, fop->fd->inode,
- &cbk->iatt[0].ia_size));
- cbk->iatt[1].ia_size = cbk->iatt[0].ia_size;
- size = fop->offset + fop->head + fop->user_size;
- if (size > cbk->iatt[0].ia_size) {
- /* Only update inode size if this is a top level fop.
- * Otherwise this is an internal write and the top
- * level fop should take care of the real inode size.
- */
- if (fop->parent == NULL) {
- /* This shouldn't fail because we have the inode
- * locked. */
- GF_ASSERT(ec_set_inode_size(fop, fop->fd->inode,
- size));
- }
- cbk->iatt[1].ia_size = size;
+ if (fop->error == 0) {
+ cbk->op_ret *= ec->fragments;
+ if (cbk->op_ret < fop->head) {
+ cbk->op_ret = 0;
+ } else {
+ cbk->op_ret -= fop->head;
}
- if (fop->error == 0) {
- cbk->op_ret *= ec->fragments;
- if (cbk->op_ret < fop->head) {
- cbk->op_ret = 0;
- } else {
- cbk->op_ret -= fop->head;
- }
- if (cbk->op_ret > fop->user_size) {
- cbk->op_ret = fop->user_size;
- }
+ if (cbk->op_ret > fop->user_size) {
+ cbk->op_ret = fop->user_size;
}
}
}
- else
- {
- ec_fop_set_error(fop, EIO);
- }
return EC_STATE_REPORT;
@@ -1694,7 +1556,7 @@ int32_t ec_manager_writev(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1710,7 +1572,7 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .writev = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(WRITE) %p", frame);
@@ -1722,8 +1584,7 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_writev, ec_manager_writev, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -1733,11 +1594,9 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->use_fd = 1;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -1746,11 +1605,9 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (count > 0)
- {
+ if (count > 0) {
fop->vector = iov_dup(vector, count);
- if (fop->vector == NULL)
- {
+ if (fop->vector == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a "
@@ -1760,11 +1617,9 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
}
fop->int32 = count;
}
- if (iobref != NULL)
- {
+ if (iobref != NULL) {
fop->buffers = iobref_ref(iobref);
- if (fop->buffers == NULL)
- {
+ if (fop->buffers == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_BUF_REF_FAIL,
"Failed to reference a "
@@ -1773,11 +1628,9 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -1790,12 +1643,9 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
}
}
diff --git a/xlators/cluster/ec/src/ec-locks.c b/xlators/cluster/ec/src/ec-locks.c
index 9c41e11..00bfc0d 100644
--- a/xlators/cluster/ec/src/ec-locks.c
+++ b/xlators/cluster/ec/src/ec-locks.c
@@ -95,7 +95,7 @@ int32_t ec_lock_unlocked(call_frame_t * frame, void * cookie,
{
if (op_ret < 0)
{
- gf_msg (this->name, GF_LOG_WARNING, 0,
+ gf_msg (this->name, GF_LOG_WARNING, op_errno,
EC_MSG_UNLOCK_FAILED,
"Failed to unlock an entry/inode");
}
@@ -109,7 +109,7 @@ int32_t ec_lock_lk_unlocked(call_frame_t * frame, void * cookie,
{
if (op_ret < 0)
{
- gf_msg(this->name, GF_LOG_WARNING, 0,
+ gf_msg(this->name, GF_LOG_WARNING, op_errno,
EC_MSG_LK_UNLOCK_FAILED,
"Failed to unlock an lk");
}
@@ -227,12 +227,7 @@ int32_t ec_manager_entrylk(ec_fop_data_t * fop, int32_t state)
}
}
} 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);
- }
+ ec_fop_prepare_answer(fop, _gf_true);
}
return EC_STATE_REPORT;
@@ -287,7 +282,7 @@ int32_t ec_manager_entrylk(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -303,7 +298,7 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .entrylk = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(ENTRYLK) %p", frame);
@@ -315,19 +310,16 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_entrylk, ec_manager_entrylk, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->entrylk_cmd = cmd;
fop->entrylk_type = type;
- if (volume != NULL)
- {
+ if (volume != NULL) {
fop->str[0] = gf_strdup(volume);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -335,22 +327,18 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (basename != NULL)
- {
+ if (basename != NULL) {
fop->str[1] = gf_strdup(basename);
- if (fop->str[1] == NULL)
- {
+ if (fop->str[1] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -358,11 +346,9 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -375,13 +361,10 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL);
}
}
@@ -451,7 +434,7 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .fentrylk = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FENTRYLK) %p", frame);
@@ -463,8 +446,7 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_fentrylk, ec_manager_entrylk, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -473,11 +455,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->entrylk_cmd = cmd;
fop->entrylk_type = type;
- if (volume != NULL)
- {
+ if (volume != NULL) {
fop->str[0] = gf_strdup(volume);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -485,11 +465,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -498,11 +476,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (basename != NULL)
- {
+ if (basename != NULL) {
fop->str[1] = gf_strdup(basename);
- if (fop->str[1] == NULL)
- {
+ if (fop->str[1] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -510,11 +486,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -527,13 +501,10 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL);
}
}
@@ -659,12 +630,7 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state)
}
}
} 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);
- }
+ ec_fop_prepare_answer(fop, _gf_true);
}
return EC_STATE_REPORT;
@@ -719,7 +685,7 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -735,7 +701,7 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .inodelk = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(INODELK) %p", frame);
@@ -747,18 +713,15 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_LOC_INODE, target, minimum,
ec_wind_inodelk, ec_manager_inodelk, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
fop->int32 = cmd;
- if (volume != NULL)
- {
+ if (volume != NULL) {
fop->str[0] = gf_strdup(volume);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -766,36 +729,30 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (loc != NULL)
- {
- if (loc_copy(&fop->loc[0], loc) != 0)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ if (loc != NULL) {
+ if (loc_copy(&fop->loc[0], loc) != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_LOC_COPY_FAIL,
"Failed to copy a location.");
goto out;
}
}
- if (flock != NULL)
- {
+ if (flock != NULL) {
fop->flock.l_type = flock->l_type;
fop->flock.l_whence = flock->l_whence;
fop->flock.l_start = flock->l_start;
fop->flock.l_len = flock->l_len;
fop->flock.l_pid = flock->l_pid;
fop->flock.l_owner.len = flock->l_owner.len;
- if (flock->l_owner.len > 0)
- {
+ if (flock->l_owner.len > 0) {
memcpy(fop->flock.l_owner.data, flock->l_owner.data,
flock->l_owner.len);
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -808,13 +765,10 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL);
}
}
@@ -884,7 +838,7 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .finodelk = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(FINODELK) %p", frame);
@@ -896,8 +850,7 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
EC_FLAG_UPDATE_FD_INODE, target, minimum,
ec_wind_finodelk, ec_manager_inodelk, callback,
data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -905,11 +858,9 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->int32 = cmd;
- if (volume != NULL)
- {
+ if (volume != NULL) {
fop->str[0] = gf_strdup(volume);
- if (fop->str[0] == NULL)
- {
+ if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
"Failed to duplicate a string.");
@@ -917,11 +868,9 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -930,25 +879,21 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (flock != NULL)
- {
+ if (flock != NULL) {
fop->flock.l_type = flock->l_type;
fop->flock.l_whence = flock->l_whence;
fop->flock.l_start = flock->l_start;
fop->flock.l_len = flock->l_len;
fop->flock.l_pid = flock->l_pid;
fop->flock.l_owner.len = flock->l_owner.len;
- if (flock->l_owner.len > 0)
- {
+ if (flock->l_owner.len > 0) {
memcpy(fop->flock.l_owner.data, flock->l_owner.data,
flock->l_owner.len);
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -961,13 +906,10 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL);
}
}
@@ -1119,12 +1061,7 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state)
}
}
} 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);
- }
+ ec_fop_prepare_answer(fop, _gf_true);
}
return EC_STATE_REPORT;
@@ -1157,7 +1094,7 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state)
return EC_STATE_END;
default:
- gf_msg (fop->xl->name, GF_LOG_ERROR, 0,
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
EC_MSG_UNHANDLED_STATE,
"Unhandled state %d for %s",
state, ec_fop_name(fop->id));
@@ -1172,7 +1109,7 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target,
{
ec_cbk_t callback = { .lk = func };
ec_fop_data_t * fop = NULL;
- int32_t error = EIO;
+ int32_t error = ENOMEM;
gf_msg_trace ("ec", 0, "EC(LK) %p", frame);
@@ -1183,8 +1120,7 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop = ec_fop_data_allocate(frame, this, GF_FOP_LK, EC_FLAG_UPDATE_FD_INODE,
target, minimum, ec_wind_lk, ec_manager_lk,
callback, data);
- if (fop == NULL)
- {
+ if (fop == NULL) {
goto out;
}
@@ -1192,11 +1128,9 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->int32 = cmd;
- if (fd != NULL)
- {
+ if (fd != NULL) {
fop->fd = fd_ref(fd);
- if (fop->fd == NULL)
- {
+ if (fop->fd == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_FILE_DESC_REF_FAIL,
"Failed to reference a "
@@ -1205,25 +1139,21 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
}
- if (flock != NULL)
- {
+ if (flock != NULL) {
fop->flock.l_type = flock->l_type;
fop->flock.l_whence = flock->l_whence;
fop->flock.l_start = flock->l_start;
fop->flock.l_len = flock->l_len;
fop->flock.l_pid = flock->l_pid;
fop->flock.l_owner.len = flock->l_owner.len;
- if (flock->l_owner.len > 0)
- {
+ if (flock->l_owner.len > 0) {
memcpy(fop->flock.l_owner.data, flock->l_owner.data,
flock->l_owner.len);
}
}
- if (xdata != NULL)
- {
+ if (xdata != NULL) {
fop->xdata = dict_ref(xdata);
- if (fop->xdata == NULL)
- {
+ if (fop->xdata == NULL) {
gf_msg (this->name, GF_LOG_ERROR, 0,
EC_MSG_DICT_REF_FAIL,
"Failed to reference a "
@@ -1236,12 +1166,9 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target,
error = 0;
out:
- if (fop != NULL)
- {
+ if (fop != NULL) {
ec_manager(fop, error);
- }
- else
- {
- func(frame, NULL, this, -1, EIO, NULL, NULL);
+ } else {
+ func(frame, NULL, this, -1, error, NULL, NULL);
}
}
diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h
index 81ae3bb..76678f8 100644
--- a/xlators/cluster/ec/src/ec-messages.h
+++ b/xlators/cluster/ec/src/ec-messages.h
@@ -45,7 +45,7 @@
*/
#define GLFS_EC_COMP_BASE GLFS_MSGID_COMP_EC
-#define GLFS_NUM_MESSAGES 65
+#define GLFS_NUM_MESSAGES 66
#define GLFS_MSGID_END (GLFS_EC_COMP_BASE + GLFS_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_x GLFS_EC_COMP_BASE, "Invalid: Start of messages"
@@ -513,6 +513,13 @@
*/
#define EC_MSG_CONFIG_XATTR_GET_FAIL (GLFS_EC_COMP_BASE + 65)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ */
+#define EC_MSG_CONFIG_XATTR_INVALID (GLFS_EC_COMP_BASE + 66)
+
/*------------*/
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index 29ff09a..7abd5cf 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -93,7 +93,7 @@ int32_t ec_prepare_childs(xlator_t * this)
}
if (count > EC_MAX_NODES)
{
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
EC_MSG_TOO_MANY_SUBVOLS, "Too many subvolumes");
return EINVAL;
@@ -358,7 +358,7 @@ ec_launch_notify_timer (xlator_t *this, ec_t *ec)
delay.tv_nsec = 0;
ec->timer = gf_timer_call_after (this->ctx, delay, ec_notify_cbk, ec);
if (ec->timer == NULL) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_TIMER_CREATE_FAIL, "Cannot create timer "
"for delayed initialization");
}
diff --git a/xlators/lib/src/libxlator.c b/xlators/lib/src/libxlator.c
index 11d0ef1..627d740 100644
--- a/xlators/lib/src/libxlator.c
+++ b/xlators/lib/src/libxlator.c
@@ -375,7 +375,7 @@ error:
int
gf_get_max_stime (xlator_t *this, dict_t *dst, char *key, data_t *value)
{
- int ret = -1;
+ int ret = -ENOMEM;
uint32_t *net_timebuf = NULL;
uint32_t *value_timebuf = NULL;
uint32_t host_timebuf[2] = {0,};
@@ -401,7 +401,7 @@ gf_get_max_stime (xlator_t *this, dict_t *dst, char *key, data_t *value)
if (!value_timebuf) {
gf_log (this->name, GF_LOG_WARNING,
"key=%s: getting value of stime failed", key);
- ret = -1;
+ ret = -EINVAL;
goto out;
}