From ed98d128a9413f7b8af328ca27bf4b27514d61e9 Mon Sep 17 00:00:00 2001 From: vmallika Date: Tue, 2 Feb 2016 14:34:19 +0530 Subject: gluster/uss: change ctime attr of a dir when USS enabled Consider a testcase: mount -t nfs host1:/vol1 /mnt ls /mnt ls /mnt/.snaps (As expected this fails) gluster volume set vol1 features.uss enable Now `ls /mnt/.snaps` should work, but fails with No such file or directory. This is because NFS client and Kernel VFS caches the list of files in a directory. This cache is updated if there are any changes in the directory attributes. This patch solves the problem by changing ctime attribute when USS is enabled Change-Id: I48b284100d0589f1c0285782a1302080c15d4e1f BUG: 1163416 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/9106 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Rajesh Joseph --- .../features/snapview-client/src/snapview-client.c | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c index 5b5bf6834bf..719fa532b5b 100644 --- a/xlators/features/snapview-client/src/snapview-client.c +++ b/xlators/features/snapview-client/src/snapview-client.c @@ -526,6 +526,30 @@ out: return 0; } +int32_t +svc_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *buf, + dict_t *xdata) +{ + /* Consider a testcase: + * #mount -t nfs host1:/vol1 /mnt + * #ls /mnt + * #ls /mnt/.snaps (As expected this fails) + * #gluster volume set vol1 features.uss enable + * Now `ls /mnt/.snaps` should work, + * but fails with No such file or directory. + * This is because NFS client caches the list of files in + * a directory. This cache is updated if there are any changes + * in the directory attributes. To solve this problem change + * a attribute 'ctime' when USS is enabled + */ + if (op_ret == 0 && IA_ISDIR(buf->ia_type)) + buf->ia_ctime_nsec++; + + SVC_STACK_UNWIND (stat, frame, op_ret, op_errno, buf, xdata); + return 0; +} + /* should all the fops be handled like lookup is supposed to be handled? i.e just based on inode type decide where the call should be sent and in the call back update the contexts. @@ -549,7 +573,8 @@ svc_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, SVC_GET_SUBVOL_FROM_CTX (this, op_ret, op_errno, inode_type, ret, loc->inode, subvolume, out); - STACK_WIND_TAIL (frame,subvolume, subvolume->fops->stat, loc, xdata); + STACK_WIND (frame, svc_stat_cbk, subvolume, + subvolume->fops->stat, loc, xdata); wind = _gf_true; -- cgit