smb: add missing create options for O_DIRECT and O_SYNC flags
Subsystems (2)
PATCH 1/1 smb: add missing create options for O_DIRECT and O_SYNC flags
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.
--- fs/smb/client/dir.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/smb/client/dir.c +6 -0
@@ -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;
Signature · 1 line
2.34.1
Quoted 17 lines · Bharath SM
The
CREATE_NO_BUFFERandCREATE_WRITE_THROUGHfile create options are correctly set incifs_nt_openandcifs_reopenfunctions based onO_DIRECTandO_SYNCflags. However flags are missing during the file creation process incifs_atomic_open, this was leading to successful write operations withO_DIRECTeven in case on un-aligned size. Fixed by setting create options based on open file flags.Signed-off-by Bharath SM <[email protected]>--- fs/smb/client/dir.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/smb/client/dir.c +0
-0
fs/smb/client/dir.c static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned · line 300
Quoted 9 lines
fs/smb/client/dir.c +6
-0@@ -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 ; +
Looks good, thanks.
I see that cifs_nt_open(), cifs_reopen_file() and cifs_do_create() use cifs_create_options().
I'd rather have those flags set in cifs_create_options() by passing a new @flags to it, so if we need to make any changes later, only cifs_create_options() will require it. What do you think?
Quoted 32 lines · Paulo Alcantara
Quoted 17 lines · Bharath SM
The
CREATE_NO_BUFFERandCREATE_WRITE_THROUGHfile create options are correctly set incifs_nt_openandcifs_reopenfunctions based onO_DIRECTandO_SYNCflags. However flags are missing during the file creation process incifs_atomic_open, this was leading to successful write operations withO_DIRECTeven in case on un-aligned size. Fixed by setting create options based on open file flags.Signed-off-by Bharath SM <[email protected]>--- fs/smb/client/dir.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/smb/client/dir.c +0
-0fs/smb/client/dir.c static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned · line 300
Quoted 9 lines
fs/smb/client/dir.c +6
-0@@ -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 ; +Looks good, thanks.
Quoted 6 lines
I see that
cifs_nt_open(),cifs_reopen_file()andcifs_do_create()usecifs_create_options().I'd rather have those flags set in
cifs_create_options()by passing a new @flags to it, so if we need to make any changes later, onlycifs_create_options()will require it. What do you think?
Thanks,
I see there are around 34 places where we call cifs_create_options() and currently it's taking cifs_sb,create options as arguments. Should we make another helper function with name "create_options=cifs_parse_flags(flags)" then pass create_options into cifs_create_options() ?
I think we can do this cleanup as the next patch. What do you think.?
Quoted 40 lines · Bharath SM
Quoted 32 lines · Paulo Alcantara
Quoted 17 lines · Bharath SM
The
CREATE_NO_BUFFERandCREATE_WRITE_THROUGHfile create options are correctly set incifs_nt_openandcifs_reopenfunctions based onO_DIRECTandO_SYNCflags. However flags are missing during the file creation process incifs_atomic_open, this was leading to successful write operations withO_DIRECTeven in case on un-aligned size. Fixed by setting create options based on open file flags.Signed-off-by Bharath SM <[email protected]>--- fs/smb/client/dir.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/smb/client/dir.c +0
-0fs/smb/client/dir.c static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned · line 300
Quoted 9 lines
fs/smb/client/dir.c +6
-0@@ -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 ; +Looks good, thanks.
Quoted 6 lines
I see that
cifs_nt_open(),cifs_reopen_file()andcifs_do_create()usecifs_create_options().I'd rather have those flags set in
cifs_create_options()by passing a new @flags to it, so if we need to make any changes later, onlycifs_create_options()will require it. What do you think?
Quoted 6 lines
I see there are around 34 places where we call
cifs_create_options()and currently it's taking cifs_sb,create options as arguments. Should we make another helper function with name "create_options=cifs_parse_flags(flags)" then passcreate_optionsintocifs_create_options()?
I think we can do this cleanup as the next patch. What do you think.?
Sounds good. Thanks.