stack.h: fix the pass_through logic
while fixing the coverity issues, we made a minor mistake in the pass through logic in STACK_WIND macro. Also, with this patch, made the code common to reduce possible future errors creeping in due to missing one place update. updates: bz#1193929 Change-Id: I6fcfd156d63b0a7e6208819872e565eacf774150 Signed-off-by: Amar Tumballi <amarts@redhat.com>
This commit is contained in:
parent
524c869976
commit
c80075466d
@ -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; \
|
||||
|
22
tests/basic/xlator-pass-through-sanity.t
Normal file
22
tests/basic/xlator-pass-through-sanity.t
Normal file
@ -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;
|
Loading…
x
Reference in New Issue
Block a user