@@ -5463,40 +5463,42 @@ static void bfq_exit_icq_bfqq(struct bfq_io_cq *bic, bool is_sync,
54635463 }
54645464}
54655465
5466+ static void _bfq_exit_icq (struct bfq_io_cq * bic , unsigned int num_actuators )
5467+ {
5468+ struct bfq_iocq_bfqq_data * bfqq_data = bic -> bfqq_data ;
5469+ unsigned int act_idx ;
5470+
5471+ for (act_idx = 0 ; act_idx < num_actuators ; act_idx ++ ) {
5472+ if (bfqq_data [act_idx ].stable_merge_bfqq )
5473+ bfq_put_stable_ref (bfqq_data [act_idx ].stable_merge_bfqq );
5474+
5475+ bfq_exit_icq_bfqq (bic , true, act_idx );
5476+ bfq_exit_icq_bfqq (bic , false, act_idx );
5477+ }
5478+ }
5479+
54665480static void bfq_exit_icq (struct io_cq * icq )
54675481{
54685482 struct bfq_io_cq * bic = icq_to_bic (icq );
54695483 struct bfq_data * bfqd = bic_to_bfqd (bic );
54705484 unsigned long flags ;
5471- unsigned int act_idx ;
5485+
54725486 /*
54735487 * If bfqd and thus bfqd->num_actuators is not available any
54745488 * longer, then cycle over all possible per-actuator bfqqs in
54755489 * next loop. We rely on bic being zeroed on creation, and
54765490 * therefore on its unused per-actuator fields being NULL.
5477- */
5478- unsigned int num_actuators = BFQ_MAX_ACTUATORS ;
5479- struct bfq_iocq_bfqq_data * bfqq_data = bic -> bfqq_data ;
5480-
5481- /*
5491+ *
54825492 * bfqd is NULL if scheduler already exited, and in that case
54835493 * this is the last time these queues are accessed.
54845494 */
54855495 if (bfqd ) {
54865496 spin_lock_irqsave (& bfqd -> lock , flags );
5487- num_actuators = bfqd -> num_actuators ;
5488- }
5489-
5490- for (act_idx = 0 ; act_idx < num_actuators ; act_idx ++ ) {
5491- if (bfqq_data [act_idx ].stable_merge_bfqq )
5492- bfq_put_stable_ref (bfqq_data [act_idx ].stable_merge_bfqq );
5493-
5494- bfq_exit_icq_bfqq (bic , true, act_idx );
5495- bfq_exit_icq_bfqq (bic , false, act_idx );
5496- }
5497-
5498- if (bfqd )
5497+ _bfq_exit_icq (bic , bfqd -> num_actuators );
54995498 spin_unlock_irqrestore (& bfqd -> lock , flags );
5499+ } else {
5500+ _bfq_exit_icq (bic , BFQ_MAX_ACTUATORS );
5501+ }
55005502}
55015503
55025504/*
0 commit comments