diff options
author | Pranith K <pranithk@gluster.com> | 2011-07-14 08:07:04 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-17 07:45:05 -0700 |
commit | bfc0e16e43815ab6d6e67f4bd26694ebd72b3360 (patch) | |
tree | 221eff40a09ce8e42ab6460bc9040d5b5f9f41fb /xlators/cluster/afr/src/afr-dir-write.c | |
parent | 64b2a56ad0f8ddae9ece8696f7d50a3129c145a3 (diff) |
cluster/afr: Add fresh children along with read-child to inode context
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2840 (files not getting self-healed when the first child goes down)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2840
Diffstat (limited to 'xlators/cluster/afr/src/afr-dir-write.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-dir-write.c | 134 |
1 files changed, 63 insertions, 71 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c index 88c3f728f49..6da666804de 100644 --- a/xlators/cluster/afr/src/afr-dir-write.c +++ b/xlators/cluster/afr/src/afr-dir-write.c @@ -119,13 +119,14 @@ afr_create_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, fd_t *fd, inode_t *inode, struct iatt *buf, struct iatt *preparent, struct iatt *postparent) { - afr_local_t * local = NULL; - afr_private_t * priv = NULL; - uint64_t ctx = 0; - afr_fd_ctx_t *fd_ctx = NULL; - int ret = 0; - int call_count = -1; - int child_index = -1; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + uint64_t ctx = 0; + afr_fd_ctx_t *fd_ctx = NULL; + int ret = 0; + int call_count = -1; + int child_index = -1; + int32_t *fresh_children = NULL; local = frame->local; priv = this->private; @@ -166,18 +167,9 @@ afr_create_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, fd_ctx->opened_on[child_index] = 1; fd_ctx->flags = local->cont.create.flags; - if (local->success_count == 0) { + if (local->success_count == 0) local->cont.create.buf = *buf; - if (priv->read_child >= 0) { - afr_set_read_child (this, inode, - priv->read_child); - } else { - afr_set_read_child (this, inode, - local->read_child_index); - } - } - if (child_index == local->read_child_index) { local->cont.create.read_child_buf = *buf; local->cont.create.preparent = *preparent; @@ -186,6 +178,8 @@ afr_create_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->cont.create.inode = inode; + fresh_children = local->fresh_children; + fresh_children[local->success_count] = child_index; local->success_count++; } @@ -198,6 +192,10 @@ unlock: call_count = afr_frame_return (frame); if (call_count == 0) { + afr_set_read_ctx_from_policy (this, inode, + local->fresh_children, + local->read_child_index, + priv->read_child); local->transaction.unwind (frame, this); local->transaction.resume (frame, this); @@ -382,10 +380,11 @@ afr_mknod_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *buf, struct iatt *preparent, struct iatt *postparent) { - afr_local_t * local = NULL; - afr_private_t * priv = NULL; - int call_count = -1; - int child_index = -1; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + int call_count = -1; + int child_index = -1; + int32_t *fresh_children = NULL; local = frame->local; priv = this->private; @@ -400,18 +399,9 @@ afr_mknod_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret != -1) { local->op_ret = op_ret; - if (local->success_count == 0){ + if (local->success_count == 0) local->cont.mknod.buf = *buf; - if (priv->read_child >= 0) { - afr_set_read_child (this, inode, - priv->read_child); - } else { - afr_set_read_child (this, inode, - local->read_child_index); - } - } - if (child_index == local->read_child_index) { local->cont.mknod.read_child_buf = *buf; local->cont.mknod.preparent = *preparent; @@ -420,6 +410,8 @@ afr_mknod_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->cont.mknod.inode = inode; + fresh_children = local->fresh_children; + fresh_children[local->success_count] = child_index; local->success_count++; } @@ -430,6 +422,10 @@ afr_mknod_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, call_count = afr_frame_return (frame); if (call_count == 0) { + afr_set_read_ctx_from_policy (this, inode, + local->fresh_children, + local->read_child_index, + priv->read_child); local->transaction.unwind (frame, this); local->transaction.resume (frame, this); @@ -609,10 +605,11 @@ afr_mkdir_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *buf, struct iatt *preparent, struct iatt *postparent) { - afr_local_t * local = NULL; - afr_private_t * priv = NULL; - int call_count = -1; - int child_index = -1; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + int call_count = -1; + int child_index = -1; + int32_t *fresh_children = NULL; local = frame->local; priv = this->private; @@ -627,18 +624,9 @@ afr_mkdir_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret != -1) { local->op_ret = op_ret; - if (local->success_count == 0) { + if (local->success_count == 0) local->cont.mkdir.buf = *buf; - if (priv->read_child >= 0) { - afr_set_read_child (this, inode, - priv->read_child); - } else { - afr_set_read_child (this, inode, - local->read_child_index); - } - } - if (child_index == local->read_child_index) { local->cont.mkdir.read_child_buf = *buf; local->cont.mkdir.preparent = *preparent; @@ -647,6 +635,8 @@ afr_mkdir_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->cont.mkdir.inode = inode; + fresh_children = local->fresh_children; + fresh_children[local->success_count] = child_index; local->success_count++; } @@ -657,6 +647,10 @@ afr_mkdir_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, call_count = afr_frame_return (frame); if (call_count == 0) { + afr_set_read_ctx_from_policy (this, inode, + local->fresh_children, + local->read_child_index, + priv->read_child); local->transaction.unwind (frame, this); local->transaction.resume (frame, this); @@ -837,10 +831,11 @@ afr_link_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *buf, struct iatt *preparent, struct iatt *postparent) { - afr_local_t * local = NULL; - afr_private_t * priv = NULL; - int call_count = -1; - int child_index = -1; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + int call_count = -1; + int child_index = -1; + int32_t *fresh_children = NULL; local = frame->local; priv = this->private; @@ -857,14 +852,6 @@ afr_link_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (local->success_count == 0) { local->cont.link.buf = *buf; - - if (priv->read_child >= 0) { - afr_set_read_child (this, inode, - priv->read_child); - } else { - afr_set_read_child (this, inode, - local->read_child_index); - } } if (child_index == local->read_child_index) { @@ -875,6 +862,8 @@ afr_link_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->cont.link.inode = inode; + fresh_children = local->fresh_children; + fresh_children[local->success_count] = child_index; local->success_count++; } @@ -885,6 +874,10 @@ afr_link_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, call_count = afr_frame_return (frame); if (call_count == 0) { + afr_set_read_ctx_from_policy (this, inode, + local->fresh_children, + local->read_child_index, + priv->read_child); local->transaction.unwind (frame, this); local->transaction.resume (frame, this); @@ -1062,10 +1055,11 @@ afr_symlink_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *buf, struct iatt *preparent, struct iatt *postparent) { - afr_local_t * local = NULL; - afr_private_t * priv = NULL; - int call_count = -1; - int child_index = -1; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + int call_count = -1; + int child_index = -1; + int32_t *fresh_children = NULL; local = frame->local; priv = this->private; @@ -1080,16 +1074,8 @@ afr_symlink_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret != -1) { local->op_ret = op_ret; - if (local->success_count == 0) { + if (local->success_count == 0) local->cont.symlink.buf = *buf; - if (priv->read_child >= 0) { - afr_set_read_child (this, inode, - priv->read_child); - } else { - afr_set_read_child (this, inode, - local->read_child_index); - } - } if (child_index == local->read_child_index) { local->cont.symlink.read_child_buf = *buf; @@ -1099,6 +1085,8 @@ afr_symlink_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->cont.symlink.inode = inode; + fresh_children = local->fresh_children; + fresh_children[local->success_count] = child_index; local->success_count++; } @@ -1109,6 +1097,10 @@ afr_symlink_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, call_count = afr_frame_return (frame); if (call_count == 0) { + afr_set_read_ctx_from_policy (this, inode, + local->fresh_children, + local->read_child_index, + priv->read_child); local->transaction.unwind (frame, this); local->transaction.resume (frame, this); @@ -1424,7 +1416,7 @@ afr_rename (call_frame_t *frame, xlator_t *this, loc_copy (&local->loc, oldloc); loc_copy (&local->newloc, newloc); - local->read_child_index = afr_read_child (this, oldloc->inode); + local->read_child_index = afr_inode_get_read_ctx (this, oldloc->inode, NULL); local->cont.rename.ino = oldloc->inode->ino; |