Bug 172081 - rename(2) onto an empty directory fails on NFS file systems
rename(2) onto an empty directory fails on NFS file systems
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Neil Horman
Brian Brock
:
Depends On:
Blocks: 168429
  Show dependency treegraph
 
Reported: 2005-10-30 19:25 EST by Chuck Lever
Modified: 2007-11-30 17:07 EST (History)
2 users (show)

See Also:
Fixed In Version: RHSA-2006-0132
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-03-07 15:36:02 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to massage upstream commit to RHEL4 kernel (593 bytes, patch)
2005-11-01 13:49 EST, Neil Horman
no flags Details | Diff

  None (edit)
Description Chuck Lever 2005-10-30 19:25:30 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):


How reproducible:
Always

Steps to Reproduce:
see description.
  

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.

Additional info:

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.
Comment 1 Neil Horman 2005-11-01 06:49:32 EST
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!
Comment 2 Chuck Lever 2005-11-01 09:16:13 EST
hi guys-

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.
Comment 3 Neil Horman 2005-11-01 10:03:22 EST
The rename utility directly uses the rename syscall, but to illustrate:
=======================================================
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv)
{
        char *from = argv[1];
        char *to = argv[2];

        if (rename(from,to)<0)
                perror("unable to rename");

        return 0;
}
===========================================================
if test is a local directory, this works fine, but if the destination is an nfs
mount point:
[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
Comment 4 Chuck Lever 2005-11-01 11:44:32 EST
hi neil-

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.
Comment 5 Neil Horman 2005-11-01 13:49:43 EST
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.
Comment 11 Andrius Benokraitis 2006-01-09 10:56:16 EST
This fix has been committed in the RHEL4 U3 beta.

Action: Netapp, please test and provide feedback to RH ASAP.
Comment 12 Chuck Lever 2006-01-18 16:21:03 EST
compared behavior of 2.6.9-1.677 with 2.6.9.27-EL via a test program.  bad
behavior reproduced on 677, but behavior now appears to be correct on EL kernel.
Comment 14 Red Hat Bugzilla 2006-03-07 15:36:02 EST
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.

http://rhn.redhat.com/errata/RHSA-2006-0132.html

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