blk-mq: Make it safe to call blk_mq_quiesce_queue_nowait() from an interrupt handler
PATCH 1/1 blk-mq: Make it safe to call blk_mq_quiesce_queue_nowait() from an interrupt handler
Since blk_mq_quiesce_queue_nowait() can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.
--- block/blk-mq.c | 14 ++++++++++++++ include/linux/blk-mq.h | 10 +--------- 2 files changed, 15 insertions(+), 9 deletions(-)
block/blk-mq.c +14 -0
@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q) }EXPORT_SYMBOL_GPL (blk_mq_unfreeze_queue); +/* +* FIXME: replace the scsi_internal_device_*block_nowait() calls in the +* mpt3sas driver such that this function can be removed. +*/ +void blk_mq_quiesce_queue_nowait (struct request_queue *q) +{ +unsigned long flags; + +spin_lock_irqsave (q->queue_lock, flags); +queue_flag_set (QUEUE_FLAG_QUIESCED , q); +spin_unlock_irqrestore (q->queue_lock, flags); +} +EXPORT_SYMBOL_GPL (blk_mq_quiesce_queue_nowait); +/** * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished * @q: request queue.
include/linux/blk-mq.h +1 -9
@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);int blk_mq_map_queues (struct blk_mq_tag_set *set);void blk_mq_update_nr_hw_queues (struct blk_mq_tag_set *set,int nr_hw_queues); -/* -* FIXME: this helper is just for working around mpt3sas. -*/ -static inline void blk_mq_quiesce_queue_nowait (struct request_queue *q) -{ -spin_lock_irq (q->queue_lock); -queue_flag_set (QUEUE_FLAG_QUIESCED , q); -spin_unlock_irq (q->queue_lock); -} +void blk_mq_quiesce_queue_nowait (struct request_queue *q);/* * Driver command data is immediately after the request. So subtract request
Signature · 1 line
2.13.1
Quoted 63 lines · Bart Van Assche
Since
blk_mq_quiesce_queue_nowait()can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.Fixes commit f4560ffe8cec ("blk-mq: use QUEUE_FLAG_QUIESCED to quiesce queue")Signed-off-by Bart Van Assche <[email protected]>Cc Ming Lei <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Martin K. Petersen <[email protected]>--- block/blk-mq.c | 14 ++++++++++++++ include/linux/blk-mq.h | 10 +--------- 2 files changed, 15 insertions(+), 9 deletions(-)block/blk-mq.c +14
-0@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q) }EXPORT_SYMBOL_GPL (blk_mq_unfreeze_queue); +/* +* FIXME: replace the scsi_internal_device_*block_nowait() calls in the +* mpt3sas driver such that this function can be removed. +*/ +void blk_mq_quiesce_queue_nowait (struct request_queue *q) +{ +unsigned long flags; + +spin_lock_irqsave (q->queue_lock, flags); +queue_flag_set (QUEUE_FLAG_QUIESCED , q); +spin_unlock_irqrestore (q->queue_lock, flags); +} +EXPORT_SYMBOL_GPL (blk_mq_quiesce_queue_nowait); +/** * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished * @q: request queue. include/linux/blk-mq.h +1
-9@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);int blk_mq_map_queues (struct blk_mq_tag_set *set);void blk_mq_update_nr_hw_queues (struct blk_mq_tag_set *set,int nr_hw_queues); -/* -* FIXME: this helper is just for working around mpt3sas. -*/ -static inline void blk_mq_quiesce_queue_nowait (struct request_queue *q) -{ -spin_lock_irq (q->queue_lock); -queue_flag_set (QUEUE_FLAG_QUIESCED , q); -spin_unlock_irq (q->queue_lock); -} +void blk_mq_quiesce_queue_nowait (struct request_queue *q);/* * Driver command data is immediately after the request. So subtract request Signature · 1 line
2.13.1
Looks fine,
Thanks,
Ming
Quoted 67 lines · Ming Lei
Quoted 63 lines · Bart Van Assche
Since
blk_mq_quiesce_queue_nowait()can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.Fixes commit f4560ffe8cec ("blk-mq: use QUEUE_FLAG_QUIESCED to quiesce queue")Signed-off-by Bart Van Assche <[email protected]>Cc Ming Lei <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Martin K. Petersen <[email protected]>--- block/blk-mq.c | 14 ++++++++++++++ include/linux/blk-mq.h | 10 +--------- 2 files changed, 15 insertions(+), 9 deletions(-)block/blk-mq.c +14
-0@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q) }EXPORT_SYMBOL_GPL (blk_mq_unfreeze_queue); +/* +* FIXME: replace the scsi_internal_device_*block_nowait() calls in the +* mpt3sas driver such that this function can be removed. +*/ +void blk_mq_quiesce_queue_nowait (struct request_queue *q) +{ +unsigned long flags; + +spin_lock_irqsave (q->queue_lock, flags); +queue_flag_set (QUEUE_FLAG_QUIESCED , q); +spin_unlock_irqrestore (q->queue_lock, flags); +} +EXPORT_SYMBOL_GPL (blk_mq_quiesce_queue_nowait); +/** * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished * @q: request queue. include/linux/blk-mq.h +1
-9@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);int blk_mq_map_queues (struct blk_mq_tag_set *set);void blk_mq_update_nr_hw_queues (struct blk_mq_tag_set *set,int nr_hw_queues); -/* -* FIXME: this helper is just for working around mpt3sas. -*/ -static inline void blk_mq_quiesce_queue_nowait (struct request_queue *q) -{ -spin_lock_irq (q->queue_lock); -queue_flag_set (QUEUE_FLAG_QUIESCED , q); -spin_unlock_irq (q->queue_lock); -} +void blk_mq_quiesce_queue_nowait (struct request_queue *q);/* * Driver command data is immediately after the request. So subtract request Signature · 1 line
2.13.1Looks fine,
Quoted 1 line
Reviewed-by Ming Lei <[email protected]>
Also we should save/restore irq flags in blk_mq_unquiesce_queue() since scsi_start_queue() does that too, could you fix the two in this patch?
Thanks,
Ming
Jens Axboe
maintainerQuoted 68 lines · Ming Lei
Quoted 67 lines · Ming Lei
Quoted 63 lines · Bart Van Assche
Since
blk_mq_quiesce_queue_nowait()can be called from interrupt context, make this safe. Since this function is not in the hot path, uninline it. Untested.Fixes commit f4560ffe8cec ("blk-mq: use QUEUE_FLAG_QUIESCED to quiesce queue")Signed-off-by Bart Van Assche <[email protected]>Cc Ming Lei <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Martin K. Petersen <[email protected]>--- block/blk-mq.c | 14 ++++++++++++++ include/linux/blk-mq.h | 10 +--------- 2 files changed, 15 insertions(+), 9 deletions(-)block/blk-mq.c +14
-0@@ -153,6 +153,20 @@ void blk_mq_unfreeze_queue(struct request_queue *q) }EXPORT_SYMBOL_GPL (blk_mq_unfreeze_queue); +/* +* FIXME: replace the scsi_internal_device_*block_nowait() calls in the +* mpt3sas driver such that this function can be removed. +*/ +void blk_mq_quiesce_queue_nowait (struct request_queue *q) +{ +unsigned long flags; + +spin_lock_irqsave (q->queue_lock, flags); +queue_flag_set (QUEUE_FLAG_QUIESCED , q); +spin_unlock_irqrestore (q->queue_lock, flags); +} +EXPORT_SYMBOL_GPL (blk_mq_quiesce_queue_nowait); +/** * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished * @q: request queue. include/linux/blk-mq.h +1
-9@@ -266,15 +266,7 @@ int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);int blk_mq_map_queues (struct blk_mq_tag_set *set);void blk_mq_update_nr_hw_queues (struct blk_mq_tag_set *set,int nr_hw_queues); -/* -* FIXME: this helper is just for working around mpt3sas. -*/ -static inline void blk_mq_quiesce_queue_nowait (struct request_queue *q) -{ -spin_lock_irq (q->queue_lock); -queue_flag_set (QUEUE_FLAG_QUIESCED , q); -spin_unlock_irq (q->queue_lock); -} +void blk_mq_quiesce_queue_nowait (struct request_queue *q);/* * Driver command data is immediately after the request. So subtract request Signature · 1 line
2.13.1Looks fine,
Quoted 5 lines
Quoted 1 line
Reviewed-by Ming Lei <[email protected]>Also we should save/restore irq flags in
blk_mq_unquiesce_queue()sincescsi_start_queue()does that too, could you fix the two in this patch?
Good catch. Bart, will you spin a v2?
Signature · 1 line
Jens Axboe
T24gVHVlLCAyMDE3LTA2LTIwIGF0IDE5OjQ4IC0wNjAwLCBKZW5zIEF4Ym9lIHdyb3RlOg0KPiBH b29kIGNhdGNoLiBCYXJ0LCB3aWxsIHlvdSBzcGluIGEgdjI/DQoNCkhlbGxvIEplbnMsDQoNClRo YXQncyB0aGUgZmlyc3QgdGFzayBJIHdpbGwgd29yayBvbiB0b21vcnJvdyBtb3JuaW5nLg0KDQpC YXJ0Lg==