path: root/xlators/cluster/afr/src/afr-inode-write.c
diff options
authorPranith Kumar K <>2016-03-19 11:40:26 +0530
committerPranith Kumar Karampuri <>2016-05-04 18:42:14 -0700
commit4c4624c9bad2edf27128cb122c64f15d7d63bbc8 (patch)
tree71e77a46f2a793c3fe1fcd4256f25ccd26b369e5 /xlators/cluster/afr/src/afr-inode-write.c
parente3b2ed938a5dc8a72d1fe3d7ced341646d241ca4 (diff)
cluster/afr: Don't let NFS cache stat after writes
Problem: Afr does post-ops after write but the stat buffer it unwinds is at the time of write, so if nfs client caches this, it will see different ctime when it does stat on it after post-op is done. From NFS client's perspective it thinks the file is changed. Tar which depends on this to be correct keeps giving 'file changed as we read it' warning. If Afr instead has to choose to unwind after post-op, eager-lock, delayed-post-op will have to be disabled which will lead to bad performance for all write usecases. Fix: Don't let client cache stat after write. Change-Id: Ic6062acc6e5cdd97a9c83c56bd529ec83cee8a23 BUG: 1302948 Signed-off-by: Pranith Kumar K <> Signed-off-by: Anuradha Talur <> Reviewed-on: Smoke: Gluster Build System <> NetBSD-regression: NetBSD Build System <> CentOS-regression: Gluster Build System <> Reviewed-by: Niels de Vos <>
Diffstat (limited to 'xlators/cluster/afr/src/afr-inode-write.c')
1 files changed, 14 insertions, 2 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
index f240b5eec39..36889429657 100644
--- a/xlators/cluster/afr/src/afr-inode-write.c
+++ b/xlators/cluster/afr/src/afr-inode-write.c
@@ -182,7 +182,9 @@ __afr_inode_write_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
afr_local_t *local = NULL;
int child_index = (long) cookie;
int call_count = -1;
+ afr_private_t *priv = NULL;
+ priv = this->private;
local = frame->local;
LOCK (&frame->lock);
@@ -198,8 +200,13 @@ __afr_inode_write_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (call_count == 0) {
__afr_inode_write_finalize (frame, this);
- if (afr_txn_nothing_failed (frame, this))
- local->transaction.unwind (frame, this);
+ if (afr_txn_nothing_failed (frame, this)) {
+ /*if it did pre-op, it will do post-op changing ctime*/
+ if (priv->consistent_metadata &&
+ afr_needs_changelog_update (local))
+ afr_zero_fill_stat (local);
+ local->transaction.unwind (frame, this);
+ }
local->transaction.resume (frame, this);
@@ -230,8 +237,13 @@ void
afr_writev_unwind (call_frame_t *frame, xlator_t *this)
afr_local_t * local = NULL;
+ afr_private_t *priv = this->private;
local = frame->local;
+ if (priv->consistent_metadata)
+ afr_zero_fill_stat (local);
AFR_STACK_UNWIND (writev, frame,
local->op_ret, local->op_errno,