@@ -730,39 +730,39 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
730
730
static int kill_ioctx (struct mm_struct * mm , struct kioctx * ctx ,
731
731
struct completion * requests_done )
732
732
{
733
- if (!atomic_xchg (& ctx -> dead , 1 )) {
734
- struct kioctx_table * table ;
733
+ struct kioctx_table * table ;
735
734
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 ;
739
737
740
- WARN_ON (ctx != table -> table [ctx -> id ]);
741
- table -> table [ctx -> id ] = NULL ;
742
- rcu_read_unlock ();
743
- spin_unlock (& mm -> ioctx_lock );
744
738
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 );
747
747
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 );
756
750
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 );
759
759
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 );
764
762
765
- return - EINVAL ;
763
+ ctx -> requests_done = requests_done ;
764
+ percpu_ref_kill (& ctx -> users );
765
+ return 0 ;
766
766
}
767
767
768
768
/* wait_on_sync_kiocb:
0 commit comments