Bug 172081 - rename(2) onto an empty directory fails on NFS file systems
Summary: rename(2) onto an empty directory fails on NFS file systems
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel
Version: 4.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Neil Horman
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks: 168429
TreeView+ depends on / blocked
 
Reported: 2005-10-31 00:25 UTC by Chuck Lever
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version: RHSA-2006-0132
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-03-07 20:36:02 UTC
Target Upstream Version:
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2005:808 0 normal SHIPPED_LIVE Important: kernel security update 2005-10-27 04:00:00 UTC
Red Hat Product Errata RHSA-2006:0132 0 qe-ready SHIPPED_LIVE Moderate: Updated kernel packages available for Red Hat Enterprise Linux 4 Update 3 2006-03-09 16:31:00 UTC

Description Chuck Lever 2005-10-31 00:25:30 UTC
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 11:49:32 UTC
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 14:16:13 UTC
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 15:03:22 UTC
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 16:44:32 UTC
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 18:49:43 UTC
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 15:56:16 UTC
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 21:21:03 UTC
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 20:36:02 UTC
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.