From 0c2fb5d80e248f8b49e0ed13de0165c30429a072 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sat, 19 Mar 2016 11:40:26 +0530 Subject: 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: http://review.gluster.org/13785 >Smoke: Gluster Build System >NetBSD-regression: NetBSD Build System >CentOS-regression: Gluster Build System >Reviewed-by: Niels de Vos BUG: 1312721 Change-Id: I42a5d524bcf2a2034fe48ee8454812ca26a98c37 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/14454 NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Smoke: Gluster Build System --- libglusterfs/src/common-utils.c | 23 +++++++++++++++++++++++ libglusterfs/src/common-utils.h | 6 ++++++ 2 files changed, 29 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 40d9b637b7a..337d5ed00fc 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4076,3 +4076,26 @@ list_node_del (struct list_node *node) GF_FREE (node); } +gf_boolean_t +gf_is_zero_filled_stat (struct iatt *buf) +{ + if (!buf) + return 1; + + /* Do not use st_dev because it is transformed to store the xlator id + * in place of the device number. Do not use st_ino because by this time + * we've already mapped the root ino to 1 so it is not guaranteed to be + * 0. + */ + if ((buf->ia_nlink == 0) && (buf->ia_ctime == 0)) + return 1; + + return 0; +} + +void +gf_zero_fill_stat (struct iatt *buf) +{ + buf->ia_nlink = 0; + buf->ia_ctime = 0; +} diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index ca9ce78c845..bfcc480293a 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -790,4 +790,10 @@ gf_nwrite (int fd, const void *buf, size_t count); void _mask_cancellation (void); void _unmask_cancellation (void); +gf_boolean_t +gf_is_zero_filled_stat (struct iatt *buf); + +void +gf_zero_fill_stat (struct iatt *buf); + #endif /* _COMMON_UTILS_H */ -- cgit