This is a note to let you know that I've just added the patch titled CIFS: Respect O_SYNC and O_DIRECT flags during reconnect to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: cifs-respect-o_sync-and-o_direct-flags-during-reconnect.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 44805b0e62f15e90d233485420e1847133716bdc Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky <pshilov@xxxxxxxxxxxxx> Date: Tue, 12 Nov 2019 17:16:35 -0800 Subject: CIFS: Respect O_SYNC and O_DIRECT flags during reconnect From: Pavel Shilovsky <pshilov@xxxxxxxxxxxxx> commit 44805b0e62f15e90d233485420e1847133716bdc upstream. Currently the client translates O_SYNC and O_DIRECT flags into corresponding SMB create options when openning a file. The problem is that on reconnect when the file is being re-opened the client doesn't set those flags and it causes a server to reject re-open requests because create options don't match. The latter means that any subsequent system call against that open file fail until a share is re-mounted. Fix this by properly setting SMB create options when re-openning files after reconnects. Fixes: 1013e760d10e6: ("SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags") Cc: Stable <stable@xxxxxxxxxxxxxxx> Signed-off-by: Pavel Shilovsky <pshilov@xxxxxxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/cifs/file.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -722,6 +722,13 @@ cifs_reopen_file(struct cifsFileInfo *cf if (backup_cred(cifs_sb)) create_options |= CREATE_OPEN_BACKUP_INTENT; + /* O_SYNC also has bit for O_DSYNC so following check picks up either */ + if (cfile->f_flags & O_SYNC) + create_options |= CREATE_WRITE_THROUGH; + + if (cfile->f_flags & O_DIRECT) + create_options |= CREATE_NO_BUFFER; + if (server->ops->get_lease_key) server->ops->get_lease_key(inode, &cfile->fid); Patches currently in stable-queue which might be from pshilov@xxxxxxxxxxxxx are queue-4.9/cifs-respect-o_sync-and-o_direct-flags-during-reconnect.patch queue-4.9/cifs-fix-null-pointer-dereference-in-smb2_push_mandatory_locks.patch queue-4.9/cifs-fix-smb2-oplock-break-processing.patch