The CREATE_NO_BUFFER and CREATE_WRITE_THROUGH file create options are correctly set in cifs_nt_open and cifs_reopen functions based on O_DIRECT and O_SYNC flags. However flags are missing during the file creation process in cifs_atomic_open, this was leading to successful write operations with O_DIRECT even in case on un-aligned size. Fixed by setting create options based on open file flags. Signed-off-by: Bharath SM <bharathsm@xxxxxxxxxxxxx> --- fs/smb/client/dir.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c index 30b1e1bfd204..4178a7fb2ac2 100644 --- a/fs/smb/client/dir.c +++ b/fs/smb/client/dir.c @@ -292,6 +292,12 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned * ACLs */ + if (oflags & O_SYNC) + create_options |= CREATE_WRITE_THROUGH; + + if (oflags & O_DIRECT) + create_options |= CREATE_NO_BUFFER; + if (!server->ops->open) { rc = -ENOSYS; goto out; -- 2.34.1