[patch 29/30] CIFS: report rename failure when target file is locked by Windows

From: Chris Wright
Date: Wed Nov 15 2006 - 21:51:23 EST


-stable review patch. If anyone has any objections, please let us know.
------------------

From: Steve French <sfrench@xxxxxxxxxx>

Fixes Samba bugzilla bug # 4182

Rename by handle failures (retry after rename by path) were not
being returned back.

Signed-off-by: Steve French <sfrench@xxxxxxxxxx>
[chrisw: trivial backport in CHANGES]
Signed-off-by: Chris Wright <chrisw@xxxxxxxxxxxx>
---

fs/cifs/CHANGES | 6 +++++-
fs/cifs/inode.c | 14 +++++++++-----
2 files changed, 14 insertions(+), 6 deletions(-)

--- linux-2.6.18.2.orig/fs/cifs/CHANGES
+++ linux-2.6.18.2/fs/cifs/CHANGES
@@ -6,7 +6,11 @@ on requests on other threads. Improve P
(lock cancel now works, and unlock of merged range works even
to Windows servers now). Fix oops on mount to lanman servers
(win9x, os/2 etc.) when null password. Do not send listxattr
-(SMB to query all EAs) if nouser_xattr specified.
+(SMB to query all EAs) if nouser_xattr specified. Return error
+in rename 2nd attempt retry (ie report if rename by handle also
+fails, after rename by path fails, we were not reporting whether
+the retry worked or not).
+

Version 1.44
------------
--- linux-2.6.18.2.orig/fs/cifs/inode.c
+++ linux-2.6.18.2/fs/cifs/inode.c
@@ -880,10 +880,14 @@ int cifs_rename(struct inode *source_ino
kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
if (info_buf_source != NULL) {
info_buf_target = info_buf_source + 1;
- rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName,
- info_buf_source, cifs_sb_source->local_nls,
- cifs_sb_source->mnt_cifs_flags &
- CIFS_MOUNT_MAP_SPECIAL_CHR);
+ if (pTcon->ses->capabilities & CAP_UNIX)
+ rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName,
+ info_buf_source,
+ cifs_sb_source->local_nls,
+ cifs_sb_source->mnt_cifs_flags &
+ CIFS_MOUNT_MAP_SPECIAL_CHR);
+ /* else rc is still EEXIST so will fall through to
+ unlink the target and retry rename */
if (rc == 0) {
rc = CIFSSMBUnixQPathInfo(xid, pTcon, toName,
info_buf_target,
@@ -932,7 +936,7 @@ int cifs_rename(struct inode *source_ino
cifs_sb_source->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) {
- CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName,
+ rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName,
cifs_sb_source->local_nls,
cifs_sb_source->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);

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