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

This Linux kernel change "cifs: do not attempt cifs operation on smb2+ rename error" is included in the Linux 3.16.72 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 aa7ead1 (patch) which is from upstream commit 652727b. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 652727b.

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

commit 652727bbe1b17993636346716ae5867627793647 upstream.

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]>
Reviewed-by: Ronnie Sahlberg <[email protected]>
Signed-off-by: Ben Hutchings <[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 09ca7c9..f681091 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1627,6 +1627,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 *