From nobody@FreeBSD.org  Tue Mar 27 02:29:08 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id C32FE37B719
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 27 Mar 2001 02:29:07 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f2RAIr213382;
	Tue, 27 Mar 2001 02:18:53 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200103271018.f2RAIr213382@freefall.freebsd.org>
Date: Tue, 27 Mar 2001 02:18:53 -0800 (PST)
From: j.schripsema@kpn.com
To: freebsd-gnats-submit@FreeBSD.org
Subject: Unlink fails on NFS mounted filesystem
X-Send-Pr-Version: www-1.0

>Number:         26142
>Category:       kern
>Synopsis:       [nfs] Unlink fails on NFS mounted filesystem
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    vwe
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 27 02:30:04 PST 2001
>Closed-Date:    Sat Jan 14 15:48:22 UTC 2012
>Last-Modified:  Sat Jan 14 15:48:22 UTC 2012
>Originator:     Jakob Schripsema
>Release:        4.2-RELEASE
>Organization:
KPN
>Environment:
client: FreeBSD nfsclient 4.2-RELEASE FreeBSD 4.2-RELEASE #0: Mon Nov 20 13:02:55 GMT 2000     jkh@bento.FreeBSD.org:/usr/src/sys/compile/GENERIC  i386
server: FreeBSD nfsserver 4.2-RELEASE FreeBSD 4.2-RELEASE #0: Mon Nov 20 13:02:55 GMT 2000     jkh@bento.FreeBSD.org:/usr/src/sys/compile/GENERIC  i386

>Description:
When removing all files in a large NFS mounted directory by calling
readdir and unlink repeatedly files get skipped.
It seems that this problem is related to problem kern/3381.
I ran into this problem when running bonnie++ (www.cooker.com.au/bonnie++)
on a NFS mounted filesystem.
>How-To-Repeat:
Run the attached program on the client. Uncomment the rewinddir call
first.

---- snip -----
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <dirent.h>


#define BASEDIR "/FS/testdir"           /* NFS mounted  */
#define NFILES  1024

main()
{
        create_files();
        delete_files();
}

create_files()
{
        int i,fd;
        char buf[2048];

        for(i = 0 ; i < NFILES ; i++) {
                snprintf(buf,2048,"%s/%04d",BASEDIR,i);
                if ((fd = open(buf,O_CREAT | O_TRUNC | O_WRONLY, 0644)) < 0) {
                        perror(buf);
                        return(-1);
                }
                close(fd);
        }
}

delete_files()
{
        DIR *dirp;
        struct dirent *dp;
        char buf[2048];

        if ((dirp = opendir(BASEDIR)) == NULL) {
                perror("opendir");
                return (-1);
        }
        while ((dp = readdir(dirp)) != NULL) {
                if (dp->d_name[0] == '.')
                        continue;
                snprintf(buf,2048,"%s/%s",BASEDIR,dp->d_name);
                fprintf(stderr,"%s\n",buf);
                if (unlink(buf) < 0) {
                        perror(buf);
                        return (-1);
		}

		/* Workaround */   
                /* rewinddir(dirp); */
		/* End workaround */
	}
}



>Fix:
Call rewinddir after each unlink call. I consider this a workaround,
not a fix.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: kris 
State-Changed-When: Sat Nov 15 13:50:55 PST 2003 
State-Changed-Why:  
See also kern/57696.  This is a known problem in the nfs code; 
the ufs code contains code to deal with this situation.  Bug peter  
for more details :-) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26142 
Responsible-Changed-From-To: freebsd-bugs->cel 
Responsible-Changed-By: cel 
Responsible-Changed-When: Sat May 13 00:08:01 UTC 2006 
Responsible-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=26142 
Responsible-Changed-From-To: cel->freebsd-bugs 
Responsible-Changed-By: cel 
Responsible-Changed-When: Mon Mar 12 15:27:09 UTC 2007 
Responsible-Changed-Why:  
Back to the public pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26142 
State-Changed-From-To: analyzed->feedback 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 04:07:57 UTC 2007 
State-Changed-Why:  

Needs new analysis. 


Responsible-Changed-From-To: freebsd-bugs->rwatson 
Responsible-Changed-By: kmacy 
Responsible-Changed-When: Fri Nov 16 04:07:57 UTC 2007 
Responsible-Changed-Why:  

Needs new analysis.  

http://www.freebsd.org/cgi/query-pr.cgi?pr=26142 
Responsible-Changed-From-To: rwatson->freebsd-bugs 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Sun Mar 2 14:48:06 UTC 2008 
Responsible-Changed-Why:  
Return to public pool; unfortunately, I don't have time to work on this 
issue currently. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=26142 
Responsible-Changed-From-To: freebsd-bugs->vwe 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Sun May 11 14:51:59 UTC 2008 
Responsible-Changed-Why:  

Dear submitter: Do you still see this problem with an actual released 
version? Over the years someone believed this problem might have gone 
but it's currently unsure if that's true. 

this ticket will be closed at the next after-EOL cleanup 
(scheduled for June) if it is not checked until then. 

-> track 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26142 
State-Changed-From-To: feedback->closed 
State-Changed-By: eadler 
State-Changed-When: Sat Jan 14 15:48:20 UTC 2012 
State-Changed-Why:  
per vwe 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26142 
>Unformatted:
This sounds like it might be related to the problem we discussed today. Can you take a look at it before 
tossing it back? It is also possible that Mohan has fixed this in the meantime.
