diff options
-rw-r--r-- | fs/aio.c | 6 | ||||
-rw-r--r-- | fs/file_table.c | 21 | ||||
-rw-r--r-- | include/linux/file.h | 1 | ||||
-rw-r--r-- | include/linux/fs.h | 1 |
4 files changed, 14 insertions, 15 deletions
@@ -527,7 +527,7 @@ static void aio_fput_routine(struct work_struct *data) | |||
527 | 527 | ||
528 | /* Complete the fput(s) */ | 528 | /* Complete the fput(s) */ |
529 | if (req->ki_filp != NULL) | 529 | if (req->ki_filp != NULL) |
530 | __fput(req->ki_filp); | 530 | fput(req->ki_filp); |
531 | 531 | ||
532 | /* Link the iocb into the context's free list */ | 532 | /* Link the iocb into the context's free list */ |
533 | spin_lock_irq(&ctx->ctx_lock); | 533 | spin_lock_irq(&ctx->ctx_lock); |
@@ -560,11 +560,11 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) | |||
560 | 560 | ||
561 | /* | 561 | /* |
562 | * Try to optimize the aio and eventfd file* puts, by avoiding to | 562 | * Try to optimize the aio and eventfd file* puts, by avoiding to |
563 | * schedule work in case it is not __fput() time. In normal cases, | 563 | * schedule work in case it is not final fput() time. In normal cases, |
564 | * we would not be holding the last reference to the file*, so | 564 | * we would not be holding the last reference to the file*, so |
565 | * this function will be executed w/out any aio kthread wakeup. | 565 | * this function will be executed w/out any aio kthread wakeup. |
566 | */ | 566 | */ |
567 | if (unlikely(atomic_long_dec_and_test(&req->ki_filp->f_count))) { | 567 | if (unlikely(!fput_atomic(req->ki_filp))) { |
568 | get_ioctx(ctx); | 568 | get_ioctx(ctx); |
569 | spin_lock(&fput_lock); | 569 | spin_lock(&fput_lock); |
570 | list_add(&req->ki_list, &fput_head); | 570 | list_add(&req->ki_list, &fput_head); |
diff --git a/fs/file_table.c b/fs/file_table.c index 32d12b78bac8..5c7d10ead4ad 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -194,14 +194,6 @@ struct file *alloc_file(struct path *path, fmode_t mode, | |||
194 | } | 194 | } |
195 | EXPORT_SYMBOL(alloc_file); | 195 | EXPORT_SYMBOL(alloc_file); |
196 | 196 | ||
197 | void fput(struct file *file) | ||
198 | { | ||
199 | if (atomic_long_dec_and_test(&file->f_count)) | ||
200 | __fput(file); | ||
201 | } | ||
202 | |||
203 | EXPORT_SYMBOL(fput); | ||
204 | |||
205 | /** | 197 | /** |
206 | * drop_file_write_access - give up ability to write to a file | 198 | * drop_file_write_access - give up ability to write to a file |
207 | * @file: the file to which we will stop writing | 199 | * @file: the file to which we will stop writing |
@@ -227,10 +219,9 @@ void drop_file_write_access(struct file *file) | |||
227 | } | 219 | } |
228 | EXPORT_SYMBOL_GPL(drop_file_write_access); | 220 | EXPORT_SYMBOL_GPL(drop_file_write_access); |
229 | 221 | ||
230 | /* __fput is called from task context when aio completion releases the last | 222 | /* the real guts of fput() - releasing the last reference to file |
231 | * last use of a struct file *. Do not use otherwise. | ||
232 | */ | 223 | */ |
233 | void __fput(struct file *file) | 224 | static void __fput(struct file *file) |
234 | { | 225 | { |
235 | struct dentry *dentry = file->f_path.dentry; | 226 | struct dentry *dentry = file->f_path.dentry; |
236 | struct vfsmount *mnt = file->f_path.mnt; | 227 | struct vfsmount *mnt = file->f_path.mnt; |
@@ -268,6 +259,14 @@ void __fput(struct file *file) | |||
268 | mntput(mnt); | 259 | mntput(mnt); |
269 | } | 260 | } |
270 | 261 | ||
262 | void fput(struct file *file) | ||
263 | { | ||
264 | if (atomic_long_dec_and_test(&file->f_count)) | ||
265 | __fput(file); | ||
266 | } | ||
267 | |||
268 | EXPORT_SYMBOL(fput); | ||
269 | |||
271 | struct file *fget(unsigned int fd) | 270 | struct file *fget(unsigned int fd) |
272 | { | 271 | { |
273 | struct file *file; | 272 | struct file *file; |
diff --git a/include/linux/file.h b/include/linux/file.h index 5555508fd517..b1e12970f617 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | struct file; | 12 | struct file; |
13 | 13 | ||
14 | extern void __fput(struct file *); | ||
15 | extern void fput(struct file *); | 14 | extern void fput(struct file *); |
16 | extern void drop_file_write_access(struct file *file); | 15 | extern void drop_file_write_access(struct file *file); |
17 | 16 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 85e823adcd4a..3d9ed8302402 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -954,6 +954,7 @@ extern spinlock_t files_lock; | |||
954 | #define file_list_unlock() spin_unlock(&files_lock); | 954 | #define file_list_unlock() spin_unlock(&files_lock); |
955 | 955 | ||
956 | #define get_file(x) atomic_long_inc(&(x)->f_count) | 956 | #define get_file(x) atomic_long_inc(&(x)->f_count) |
957 | #define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) | ||
957 | #define file_count(x) atomic_long_read(&(x)->f_count) | 958 | #define file_count(x) atomic_long_read(&(x)->f_count) |
958 | 959 | ||
959 | #ifdef CONFIG_DEBUG_WRITECOUNT | 960 | #ifdef CONFIG_DEBUG_WRITECOUNT |