Subject: port-powerpc/16889: NFS on powerpc is broken
To: None <gnats-bugs@gnats.netbsd.org>
From: Lennart Augustsson <lennart@augustsson.net>
List: netbsd-bugs
Date: 05/18/2002 21:31:32
>Number:         16889
>Category:       port-powerpc
>Synopsis:       NFS on powerpc is broken
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-powerpc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 18 20:32:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Lennart Augustsson
>Release:        NetBSD 1.5ZC
>Organization:
>Environment:
>Description:
	NFS writes of mmap()ed files on ppc is horribly broken.  The written
	file sometimes gets partly filled with 0.
	This seems to be a similar problem as PR#14220 (which I thought was fixed).
>How-To-Repeat:
	Run the following program on an NFS mounted file system and look at ooo.

#include <sys/mman.h>

#define SIZE 6133

int
main(int argc, char **argv)
{
	int ifd, ofd, size;
	char *buf;
	char file[SIZE];
	
	memset(file, 'a', SIZE);
	ofd = creat("iii", 0666);
	write(ofd, file, SIZE);
	close(ofd);

	unlink("ooo");
	ofd = creat("ooo", 0666);
	ifd = open("iii", 0);

	buf = mmap(0, SIZE, PROT_READ, MAP_FILE, ifd, 0);

#if 0
	printf("%p %02x %02x %02x %02x\n", buf, buf[1], buf[2],
	       buf[4096+1], buf[4096+2]);
#endif

	write(ofd, buf, SIZE);
	exit(0);
}

>Fix:
	I don't have a fix, but after some of digging I have narrowed down the problem
	somewhat.  It seems related to the fact that the pages written get faulted in.
	By changing copyin() so the the memcpy() is duplicated you can make the test
	program work (presumably because the second time the pages don't get faults).
>Release-Note:
>Audit-Trail:
>Unformatted: