Subject: Re: kern/25279: NFS read doesn't update atime
To: Chuck Silvers <chuq@chuq.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 06/28/2005 19:23:45
On Tue, Jun 28, 2005 at 09:05:11AM -0700, Chuck Silvers wrote:
> > Yes, but this requires an interface change in the vnode op, which may not
> > be doable on the existing branches. In addition, this code doens't exist
> > yet.
>
> my point is that it does not seem correct to update timestamps as part of
> cache-flushing. whether or not the incorrect change is doable on a branch
> is irrelevant.
>
> it seems better to have VOP_GETPAGES() update atime on VM_PROT_READ accesses
> and update mtime on VM_PROT_WRITE accesses. the only caller that doesn't
> fit with this behaviour that has been mentioned so far is ufs_balloc_range().
Well, this doens't work. With the test program below:
#include <fcntl.h>
#include <sys/mman.h>
main()
{
int fd;
void *p;
char *c;
int i;
fd = open("udptun", O_RDWR, 0);
if (fd < 0) {
perror("open");
exit(1);
}
p = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0);
if (p == NULL) {
perror("mmap");
exit(1);
}
c = (char *)p;
i = *c;
i++;
printf("%d\n", i);
*c = i;
munmap(p, 4096);
close(fd);
}
the atime is updated, but not the mtime. Or do I need to set other flags on
the inode to get the mtime updated ?
My guess is that the first access cause VOP_GETPAGE to be called with
VM_PROT_READ only, because the page is not mapped read/write. Then the write
cause another page fault, but this one doesn't call VOP_GETPAGE().
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--