Bug 14285

Summary: NFS client appears to lose data
Product: Base System Reporter: amobbs <amobbs>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description amobbs 1999-10-12 14:20:00 UTC
As far as I can tell, the following program will lose data on a
FreeBSD->FreeBSD NFS mount, but not on a
FreeBSD->{Solaris,Linux,AIX} or a {Solaris,Linux}->FreeBSD mount
(Notation is server->client)
All mounts are hard. NFS options are whatever the default on a given 
platform is.
Network is 100MBps switched ethernet.

The output file "testfile" loses occasional characters
OS versions:
Solaris 2.5.1 (sparc)
Linux 2.2.10 (i386)
FreeBSD 3.3-RC (client) (i386)
FreeBSD 3.2-R  (server) (i386)
AIX 4.2 (rs6000)

How-To-Repeat: #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <sys/types.h>

main(void){

        int error=0,len,i;
        FILE *fp;
        pid_t mypid;
        char str[80];

        init_mutex(&mutex);

        srandom(time(NULL));

        mypid=getpid();

        sprintf(str,"Hello, I'm process %d.\n",mypid);
        len=strlen(str);

        if((fp=fopen("testfile","a+"))==NULL){
                fprintf(stderr,"Cannot open testfile failed %d\n",errno);
                exit(1);
        }

        for(;;){
                for(i=0;i<len;i++){
                        fputc(str[i],fp);
                        usleep((random()%1000)*100);
                        fflush(fp);
                }
        }
}
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 1999-10-12 14:53:16 UTC
Responsible Changed
From-To: freebsd-bugs->dillon

Over to Mr NFS. :-) 
Comment 2 Giorgos Keramidas freebsd_committer freebsd_triage 2003-02-23 02:13:56 UTC
Responsible Changed
From-To: dillon->freebsd-bugs

Back to the free pool.
Comment 3 Kris Kennaway freebsd_committer freebsd_triage 2003-11-15 21:55:36 UTC
State Changed
From-To: open->closed

I am unable to reproduce this.  Your code does not compile 
as it stands because of "init_mutex(&mutex);", which suggests 
it was originally written as a multi-threaded program.  Removing 
this call, I do not experience any unexpected results on a 4.x NFS 
server.  Either the bug has been fixed, or your problem was actually 
a threading bug in your test code.