fold put_filp() into fput()
Just check FMODE_OPENED in __fput() and be done with that... Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
f5d11409e6
commit
4d27f3266f
|
@ -192,6 +192,9 @@ static void __fput(struct file *file)
|
||||||
struct vfsmount *mnt = file->f_path.mnt;
|
struct vfsmount *mnt = file->f_path.mnt;
|
||||||
struct inode *inode = file->f_inode;
|
struct inode *inode = file->f_inode;
|
||||||
|
|
||||||
|
if (unlikely(!(file->f_mode & FMODE_OPENED)))
|
||||||
|
goto out;
|
||||||
|
|
||||||
might_sleep();
|
might_sleep();
|
||||||
|
|
||||||
fsnotify_close(file);
|
fsnotify_close(file);
|
||||||
|
@ -221,12 +224,10 @@ static void __fput(struct file *file)
|
||||||
put_write_access(inode);
|
put_write_access(inode);
|
||||||
__mnt_drop_write(mnt);
|
__mnt_drop_write(mnt);
|
||||||
}
|
}
|
||||||
file->f_path.dentry = NULL;
|
|
||||||
file->f_path.mnt = NULL;
|
|
||||||
file->f_inode = NULL;
|
|
||||||
file_free(file);
|
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
mntput(mnt);
|
mntput(mnt);
|
||||||
|
out:
|
||||||
|
file_free(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LLIST_HEAD(delayed_fput_list);
|
static LLIST_HEAD(delayed_fput_list);
|
||||||
|
@ -301,12 +302,6 @@ void __fput_sync(struct file *file)
|
||||||
|
|
||||||
EXPORT_SYMBOL(fput);
|
EXPORT_SYMBOL(fput);
|
||||||
|
|
||||||
void put_filp(struct file *file)
|
|
||||||
{
|
|
||||||
if (atomic_long_dec_and_test(&file->f_count))
|
|
||||||
file_free(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void __init files_init(void)
|
void __init files_init(void)
|
||||||
{
|
{
|
||||||
filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
|
filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
|
||||||
|
|
|
@ -3531,7 +3531,7 @@ static struct file *path_openat(struct nameidata *nd,
|
||||||
|
|
||||||
s = path_init(nd, flags);
|
s = path_init(nd, flags);
|
||||||
if (IS_ERR(s)) {
|
if (IS_ERR(s)) {
|
||||||
put_filp(file);
|
fput(file);
|
||||||
return ERR_CAST(s);
|
return ERR_CAST(s);
|
||||||
}
|
}
|
||||||
while (!(error = link_path_walk(s, nd)) &&
|
while (!(error = link_path_walk(s, nd)) &&
|
||||||
|
@ -3547,7 +3547,7 @@ static struct file *path_openat(struct nameidata *nd,
|
||||||
out2:
|
out2:
|
||||||
if (!(opened & FILE_OPENED)) {
|
if (!(opened & FILE_OPENED)) {
|
||||||
BUG_ON(!error);
|
BUG_ON(!error);
|
||||||
put_filp(file);
|
fput(file);
|
||||||
}
|
}
|
||||||
if (unlikely(error)) {
|
if (unlikely(error)) {
|
||||||
if (error == -EOPENSTALE) {
|
if (error == -EOPENSTALE) {
|
||||||
|
|
11
fs/open.c
11
fs/open.c
|
@ -921,15 +921,10 @@ struct file *dentry_open(const struct path *path, int flags,
|
||||||
f = alloc_empty_file(flags, cred);
|
f = alloc_empty_file(flags, cred);
|
||||||
if (!IS_ERR(f)) {
|
if (!IS_ERR(f)) {
|
||||||
error = vfs_open(path, f);
|
error = vfs_open(path, f);
|
||||||
if (!error) {
|
if (!error)
|
||||||
/* from now on we need fput() to dispose of f */
|
|
||||||
error = open_check_o_direct(f);
|
error = open_check_o_direct(f);
|
||||||
if (error) {
|
if (error) {
|
||||||
fput(f);
|
fput(f);
|
||||||
f = ERR_PTR(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
put_filp(f);
|
|
||||||
f = ERR_PTR(error);
|
f = ERR_PTR(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,6 @@ extern int f_dupfd(unsigned int from, struct file *file, unsigned flags);
|
||||||
extern int replace_fd(unsigned fd, struct file *file, unsigned flags);
|
extern int replace_fd(unsigned fd, struct file *file, unsigned flags);
|
||||||
extern void set_close_on_exec(unsigned int fd, int flag);
|
extern void set_close_on_exec(unsigned int fd, int flag);
|
||||||
extern bool get_close_on_exec(unsigned int fd);
|
extern bool get_close_on_exec(unsigned int fd);
|
||||||
extern void put_filp(struct file *);
|
|
||||||
extern int get_unused_fd_flags(unsigned flags);
|
extern int get_unused_fd_flags(unsigned flags);
|
||||||
extern void put_unused_fd(unsigned int fd);
|
extern void put_unused_fd(unsigned int fd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue