aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/aio.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/aio.c b/fs/aio.c
index f4a27af6c9ac..6b868f0e0c4c 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -479,6 +479,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
479 struct aio_ring *ring; 479 struct aio_ring *ring;
480 480
481 spin_lock(&mm->ioctx_lock); 481 spin_lock(&mm->ioctx_lock);
482 rcu_read_lock();
482 table = rcu_dereference(mm->ioctx_table); 483 table = rcu_dereference(mm->ioctx_table);
483 484
484 while (1) { 485 while (1) {
@@ -487,6 +488,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
487 if (!table->table[i]) { 488 if (!table->table[i]) {
488 ctx->id = i; 489 ctx->id = i;
489 table->table[i] = ctx; 490 table->table[i] = ctx;
491 rcu_read_unlock();
490 spin_unlock(&mm->ioctx_lock); 492 spin_unlock(&mm->ioctx_lock);
491 493
492 ring = kmap_atomic(ctx->ring_pages[0]); 494 ring = kmap_atomic(ctx->ring_pages[0]);
@@ -497,6 +499,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
497 499
498 new_nr = (table ? table->nr : 1) * 4; 500 new_nr = (table ? table->nr : 1) * 4;
499 501
502 rcu_read_unlock();
500 spin_unlock(&mm->ioctx_lock); 503 spin_unlock(&mm->ioctx_lock);
501 504
502 table = kzalloc(sizeof(*table) + sizeof(struct kioctx *) * 505 table = kzalloc(sizeof(*table) + sizeof(struct kioctx *) *
@@ -507,6 +510,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
507 table->nr = new_nr; 510 table->nr = new_nr;
508 511
509 spin_lock(&mm->ioctx_lock); 512 spin_lock(&mm->ioctx_lock);
513 rcu_read_lock();
510 old = rcu_dereference(mm->ioctx_table); 514 old = rcu_dereference(mm->ioctx_table);
511 515
512 if (!old) { 516 if (!old) {
@@ -631,10 +635,12 @@ static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx)
631 struct kioctx_table *table; 635 struct kioctx_table *table;
632 636
633 spin_lock(&mm->ioctx_lock); 637 spin_lock(&mm->ioctx_lock);
638 rcu_read_lock();
634 table = rcu_dereference(mm->ioctx_table); 639 table = rcu_dereference(mm->ioctx_table);
635 640
636 WARN_ON(ctx != table->table[ctx->id]); 641 WARN_ON(ctx != table->table[ctx->id]);
637 table->table[ctx->id] = NULL; 642 table->table[ctx->id] = NULL;
643 rcu_read_unlock();
638 spin_unlock(&mm->ioctx_lock); 644 spin_unlock(&mm->ioctx_lock);
639 645
640 /* percpu_ref_kill() will do the necessary call_rcu() */ 646 /* percpu_ref_kill() will do the necessary call_rcu() */