Bug 21505 - mmap & unlink over NFS cause long-lived .nfs files which break rmdir
Summary: mmap & unlink over NFS cause long-lived .nfs files which break rmdir
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: kernel
Version: 6.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Arjan van de Ven
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-11-30 04:21 UTC by Todd Allen
Modified: 2008-08-01 16:22 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-09-30 15:38:52 UTC
Embargoed:


Attachments (Terms of Use)

Description Todd Allen 2000-11-30 04:21:14 UTC
Just build and try this small example.  There are two pieces, some source
in "mapit.c", and the script that uses it to demonstrate the problem, in
"doit".  If you place both of those in the same directory on an NFS
partition, and run the script, you'll see output like:

rm: cannot remove directory `dir': File exists
rm: cannot unlink `dir/.nfs0001081d0000042f': Device or resource busy
rm: cannot remove directory `dir': File exists

It's the nfs_sillyrename() code that's creating that .nfs file.  I
understand its reason for existing.

The only trouble is that the kernel doesn't realize that it can delete it
in any kind of timely fashion.  So, when a subsequent rmdir() is called on
the parent directory, it fails.  And to make matters worse, a subsequent rm
-rf command fails (with EBUSY) trying to delete the .nfs file itself.

=====mapit.c=====
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>

main()
{
   int    fd;
   char*  addr;

   fd = open("dir/file", O_RDWR|O_CREAT|O_TRUNC, 0666);
   ftruncate(fd, 4096);
   addr = mmap((void*)0, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
   memset(addr, ' ', 4096);
   close(fd);
}

=====doit=====
#!/bin/ksh
#

make -s mapit

rm -rf dir 2>/dev/null
if [ -d dir ]; then
   echo "... waiting for directory \"dir\" to clear out to re-run test ..."
   while [ -d dir ]; do
      rm -rf dir 2>/dev/null
   done
fi
mkdir -p dir

./mapit

rm -rf dir || rm -rf dir

Comment 1 Bugzilla owner 2004-09-30 15:38:52 UTC
Thanks for the bug report. However, Red Hat no longer maintains this version of
the product. Please upgrade to the latest version and open a new bug if the problem
persists.

The Fedora Legacy project (http://fedoralegacy.org/) maintains some older releases, 
and if you believe this bug is interesting to them, please report the problem in
the bug tracker at: http://bugzilla.fedora.us/



Note You need to log in before you can comment on or make changes to this bug.