@@ -65,9 +65,6 @@ static DEFINE_PER_CPU(unsigned long, cfq_ioc_count);
6565static struct completion * ioc_gone ;
6666static DEFINE_SPINLOCK (ioc_gone_lock );
6767
68- static DEFINE_SPINLOCK (cic_index_lock );
69- static DEFINE_IDA (cic_index_ida );
70-
7168#define CFQ_PRIO_LISTS IOPRIO_BE_NR
7269#define cfq_class_idle (cfqq ) ((cfqq)->ioprio_class == IOPRIO_CLASS_IDLE)
7370#define cfq_class_rt (cfqq ) ((cfqq)->ioprio_class == IOPRIO_CLASS_RT)
@@ -290,7 +287,6 @@ struct cfq_data {
290287 unsigned int cfq_group_idle ;
291288 unsigned int cfq_latency ;
292289
293- unsigned int cic_index ;
294290 struct list_head cic_list ;
295291
296292 /*
@@ -484,7 +480,7 @@ static inline void cic_set_cfqq(struct cfq_io_context *cic,
484480
485481static inline void * cfqd_dead_key (struct cfq_data * cfqd )
486482{
487- return (void * )(cfqd -> cic_index << CIC_DEAD_INDEX_SHIFT | CIC_DEAD_KEY );
483+ return (void * )(cfqd -> queue -> id << CIC_DEAD_INDEX_SHIFT | CIC_DEAD_KEY );
488484}
489485
490486static inline struct cfq_data * cic_to_cfqd (struct cfq_io_context * cic )
@@ -3105,7 +3101,7 @@ cfq_drop_dead_cic(struct cfq_data *cfqd, struct io_context *ioc,
31053101 BUG_ON (rcu_dereference_check (ioc -> ioc_data ,
31063102 lockdep_is_held (& ioc -> lock )) == cic );
31073103
3108- radix_tree_delete (& ioc -> radix_root , cfqd -> cic_index );
3104+ radix_tree_delete (& ioc -> radix_root , cfqd -> queue -> id );
31093105 hlist_del_rcu (& cic -> cic_list );
31103106 spin_unlock_irqrestore (& ioc -> lock , flags );
31113107
@@ -3133,7 +3129,7 @@ cfq_cic_lookup(struct cfq_data *cfqd, struct io_context *ioc)
31333129 }
31343130
31353131 do {
3136- cic = radix_tree_lookup (& ioc -> radix_root , cfqd -> cic_index );
3132+ cic = radix_tree_lookup (& ioc -> radix_root , cfqd -> queue -> id );
31373133 rcu_read_unlock ();
31383134 if (!cic )
31393135 break ;
@@ -3169,8 +3165,7 @@ static int cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
31693165 cic -> key = cfqd ;
31703166
31713167 spin_lock_irqsave (& ioc -> lock , flags );
3172- ret = radix_tree_insert (& ioc -> radix_root ,
3173- cfqd -> cic_index , cic );
3168+ ret = radix_tree_insert (& ioc -> radix_root , cfqd -> queue -> id , cic );
31743169 if (!ret )
31753170 hlist_add_head_rcu (& cic -> cic_list , & ioc -> cic_list );
31763171 spin_unlock_irqrestore (& ioc -> lock , flags );
@@ -3944,10 +3939,6 @@ static void cfq_exit_queue(struct elevator_queue *e)
39443939
39453940 cfq_shutdown_timer_wq (cfqd );
39463941
3947- spin_lock (& cic_index_lock );
3948- ida_remove (& cic_index_ida , cfqd -> cic_index );
3949- spin_unlock (& cic_index_lock );
3950-
39513942 /*
39523943 * Wait for cfqg->blkg->key accessors to exit their grace periods.
39533944 * Do this wait only if there are other unlinked groups out
@@ -3969,48 +3960,16 @@ static void cfq_exit_queue(struct elevator_queue *e)
39693960 kfree (cfqd );
39703961}
39713962
3972- static int cfq_alloc_cic_index (void )
3973- {
3974- int index , error ;
3975-
3976- do {
3977- if (!ida_pre_get (& cic_index_ida , GFP_KERNEL ))
3978- return - ENOMEM ;
3979-
3980- spin_lock (& cic_index_lock );
3981- error = ida_get_new (& cic_index_ida , & index );
3982- spin_unlock (& cic_index_lock );
3983- if (error && error != - EAGAIN )
3984- return error ;
3985- } while (error );
3986-
3987- return index ;
3988- }
3989-
39903963static void * cfq_init_queue (struct request_queue * q )
39913964{
39923965 struct cfq_data * cfqd ;
39933966 int i , j ;
39943967 struct cfq_group * cfqg ;
39953968 struct cfq_rb_root * st ;
39963969
3997- i = cfq_alloc_cic_index ();
3998- if (i < 0 )
3999- return NULL ;
4000-
40013970 cfqd = kmalloc_node (sizeof (* cfqd ), GFP_KERNEL | __GFP_ZERO , q -> node );
4002- if (!cfqd ) {
4003- spin_lock (& cic_index_lock );
4004- ida_remove (& cic_index_ida , i );
4005- spin_unlock (& cic_index_lock );
3971+ if (!cfqd )
40063972 return NULL ;
4007- }
4008-
4009- /*
4010- * Don't need take queue_lock in the routine, since we are
4011- * initializing the ioscheduler, and nobody is using cfqd
4012- */
4013- cfqd -> cic_index = i ;
40143973
40153974 /* Init root service tree */
40163975 cfqd -> grp_service_tree = CFQ_RB_ROOT ;
@@ -4294,7 +4253,6 @@ static void __exit cfq_exit(void)
42944253 */
42954254 if (elv_ioc_count_read (cfq_ioc_count ))
42964255 wait_for_completion (& all_gone );
4297- ida_destroy (& cic_index_ida );
42984256 cfq_slab_kill ();
42994257}
43004258
0 commit comments