summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/ec/src/ec-common.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2017-07-06 16:40:07 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2017-07-13 08:10:11 +0000
commitf367671d451ae0fc3e178d26cae1880d59eb6ebd (patch)
treee50d5b7b2bbf654e41933c347012b7651101ecab /xlators/cluster/ec/src/ec-common.c
parent73b2b7fe57069eb85485465fb92c52a97d4d411c (diff)
cluster/ec: Get size of file in EC [f]xattrop
Problem: For allowing parallel writes we shouldn't depend on ia_size to be same for all the bricks in each write_cbk(). But we need to make sure backend size is correct on all the bricks and no crashes/manual modifications happened. Fix: At the time of get_size_version() we do 1 check to make sure size of the file is same across the bricks. From then on the FOPs will give the status of the fop, so we rely on this information to keep which bricks are good/bad. Updates #251 Change-Id: I1df645347e2e9f2e09cfa4411b6cc305d7f4e4e5 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: https://review.gluster.org/17741 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
Diffstat (limited to 'xlators/cluster/ec/src/ec-common.c')
-rw-r--r--xlators/cluster/ec/src/ec-common.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index 284c2cd5a62..14aefff0ae3 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -1121,6 +1121,7 @@ void ec_get_size_version(ec_lock_link_t *link)
ec_inode_t *ctx;
ec_fop_data_t *fop;
dict_t *dict = NULL;
+ dict_t *xdata = NULL;
ec_t *ec = NULL;
int32_t error = 0;
gf_boolean_t getting_xattr;
@@ -1177,6 +1178,16 @@ void ec_get_size_version(ec_lock_link_t *link)
error = -ENOMEM;
goto out;
}
+
+ if (lock->loc.inode->ia_type == IA_IFREG ||
+ lock->loc.inode->ia_type == IA_INVAL) {
+ xdata = dict_new();
+ if (xdata == NULL || dict_set_int32 (xdata, GF_GET_SIZE, 1)) {
+ error = -ENOMEM;
+ goto out;
+ }
+ }
+
if (lock->query && !ctx->have_info) {
fop->flags |= EC_FLAG_QUERY_METADATA;
/* Once we know that an xattrop will be needed,
@@ -1234,11 +1245,11 @@ void ec_get_size_version(ec_lock_link_t *link)
ec_xattrop (fop->frame, fop->xl, fop->mask, fop->minimum,
ec_prepare_update_cbk, link, &loc,
- GF_XATTROP_ADD_ARRAY64, dict, NULL);
+ GF_XATTROP_ADD_ARRAY64, dict, xdata);
} else {
ec_fxattrop(fop->frame, fop->xl, fop->mask, fop->minimum,
ec_prepare_update_cbk, link, lock->fd,
- GF_XATTROP_ADD_ARRAY64, dict, NULL);
+ GF_XATTROP_ADD_ARRAY64, dict, xdata);
}
error = 0;
@@ -1253,6 +1264,10 @@ out:
dict_unref(dict);
}
+ if (xdata != NULL) {
+ dict_unref(xdata);
+ }
+
if (error != 0) {
ec_fop_set_error(fop, -error);
}