summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-04-15 06:02:22 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-16 17:10:28 +0530
commit8a00ad080cbea0d01470c5f724d7d8ff54b0e254 (patch)
treed7bfa95ebea1cb87c5f9babd092b5fdf528f9575 /xlators/cluster
parent34f8f0b3e1f992cf59da2c2d410471e440e6ed92 (diff)
Use original pid when calling the FOP in afr transaction.
Save the original pid while locking and restore it after the FOP is done. This ensures posix-locks can release locks (fcntl) properly. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c41
-rw-r--r--xlators/cluster/afr/src/afr.h4
2 files changed, 42 insertions, 3 deletions
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 7245ee1acbc..9baba79b9dd 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -27,6 +27,28 @@
static void
+afr_pid_save (call_frame_t *frame)
+{
+ afr_local_t * local = NULL;
+
+ local = frame->local;
+
+ local->saved_pid = frame->root->pid;
+}
+
+
+static void
+afr_pid_restore (call_frame_t *frame)
+{
+ afr_local_t * local = NULL;
+
+ local = frame->local;
+
+ frame->root->pid = local->saved_pid;
+}
+
+
+static void
__mark_all_pending (int32_t *pending[], int child_count,
afr_transaction_type type)
{
@@ -389,7 +411,14 @@ afr_unlock (call_frame_t *frame, xlator_t *this)
afr_private_t * priv = this->private;
local = frame->local;
-
+
+ /*
+ pid has been restored to saved_pid in the fop,
+ so set it back to frame->root
+ */
+
+ frame->root->pid = (long) frame->root;
+
call_count = afr_locked_nodes_count (local->transaction.locked_nodes,
priv->child_count);
@@ -677,7 +706,9 @@ afr_changelog_pre_op_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
} else {
__mark_all_success (local->pending, priv->child_count,
local->transaction.type);
-
+
+ afr_pid_restore (frame);
+
local->transaction.fop (frame, this);
}
}
@@ -947,6 +978,8 @@ int afr_lock_rec (call_frame_t *frame, xlator_t *this, int child_index)
__mark_all_success (local->pending, priv->child_count,
local->transaction.type);
+ afr_pid_restore (frame);
+
local->transaction.fop (frame, this);
}
@@ -1047,6 +1080,8 @@ int afr_lock_rec (call_frame_t *frame, xlator_t *this, int child_index)
int32_t afr_lock (call_frame_t *frame, xlator_t *this)
{
+ afr_pid_save (frame);
+
frame->root->pid = (long) frame->root;
return afr_lock_rec (frame, this, 0);
@@ -1124,6 +1159,8 @@ afr_transaction (call_frame_t *frame, xlator_t *this, afr_transaction_type type)
__mark_all_success (local->pending, priv->child_count,
local->transaction.type);
+ afr_pid_restore (frame);
+
local->transaction.fop (frame, this);
}
} else {
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 32484fd0a53..2871bfc47dd 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -145,7 +145,9 @@ typedef struct _afr_local {
unsigned int govinda_gOvinda;
unsigned int read_child_index;
-
+
+ pid_t saved_pid;
+
int32_t op_ret;
int32_t op_errno;