Red Hat Bugzilla – Bug 172081
rename(2) onto an empty directory fails on NFS file systems
Last modified: 2007-11-30 17:07:21 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921 Red Hat/1.0.7-1.4.1 Firefox/1.0.7
Description of problem:
Any application using the rename(2) system call to rename onto an empty
directory will receive EBUSY if doing this on an NFS mount point. If both
the source and targets of the rename are directories, and the target is
empty, the rename should succeed.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Actual Results: rename() system call returns EBUSY
Expected Results: rename() should succeed if two directories are involved, and receive an error
(EISDIR or ENOTDIR) only if renaming a file to a directory or vice versa.
this problem should be investigated in RHEL 3 as well.
commit 6fe43f9e3701f7a9f2be151a5e6cfe94b87e92f9 in the master 2.6 git
repository contains a fix for this problem.
chuck, can you provide the exact command please? This command:
rename \/mnt\/ \/mnt\/test\/ /mnt/neil.txt
works fine if test is a local directory but return EXDEV if test is NFS mounted.
Since you said it returns EBUSY, I'd like to be sure that we're seeing the same
problem before I look at the fix. Thanks!
the problem is with the rename(2) system call. write a test program that
creates an arbitrary empty directory in NFS, then uses rename(2) to rename
another NFS directory onto it. the expected result is that the empty directory
will be replaced.
The rename utility directly uses the rename syscall, but to illustrate:
int main(int argc, char **argv)
char *from = argv;
char *to = argv;
perror("unable to rename");
if test is a local directory, this works fine, but if the destination is an nfs
[root@x120-8678-2 mnt]# ./a.out ./neil.txt /mnt/test/neil.txt
unable to rename: Invalid cross-device link
[root@x120-8678-2 mnt]# uname -a
Linux x120-8678-2.gsslab.rdu.redhat.com 2.6.9-22.9.ELsmp #1 SMP Fri Oct 28
18:38:46 EDT 2005 i686 i686 i386 GNU/Linux
Given that the man page indicates that EXDEV is the required return code from
the use of the rename syscall accross filesystems, this seems to be operating
correctly. I can't seem to get it to produce an EBUSY. If you could provide
your exact test case, I'd certainly appreciate it. Thanks
i'm not trying to rename across file systems.
1. create two subdirectories of a directory on an NFS mount. call them
subdirectory "A" and subdirectory "B". they both reside in the same parent
directory, and thus they are both contained in the same file system.
2. use your program to rename A as B.
rename(2) will return EBUSY.
Created attachment 120617 [details]
patch to massage upstream commit to RHEL4 kernel
Sorry, Chuck. I've reproduced the problem now, and verified the fix on the
latest RHEL4 kernel.
This fix has been committed in the RHEL4 U3 beta.
Action: Netapp, please test and provide feedback to RH ASAP.
compared behavior of 2.6.9-1.677 with 18.104.22.168-EL via a test program. bad
behavior reproduced on 677, but behavior now appears to be correct on EL kernel.
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.