From: Uday Shankar <ushankar@purestorage.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Caleb Sander Mateos <csander@purestorage.com>
Subject: Re: [PATCH V2 3/8] ublk: rely on ->canceling for dealing with ublk_nosrv_dev_should_queue_io
Date: Wed, 16 Apr 2025 12:35:23 -0600 [thread overview]
Message-ID: <Z//4ax6RhR7kz3VA@dev-ushankar.dev.purestorage.com> (raw)
In-Reply-To: <20250416035444.99569-4-ming.lei@redhat.com>
On Wed, Apr 16, 2025 at 11:54:37AM +0800, Ming Lei wrote:
> Now ublk deals with ublk_nosrv_dev_should_queue_io() by keeping request
> queue as quiesced. This way is fragile because queue quiesce crosses syscalls
> or process contexts.
>
> Switch to rely on ubq->canceling for dealing with
> ublk_nosrv_dev_should_queue_io(), because it has been used for this purpose
> during io_uring context exiting, and it can be reused before recovering too.
> In ublk_queue_rq(), the request will be added to requeue list without
> kicking off requeue in case of ubq->canceling, and finally requests added in
> requeue list will be dispatched from either ublk_stop_dev() or
> ublk_ctrl_end_recovery().
>
> Meantime we have to move reset of ubq->canceling from ublk_ctrl_start_recovery()
> to ublk_ctrl_end_recovery(), when IO handling can be recovered completely.
>
> Then blk_mq_quiesce_queue() and blk_mq_unquiesce_queue() are always used
> in same context.
>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Uday Shankar <ushankar@purestorage.com>
> ---
> drivers/block/ublk_drv.c | 31 +++++++++++++++++--------------
> 1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index e1b4db2f8a56..a479969fd77e 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1734,13 +1734,19 @@ static void ublk_wait_tagset_rqs_idle(struct ublk_device *ub)
>
> static void __ublk_quiesce_dev(struct ublk_device *ub)
> {
> + int i;
> +
> pr_devel("%s: quiesce ub: dev_id %d state %s\n",
> __func__, ub->dev_info.dev_id,
> ub->dev_info.state == UBLK_S_DEV_LIVE ?
> "LIVE" : "QUIESCED");
> blk_mq_quiesce_queue(ub->ub_disk->queue);
> + /* mark every queue as canceling */
> + for (i = 0; i < ub->dev_info.nr_hw_queues; i++)
> + ublk_get_queue(ub, i)->canceling = true;
> ublk_wait_tagset_rqs_idle(ub);
> ub->dev_info.state = UBLK_S_DEV_QUIESCED;
> + blk_mq_unquiesce_queue(ub->ub_disk->queue);
> }
>
> static void ublk_force_abort_dev(struct ublk_device *ub)
> @@ -2961,7 +2967,6 @@ static void ublk_queue_reinit(struct ublk_device *ub, struct ublk_queue *ubq)
> /* We have to reset it to NULL, otherwise ub won't accept new FETCH_REQ */
> ubq->ubq_daemon = NULL;
> ubq->timeout = false;
> - ubq->canceling = false;
>
> for (i = 0; i < ubq->q_depth; i++) {
> struct ublk_io *io = &ubq->ios[i];
> @@ -3048,20 +3053,18 @@ static int ublk_ctrl_end_recovery(struct ublk_device *ub,
> pr_devel("%s: new ublksrv_pid %d, dev id %d\n",
> __func__, ublksrv_pid, header->dev_id);
>
> - if (ublk_nosrv_dev_should_queue_io(ub)) {
> - ub->dev_info.state = UBLK_S_DEV_LIVE;
> - blk_mq_unquiesce_queue(ub->ub_disk->queue);
> - pr_devel("%s: queue unquiesced, dev id %d.\n",
> - __func__, header->dev_id);
> - blk_mq_kick_requeue_list(ub->ub_disk->queue);
> - } else {
> - blk_mq_quiesce_queue(ub->ub_disk->queue);
> - ub->dev_info.state = UBLK_S_DEV_LIVE;
> - for (i = 0; i < ub->dev_info.nr_hw_queues; i++) {
> - ublk_get_queue(ub, i)->fail_io = false;
> - }
> - blk_mq_unquiesce_queue(ub->ub_disk->queue);
> + blk_mq_quiesce_queue(ub->ub_disk->queue);
> + ub->dev_info.state = UBLK_S_DEV_LIVE;
> + for (i = 0; i < ub->dev_info.nr_hw_queues; i++) {
> + struct ublk_queue *ubq = ublk_get_queue(ub, i);
> +
> + ubq->canceling = false;
> + ubq->fail_io = false;
> }
> + blk_mq_unquiesce_queue(ub->ub_disk->queue);
> + pr_devel("%s: queue unquiesced, dev id %d.\n",
> + __func__, header->dev_id);
> + blk_mq_kick_requeue_list(ub->ub_disk->queue);
>
> ret = 0;
> out_unlock:
> --
> 2.47.0
>
next prev parent reply other threads:[~2025-04-16 18:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 3:54 [PATCH V2 0/8] ublk: simplify & improve IO canceling Ming Lei
2025-04-16 3:54 ` [PATCH V2 1/8] ublk: properly serialize all FETCH_REQs Ming Lei
2025-04-16 3:54 ` [PATCH V2 2/8] ublk: add ublk_force_abort_dev() Ming Lei
2025-04-16 3:54 ` [PATCH V2 3/8] ublk: rely on ->canceling for dealing with ublk_nosrv_dev_should_queue_io Ming Lei
2025-04-16 18:35 ` Uday Shankar [this message]
2025-04-16 3:54 ` [PATCH V2 4/8] ublk: move device reset into ublk_ch_release() Ming Lei
2025-04-16 19:02 ` Uday Shankar
2025-04-16 23:31 ` Ming Lei
2025-04-16 3:54 ` [PATCH V2 5/8] ublk: improve detection and handling of ublk server exit Ming Lei
2025-04-16 19:09 ` Uday Shankar
2025-04-16 3:54 ` [PATCH V2 6/8] ublk: remove __ublk_quiesce_dev() Ming Lei
2025-04-16 3:54 ` [PATCH V2 7/8] ublk: simplify aborting ublk request Ming Lei
2025-04-16 3:54 ` [PATCH V2 8/8] selftests: ublk: add generic_06 for covering fault inject Ming Lei
2025-04-16 18:45 ` [PATCH V2 0/8] ublk: simplify & improve IO canceling Jens Axboe
2025-04-17 0:03 ` Ming Lei
2025-04-17 1:33 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z//4ax6RhR7kz3VA@dev-ushankar.dev.purestorage.com \
--to=ushankar@purestorage.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox