diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2015-04-08 21:42:49 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-11 09:11:15 +0000 |
commit | 4797cb1c9dbf3910952f9d28d8272ff83cd25e7b (patch) | |
tree | 8efcdc1b2057166fcd53101824d64a05f095aead /xlators/cluster/ec/src/ec.c | |
parent | af569aaf6ee69ed77be8afc82b4c496041a7bd1b (diff) |
cluster/ec: Fix readdir de-itransform
Problem:
gf_deitransform returns the glbal client-id in the complete graph. So except
for the first disperse subvolume under dht, all the other disperse subvolumes
will return a client-id greater than ec->nodes, so readdir will always error
out in those subvolumes.
Fix:
Get the client subvolume whose client-id matches the client-id returned by
gf_deitransform of offset.
Change-Id: I26aa17504352d48d7ff14b390b62f49d7ab2d699
BUG: 1209113
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/10165
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
Diffstat (limited to 'xlators/cluster/ec/src/ec.c')
-rw-r--r-- | xlators/cluster/ec/src/ec.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c index fd5123d61da..5476ac6562e 100644 --- a/xlators/cluster/ec/src/ec.c +++ b/xlators/cluster/ec/src/ec.c @@ -115,6 +115,35 @@ int32_t ec_prepare_childs(xlator_t * this) return 0; } +/* This function transforms the subvol to subvol-id*/ +static int +_subvol_to_subvolid (dict_t *this, char *key, data_t *value, void *data) +{ + ec_t *ec = data; + xlator_t *subvol = NULL; + int i = 0; + int ret = -1; + + subvol = data_to_ptr (value); + for (i = 0; i < ec->nodes; i++) { + if (ec->xl_list[i] == subvol) { + ret = dict_set_int32 (this, key, i); + /* -1 stops dict_foreach and returns -1*/ + if (ret < 0) + ret = -1; + goto out; + } + } +out: + return ret; +} + +int +ec_subvol_to_subvol_id_transform (ec_t *ec, dict_t *leaf_to_subvolid) +{ + return dict_foreach (leaf_to_subvolid, _subvol_to_subvolid, ec); +} + void __ec_destroy_private(xlator_t * this) { ec_t * ec = this->private; @@ -165,6 +194,8 @@ void __ec_destroy_private(xlator_t * this) LOCK_DESTROY(&ec->lock); + if (ec->leaf_to_subvolid) + dict_unref (ec->leaf_to_subvolid); GF_FREE(ec); } } @@ -480,6 +511,21 @@ init (xlator_t *this) ec_selfheal_daemon_init (this); gf_log(this->name, GF_LOG_DEBUG, "Disperse translator initialized."); + ec->leaf_to_subvolid = dict_new (); + if (!ec->leaf_to_subvolid) + goto failed; + if (glusterfs_reachable_leaves (this, ec->leaf_to_subvolid)) { + gf_log (this->name, GF_LOG_ERROR, "Failed to build subvol " + "dictionary"); + goto failed; + } + + if (ec_subvol_to_subvol_id_transform (ec, ec->leaf_to_subvolid) < 0) { + gf_log (this->name, GF_LOG_ERROR, "Failed to build subvol-id " + "dictionary"); + goto failed; + } + return 0; failed: |