public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: "Jens Axboe" <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	"Valdis Klētnieks" <valdis.kletnieks@vt.edu>,
	"Nilay Shroff" <nilay@linux.ibm.com>,
	"Christoph Hellwig" <hch@lst.de>
Subject: Re: [PATCH V2 1/3] block: add blk_mq_enter_no_io() and blk_mq_exit_no_io()
Date: Thu, 3 Apr 2025 07:44:27 +0200	[thread overview]
Message-ID: <20250403054427.GB24133@lst.de> (raw)
In-Reply-To: <20250403025214.1274650-2-ming.lei@redhat.com>

On Thu, Apr 03, 2025 at 10:52:08AM +0800, Ming Lei wrote:
> Add blk_mq_enter_no_io() and blk_mq_exit_no_io() for preventing queue
> from handling any FS or passthrough IO, meantime the queue is kept in
> non-freeze state.

How does that differ from the actual freeze?  Please document that
clearly in the commit log and in kerneldoc comments, and do an analysis
of which callers should do the full freeze and which the limited I/O
freeze.

Also the name is really unfortunate - no_io has a very clear connotation
for memory allocations, so this should be using something else.

> Also add two variants of memsave version, since no fs_reclaim is allowed
> in case of blk_mq_enter_no_io().

Please explain why.



> index ae8494d88897..d117fa18b394 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -222,8 +222,7 @@ bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic)
>  	bool unfreeze;
>  
>  	mutex_lock(&q->mq_freeze_lock);
> -	if (force_atomic)
> -		q->q_usage_counter.data->force_atomic = true;
> +	q->q_usage_counter.data->force_atomic = force_atomic;
>  	q->mq_freeze_depth--;
>  	WARN_ON_ONCE(q->mq_freeze_depth < 0);
>  	if (!q->mq_freeze_depth) {

This is a completely unrelated cleanup.

> +void blk_mq_enter_no_io(struct request_queue *q)
> +{
> +	blk_mq_freeze_queue_nomemsave(q);
> +	q->no_io = true;
> +	if (__blk_mq_unfreeze_queue(q, true))
> +		blk_unfreeze_release_lock(q);

So this freezes the queue, sets a flag to not do I/O then unfreezes
it.   So AFAIK it just is a freeze without the automatic recursion.

But maybe I'm missing something?

> +	if ((blk_queue_pm_only(q) &&
> +	    (!pm || queue_rpm_status(q) == RPM_SUSPENDED)) ||
> +			blk_queue_no_io(q))

The indentation is very inconsistent here.  This would looks
more reasonable:

	if (blk_queue_no_io(q) ||
	    (blk_queue_pm_only(q) &&
	     (!pm || queue_rpm_status(q) == RPM_SUSPENDED))) {

Also as this logic is duplicated it might make sense to de-dup it.


  reply	other threads:[~2025-04-03  5:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03  2:52 [PATCH V2 0/3] block: fix lock dependency between freeze and elevator lock Ming Lei
2025-04-03  2:52 ` [PATCH V2 1/3] block: add blk_mq_enter_no_io() and blk_mq_exit_no_io() Ming Lei
2025-04-03  5:44   ` Christoph Hellwig [this message]
2025-04-03 10:22     ` Ming Lei
2025-04-03  2:52 ` [PATCH V2 2/3] block: don't call freeze queue in elevator_switch() and elevator_disable() Ming Lei
2025-04-03  5:36   ` Christoph Hellwig
2025-04-03  2:52 ` [PATCH V2 3/3] block: use blk_mq_no_io() for avoiding lock dependency Ming Lei
2025-04-03  5:44   ` Christoph Hellwig

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=20250403054427.GB24133@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=nilay@linux.ibm.com \
    --cc=valdis.kletnieks@vt.edu \
    /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