diff options
| author | Amar Tumballi <amarts@redhat.com> | 2018-02-13 06:24:18 +0530 | 
|---|---|---|
| committer | Amar Tumballi <amarts@redhat.com> | 2018-03-09 18:32:56 +0000 | 
| commit | 940f870f4716f9cd32c68db95aa326a0ae87bf03 (patch) | |
| tree | 36ccd616706422a69b771b0402e55f56dbd84093 | |
| parent | b2613c9eed6b9d840bc88105dadf282488e6cd64 (diff) | |
core: provide infra to make any xlator pass-through
updates: #304
Change-Id: If6a13d2e56b195390a386d720103a882e077f66c
Signed-off-by: Amar Tumballi <amarts@redhat.com>
| -rw-r--r-- | libglusterfs/src/stack.h | 26 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.c | 18 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 9 | 
3 files changed, 41 insertions, 12 deletions
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index e7d0b3ff7f4..87fbef9e3c9 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -258,6 +258,7 @@ STACK_RESET (call_stack_t *stack)                  xlator_t     *old_THIS = NULL;                          \                  xlator_t     *next_xl = obj;                            \                  typeof(fn)    next_xl_fn = fn;                          \ +                int opn = get_fop_index_from_fn((next_xl), (fn));       \                                                                          \                  frame->this = next_xl;                                  \                  frame->wind_to = #fn;                                   \ @@ -269,13 +270,15 @@ STACK_RESET (call_stack_t *stack)                                frame->root, old_THIS->name,              \                                THIS->name);                              \                  /* Need to capture counts at leaf node */               \ -                if (!next_xl->children) {                               \ -                        int op = get_fop_index_from_fn((next_xl), (fn)); \ -                        GF_ATOMIC_INC (next_xl->stats.total.metrics[op].fop); \ -                        GF_ATOMIC_INC (next_xl->stats.interval.metrics[op].fop); \ +                if (!next_xl->pass_through && !next_xl->children) {     \ +                        GF_ATOMIC_INC (next_xl->stats.total.metrics[opn].fop); \ +                        GF_ATOMIC_INC (next_xl->stats.interval.metrics[opn].fop); \                          GF_ATOMIC_INC (next_xl->stats.total.count);     \                          GF_ATOMIC_INC (next_xl->stats.interval.count);  \                  }                                                       \ +                if (next_xl->pass_through) {                            \ +                        next_xl_fn = (void *)*((&next_xl->pass_through_fops->stat) + (opn - 1)); \ +                }                                                       \                  next_xl_fn (frame, next_xl, params);                    \                  THIS = old_THIS;                                        \          } while (0) @@ -298,6 +301,7 @@ STACK_RESET (call_stack_t *stack)          do {                                                            \                  call_frame_t *_new = NULL;                              \                  xlator_t     *old_THIS = NULL;                          \ +                typeof(fn)    next_xl_fn = fn;                          \                                                                          \                  _new = mem_get0 (frame->root->pool->frame_mem_pool);    \                  if (!_new) {                                            \ @@ -332,11 +336,15 @@ STACK_RESET (call_stack_t *stack)                  if (obj->ctx->measure_latency)                          \                          timespec_now (&_new->begin);                    \                  _new->op = get_fop_index_from_fn ((_new->this), (fn));  \ -                GF_ATOMIC_INC (obj->stats.total.metrics[_new->op].fop); \ -                GF_ATOMIC_INC (obj->stats.interval.metrics[_new->op].fop); \ -                GF_ATOMIC_INC (obj->stats.total.count);                 \ -                GF_ATOMIC_INC (obj->stats.interval.count);              \ -                fn (_new, obj, params);                                 \ +                if (!obj->pass_through) {                               \ +                        GF_ATOMIC_INC (obj->stats.total.metrics[_new->op].fop); \ +                        GF_ATOMIC_INC (obj->stats.interval.metrics[_new->op].fop); \ +                        GF_ATOMIC_INC (obj->stats.total.count);         \ +                        GF_ATOMIC_INC (obj->stats.interval.count);      \ +                } else {                                                \ +                        next_xl_fn = (void *)*((&obj->pass_through_fops->stat) + (_new->op - 1)); \ +                }                                                       \ +                next_xl_fn (_new, obj, params);                         \                  THIS = old_THIS;                                        \          } while (0) diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 4071a7c0569..466be5e3a3a 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -15,9 +15,11 @@  #include "defaults.h"  #include "libglusterfs-messages.h" -#define SET_DEFAULT_FOP(fn) do {			\ -                if (!xl->fops->fn)			\ -                        xl->fops->fn = default_##fn;	\ +#define SET_DEFAULT_FOP(fn) do {                                        \ +                if (!xl->fops->fn)                                      \ +                        xl->fops->fn = default_##fn;                    \ +                if (!xl->pass_through_fops->fn)                         \ +                        xl->pass_through_fops->fn = default_##fn;       \          } while (0)  #define SET_DEFAULT_CBK(fn) do {			\ @@ -54,6 +56,9 @@ fill_defaults (xlator_t *xl)                  return;          } +        if (!xl->pass_through_fops) +                xl->pass_through_fops = default_fops; +          SET_DEFAULT_FOP (create);          SET_DEFAULT_FOP (open);          SET_DEFAULT_FOP (stat); @@ -386,6 +391,13 @@ int xlator_dynload_newway (xlator_t *xl)                                xl->name);          } +        xl->pass_through_fops = xlapi->pass_through_fops; +        if (!xl->pass_through_fops) { +                gf_msg_trace ("xlator", 0, "%s: method missing (pass_through_fops), " +                              "falling back to default", +                              xl->name); +        } +          vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),                               gf_common_mt_volume_opt_list_t);          if (!vol_opt) { diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index bfab57a0133..b03998d36af 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -1039,6 +1039,10 @@ struct _xlator {          /* identifier: a full string which can unique identify the xlator */          char *identifier; + +        /* Is this pass_through? */ +        gf_boolean_t   pass_through; +        struct xlator_fops    *pass_through_fops;  };  typedef struct { @@ -1123,6 +1127,11 @@ typedef struct {          /* dumpops: a structure again, with methods to dump the details.             optional. */          struct xlator_dumpops  *dumpops; + +        /* struct pass_through_fops: optional. provides all the filesystem +           operations which should be used if the xlator is marked as pass_through */ +        /* by default, the default_fops would be used */ +        struct xlator_fops *pass_through_fops;  } xlator_api_t;  #define xlator_has_parent(xl) (xl->parents != NULL)  | 
