Subject: NFS bug?
To: None <>
From: Arne Jansen <>
List: current-users
Date: 05/04/2001 10:14:02
I'm currently porting NetBSD to an MPC860 (embedded PowerPC). It's
runnning in multiuser mode now, booting as a diskless client.
At first, all seemed fine with NFS, but I was unable to build
a new pwd.db: each time I called pwd_mkdb, the first 4096 bytes
in the pwd.db were zero.
Writing a little test program, I figured out that 
     fd = open("testfile", O_WRONLY | O_TRUNC | O_CREAT, 0666);
     memset(buf, 1, 4096);
     pwrite(fd, buf, 1024, 4096);
     pwrite(fd, buf, 1024, 0);
didn't render the expected result: the first 4096 were zero.
Using lseek() didn't change anything. If I write the file sequentially,
all went fine.
A million printfs later (I don't know anything about NFS and uvm),
I found out that the first page has not been marked unclean and thus
not been written back to disk.
Another million printfs later I inserted 2 lines into nfs_bio.c, near
the end where allocated pages are unfaked:
        pgs[i]->flags &= ~(PG_FAKE);
+       if (ap->a_access_type & VM_PROT_WRITE)
+               pgs[i]->flags &= ~PG_CLEAN;
Now it's working correctly for me, but I know this is only a dirty
hack, but I don't have no more energy left to track down the problem
to its root, thus seeking your help.
Maybe the problem is that the last page is not yet commited, so the
file on the server is truncated to 0 and reading the hole from 0-4095
I can't figure how this bug can have anything to do with my port, but
I can't exclude the possibility. My port is based on work done by
Tsubai Masanari in March, so maybe I have to update some parts.