summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/stack.h25
-rw-r--r--tests/basic/xlator-pass-through-sanity.t22
2 files changed, 37 insertions, 10 deletions
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index abcc2677350..212a649d42e 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -259,6 +259,18 @@ STACK_RESET (call_stack_t *stack)
#define get_fop_index_from_fn(xl, fn) \
(1 + (((long)&(fn) - (long)&((xl)->fops->stat)) / sizeof (void *)))
+/* NOTE: the above reason holds good here too. But notice that we are getting
+ the base address of the 'stat' fop, which is the first entry in the fop
+ structure. All we need to do is move as much as 'idx' fields, and get the
+ actual pointer from that field. */
+
+static inline void *
+get_the_pt_fop(void *base_fop, int fop_idx)
+{
+ void *target_addr = (base_fop + ((fop_idx - 1) * sizeof (void *)));
+ /* all below type casting is for not getting warning. */
+ return (void *)*(unsigned long *)target_addr;
+}
/* make a call without switching frames */
#define STACK_WIND_TAIL(frame, obj, fn, params ...) \
@@ -286,11 +298,7 @@ STACK_RESET (call_stack_t *stack)
} \
\
if (next_xl->pass_through) { \
- /* next_xl_fn = (void *)*((&next_xl->pass_through_fops->stat) + (opn - 1));
- * This assignment is changed to fix ARRAY_VS_SINGLETON coverity error.
- */ \
- void *base_addr = &next_xl->pass_through_fops->stat; \
- next_xl_fn = base_addr + ((opn - 1) * sizeof(void*)); \
+ next_xl_fn = get_the_pt_fop(&next_xl->pass_through_fops->stat, opn); \
} \
next_xl_fn (frame, next_xl, params); \
THIS = old_THIS; \
@@ -355,11 +363,8 @@ STACK_RESET (call_stack_t *stack)
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));
- * This assignment is changed to fix ARRAY_VS_SINGLETON coverity error.
- */ \
- void *base_addr = &obj->pass_through_fops->stat; \
- next_xl_fn = base_addr + ((_new->op - 1) * sizeof(void*)); \
+ /* we want to get to the actual fop to call */ \
+ next_xl_fn = get_the_pt_fop(&obj->pass_through_fops->stat, _new->op); \
} \
next_xl_fn (_new, obj, params); \
THIS = old_THIS; \
diff --git a/tests/basic/xlator-pass-through-sanity.t b/tests/basic/xlator-pass-through-sanity.t
new file mode 100644
index 00000000000..e996be89260
--- /dev/null
+++ b/tests/basic/xlator-pass-through-sanity.t
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+cleanup;
+
+TEST glusterd
+TEST pidof glusterd
+
+TEST $CLI volume create $V0 $H0:$B0/${V0}
+TEST $CLI volume set $V0 performance.io-cache-pass-through enable;
+TEST $CLI volume start $V0;
+
+## Mount FUSE
+TEST $GFS -s $H0 --volfile-id $V0 $M1;
+
+# This test covers lookup, mkdir, mknod, symlink, link, rename,
+# create operations
+TEST $(dirname $0)/rpc-coverage.sh $M1
+
+cleanup;