Bug 1436673

Summary: Restore atime/mtime for symlinks and other non-regular files.
Product: Red Hat Gluster Storage Reporter: Ravishankar N <ravishankar>
Component: replicateAssignee: Ravishankar N <ravishankar>
Status: CLOSED ERRATA QA Contact: Vijay Avuthu <vavuthu>
Severity: unspecified Docs Contact:
Priority: high    
Version: rhgs-3.3CC: amukherj, bugs, nchilaka, ravishankar, rhinduja, rhs-bugs, sanandpa, sheggodu, storage-qa-internal
Target Milestone: ---Keywords: Triaged
Target Release: RHGS 3.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: rebase
Fixed In Version: glusterfs-3.12.2-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1429402 Environment:
Last Closed: 2018-09-04 06:32:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 1429198, 1429402, 1429405    
Bug Blocks: 1414456, 1472361, 1503135    

Description Ravishankar N 2017-03-28 12:21:31 UTC
+++ This bug was initially created as a clone of Bug #1429402 +++

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

AFR restores atime/mtime only as a part of data heal. For non-regular
    files (dirs, symlinks, char/block/socket files etc) which do not undergo
    data-heal, atime/mtime is not restored.

--- Additional comment from Worker Ant on 2017-03-05 10:26:39 EST ---

REVIEW: https://review.gluster.org/16844 (afr: restore atime/mtime for non-regular files) posted (#1) for review on master by Ravishankar N (ravishankar@redhat.com)

--- Additional comment from Worker Ant on 2017-03-06 00:15:46 EST ---

REVIEW: https://review.gluster.org/16844 (afr: restore atime/mtime for non-regular files) posted (#2) for review on master by Ravishankar N (ravishankar@redhat.com)

--- Additional comment from Worker Ant on 2017-03-06 05:01:52 EST ---

COMMIT: https://review.gluster.org/16844 committed in master by Pranith Kumar Karampuri (pkarampu@redhat.com) 
------
commit 804a65f07ea8e2093f781807651d0d07513b2627
Author: Ravishankar N <ravishankar@redhat.com>
Date:   Sat Mar 4 01:04:10 2017 +0530

    afr: restore atime/mtime for non-regular files
    
    AFR restores atime/mtime only as a part of data heal. For non-regular
    files (dirs, symlinks, char/block/socket files etc) which do not undergo
    data-heal, atime/mtime is not restored.
    
    This patch restores atime/mtime as a part of metadata heal for such
    files.
    
    Change-Id: Id8da885fc93fdf65c2f4bae2af3605b146ac1f16
    BUG: 1429198
    Signed-off-by: Ravishankar N <ravishankar@redhat.com>
    Reviewed-on: https://review.gluster.org/16844
    Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
    Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
    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>

--- Additional comment from Worker Ant on 2017-03-06 05:10:22 EST ---

REVIEW: https://review.gluster.org/16851 (afr: restore atime/mtime for non-regular files) posted (#1) for review on release-3.10 by Ravishankar N (ravishankar@redhat.com)

--- Additional comment from Worker Ant on 2017-03-06 10:45:51 EST ---

COMMIT: https://review.gluster.org/16851 committed in release-3.10 by Shyamsundar Ranganathan (srangana@redhat.com) 
------
commit e46cb08e9d381c46277631fa266751cd63f3823c
Author: Ravishankar N <ravishankar@redhat.com>
Date:   Sat Mar 4 01:04:10 2017 +0530

    afr: restore atime/mtime for non-regular files
    
    AFR restores atime/mtime only as a part of data heal. For non-regular
    files (dirs, symlinks, char/block/socket files etc) which do not undergo
    data-heal, atime/mtime is not restored.
    
    This patch restores atime/mtime as a part of metadata heal for such
    files.
    
    > Reviewed-on: https://review.gluster.org/16844
    > Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
    > Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
    > 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>
    (cherry picked from commit 804a65f07ea8e2093f781807651d0d07513b2627)
    
    Change-Id: Id8da885fc93fdf65c2f4bae2af3605b146ac1f16
    BUG: 1429402
    Signed-off-by: Ravishankar N <ravishankar@redhat.com>
    Reviewed-on: https://review.gluster.org/16851
    Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
    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>

