summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/switch.c
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2016-12-06 14:43:10 +0530
committerJeff Darcy <jdarcy@redhat.com>2017-01-09 10:37:02 -0800
commita988741713752c2ec04a0680224d8fa4d42dc203 (patch)
treeb0cfd626c7cf8b5475e7cc533333dd17a47dc988 /xlators/cluster/dht/src/switch.c
parentcc55be619830bc64544a1044f05367b8be9421bc (diff)
dht: At places needed use STACK_WIND_COOKIE
Issue: frame has a void * cookie pointer. In case of STACK_WIND_COOKIE frame->cookie is assigned to what is sent by the caller. In case of STACK_WIND frame->cookie is assigned to point point to the frame itself. For ease of coding, at many places, the cookie in the cbk is used to get the pointer to the next xl. This is inconsistent when STACK_WIND_TAIL comes into picture. Eg: dht_setxattr () { for (i = 0 ; i < conf->subvolume_cnt ; i++) { STACK_WIND (..dht_checking_pathinfo_cbk, conf->subvolumes[i] ..); } dht_checking_pathinfo_cbk (...void *cookie...) { prev = cookie; ... for (i = 0; i < conf->subvolume_cnt; i++) { if (conf->subvolumes[i] == prev->this) { ... } } } Consider the below graph: dht (parent) readdir-ahead => Doesn't define setxattr and uses STACK_WIND_TAIL protocol-client With this graph, when dht_checking_pathinfo_cbk is called, cookie will have frame pointing to protocol-client. i.e. prev->this will be protocol-client. But dht was expecting it to be readdir-ahead as it has stored in conf->subvolumes[i] Solution: Hence, as a thumb rule, if cbk is using cookie, then we explicitly call STACK_WIND_COOKIE. Change-Id: I83aea1e24c809c5a91a0db7283e908e125471bd4 BUG: 1401812 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/16039 Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/cluster/dht/src/switch.c')
-rw-r--r--xlators/cluster/dht/src/switch.c73
1 files changed, 38 insertions, 35 deletions
diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c
index f1e9a399442..9795ff4af4d 100644
--- a/xlators/cluster/dht/src/switch.c
+++ b/xlators/cluster/dht/src/switch.c
@@ -111,7 +111,7 @@ switch_local_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
dht_local_t *local = NULL;
loc_t *loc = NULL;
int i = 0;
- call_frame_t *prev = NULL;
+ xlator_t *prev = NULL;
int call_cnt = 0;
int ret = 0;
@@ -139,12 +139,12 @@ switch_local_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (!is_dir && !is_linkfile) {
/* non-directory and not a linkfile */
- ret = dht_layout_preset (this, prev->this, inode);
+ ret = dht_layout_preset (this, prev, inode);
if (ret < 0) {
gf_msg_debug (this->name, 0,
"could not set pre-set layout "
"for subvol %s",
- prev->this->name);
+ prev->name);
op_ret = -1;
op_errno = EINVAL;
goto err;
@@ -173,10 +173,11 @@ switch_local_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
for (i = 0; i < call_cnt; i++) {
- STACK_WIND (frame, dht_lookup_dir_cbk,
- conf->subvolumes[i],
- conf->subvolumes[i]->fops->lookup,
- &local->loc, local->xattr_req);
+ STACK_WIND_COOKIE (frame, dht_lookup_dir_cbk,
+ conf->subvolumes[i],
+ conf->subvolumes[i],
+ conf->subvolumes[i]->fops->lookup,
+ &local->loc, local->xattr_req);
}
}
@@ -191,9 +192,9 @@ switch_local_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
return 0;
}
- STACK_WIND (frame, dht_lookup_linkfile_cbk,
- subvol, subvol->fops->lookup,
- &local->loc, local->xattr_req);
+ STACK_WIND_COOKIE (frame, dht_lookup_linkfile_cbk, subvol,
+ subvol, subvol->fops->lookup,
+ &local->loc, local->xattr_req);
}
return 0;
@@ -208,9 +209,10 @@ out:
return 0;
}
- STACK_WIND (frame, dht_lookup_cbk,
- local->hashed_subvol, local->hashed_subvol->fops->lookup,
- &local->loc, local->xattr_req);
+ STACK_WIND_COOKIE (frame, dht_lookup_cbk, local->hashed_subvol,
+ local->hashed_subvol,
+ local->hashed_subvol->fops->lookup,
+ &local->loc, local->xattr_req);
return 0;
@@ -298,9 +300,9 @@ switch_lookup (call_frame_t *frame, xlator_t *this,
for (i = 0; i < layout->cnt; i++) {
subvol = layout->list[i].xlator;
- STACK_WIND (frame, dht_revalidate_cbk,
- subvol, subvol->fops->lookup,
- loc, local->xattr_req);
+ STACK_WIND_COOKIE (frame, dht_revalidate_cbk, subvol,
+ subvol, subvol->fops->lookup,
+ loc, local->xattr_req);
if (!--call_cnt)
break;
@@ -339,10 +341,11 @@ switch_lookup (call_frame_t *frame, xlator_t *this,
}
for (i = 0; i < call_cnt; i++) {
- STACK_WIND (frame, dht_lookup_dir_cbk,
- conf->subvolumes[i],
- conf->subvolumes[i]->fops->lookup,
- &local->loc, local->xattr_req);
+ STACK_WIND_COOKIE (frame, dht_lookup_dir_cbk,
+ conf->subvolumes[i],
+ conf->subvolumes[i],
+ conf->subvolumes[i]->fops->lookup,
+ &local->loc, local->xattr_req);
}
return 0;
}
@@ -351,15 +354,15 @@ switch_lookup (call_frame_t *frame, xlator_t *this,
cached_subvol = get_switch_matching_subvol (loc->path, conf,
hashed_subvol);
if (cached_subvol == hashed_subvol) {
- STACK_WIND (frame, dht_lookup_cbk,
- hashed_subvol,
- hashed_subvol->fops->lookup,
- loc, local->xattr_req);
+ STACK_WIND_COOKIE (frame, dht_lookup_cbk, hashed_subvol,
+ hashed_subvol,
+ hashed_subvol->fops->lookup,
+ loc, local->xattr_req);
} else {
- STACK_WIND (frame, switch_local_lookup_cbk,
- cached_subvol,
- cached_subvol->fops->lookup,
- loc, local->xattr_req);
+ STACK_WIND_COOKIE (frame, switch_local_lookup_cbk,
+ cached_subvol, cached_subvol,
+ cached_subvol->fops->lookup,
+ loc, local->xattr_req);
}
}
@@ -386,10 +389,10 @@ switch_create_linkfile_create_cbk (call_frame_t *frame, void *cookie,
if (op_ret == -1)
goto err;
- STACK_WIND (frame, dht_create_cbk,
- local->cached_subvol, local->cached_subvol->fops->create,
- &local->loc, local->flags, local->mode, local->umask,
- local->fd, local->params);
+ STACK_WIND_COOKIE (frame, dht_create_cbk, local->cached_subvol,
+ local->cached_subvol, local->cached_subvol->fops->create,
+ &local->loc, local->flags, local->mode, local->umask,
+ local->fd, local->params);
return 0;
@@ -454,9 +457,9 @@ switch_create (call_frame_t *frame, xlator_t *this,
gf_msg_trace (this->name, 0,
"creating %s on %s", loc->path, subvol->name);
- STACK_WIND (frame, dht_create_cbk,
- subvol, subvol->fops->create,
- loc, flags, mode, umask, fd, params);
+ STACK_WIND_COOKIE (frame, dht_create_cbk, subvol, subvol,
+ subvol->fops->create, loc, flags, mode, umask, fd,
+ params);
return 0;