diff options
author | Pavel Shilovsky <pshilov@microsoft.com> | 2019-11-12 17:16:35 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-12-21 10:35:44 +0100 |
commit | 56aecce9aff02e8ccbb51d2eb716e2117d405ab9 (patch) | |
tree | 15d136647868baa1c45412ccb57c21f6a9519ef1 /fs/cifs | |
parent | 2dd67de005c93f3465de34cd88f52b416622e07a (diff) | |
download | linux-stable-56aecce9aff02e8ccbb51d2eb716e2117d405ab9.tar.gz linux-stable-56aecce9aff02e8ccbb51d2eb716e2117d405ab9.tar.bz2 linux-stable-56aecce9aff02e8ccbb51d2eb716e2117d405ab9.zip |
CIFS: Respect O_SYNC and O_DIRECT flags during reconnect
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@vger.kernel.org>
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/file.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 86e914b860d4..2ffdaedca7e9 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -703,6 +703,13 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) 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); |