Re: [PATCH] proc: update i_atime when reading files
From: Alexey Dobriyan
Date: Fri Feb 22 2019 - 00:37:50 EST
On Thu, Feb 21, 2019 at 11:37:14AM -0500, Jeremy Cline wrote:
> Prior to commit 1da4d377f943 ("proc: revalidate misc dentries"), the
> access, modify, and change times of files in /proc were just the current
> time.
Ehh, actually no. Doing
$(which sleep) infinity </proc/foo &
will sabotage atime updates because dentry and inode will be pinned in
caches.
"revalidate misc denries" commit simply makes the effect (much) more
visible by making objects stay in caches for longer.
> Now the mtime and ctime values change mostly as a user would
> expect, but the atime isn't updated when the file read. This patch
> updates the access time of /proc files when they are read.
> rv = read(file, buf, count, ppos);
> + if (rv >= 0)
> + inode->i_atime = current_time(inode);
> + }
Maybe it should be done given /proc is virtual so there are no concerns
about scheduling writes noone cares about to the filesystem.