Skip to contentSkip to conversation

gfs2: Support negative atimes

PATCH New Andreas Gruenbacher 2 participants 2 messages Sep 22, 2017 – Sep 25, 2017 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Support negative atimes

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.

---
 fs/gfs2/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/inode.c +2 -1
index 52783d7bae1a..4749a6b8e4dd 100644
@@ -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);
Signature · 1 line
2.13.3
#1 lore raw

PATCH 1/1 gfs2: Support negative atimes

----- Original Message -----

| 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 <[email protected]>
| ---
|  fs/gfs2/inode.c | 3 ++-
|  1 file changed, 2 insertions(+), 1 deletion(-)

Hi,

Thanks. This is now pushed to the for-next branch of the linux-gfs2 tree:
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?h=for-next&id=37f94616c0d01dc2c1d10e3b51559092882fbc4f

Regards,

Bob Peterson
Red Hat File Systems