Skip to content

Commit 44805b0

Browse files
piastrySteve French
authored and
Steve French
committed
CIFS: Respect O_SYNC and O_DIRECT flags during reconnect
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: 1013e76: ("SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags") Cc: Stable <[email protected]> Signed-off-by: Pavel Shilovsky <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 037d050 commit 44805b0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/cifs/file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
728728
if (backup_cred(cifs_sb))
729729
create_options |= CREATE_OPEN_BACKUP_INTENT;
730730

731+
/* O_SYNC also has bit for O_DSYNC so following check picks up either */
732+
if (cfile->f_flags & O_SYNC)
733+
create_options |= CREATE_WRITE_THROUGH;
734+
735+
if (cfile->f_flags & O_DIRECT)
736+
create_options |= CREATE_NO_BUFFER;
737+
731738
if (server->ops->get_lease_key)
732739
server->ops->get_lease_key(inode, &cfile->fid);
733740

0 commit comments

Comments
 (0)