cifs: work around samba returning -ENOENT on SetFileDisposition call
authorJeff Layton <jlayton@redhat.com>
Wed, 24 Sep 2008 15:32:59 +0000 (11:32 -0400)
committerSteve French <sfrench@us.ibm.com>
Wed, 24 Sep 2008 18:59:20 +0000 (18:59 +0000)
cifs: work around samba returning -ENOENT on SetFileDisposition call

Samba seems to return STATUS_OBJECT_NAME_NOT_FOUND when we try to set
the delete on close bit after doing a rename by filehandle. This looks
like a samba bug to me, but a lot of servers will do this. For now,
pretend an -ENOENT return is a success.

Samba does however seem to respect the CREATE_DELETE_ON_CLOSE bit
when opening files that already exist. Windows will ignore it, but
so adding it to the open flags should be harmless.

We're also currently ignoring the return code on the rename by
filehandle, so no need to set rc based on it.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/inode.c

index 079f39a8dd3be5c68aad273cb7bbf8729022e3ae..27e97d43c75964eb0557c09f6f20dd75f6707eb7 100644 (file)
@@ -778,7 +778,8 @@ cifs_rename_pending_delete(char *full_path, struct inode *inode, int xid)
        FILE_BASIC_INFO *info_buf;
 
        rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
-                        DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
+                        DELETE|FILE_WRITE_ATTRIBUTES,
+                        CREATE_NOT_DIR|CREATE_DELETE_ON_CLOSE,
                         &netfid, &oplock, NULL, cifs_sb->local_nls,
                         cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
        if (rc != 0)
@@ -803,13 +804,20 @@ cifs_rename_pending_delete(char *full_path, struct inode *inode, int xid)
                goto out_close;
 
        /* silly-rename the file */
-       rc = CIFSSMBRenameOpenFile(xid, tcon, netfid, NULL, cifs_sb->local_nls,
+       CIFSSMBRenameOpenFile(xid, tcon, netfid, NULL, cifs_sb->local_nls,
                                   cifs_sb->mnt_cifs_flags &
                                            CIFS_MOUNT_MAP_SPECIAL_CHR);
 
        /* set DELETE_ON_CLOSE */
        rc = CIFSSMBSetFileDisposition(xid, tcon, true, netfid, current->tgid);
 
+       /*
+        * some samba versions return -ENOENT when we try to set the file
+        * disposition here. Likely a samba bug, but work around it for now
+        */
+       if (rc == -ENOENT)
+               rc = 0;
+
 out_close:
        CIFSSMBClose(xid, tcon, netfid);
 out: