summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-11-09 13:11:58 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-09 09:32:34 -0800
commita9b785b84e509c4dd9ffe3e580201ae1f000599d (patch)
tree943150439f8fa88fe7ae228a020ae387ac59051d /xlators
parent78a7a092d7a43a7242f863c201a1390b6fbf05b9 (diff)
cluster/distribute stat: Take ref on inode before to prevent crash.
Possible situation is a forget call which unref's the inode, and the layout gets freed before we access it in stat. By taking a ref before we call ctx get, the layout is going to be persistent till we unref it. Also use local call_cnt var instead of layout->cnt when wind is involved Change-Id: Ie04a7afd9e2c89cc14c08dd923d06c5f0193beb8 BUG: 3730 Reviewed-on: http://review.gluster.com/687 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amar@gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-common.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index f2d7252f90b..4225e628593 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -1256,15 +1256,13 @@ dht_lookup (call_frame_t *frame, xlator_t *this,
ret = dict_set_uint32 (local->xattr_req,
"trusted.glusterfs.dht", 4 * 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:
@@ -1417,6 +1415,7 @@ dht_stat (call_frame_t *frame, xlator_t *this,
dht_local_t *local = NULL;
dht_layout_t *layout = NULL;
int i = 0;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
@@ -1432,6 +1431,8 @@ dht_stat (call_frame_t *frame, xlator_t *this,
goto err;
}
+ local->inode = inode_ref (loc->inode);
+
local->layout = layout = dht_layout_get (this, loc->inode);
if (!layout) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -1440,10 +1441,9 @@ dht_stat (call_frame_t *frame, xlator_t *this,
goto err;
}
- local->inode = inode_ref (loc->inode);
- 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,
@@ -1470,6 +1470,7 @@ dht_fstat (call_frame_t *frame, xlator_t *this,
dht_local_t *local = NULL;
dht_layout_t *layout = NULL;
int i = 0;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
@@ -1491,9 +1492,9 @@ dht_fstat (call_frame_t *frame, xlator_t *this,
}
local->inode = inode_ref (fd->inode);
- 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,
@@ -2361,6 +2362,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
dht_layout_t *layout = NULL;
int i = 0;
int op_errno = EINVAL;
+ int call_cnt = 0;
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
@@ -2391,9 +2393,9 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
goto err;
}
- 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_err_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->setxattr,
@@ -2453,6 +2455,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;
@@ -2484,9 +2487,9 @@ dht_removexattr (call_frame_t *frame, xlator_t *this,
goto err;
}
- 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_removexattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->removexattr,
@@ -5025,6 +5028,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);
@@ -5057,9 +5061,9 @@ dht_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
local->inode = inode_ref (loc->inode);
- 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,
@@ -5084,6 +5088,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);
@@ -5113,9 +5118,9 @@ dht_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
}
local->inode = inode_ref (fd->inode);
- 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,