diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2023-11-26 05:08:34 +0300 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2023-12-12 16:24:09 +0300 |
commit | 7cb537b6f6d7d6529be04139178f929d9a63b918 (patch) | |
tree | 21261fb352f5a3c788e01b5d418869225b17ea54 /fs/namei.c | |
parent | b85ea95d086471afb4ad062012a4d73cd328fa86 (diff) | |
download | linux-7cb537b6f6d7d6529be04139178f929d9a63b918.tar.xz |
file: massage cleanup of files that failed to open
A file that has never gotten FMODE_OPENED will never have RCU-accessed
references, its final fput() is equivalent to file_free() and if it
doesn't have FMODE_BACKING either, it can be done from any context and
won't need task_work treatment.
Now that we have SLAB_TYPESAFE_BY_RCU we can simplify this and have
other callers benefit. All of that can be achieved easier is to make
fput() recoginze that case and call file_free() directly.
No need to introduce a special primitive for that. It also allowed
things like failing dentry_open() could benefit from that as well.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[Christian Brauner <brauner@kernel.org>: massage commit message]
Link: https://lore.kernel.org/r/20231126020834.GC38156@ZenIV
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c index 71c13b2990b4..f0ead1858267 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3785,10 +3785,7 @@ static struct file *path_openat(struct nameidata *nd, WARN_ON(1); error = -EINVAL; } - if (unlikely(file->f_mode & FMODE_OPENED)) - fput(file); - else - release_empty_file(file); + fput(file); if (error == -EOPENSTALE) { if (flags & LOOKUP_RCU) error = -ECHILD; |