diff options
author | Vikas Gorur <vikas@gluster.com> | 2009-04-15 06:02:22 -0700 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-16 17:10:28 +0530 |
commit | 8a00ad080cbea0d01470c5f724d7d8ff54b0e254 (patch) | |
tree | d7bfa95ebea1cb87c5f9babd092b5fdf528f9575 /xlators/cluster/afr/src/afr-transaction.c | |
parent | 34f8f0b3e1f992cf59da2c2d410471e440e6ed92 (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/afr/src/afr-transaction.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-transaction.c | 41 |
1 files changed, 39 insertions, 2 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 { |