diff options
-rw-r--r-- | fs/aio.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -228,12 +228,6 @@ static void __put_ioctx(struct kioctx *ctx) | |||
228 | call_rcu(&ctx->rcu_head, ctx_rcu_free); | 228 | call_rcu(&ctx->rcu_head, ctx_rcu_free); |
229 | } | 229 | } |
230 | 230 | ||
231 | static inline void get_ioctx(struct kioctx *kioctx) | ||
232 | { | ||
233 | BUG_ON(atomic_read(&kioctx->users) <= 0); | ||
234 | atomic_inc(&kioctx->users); | ||
235 | } | ||
236 | |||
237 | static inline int try_get_ioctx(struct kioctx *kioctx) | 231 | static inline int try_get_ioctx(struct kioctx *kioctx) |
238 | { | 232 | { |
239 | return atomic_inc_not_zero(&kioctx->users); | 233 | return atomic_inc_not_zero(&kioctx->users); |
@@ -527,11 +521,16 @@ static void aio_fput_routine(struct work_struct *data) | |||
527 | fput(req->ki_filp); | 521 | fput(req->ki_filp); |
528 | 522 | ||
529 | /* Link the iocb into the context's free list */ | 523 | /* Link the iocb into the context's free list */ |
524 | rcu_read_lock(); | ||
530 | spin_lock_irq(&ctx->ctx_lock); | 525 | spin_lock_irq(&ctx->ctx_lock); |
531 | really_put_req(ctx, req); | 526 | really_put_req(ctx, req); |
527 | /* | ||
528 | * at that point ctx might've been killed, but actual | ||
529 | * freeing is RCU'd | ||
530 | */ | ||
532 | spin_unlock_irq(&ctx->ctx_lock); | 531 | spin_unlock_irq(&ctx->ctx_lock); |
532 | rcu_read_unlock(); | ||
533 | 533 | ||
534 | put_ioctx(ctx); | ||
535 | spin_lock_irq(&fput_lock); | 534 | spin_lock_irq(&fput_lock); |
536 | } | 535 | } |
537 | spin_unlock_irq(&fput_lock); | 536 | spin_unlock_irq(&fput_lock); |
@@ -562,7 +561,6 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) | |||
562 | * this function will be executed w/out any aio kthread wakeup. | 561 | * this function will be executed w/out any aio kthread wakeup. |
563 | */ | 562 | */ |
564 | if (unlikely(!fput_atomic(req->ki_filp))) { | 563 | if (unlikely(!fput_atomic(req->ki_filp))) { |
565 | get_ioctx(ctx); | ||
566 | spin_lock(&fput_lock); | 564 | spin_lock(&fput_lock); |
567 | list_add(&req->ki_list, &fput_head); | 565 | list_add(&req->ki_list, &fput_head); |
568 | spin_unlock(&fput_lock); | 566 | spin_unlock(&fput_lock); |