summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/ec/src/ec-common.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2015-09-08 16:23:36 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-10-29 04:52:49 -0700
commit6bbce9b1a48d5d50a2044b4518270e952331f159 (patch)
tree0c3cb1038b7b7b22a884e87897f1a1916f350cdc /xlators/cluster/ec/src/ec-common.c
parent73f8a582e365ef43b2454f263b5ca91a6de0475e (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> BUG: 1270705 Change-Id: Ibf0d21d7210125fa7aaa12b3f98bcdf7cd89ef02 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/12456 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/ec/src/ec-common.c')
-rw-r--r--xlators/cluster/ec/src/ec-common.c37
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 616b57232f3..7f1c3c535fa 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)