diff options
author | Xavier Hernandez <xhernandez@datalab.es> | 2015-02-09 09:26:46 +0100 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-02-23 23:58:11 -0800 |
commit | 46a2b9e48160c593a73756d91781298144528e50 (patch) | |
tree | 85b688676dbdd8e8d1bbc55343ef411ad80465da /xlators/cluster/ec/src/ec-generic.c | |
parent | a4a760a3cf793857e5fac7d13f5ef7028d30f666 (diff) |
ec: Add trusted.ec.dirty xattr
This xattr will be incremented before each data modifying operation and
decremented after it. This will add the possibility to detect partially
updated writes and refuse them on reads.
It will also be useful for interacting with index xlator and have a way
to heal dispersed files from the self-heal daemon.
Change-Id: Ie644a8dd074ae0f254c809c5863bdb030be5486a
BUG: 1190581
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/9607
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster/ec/src/ec-generic.c')
-rw-r--r-- | xlators/cluster/ec/src/ec-generic.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/xlators/cluster/ec/src/ec-generic.c b/xlators/cluster/ec/src/ec-generic.c index bccbc009457..73df0d89db8 100644 --- a/xlators/cluster/ec/src/ec-generic.c +++ b/xlators/cluster/ec/src/ec-generic.c @@ -753,16 +753,17 @@ void ec_lookup_rebuild(ec_t * ec, ec_fop_data_t * fop, ec_cbk_data_t * cbk) for (i = 0, ans = cbk; (ans != NULL) && (i < ec->fragments); ans = ans->next) { - data = dict_get(ans->xdata, GF_CONTENT_KEY); - if (data != NULL) - { - values[i] = ans->idx; - blocks[i] = (uint8_t *)data->data; - if (size > data->len) + if (!ans->dirty) { + data = dict_get(ans->xdata, GF_CONTENT_KEY); + if (data != NULL) { - size = data->len; + values[i] = ans->idx; + blocks[i] = (uint8_t *)data->data; + if (size > data->len) { + size = data->len; + } + i++; } - i++; } } @@ -871,6 +872,8 @@ int32_t ec_lookup_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } if (xdata != NULL) { + uint64_t dirty; + cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { @@ -879,6 +882,9 @@ int32_t ec_lookup_cbk(call_frame_t * frame, void * cookie, xlator_t * this, goto out; } + if (ec_dict_del_number(cbk->xdata, EC_XATTR_DIRTY, &dirty) == 0) { + cbk->dirty = dirty != 0; + } } ec_combine(cbk, ec_combine_lookup); @@ -938,7 +944,8 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state) } } 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_VERSION, 0) != 0) || + (dict_set_uint64(fop->xdata, EC_XATTR_DIRTY, 0) != 0)) { gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to prepare lookup " "request"); @@ -1339,6 +1346,8 @@ int32_t ec_xattrop_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } if (xdata != NULL) { + uint64_t dirty; + cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { @@ -1347,6 +1356,9 @@ int32_t ec_xattrop_cbk(call_frame_t * frame, void * cookie, xlator_t * this, goto out; } + if (ec_dict_del_number(cbk->xdata, EC_XATTR_DIRTY, &dirty) == 0) { + cbk->dirty = dirty != 0; + } } ec_combine(cbk, ec_combine_xattrop); |