diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2013-02-06 12:26:08 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-02-06 09:24:31 -0800 |
commit | e0a331c4bea8713a67a0f8c5dc4bac1e6f81f358 (patch) | |
tree | 3bc6c76528e43b71578460c8c858668f91a914e1 | |
parent | 765fdd0809afb1bdac49fae2a0a58ae092e5cde3 (diff) |
cluster/afr: Perform wakeup just before fop
There is no necessity for the delayed-post-op to wait until
the next fop phase on the fd completes. Change-log,
locks are inherited by the time next fop phase is attempted
so the wakeup can happen just before the fop phase is started.
Change-Id: I0b8e591f591b0f7565eb55265ab51f476ed2b165
BUG: 908302
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/4073
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r-- | xlators/cluster/afr/src/afr-inode-write.c | 7 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-transaction.c | 27 |
2 files changed, 21 insertions, 13 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c index 7c3d38e9020..c619536ca17 100644 --- a/xlators/cluster/afr/src/afr-inode-write.c +++ b/xlators/cluster/afr/src/afr-inode-write.c @@ -296,6 +296,13 @@ afr_do_writev (call_frame_t *frame, xlator_t *this) local->transaction.main_frame = frame; if (local->fd->flags & O_APPEND) { + /* + * Backend vfs ignores the 'offset' for append mode fd so + * locking just the region provided for the writev does not + * give consistency gurantee. The actual write may happen at a + * completely different range than the one provided by the + * offset, len in the fop. So lock the entire file. + */ local->transaction.start = 0; local->transaction.len = 0; } else { diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 4e7ed55a0d9..c0316f86aae 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -220,9 +220,12 @@ afr_transaction_perform_fop (call_frame_t *frame, xlator_t *this) { afr_local_t *local = NULL; afr_private_t *priv = NULL; + fd_t *fd = NULL; local = frame->local; priv = this->private; + fd = local->fd; + __mark_all_success (local->pending, priv->child_count, local->transaction.type); @@ -236,6 +239,17 @@ afr_transaction_perform_fop (call_frame_t *frame, xlator_t *this) frame->root->lk_owner = local->transaction.main_frame->root->lk_owner; + + /* The wake up needs to happen independent of + what type of fop arrives here. If it was + a write, then it has already inherited the + lock and changelog. If it was not a write, + then the presumption of the optimization (of + optimizing for successive write operations) + fails. + */ + if (fd) + afr_delayed_changelog_wake_up (this, fd); local->transaction.fop (frame, this); } @@ -1392,23 +1406,10 @@ afr_transaction_resume (call_frame_t *frame, xlator_t *this) afr_internal_lock_t *int_lock = NULL; afr_local_t *local = NULL; afr_private_t *priv = NULL; - fd_t *fd = NULL; local = frame->local; int_lock = &local->internal_lock; priv = this->private; - fd = local->fd; - - if (fd) - /* The wake up needs to happen independent of - what type of fop arrives here. If it was - a write, then it has already inherited the - lock and changelog. If it was not a write, - then the presumption of the optimization (of - optimizing for successive write operations) - fails. - */ - afr_delayed_changelog_wake_up (this, fd); afr_restore_lk_owner (frame); |