summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-11-10 16:39:31 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-16 01:54:34 -0800
commit3440b6d68a5e787a6a1baba2073ee0c44a9b1632 (patch)
tree1f664139a04ecdad268fc9eccbc276f9bedc2b1f /xlators
parenta3c49bb260263dce98d44c28e7106da2a2173ed9 (diff)
cluster/distribute: Use local call_cnt while winding
layout->cnt might be modified in cbk's or different threads, which will lead to corruptions Change-Id: Icfdab01ac583cb3d27d62f878b79e0098b597952 BUG: 3730 Reviewed-on: http://review.gluster.com/694 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Amar Tumballi <amar@gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-common.c16
-rw-r--r--xlators/cluster/dht/src/dht-inode-read.c10
-rw-r--r--xlators/cluster/dht/src/dht-inode-write.c10
3 files changed, 20 insertions, 16 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index faf575df9af..501bd31e3f5 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -1137,15 +1137,13 @@ dht_lookup (call_frame_t *frame, xlator_t *this,
ret = dict_set_uint32 (local->xattr_req,
GLUSTERFS_OPEN_FD_COUNT, 4);
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
subvol = layout->list[i].xlator;
STACK_WIND (frame, dht_revalidate_cbk,
subvol, subvol->fops->lookup,
&local->loc, local->xattr_req);
- if (!--call_cnt)
- break;
}
} else {
do_fresh_lookup:
@@ -1806,6 +1804,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
uint32_t dir_spread = 0;
char value[4096] = {0,};
int forced_rebalance = 0;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
@@ -1837,7 +1836,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
goto err;
}
- local->call_cnt = layout->cnt;
+ local->call_cnt = call_cnt = layout->cnt;
/* This key is sent by Unified File and Object storage
* to test xattr support in backend.
@@ -1849,7 +1848,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
goto err;
}
local->op_ret = 0;
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
STACK_WIND (frame, dht_ufo_xattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->setxattr,
@@ -1946,7 +1945,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
goto err;
}
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
STACK_WIND (frame, dht_err_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->setxattr,
@@ -2006,6 +2005,7 @@ dht_removexattr (call_frame_t *frame, xlator_t *this,
int op_errno = -1;
dht_local_t *local = NULL;
dht_layout_t *layout = NULL;
+ int call_cnt = 0;
int i;
@@ -2037,10 +2037,10 @@ dht_removexattr (call_frame_t *frame, xlator_t *this,
goto err;
}
- local->call_cnt = layout->cnt;
+ local->call_cnt = call_cnt = layout->cnt;
local->key = gf_strdup (key);
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
STACK_WIND (frame, dht_removexattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->removexattr,
diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c
index d6a2cf36971..7352e47bd62 100644
--- a/xlators/cluster/dht/src/dht-inode-read.c
+++ b/xlators/cluster/dht/src/dht-inode-read.c
@@ -271,6 +271,7 @@ dht_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
dht_local_t *local = NULL;
dht_layout_t *layout = NULL;
int i = 0;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
@@ -304,9 +305,9 @@ dht_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
return 0;
}
- local->call_cnt = layout->cnt;
+ local->call_cnt = call_cnt = layout->cnt;
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
subvol = layout->list[i].xlator;
STACK_WIND (frame, dht_attr_cbk,
@@ -332,6 +333,7 @@ dht_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
dht_local_t *local = NULL;
dht_layout_t *layout = NULL;
int i = 0;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
@@ -363,9 +365,9 @@ dht_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
return 0;
}
- local->call_cnt = layout->cnt;
+ local->call_cnt = call_cnt = layout->cnt;
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
subvol = layout->list[i].xlator;
STACK_WIND (frame, dht_attr_cbk,
subvol, subvol->fops->fstat,
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c
index f9dea75aa21..4f65b46713c 100644
--- a/xlators/cluster/dht/src/dht-inode-write.c
+++ b/xlators/cluster/dht/src/dht-inode-write.c
@@ -480,6 +480,7 @@ dht_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
dht_local_t *local = NULL;
int op_errno = -1;
int i = -1;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
@@ -523,9 +524,9 @@ dht_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return 0;
}
- local->call_cnt = layout->cnt;
+ local->call_cnt = call_cnt = layout->cnt;
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
STACK_WIND (frame, dht_setattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->setattr,
@@ -551,6 +552,7 @@ dht_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
dht_local_t *local = NULL;
int op_errno = -1;
int i = -1;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
@@ -593,9 +595,9 @@ dht_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
return 0;
}
- local->call_cnt = layout->cnt;
+ local->call_cnt = call_cnt = layout->cnt;
- for (i = 0; i < layout->cnt; i++) {
+ for (i = 0; i < call_cnt; i++) {
STACK_WIND (frame, dht_setattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->fsetattr,