summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-transaction.c
diff options
context:
space:
mode:
authorVikas Gorur <vikas@zresearch.com>2009-02-27 22:35:25 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-02-27 22:49:17 +0530
commit3aff44fab8ba7a109bd691b8675dbfd9842237a3 (patch)
tree14e05767ce54ae6b77c5fb62e2d2f45583ea5137 /xlators/cluster/afr/src/afr-transaction.c
parent1e5ac91d05e89356ac63fb07cc09bed7a979289f (diff)
check for fd ctx set in changelog_needed_post_op for flush() in afr
Earlier the check was in afr_flush(), which caused race conditions with writev() Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-transaction.c')
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 6a1f228a6..82c2ee340 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -89,6 +89,26 @@ __is_first_write_on_fd (xlator_t *this, fd_t *fd)
static int
+__unset_fd_ctx_if_set (xlator_t *this, fd_t *fd)
+{
+ int op_ret = 0;
+ int _ret = -1;
+
+ LOCK (&fd->inode->lock);
+ {
+ _ret = fd_ctx_get (fd, this, NULL);
+ if (_ret == 0) {
+ fd_ctx_del (fd, this, NULL);
+ op_ret = 1;
+ }
+ }
+ UNLOCK (&fd->inode->lock);
+
+ return op_ret;
+}
+
+
+static int
__changelog_enabled (afr_private_t *priv, afr_transaction_type type)
{
int ret = 0;
@@ -170,19 +190,31 @@ __changelog_needed_post_op (call_frame_t *frame, xlator_t *this)
afr_private_t * priv = NULL;
afr_local_t * local = NULL;
- int ret = 0;
+ int op_ret = 0;
afr_transaction_type type = -1;
priv = this->private;
local = frame->local;
type = local->transaction.type;
- if (__changelog_enabled (priv, type)
- && (local->op != GF_FOP_WRITE)
- && (local->op != GF_FOP_FTRUNCATE))
- ret = 1;
-
- return ret;
+ if (__changelog_enabled (priv, type)) {
+ switch (local->op) {
+
+ case GF_FOP_WRITE:
+ case GF_FOP_FTRUNCATE:
+ op_ret = 0;
+ break;
+
+ case GF_FOP_FLUSH:
+ op_ret = __unset_fd_ctx_if_set (this, local->fd);
+ break;
+
+ default:
+ op_ret = 1;
+ }
+ }
+
+ return op_ret;
}