Date: Fri, 23 Mar 2001 11:21:55 +0100 From: j.schripsema@kpn.com To: freebsd-hackers@freebsd.org Subject: NFS: "got bad cookie" error (again?) Message-ID: <F16EB3CA3CD6D211893C0000F81AF4A542D946@gn007v3>
next in thread | raw e-mail | index | archive | help
Hello,
Running bonnie++ on a NFS mounted files system doesn't work. Bonnie exits
with a fatal error caused by an attempt to remove a non-empty directory.
Bonnie tries to remove all files in a directory by calling 'readdir' an
'unlink' in a loop. This works fine on a local filesystem (UFS) but not on a
NFS mounted filesystem (also UFS on the server).
I'm running FreeBSD 4.2-RELEASE on both the nfs-server and nfs-client. I
have used several NFS configs (v2/v3).
I have seen references to this problem in old archives (1997, FBSD 2.2.5/6),
but it seems the problem has never been fixed. Is this correct? I even read
the manual :-( but could not find a solution.
Below you will find a small program that reveals the problem, including a
fix., which I do not like, because it requires a change in user programs.
Regards,
Jakob Schripsema
sch@kpn.com
-------------------------------
#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);
}
/* This fixes the problem */
rewinddir(dirp);
/* End fix */
}
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F16EB3CA3CD6D211893C0000F81AF4A542D946>
