summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-dir-write.c
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-07-30 12:05:11 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-30 12:00:56 -0700
commitfdbc5cf320fe85d128d498184135df10146047ba (patch)
tree60031d1372829c17a6b798c8300a767152c8baab /xlators/cluster/afr/src/afr-dir-write.c
parent83ef3c8211282a9ef66659bfbde25116e4949b71 (diff)
replicate: Return ino from first subvolume on inode creation fops
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 177 (replicate: On file/dir creation, replicate returns inode from random subvolumes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=177
Diffstat (limited to 'xlators/cluster/afr/src/afr-dir-write.c')
-rw-r--r--xlators/cluster/afr/src/afr-dir-write.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c
index 88a3ded5ef0..7be32ce4c9d 100644
--- a/xlators/cluster/afr/src/afr-dir-write.c
+++ b/xlators/cluster/afr/src/afr-dir-write.c
@@ -77,9 +77,11 @@ int
afr_create_unwind (call_frame_t *frame, xlator_t *this)
{
call_frame_t *main_frame = NULL;
+ afr_private_t * priv = NULL;
afr_local_t *local = NULL;
struct stat *unwind_buf = NULL;
+ priv = this->private;
local = frame->local;
LOCK (&frame->lock);
@@ -98,6 +100,8 @@ afr_create_unwind (call_frame_t *frame, xlator_t *this)
unwind_buf = &local->cont.create.buf;
}
+ unwind_buf->st_ino = local->cont.create.ino;
+
AFR_STACK_UNWIND (main_frame, local->op_ret, local->op_errno,
local->cont.create.fd,
local->cont.create.inode,
@@ -120,6 +124,7 @@ afr_create_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int call_count = -1;
int child_index = -1;
+ int first_up_child = 0;
local = frame->local;
priv = this->private;
@@ -147,10 +152,6 @@ afr_create_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (local->success_count == 0) {
local->cont.create.buf = *buf;
- local->cont.create.buf.st_ino =
- afr_itransform (buf->st_ino,
- priv->child_count,
- child_index);
if (priv->read_child >= 0) {
afr_set_read_child (this, inode,
@@ -161,6 +162,15 @@ afr_create_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
}
+ first_up_child = afr_first_up_child (priv);
+
+ if (child_index == first_up_child) {
+ local->cont.create.ino =
+ afr_itransform (buf->st_ino,
+ priv->child_count,
+ first_up_child);
+ }
+
if (child_index == local->read_child_index) {
local->cont.create.read_child_buf = *buf;
}
@@ -568,6 +578,8 @@ afr_mkdir_unwind (call_frame_t *frame, xlator_t *this)
unwind_buf = &local->cont.mkdir.buf;
}
+ unwind_buf->st_ino = local->cont.mkdir.ino;
+
AFR_STACK_UNWIND (main_frame, local->op_ret, local->op_errno,
local->cont.mkdir.inode,
unwind_buf);
@@ -587,6 +599,7 @@ afr_mkdir_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int call_count = -1;
int child_index = -1;
+ int first_up_child = 0;
local = frame->local;
priv = this->private;
@@ -603,9 +616,6 @@ afr_mkdir_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (local->success_count == 0) {
local->cont.mkdir.buf = *buf;
- local->cont.mkdir.buf.st_ino =
- afr_itransform (buf->st_ino, priv->child_count,
- child_index);
if (priv->read_child >= 0) {
afr_set_read_child (this, inode,
@@ -615,6 +625,15 @@ afr_mkdir_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local->read_child_index);
}
}
+
+ first_up_child = afr_first_up_child (priv);
+
+ if (child_index == first_up_child) {
+ local->cont.mkdir.ino =
+ afr_itransform (buf->st_ino,
+ priv->child_count,
+ first_up_child);
+ }
if (child_index == local->read_child_index) {
local->cont.mkdir.read_child_buf = *buf;
@@ -788,14 +807,14 @@ afr_link_unwind (call_frame_t *frame, xlator_t *this)
UNLOCK (&frame->lock);
if (main_frame) {
- local->cont.link.buf.st_ino = local->cont.link.ino;
-
if (local->cont.link.read_child_buf.st_ino) {
unwind_buf = &local->cont.link.read_child_buf;
} else {
unwind_buf = &local->cont.link.buf;
}
+ unwind_buf->st_ino = local->cont.link.ino;
+
AFR_STACK_UNWIND (main_frame, local->op_ret, local->op_errno,
local->cont.link.inode,
unwind_buf);