"dpkg --info" produces errors if /tmp NFS mounted

Brian May (bam@snoopy.apana.org.au)
Tue, 09 Mar 1999 10:45:36 +1100


Hello,

[ I started writing this message just to debian-devel, when I suddenly
realized that it looked more like a kernel problem then a Debian
one; however as it affects dpkg so I am also sending it to debian-devel. ]

I apologize if this is a known problem and has previously been
discussed.

I have been trying to work out why thw following dpkg command
should produce errors:

dpkg --info /home/ftp/files/linux/hurd-i386/base/timezones_2.0.110-0.1.deb
[... good output deleted...]
rm: /tmp/00545aaa/.nfs58031b3b00000013: Device or resource busy
rm: /tmp/00545aaa: Device or resource busy
rm cleanup failed, code 256

Under strace, the problem part seems to be:

stat("/tmp/00531aaa", {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0
open("/tmp/00531aaa", O_RDONLY|O_NONBLOCK) = 6
fcntl(6, F_SETFD, FD_CLOEXEC) = 0
lseek(6, 0, SEEK_CUR) = 0
getdents(6, /* 3 entries */, 3933) = 60
lseek(6, 0, SEEK_CUR) = 1024
getdents(6, /* 0 entries */, 3933) = 0
close(6) = 0
lstat("/tmp/00531aaa/.nfs58031b3a00000012", {st_mode=S_IFREG|0644, st_size=389,
...}) = 0
unlink("/tmp/00531aaa/.nfs58031b3a00000012") = -1 EBUSY (Device or resource busy)
write(2, "rm: ", 4) = 4
write(2, "/tmp/00531aaa/.nfs58031b3a000000"..., 34) = 34
write(2, ": Device or resource busy", 25) = 25
write(2, "\n", 1) = 1
rmdir("/tmp/00531aaa") = -1 EBUSY (Device or resource busy)
write(2, "rm: ", 4) = 4
write(2, "/tmp/00531aaa", 13) = 13
write(2, ": Device or resource busy", 25) = 25
write(2, "\n", 1) = 1
_exit(1) = ?

My Interpretation of what is going on:

1) My guess is that the file .nfs58031b3a00000012 is required because
temp files are deleted while they are still being created in this
directory (not sure about this) by another process; I have been told
that NFS doesn't support deleting an open file, hence this hack is
required.

I can reproduce the problem under bash:

mkdir /tmp/00559 (name can be anything, but I haven't tested anything
else).

Run a script like the following in the background:

( while true; do echo hi; sleep 1; done > /tmp/00559aaa/abc ) &

check that it is working (use ls), every 2nd time for me it just exits
(don't ask me why).

rm /tmp/00559/abc

The abc file will be renamed to .nfs* and cannot be deleted until
the process is killed.

2) I believe the straced code is listing the contents of this temp directory,
so it can remove all files in it, and delete the directory.

The problem seems to center around this .nfs58031b3a00000012 file,
which shouldn't be there (as far as dpkg is concerned), and cannot
be deleted by the process that is running.

3) Why does the kernel put its temp file in dpkg's temp
directory and not, say, /tmp?? I suspect this may be the real issue here.
What do other Unixes do?

4) The .nfs58031b3a00000012 file is automatically deleted when
the program exits; typing in "rmdir /tmp/*" will then automatically
delete all temp directories as they are empty. This is expected.

5) Who is at fault? dpkg for removing a directory even though files
are still being written to it at the time, or the kernel for not
supporting this operation that is legal for non-NFS filesystems?

Notes:
- NFS file locking is not used (the nolock option is used).
- NFS Server is Linux 2.2.2
- NFS Client is Linux 2.2.1

Thanks in advance,

Brian May <bam@snoopy.apana.org.au>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/