Comment 2 Ravishankar N 2017-03-28 12:28:19 UTC
Downstream patch: https://code.engineering.redhat.com/gerrit/#/c/101659/

Comment 3 Ravishankar N 2017-04-11 12:11:24 UTC
Leaving a need-info on Nag for his decision on QE ack for this bug which fixes an issue found while debugging gss bz 1414456

Comment 8 Vijay Avuthu 2018-04-25 10:53:33 UTC
Update:
========

Build used: glusterfs-3.12.2-8.el7rhgs.x86_64


Scenario :

1) create 2 * 3 volume and start 
2) kill one of the brick ( N1:b0 )
3) create dirs, file, soft link, hard link and char files.
4) wait for few minutes and modify/append some files and create files inside some dirs 
4) wait for few min
5) go to node where brick is up ( in the same replica set )
6) "ls -lrt" on the data and note down the timings
7) bringup the brick
9) After healing , from the node where brick was brough down previously ( step 2 ) do "ls -lrt" on the data 
10) compare the atime/mtime from step 6 and step 9

Observation :

All the files, soft links, hardlinks and char files restored the time but only below dir is not restored the time.


From N1:

drwxr-xr-x. 2 root root    47 Apr 24 09:01 dir1
drwxr-xr-x. 2 root root    47 Apr 24 09:01 dir2


From N2:

drwxr-xr-x. 2 root root    47 Apr 24 08:36 dir1
drwxr-xr-x. 2 root root    47 Apr 24 08:36 dir2

> attribute for N2

# getfattr -d -m . -e hex  /bricks/brick0/testvol_distributed-replicated_brick1/dir1
getfattr: Removing leading '/' from absolute path names
# file: bricks/brick0/testvol_distributed-replicated_brick1/dir1
security.selinux=0x73797374656d5f753a6f626a6563745f723a676c7573746572645f627269636b5f743a733000
trusted.afr.23-client-0=0x000000000000000000000000
trusted.afr.dirty=0x000000000000000000000000
trusted.gfid=0x342afbb2ce814094895409deed35465d
trusted.glusterfs.dht=0x00000000000000007fffffffffffffff
trusted.glusterfs.dht.mds=0x00000000

# 

> scenario for that dir is , kill b0 and create dir from client and touch a empty file inside dir and after 5 min brought up b0.

Placing Needinfo to check the above behavior

Comment 9 Ravishankar N 2018-04-26 04:09:32 UTC
Vijay,

What is happening is when the empty file is  created on the down brick (after bringing it up) as a part of entry self-heal, it changes time stamp of the parent directory.

The patch for this bug basically handles fixing timestamps during metadata self-heal. We need to do it for entry self-heals too. But given it is a day one issue, you could probably raise a separate bug for it that can be targeted for the next release.

A simple reproducer would be:
-create 1x2 volume
-create a 'dir' from mount
-kill one brick
-touch 'dir/file'
-bring back brick after some time
-after healing, mtime and ctime of 'dir' will be different, while it should be same.

Comment 10 Vijay Avuthu 2018-04-26 06:31:33 UTC
(In reply to Ravishankar N from comment #9)
> Vijay,
> 
> What is happening is when the empty file is  created on the down brick
> (after bringing it up) as a part of entry self-heal, it changes time stamp
> of the parent directory.
> 
> The patch for this bug basically handles fixing timestamps during metadata
> self-heal. We need to do it for entry self-heals too. But given it is a day
> one issue, you could probably raise a separate bug for it that can be
> targeted for the next release.
> 
> A simple reproducer would be:
> -create 1x2 volume
> -create a 'dir' from mount
> -kill one brick
> -touch 'dir/file'
> -bring back brick after some time
> -after healing, mtime and ctime of 'dir' will be different, while it should
> be same.

Thanks Ravi for the explanation. I will raise separate bug for the same.

Moving status to verified.

Comment 11 errata-xmlrpc 2018-09-04 06:32:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2607