Bug 1411010 - atime becomes zero when truncating file via ganesha (or gluster-NFS)
Summary: atime becomes zero when truncating file via ganesha (or gluster-NFS)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: posix
Version: 3.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Niels de Vos
QA Contact:
URL:
Whiteboard:
Depends On: 1401777
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-07 13:21 UTC by Niels de Vos
Modified: 2017-03-08 10:23 UTC (History)
1 user (show)

Fixed In Version: glusterfs-3.9.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1401777
Environment:
Last Closed: 2017-03-08 10:23:55 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:


Attachments (Terms of Use)

Description Niels de Vos 2017-01-07 13:21:20 UTC
+++ This bug was initially created as a clone of Bug #1401777 +++

+++ This bug was initially created as a clone of Bug #1401122 +++

Description of problem:
Ganesha and gluster-NFS can both issue an fop_setattr(GF_SET_ATTR_MTIME) without also setting GF_SET_ATTR_ATIME.  This will cause posix_setattr() to issue lutimes() with zero value for atime.
There are slightly different ways to cause the issue in gluster-NFS and Ganesha, but end result is the same.


Version-Release number of selected component (if applicable):
All versions of gluster


How reproducible: Every time


Steps to Reproduce (gluster-NFS):
1. cp /vmlinuz /nfs/
2. dd if=/vmlinuz of=/nfs/vmlinuz conv=nocreat
3. stat /nfs/vmlinuz

Steps to Reproduce (Ganesha):
1. cp /vmlinuz /ganesha/
2. truncate -s 1000 /ganesha/vmlinuz
3. stat /ganesha/vmlinuz

Actual results:
root@vsan125:~# stat /nfs/vmlinuz
  File: ‘/nfs/vmlinuz’
  Size:  6579344      Blocks: 12851       IO Block: 1048576 regular file
Device: 1ch/28d Inode: 13728026437677438595  Links: 1
Access: (0600/-rw-------)  Uid: (65534/  nobody)   Gid: (4294967294/ UNKNOWN)
Access: 1969-12-31 16:00:00.000000000 -0800
Modify: 2016-12-02 11:07:36.000000000 -0800
Change: 2016-12-02 11:07:36.000000000 -0800
 Birth: -


Expected results:
Access time should not be 0.

Additional info:
Strace of glusterfsd setting atime to zero (in posix_do_utimes):
16332 utimensat(AT_FDCWD, "/brick/gv5/.glusterfs/ac/b6/acb67218-b076-464e-b6a4-d153d7391e76", {{0, 0}, {1480627988, 0}}, AT_SYMLINK_NOFOLLOW

I have attached a proposed solution.

--- Additional comment from Niels de Vos on 2016-12-06 05:47 CET ---

This patch uses the atime+mtime for missing values from the locally executed lstat() instead of the values from the passed IATT. It otherwise is pretty much the same as the other proposed change.

--- Additional comment from Worker Ant on 2016-12-06 06:06:47 CET ---

REVIEW: http://review.gluster.org/16034 (posix: make sure atime and mtime are set when calling lutimes()) posted (#2) for review on master by Niels de Vos (ndevos@redhat.com)

--- Additional comment from Worker Ant on 2016-12-06 07:41:58 CET ---

REVIEW: http://review.gluster.org/16034 (posix: make sure atime and mtime are set when calling lutimes()) posted (#3) for review on master by Niels de Vos (ndevos@redhat.com)

--- Additional comment from Worker Ant on 2016-12-06 07:47:18 CET ---

REVIEW: http://review.gluster.org/16034 (posix: make sure atime and mtime are set when calling lutimes()) posted (#4) for review on master by Niels de Vos (ndevos@redhat.com)

--- Additional comment from Worker Ant on 2017-01-06 18:33:15 CET ---

COMMIT: http://review.gluster.org/16034 committed in master by Jeff Darcy (jdarcy@redhat.com) 
------
commit 9bed81ada6f91f998e9abd915b18e3f06557cdcb
Author: Niels de Vos <ndevos@redhat.com>
Date:   Tue Dec 6 07:46:52 2016 +0100

    posix: make sure atime and mtime are set when calling lutimes()
    
    When overwriting an existing file with O_TRUNC, the 'atime' was set to
    0, meaning the Epoch (01-Jan-1970 UTC). However, the 'mtime' gets
    updated correcty.
    
    In case 'atime' or 'mtime' is not passed in the 'struct iatt', the time
    values passed to the systemcall are taken from the current values are
    returned by lstat().
    
    Change-Id: I7021b7161dcd6c9a3e515d98f6d4847533c434b3
    BUG: 1401777
    Reported-by: Eivind Sarto <eivindsarto@gmail.com>
    Signed-off-by: Niels de Vos <ndevos@redhat.com>
    Reviewed-on: http://review.gluster.org/16034
    Smoke: Gluster Build System <jenkins@build.gluster.org>
    NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
    Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
    CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
    Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>

Comment 1 Worker Ant 2017-01-07 13:22:46 UTC
REVIEW: http://review.gluster.org/16355 (posix: make sure atime and mtime are set when calling lutimes()) posted (#1) for review on release-3.9 by Niels de Vos (ndevos@redhat.com)

Comment 2 Worker Ant 2017-01-09 01:10:45 UTC
COMMIT: http://review.gluster.org/16355 committed in release-3.9 by Kaleb KEITHLEY (kkeithle@redhat.com) 
------
commit 411471c1827640fbb38813d0f870b3c85773039f
Author: Niels de Vos <ndevos@redhat.com>
Date:   Sat Jan 7 14:21:54 2017 +0100

    posix: make sure atime and mtime are set when calling lutimes()
    
    When overwriting an existing file with O_TRUNC, the 'atime' was set to
    0, meaning the Epoch (01-Jan-1970 UTC). However, the 'mtime' gets
    updated correcty.
    
    In case 'atime' or 'mtime' is not passed in the 'struct iatt', the time
    values passed to the systemcall are taken from the current values are
    returned by lstat().
    
    Cherry picked from commit 9bed81ada6f91f998e9abd915b18e3f06557cdcb:
    > Change-Id: I7021b7161dcd6c9a3e515d98f6d4847533c434b3
    > BUG: 1401777
    > Reported-by: Eivind Sarto <eivindsarto@gmail.com>
    > Signed-off-by: Niels de Vos <ndevos@redhat.com>
    > Reviewed-on: http://review.gluster.org/16034
    > Smoke: Gluster Build System <jenkins@build.gluster.org>
    > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
    > Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
    > CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
    > Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
    
    Change-Id: I7021b7161dcd6c9a3e515d98f6d4847533c434b3
    BUG: 1411010
    Reported-by: Eivind Sarto <eivindsarto@gmail.com>
    Signed-off-by: Niels de Vos <ndevos@redhat.com>
    Reviewed-on: http://review.gluster.org/16355
    Smoke: Gluster Build System <jenkins@build.gluster.org>
    NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
    CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
    Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>

Comment 3 Kaushal 2017-03-08 10:23:55 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.9.1, please open a new bug report.

glusterfs-3.9.1 has been announced on the Gluster mailinglists [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://lists.gluster.org/pipermail/gluster-users/2017-January/029725.html
[2] https://www.gluster.org/pipermail/gluster-users/


Note You need to log in before you can comment on or make changes to this bug.