From 8a00ad080cbea0d01470c5f724d7d8ff54b0e254 Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Wed, 15 Apr 2009 06:02:22 -0700 Subject: 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 --- xlators/cluster/afr/src/afr-transaction.c | 41 +++++++++++++++++++++++++++++-- xlators/cluster/afr/src/afr.h | 4 ++- 2 files changed, 42 insertions(+), 3 deletions(-) (limited to 'xlators/cluster/afr') diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 7245ee1ac..9baba79b9 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -26,6 +26,28 @@ #include +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 32484fd0a..2871bfc47 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; -- cgit