Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Mar 2001 02:18:53 -0800 (PST)
From:      j.schripsema@kpn.com
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/26142: Unlink fails on NFS mounted filesystem
Message-ID:  <200103271018.f2RAIr213382@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         26142
>Category:       kern
>Synopsis:       Unlink fails on NFS mounted filesystem
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 27 02:30:04 PST 2001
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103271018.f2RAIr213382>