@@ -241,7 +241,12 @@ EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
241241 */
242242void blk_mq_quiesce_queue_nowait (struct request_queue * q )
243243{
244- blk_queue_flag_set (QUEUE_FLAG_QUIESCED , q );
244+ unsigned long flags ;
245+
246+ spin_lock_irqsave (& q -> queue_lock , flags );
247+ if (!q -> quiesce_depth ++ )
248+ blk_queue_flag_set (QUEUE_FLAG_QUIESCED , q );
249+ spin_unlock_irqrestore (& q -> queue_lock , flags );
245250}
246251EXPORT_SYMBOL_GPL (blk_mq_quiesce_queue_nowait );
247252
@@ -282,10 +287,21 @@ EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue);
282287 */
283288void blk_mq_unquiesce_queue (struct request_queue * q )
284289{
285- blk_queue_flag_clear (QUEUE_FLAG_QUIESCED , q );
290+ unsigned long flags ;
291+ bool run_queue = false;
292+
293+ spin_lock_irqsave (& q -> queue_lock , flags );
294+ if (WARN_ON_ONCE (q -> quiesce_depth <= 0 )) {
295+ ;
296+ } else if (!-- q -> quiesce_depth ) {
297+ blk_queue_flag_clear (QUEUE_FLAG_QUIESCED , q );
298+ run_queue = true;
299+ }
300+ spin_unlock_irqrestore (& q -> queue_lock , flags );
286301
287302 /* dispatch requests which are inserted during quiescing */
288- blk_mq_run_hw_queues (q , true);
303+ if (run_queue )
304+ blk_mq_run_hw_queues (q , true);
289305}
290306EXPORT_SYMBOL_GPL (blk_mq_unquiesce_queue );
291307
0 commit comments