]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gfs2: Support negative atimes
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 22 Sep 2017 13:34:46 +0000 (08:34 -0500)
committerBob Peterson <rpeterso@redhat.com>
Mon, 25 Sep 2017 17:33:19 +0000 (12:33 -0500)
When inodes are read from disk, GFS2 will only update in-memory atimes
older than the on-disk atimes; this prevents atimes from going
backwards.  The atimes of newly allocated inodes are initialized to 0.
This means that when an atime is explicitly set to a negative value,
this value will not persist.

Fix by setting the atime of newly allocated inodes to the lowest
possible value instead of 0.

Fixes xfstest generic/258.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/inode.c

index 863749e29bf90607238a6b8a09c28dc1abd1ce8a..b288cf2f85e62d2a43009176179304f220c003bd 100644 (file)
@@ -189,7 +189,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
 
                gfs2_set_iop(inode);
 
-               inode->i_atime.tv_sec = 0;
+               /* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
+               inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
                inode->i_atime.tv_nsec = 0;
 
                unlock_new_inode(inode);