diff options
author | KalimochoAz <calimochoazucarado@gmail.com> | 2012-03-19 23:29:00 +0100 |
---|---|---|
committer | KalimochoAz <calimochoazucarado@gmail.com> | 2012-03-19 23:29:00 +0100 |
commit | 96b165e5470cb58e747c257dadc44e427274fa83 (patch) | |
tree | 72d7b8f92428ae4000f05755aecdf73944e1879c /fs/aio.c | |
parent | bd21819a35cd50e552ee2bfc240f76fc2eaab2ee (diff) | |
parent | 9bf176a3e029ae7f2dc6feae185091525a988be2 (diff) | |
download | kernel_samsung_crespo-96b165e5470cb58e747c257dadc44e427274fa83.zip kernel_samsung_crespo-96b165e5470cb58e747c257dadc44e427274fa83.tar.gz kernel_samsung_crespo-96b165e5470cb58e747c257dadc44e427274fa83.tar.bz2 |
Merge branch 'linux-3.0.y' into cm.ics
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -228,12 +228,6 @@ static void __put_ioctx(struct kioctx *ctx) call_rcu(&ctx->rcu_head, ctx_rcu_free); } -static inline void get_ioctx(struct kioctx *kioctx) -{ - BUG_ON(atomic_read(&kioctx->users) <= 0); - atomic_inc(&kioctx->users); -} - static inline int try_get_ioctx(struct kioctx *kioctx) { return atomic_inc_not_zero(&kioctx->users); @@ -273,7 +267,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) mm = ctx->mm = current->mm; atomic_inc(&mm->mm_count); - atomic_set(&ctx->users, 1); + atomic_set(&ctx->users, 2); spin_lock_init(&ctx->ctx_lock); spin_lock_init(&ctx->ring_info.ring_lock); init_waitqueue_head(&ctx->wait); @@ -527,11 +521,16 @@ static void aio_fput_routine(struct work_struct *data) fput(req->ki_filp); /* Link the iocb into the context's free list */ + rcu_read_lock(); spin_lock_irq(&ctx->ctx_lock); really_put_req(ctx, req); + /* + * at that point ctx might've been killed, but actual + * freeing is RCU'd + */ spin_unlock_irq(&ctx->ctx_lock); + rcu_read_unlock(); - put_ioctx(ctx); spin_lock_irq(&fput_lock); } spin_unlock_irq(&fput_lock); @@ -562,7 +561,6 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) * this function will be executed w/out any aio kthread wakeup. */ if (unlikely(!fput_atomic(req->ki_filp))) { - get_ioctx(ctx); spin_lock(&fput_lock); list_add(&req->ki_list, &fput_head); spin_unlock(&fput_lock); @@ -1256,10 +1254,10 @@ SYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp) ret = PTR_ERR(ioctx); if (!IS_ERR(ioctx)) { ret = put_user(ioctx->user_id, ctxp); - if (!ret) + if (!ret) { + put_ioctx(ioctx); return 0; - - get_ioctx(ioctx); /* io_destroy() expects us to hold a ref */ + } io_destroy(ioctx); } |