Subject: Re: kern/25279: NFS read doesn't update atime
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 06/27/2005 00:39:30
On Mon, Jun 27, 2005 at 07:26:21AM +0900, YAMAMOTO Takashi wrote:
> hi,
> 
> > > quoting kern/25279:
> > > 	nfsd doesn't update atime of the file for READ RPCs
> > > 	because recently nfsd uses VOP_GETPAGES to serve them.
> 
> sorry for leaving the PR for this long time.
> 
> > > This is hightly annoying in some environnement, and because of this
> > > I'm stuck with 1.6.x on my production NFS servers.
> > > It looks like it shoudln't be too hard to make VOP_GETPAGES update the
> > > atime at last for UFS-like filesystems (FFS and LFS already have their
> > > own getpage vnode operation, I can easily add one for ext2fs), but is it
> > > the right way to go ? would updating the atime from getpage have
> > > bad side effects, or break a traditionnal behavior ?
> 
> i don't think it's the right way.
> 
> > Here is a patch that makes VOP_GETPAGES update atime for UFS-like filesystems.
> > This fixes the mailbox issue for me.
> 
> doesn't it make write(2) and mmap'ed accesses update atime
> in somewhat unpredictable manner?

For mmap'ed accesses, probably. But I don't think this is a problem,
because if we're faulting in a page via mmap(), we're reading the file,
isn't it ?
For write, yes, it can be a problem if a write can cause a page to be
read via VOP_GETPAGES() (this I don't know). But maybe we can avoid it,
by checking PGO_OVERWRITE in ap->a_flags ? This is already done in
ffs_getpages() for something else.

> 
> because i don't think the problem can be solved properly without
> vnode interface changes, i plan to export nfsd_use_loan as a sysctl knob
> for now.  does it make sense for you?

It does, but I prefer to use page load for nfsd :)

> 
> for long term, i think it's better to extend VOP_SETATTR so that
> it can be used for this purpose.

Yes, this is the direction I initially took (my idea was to add another vnop,
but it's the same idea). The problem is that it can't be pulled up to the
netbsd-2 branch, and maybe not the netbsd-3 brnach either (this is a kernel
API change).

> 
> (although i think it's silly to rely on atime over nfs...)

Lots of things rely on this (especially email tools). It's also a usefull
statistic tool to see which files are really used on a NFS server.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--