Skip to content

Commit fa88b6f

Browse files
committed
aio: cleanup: flatten kill_ioctx()
There is no need to have most of the code in kill_ioctx() indented. Flatten it. Signed-off-by: Benjamin LaHaise <[email protected]>
1 parent fb2d448 commit fa88b6f

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

fs/aio.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -730,39 +730,39 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
730730
static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx,
731731
struct completion *requests_done)
732732
{
733-
if (!atomic_xchg(&ctx->dead, 1)) {
734-
struct kioctx_table *table;
733+
struct kioctx_table *table;
735734

736-
spin_lock(&mm->ioctx_lock);
737-
rcu_read_lock();
738-
table = rcu_dereference(mm->ioctx_table);
735+
if (atomic_xchg(&ctx->dead, 1))
736+
return -EINVAL;
739737

740-
WARN_ON(ctx != table->table[ctx->id]);
741-
table->table[ctx->id] = NULL;
742-
rcu_read_unlock();
743-
spin_unlock(&mm->ioctx_lock);
744738

745-
/* percpu_ref_kill() will do the necessary call_rcu() */
746-
wake_up_all(&ctx->wait);
739+
spin_lock(&mm->ioctx_lock);
740+
rcu_read_lock();
741+
table = rcu_dereference(mm->ioctx_table);
742+
743+
WARN_ON(ctx != table->table[ctx->id]);
744+
table->table[ctx->id] = NULL;
745+
rcu_read_unlock();
746+
spin_unlock(&mm->ioctx_lock);
747747

748-
/*
749-
* It'd be more correct to do this in free_ioctx(), after all
750-
* the outstanding kiocbs have finished - but by then io_destroy
751-
* has already returned, so io_setup() could potentially return
752-
* -EAGAIN with no ioctxs actually in use (as far as userspace
753-
* could tell).
754-
*/
755-
aio_nr_sub(ctx->max_reqs);
748+
/* percpu_ref_kill() will do the necessary call_rcu() */
749+
wake_up_all(&ctx->wait);
756750

757-
if (ctx->mmap_size)
758-
vm_munmap(ctx->mmap_base, ctx->mmap_size);
751+
/*
752+
* It'd be more correct to do this in free_ioctx(), after all
753+
* the outstanding kiocbs have finished - but by then io_destroy
754+
* has already returned, so io_setup() could potentially return
755+
* -EAGAIN with no ioctxs actually in use (as far as userspace
756+
* could tell).
757+
*/
758+
aio_nr_sub(ctx->max_reqs);
759759

760-
ctx->requests_done = requests_done;
761-
percpu_ref_kill(&ctx->users);
762-
return 0;
763-
}
760+
if (ctx->mmap_size)
761+
vm_munmap(ctx->mmap_base, ctx->mmap_size);
764762

765-
return -EINVAL;
763+
ctx->requests_done = requests_done;
764+
percpu_ref_kill(&ctx->users);
765+
return 0;
766766
}
767767

768768
/* wait_on_sync_kiocb:

0 commit comments

Comments
 (0)