Skip to content

Commit 9ef4d02

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: add one API for waiting until quiesce is done
Some drivers(NVMe, SCSI) need to call quiesce and unquiesce in pair, but it is hard to switch to this style, so these drivers need one atomic flag for helping to balance quiesce and unquiesce. When quiesce is in-progress, the driver still needs to wait until the quiesce is done, so add API of blk_mq_wait_quiesce_done() for these drivers. Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a846a8e commit 9ef4d02

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

block/blk-mq.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,18 @@ void blk_mq_quiesce_queue_nowait(struct request_queue *q)
251251
EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait);
252252

253253
/**
254-
* blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished
254+
* blk_mq_wait_quiesce_done() - wait until in-progress quiesce is done
255255
* @q: request queue.
256256
*
257-
* Note: this function does not prevent that the struct request end_io()
258-
* callback function is invoked. Once this function is returned, we make
259-
* sure no dispatch can happen until the queue is unquiesced via
260-
* blk_mq_unquiesce_queue().
257+
* Note: it is driver's responsibility for making sure that quiesce has
258+
* been started.
261259
*/
262-
void blk_mq_quiesce_queue(struct request_queue *q)
260+
void blk_mq_wait_quiesce_done(struct request_queue *q)
263261
{
264262
struct blk_mq_hw_ctx *hctx;
265263
unsigned int i;
266264
bool rcu = false;
267265

268-
blk_mq_quiesce_queue_nowait(q);
269-
270266
queue_for_each_hw_ctx(q, hctx, i) {
271267
if (hctx->flags & BLK_MQ_F_BLOCKING)
272268
synchronize_srcu(hctx->srcu);
@@ -276,6 +272,22 @@ void blk_mq_quiesce_queue(struct request_queue *q)
276272
if (rcu)
277273
synchronize_rcu();
278274
}
275+
EXPORT_SYMBOL_GPL(blk_mq_wait_quiesce_done);
276+
277+
/**
278+
* blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished
279+
* @q: request queue.
280+
*
281+
* Note: this function does not prevent that the struct request end_io()
282+
* callback function is invoked. Once this function is returned, we make
283+
* sure no dispatch can happen until the queue is unquiesced via
284+
* blk_mq_unquiesce_queue().
285+
*/
286+
void blk_mq_quiesce_queue(struct request_queue *q)
287+
{
288+
blk_mq_quiesce_queue_nowait(q);
289+
blk_mq_wait_quiesce_done(q);
290+
}
279291
EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue);
280292

281293
/*

include/linux/blk-mq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ void blk_mq_start_hw_queues(struct request_queue *q);
803803
void blk_mq_start_stopped_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
804804
void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async);
805805
void blk_mq_quiesce_queue(struct request_queue *q);
806+
void blk_mq_wait_quiesce_done(struct request_queue *q);
806807
void blk_mq_unquiesce_queue(struct request_queue *q);
807808
void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs);
808809
void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);

0 commit comments

Comments
 (0)