fs: fold open_check_o_direct into do_dentry_open
PATCH 1/1 fs: fold open_check_o_direct into do_dentry_open
do_dentry_open is where we do the actual open of the file, so this is where we should do our O_DIRECT sanity check to cover all potential callers.
--- fs/internal.h | 1 - fs/namei.c | 7 +------ fs/open.c | 44 ++++++++++++++++++-------------------------- 3 files changed, 19 insertions(+), 33 deletions(-)
fs/internal.h +0 -1
@@ -111,7 +111,6 @@ extern struct file *do_filp_open(int dfd, struct filename *pathname,extern struct file *do_file_open_root (struct dentry *,struct vfsmount *,const char *,const struct open_flags *); -extern int open_check_o_direct (struct file *f);extern int vfs_open (const struct path *,struct file *,const struct cred *);extern struct file *filp_clone_open (struct file *);
fs/namei.c +1 -6
@@ -3374,9 +3374,7 @@ static int do_last(struct nameidata *nd, goto out; *opened |=FILE_OPENED ; opened: - error =open_check_o_direct (file); -if (!error) - error =ima_file_check (file, op->acc_mode, *opened); + error =ima_file_check (file, op->acc_mode, *opened);if (!error && will_truncate) error =handle_truncate (file); out:
@@ -3456,9 +3454,6 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags, error =finish_open (file, child,NULL , opened);if (error) goto out2; - error =open_check_o_direct (file); -if (error) -fput (file); out2:mnt_drop_write (path.mnt); out:
fs/open.c +18 -26
74 lines not on this page · raw message
Signature · 1 line
2.14.2
Christoph Hellwig:
Quoted 3 lines
do_dentry_openis where we do the actual open of the file, so this is where we should do ourO_DIRECTsanity check to cover all potential callers.
:::
Quoted 5 lines
fs/namei.c +0
-0
fs/namei.c static int do_last(struct nameidata *nd, · line 3379
Quoted 9 lines
fs/namei.c +1
-3@@ -3374,9 +3374,7 @@ static int do_last(struct nameidata *nd, goto out; *opened |=FILE_OPENED ; opened: - error =open_check_o_direct (file); -if (!error) - error =ima_file_check (file, op->acc_mode, *opened); + error =ima_file_check (file, op->acc_mode, *opened);if (!error && will_truncate) error =handle_truncate (file);
Removing the check from here may cause a problem I am afraid. In open(O_ATOMIC|O_DIRECT) case, the check is totally gone, isn't it?
J. R. Okajima
Quoted 14 lines · J. R. Okajima
Christoph Hellwig:
Quoted 3 lines
do_dentry_openis where we do the actual open of the file, so this is where we should do ourO_DIRECTsanity check to cover all potential callers.:::Quoted 9 lines
fs/namei.c +0
-1@@ -3374,9 +3374,7 @@ static int do_last(struct nameidata *nd, goto out; *opened |=FILE_OPENED ; opened: - error =open_check_o_direct (file);
Quoted 8 lines
fs/namei.c static int do_last(struct nameidata *nd, · line 3379
Quoted 5 lines
fs/namei.c +1
-2-if (!error) - error =ima_file_check (file, op->acc_mode, *opened); + error =ima_file_check (file, op->acc_mode, *opened);if (!error && will_truncate) error =handle_truncate (file);Removing the check from here may cause a problem I am afraid. In
open(O_ATOMIC|O_DIRECT)case, the check is totally gone, isn't it?
You mean O_DIRECT using ->atomic_open?
Those are supposed to call finish_open(), which calls do_dentry_open and thus the O_DIRECT check.
Quoted 4 lines
J. R. Okajima
---end quoted text---
Christoph Hellwig:
Quoted 2 lines
Those are supposed to call
finish_open(), which callsdo_dentry_openand thus theO_DIRECTcheck.
Now I see the scenario.
Thanx for answering my question.
J. R. Okajima