summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/stack.c1
-rw-r--r--libglusterfs/src/stack.h18
-rw-r--r--libglusterfs/src/xlator.c12
-rw-r--r--libglusterfs/src/xlator.h16
4 files changed, 47 insertions, 0 deletions
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
index 5527814a19d..bf905ca0b0e 100644
--- a/libglusterfs/src/stack.c
+++ b/libglusterfs/src/stack.c
@@ -55,6 +55,7 @@ create_frame (xlator_t *xl, call_pool_t *pool)
pool->cnt++;
}
UNLOCK (&pool->lock);
+ GF_ATOMIC_INC (pool->total_count);
LOCK_INIT (&stack->stack_lock);
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index 8a617377bc7..ac395fcc4b0 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -56,6 +56,7 @@ struct call_pool {
} all_stacks;
};
int64_t cnt;
+ gf_atomic_t total_count;
gf_lock_t lock;
struct mem_pool *frame_mem_pool;
struct mem_pool *stack_mem_pool;
@@ -253,6 +254,14 @@ STACK_RESET (call_stack_t *stack)
"winding from %s to %s", \
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); \
+ GF_ATOMIC_INC (next_xl->stats.total.count); \
+ GF_ATOMIC_INC (next_xl->stats.interval.count); \
+ } \
next_xl_fn (frame, next_xl, params); \
THIS = old_THIS; \
} while (0)
@@ -309,6 +318,10 @@ 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); \
THIS = old_THIS; \
} while (0)
@@ -367,6 +380,10 @@ STACK_RESET (call_stack_t *stack)
if (_parent->ret == NULL) \
timespec_now (&_parent->end); \
} \
+ if (op_ret < 0) { \
+ GF_ATOMIC_INC (THIS->stats.total.metrics[frame->op].cbk); \
+ GF_ATOMIC_INC (THIS->stats.interval.metrics[frame->op].cbk); \
+ } \
fn (_parent, frame->cookie, _parent->this, op_ret, \
op_errno, params); \
THIS = old_THIS; \
@@ -485,6 +502,7 @@ copy_frame (call_frame_t *frame)
newstack->pool->cnt++;
}
UNLOCK (&oldstack->pool->lock);
+ GF_ATOMIC_INC (newstack->pool->total_count);
return newframe;
}
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 4817da43da1..e371038f2c7 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -495,10 +495,22 @@ __xlator_init(xlator_t *xl)
{
xlator_t *old_THIS = NULL;
int ret = 0;
+ int fop_idx = 0;
old_THIS = THIS;
THIS = xl;
+ /* initialize the metrics related locks */
+ for (fop_idx = 0; fop_idx < GF_FOP_MAXVALUE; fop_idx++) {
+ GF_ATOMIC_INIT (xl->stats.total.metrics[fop_idx].fop, 0);
+ GF_ATOMIC_INIT (xl->stats.total.metrics[fop_idx].cbk, 0);
+
+ GF_ATOMIC_INIT (xl->stats.interval.metrics[fop_idx].fop, 0);
+ GF_ATOMIC_INIT (xl->stats.interval.metrics[fop_idx].cbk, 0);
+ }
+ GF_ATOMIC_INIT (xl->stats.total.count, 0);
+ GF_ATOMIC_INIT (xl->stats.interval.count, 0);
+
xlator_init_lock ();
ret = xl->init (xl);
xlator_init_unlock ();
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 430dbadd517..d802bdc76c3 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -923,6 +923,11 @@ typedef struct xlator_list {
struct xlator_list *next;
} xlator_list_t;
+typedef struct fop_metrics {
+ gf_atomic_t fop;
+ gf_atomic_t cbk; /* only updaed when there is failure */
+} fop_metrics_t;
+
struct _xlator {
/* Built during parsing */
char *name;
@@ -953,7 +958,18 @@ struct _xlator {
int64_t client_latency; /* This is in 'milliseconds' units */
struct {
/* for latency measurement */
+ fop_metrics_t metrics[GF_FOP_MAXVALUE];
+
+ gf_atomic_t count;
+ } total;
+
+ struct {
+ /* for latency measurement */
fop_latency_t latencies[GF_FOP_MAXVALUE];
+ /* for latency measurement */
+ fop_metrics_t metrics[GF_FOP_MAXVALUE];
+
+ gf_atomic_t count;
} interval;
} stats;