Commit a930f84b authored by Benjamin LaHaise's avatar Benjamin LaHaise

[PATCH] add __fput for aio

This patch splits fput into fput and __fput.  __fput is needed by aio to
construct a mechanism for performing a deferred fput during io
completion, which typically occurs during interrupt context.
parent 4ab4cd4b
...@@ -99,12 +99,20 @@ int init_private_file(struct file *filp, struct dentry *dentry, int mode) ...@@ -99,12 +99,20 @@ int init_private_file(struct file *filp, struct dentry *dentry, int mode)
} }
void fput(struct file * file) void fput(struct file * file)
{
if (atomic_dec_and_test(&file->f_count))
__fput(file);
}
/* __fput is called from task context when aio completion releases the last
* last use of a struct file *. Do not use otherwise.
*/
void __fput(struct file * file)
{ {
struct dentry * dentry = file->f_dentry; struct dentry * dentry = file->f_dentry;
struct vfsmount * mnt = file->f_vfsmnt; struct vfsmount * mnt = file->f_vfsmnt;
struct inode * inode = dentry->d_inode; struct inode * inode = dentry->d_inode;
if (atomic_dec_and_test(&file->f_count)) {
locks_remove_flock(file); locks_remove_flock(file);
if (file->f_iobuf) if (file->f_iobuf)
...@@ -124,7 +132,6 @@ void fput(struct file * file) ...@@ -124,7 +132,6 @@ void fput(struct file * file)
file_list_unlock(); file_list_unlock();
dput(dentry); dput(dentry);
mntput(mnt); mntput(mnt);
}
} }
struct file * fget(unsigned int fd) struct file * fget(unsigned int fd)
......
...@@ -33,6 +33,7 @@ struct files_struct { ...@@ -33,6 +33,7 @@ struct files_struct {
struct file * fd_array[NR_OPEN_DEFAULT]; struct file * fd_array[NR_OPEN_DEFAULT];
}; };
extern void FASTCALL(__fput(struct file *));
extern void FASTCALL(fput(struct file *)); extern void FASTCALL(fput(struct file *));
extern struct file * FASTCALL(fget(unsigned int fd)); extern struct file * FASTCALL(fget(unsigned int fd));
extern void FASTCALL(set_close_on_exec(unsigned int fd, int flag)); extern void FASTCALL(set_close_on_exec(unsigned int fd, int flag));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment