cifs: do not attempt cifs operation on smb2+ rename error [Linux 5.1]

cifs: do not attempt cifs operation on smb2+ rename error [Linux 5.1]

This Linux kernel change "cifs: do not attempt cifs operation on smb2+ rename error" is included in the Linux 5.1 release. This change is authored by Frank Sorenson <sorenson [at] redhat.com> on Tue Apr 16 08:37:27 2019 -0500. The commit for this change in Linux stable tree is 652727b (patch).

cifs: do not attempt cifs operation on smb2+ rename error

A path-based rename returning EBUSY will incorrectly try opening
the file with a cifs (NT Create AndX) operation on an smb2+ mount,
which causes the server to force a session close.

If the mount is smb2+, skip the fallback.

Signed-off-by: Frank Sorenson <[email protected]>
Signed-off-by: Steve French <[email protected]>
CC: Stable <[email protected]>
Reviewed-by: Ronnie Sahlberg <[email protected]>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/cifs/inode.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 53fdb5d..538fd7d 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1735,6 +1735,10 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
    if (rc == 0 || rc != -EBUSY)
        goto do_rename_exit;

+   /* Don't fall back to using SMB on SMB 2+ mount */
+   if (server->vals->protocol_id != 0)
+       goto do_rename_exit;
+
    /* open-file renames don't work across directories */
    if (to_dentry->d_parent != from_dentry->d_parent)
        goto do_rename_exit;

Leave a Reply

Your email address will not be published. Required fields are marked *