Bug 591938 - cifs: busy file renames across directories should fail with error
cifs: busy file renames across directories should fail with error
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
All Linux
high Severity medium
: rc
: ---
Assigned To: Jeff Layton
Filesystem QE
Depends On: 603707
Blocks: 603706
  Show dependency treegraph
Reported: 2010-05-13 10:17 EDT by Sachin Prabhu
Modified: 2014-06-18 03:39 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 603706 (view as bug list)
Last Closed: 2011-02-16 10:52:17 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patch -- don't attempt busy-file rename unless source and target dir are same (1.04 KB, patch)
2010-05-20 11:06 EDT, Jeff Layton
no flags Details | Diff

  None (edit)
Description Sachin Prabhu 2010-05-13 10:17:04 EDT
There is an inconsistency seen when comparing the locking behaviour of CIFS clients on RHEL 4 U6 and RHEL 4 U8 on a share mounted from a Win2K3 server.

##### Reproducer:

//win2k3_server/temp on /mnt type cifs (rw,mand)      ### Win2k3 server
//rhel4.6_server/public on /mnt2 type cifs (rw,mand)  ### RHEL 4.6 samba

### FAIL test with w2k3 on RHEL 4.8.

[root@AS4-8-test mnt]# ping localhost > aa &
[1] 19763
[root@AS4-8-test mnt]# ls
aa  done
[root@AS4-8-test mnt]# mv aa done/bb
[root@AS4-8-test mnt]# ls
bb  done
[root@AS4-8-test mnt]# ls -lR .
total 4
-rwxrwSrwt  1 root root 2023 Apr 27 17:49 bb
drwxrwxrwx  1 root root    0 Apr 21 18:46 done
total 0

The `mv` command renames the file aa to bb. However it fails to move it to directory done. 

This behaviour is different on RHEL 4.6 where the move would fail with the error message
mv: cannot move `aa' to `done/bb': Text file busy 

There is further confusion because the behaviour is different when the Samba share is a RHEL box.

### OK test with Samba on rhel
[root@AS4-8-test mnt2]# ping localhost > aa &
[1] 19793
[root@AS4-8-test mnt2]# ls
aa  done
[root@AS4-8-test mnt2]# mv aa done/bb
[root@AS4-8-test mnt2]# ls .
[root@AS4-8-test mnt2]# ls done/

Here the file is moved correctly.

Desired behaviour:
The behaviour should be the same in 4.8 as in 4.6. These are affecting applications which expect the original behaviour.
Comment 2 Jeff Layton 2010-05-19 09:27:02 EDT
Hmm...can't seem to reproduce the issue against win2k8 so apparently it's less finicky about allowing someone to rename an open file. I think I see the problem though:

        if (rc == 0) {
                rc = CIFSSMBRenameOpenFile(xid, pTcon, srcfid,
                                (const char *) to_dentry->d_name.name,
                                cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &

                CIFSSMBClose(xid, pTcon, srcfid);

...the above CIFSSMBRenameOpenFile is renaming to to_dentry->d_name.name, but should probably be using toPath instead. IIRC though there was a problem with that -- maybe renaming open files across directories isn't allowed? In any case, I'll have to set up a reproducer against a win2k3 host and see what can be done.
Comment 3 Jeff Layton 2010-05-20 11:06:18 EDT
Created attachment 415448 [details]
patch -- don't attempt busy-file rename unless source and target dir are same

Proposed patch. Don't attempt a busy file rename unless the source and target dentries are in the same directory. The patch is pretty obvious so I think it makes sense.

This will need to go upstream and into RHEL5, 6 etc...
Comment 6 Sachin Prabhu 2010-06-04 09:16:50 EDT
Upstream post.
Comment 7 Jeff Layton 2010-06-14 08:16:09 EDT
Steve F. took the patch into his tree and we're planning to push this to stable too. I'll plan to propose internally soon.
Comment 8 RHEL Product and Program Management 2010-06-14 08:29:04 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
Comment 11 Vivek Goyal 2010-06-17 11:15:13 EDT
Committed in 89.28.EL . RPMS are available at http://people.redhat.com/vgoyal/rhel4/
Comment 17 yanfu,wang 2010-10-21 05:35:15 EDT
can reproduced on rhel4-u8:
// /mnt cifs rw,mand,noatime,nodiratime,unc=\\\win_share,username=Administrator,uid=0,gid=0,file_mode=03767,dir_mode=0777,rsize=16384,wsize=57344 0 0

.live.[root@x86-64-4as-8-m1 mnt]# ls -l
total 404
-rwxrwSrwt  1 root root 412150 Oct 21  2010 aa
drwxrwxrwx  1 root root      0 Oct 21  2010 done
.live.[root@x86-64-4as-8-m1 mnt]# mv aa done/bb
.live.[root@x86-64-4as-8-m1 mnt]# ls -l 
total 408
-rwxrwSrwt  1 root root 415510 Oct 21  2010 bb
drwxrwxrwx  1 root root      0 Oct 21  2010 done
.live.[root@x86-64-4as-8-m1 mnt]# ls -lR
total 408
-rwxrwSrwt  1 root root 415846 Oct 21  2010 bb
drwxrwxrwx  1 root root      0 Oct 21  2010 done

total 0

verified on kernel-2.6.9-89.45.EL on i386 and x86_64 arch:
# mv aa done/bb
mv: cannot move `aa' to `done/bb': Text file busy
# uname -a
Linux hp-sl2x160zg6-02.rhts.eng.bos.redhat.com 2.6.9-89.45.EL #1 Fri Oct 15 17:05:21 EDT 2010 i686 i686 i386 GNU/Linux
Comment 18 errata-xmlrpc 2011-02-16 10:52:17 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 therefore 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.


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