diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2015-09-08 16:23:36 +0530 |
---|---|---|
committer | Xavier Hernandez <xhernandez@datalab.es> | 2015-10-09 05:26:05 -0700 |
commit | fe3c6f0fa2bf8590f4c540fd9561aeeec1243361 (patch) | |
tree | 03955fdaac90d3254b5c833094839aa44af5fe34 /xlators/cluster/ec/src/ec-common.c | |
parent | 47d8d2fc9c88c95dfcae2c5c06e6eb3b1ce03a92 (diff) |
cluster/ec: Implement gfid-hash read-policy
Add a policy in ec to performs reads from same bricks as long as they
are good. Based on the gfid of the file/directory it determines the
bricks to be considered for reading.
Change-Id: Ic97b5c54c086a28b5e07a330a4fd448551b49376
BUG: 1261260
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/12133
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
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.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c index d0c9f97ab28..39a529d3a0b 100644 --- a/xlators/cluster/ec/src/ec-common.c +++ b/xlators/cluster/ec/src/ec-common.c @@ -9,6 +9,7 @@ */ #include "byte-order.h" +#include "hashfn.h" #include "ec-mem-types.h" #include "ec-data.h" @@ -20,6 +21,25 @@ #include "ec.h" #include "ec-messages.h" +uint32_t +ec_select_first_by_read_policy (ec_t *ec, ec_fop_data_t *fop) +{ + if (ec->read_policy == EC_ROUND_ROBIN) { + return ec->idx; + } else if (ec->read_policy == EC_GFID_HASH) { + if (fop->use_fd) { + return SuperFastHash((char *)fop->fd->inode->gfid, + sizeof(fop->fd->inode->gfid)) % ec->nodes; + } else { + if (gf_uuid_is_null (fop->loc[0].gfid)) + loc_gfid (&fop->loc[0], fop->loc[0].gfid); + return SuperFastHash((char *)fop->loc[0].gfid, + sizeof(fop->loc[0].gfid)) % ec->nodes; + } + } + return 0; +} + int32_t ec_child_valid(ec_t * ec, ec_fop_data_t * fop, int32_t idx) { return (idx < ec->nodes) && (((fop->remaining >> idx) & 1) == 1); @@ -415,12 +435,13 @@ int32_t ec_child_select(ec_fop_data_t * fop) fop->minimum = 1; } - first = ec->idx; - if (++first >= ec->nodes) - { - first = 0; + if (ec->read_policy == EC_ROUND_ROBIN) { + first = ec->idx; + if (++first >= ec->nodes) { + first = 0; + } + ec->idx = first; } - ec->idx = first; /*Unconditionally wind on healing subvolumes*/ fop->mask |= fop->healing; @@ -518,14 +539,12 @@ void ec_dispatch_start(ec_fop_data_t * fop) void ec_dispatch_one(ec_fop_data_t * fop) { - ec_t * ec = fop->xl->private; - ec_dispatch_start(fop); if (ec_child_select(fop)) { fop->expected = 1; - fop->first = ec->idx; + fop->first = ec_select_first_by_read_policy (fop->xl->private, fop); ec_dispatch_next(fop, fop->first); } @@ -589,7 +608,7 @@ void ec_dispatch_min(ec_fop_data_t * fop) if (ec_child_select(fop)) { fop->expected = count = ec->fragments; - fop->first = ec->idx; + fop->first = ec_select_first_by_read_policy (fop->xl->private, fop); idx = fop->first - 1; mask = 0; while (count-- > 0) |