This service will be undergoing maintenance at 20:00 UTC, 2017-04-03. It is expected to last about 30 minutes
Bug 21505 - mmap & unlink over NFS cause long-lived .nfs files which break rmdir
mmap & unlink over NFS cause long-lived .nfs files which break rmdir
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: kernel (Show other bugs)
6.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Arjan van de Ven
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-11-29 23:21 EST by Todd Allen
Modified: 2008-08-01 12:22 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-09-30 11:38:52 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Todd Allen 2000-11-29 23:21:14 EST
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 11:38:52 EDT
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.