public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-block@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 10/12] block: move blk_exit_queue into disk_release
Date: Wed, 23 Feb 2022 14:56:37 +0800	[thread overview]
Message-ID: <YhXapc7fuhb8mlwW@T590> (raw)
In-Reply-To: <4b9a4121-7f37-9bd3-036a-51892a456eef@acm.org>

On Tue, Feb 22, 2022 at 10:29:47AM -0800, Bart Van Assche wrote:
> On 2/22/22 06:14, Christoph Hellwig wrote:
> > From: Ming Lei <ming.lei@redhat.com>
> > 
> > There can't be FS IO in disk_release(), so move blk_exit_queue() there.
> > 
> > We still need to freeze queue here since the request is freed after the
> > bio is completed and passthrough request rely on scheduler tags as well.
> > 
> > The disk can be released before or after queue is cleaned up, and we have
> > to free the scheduler request pool before blk_cleanup_queue returns,
> > while the static request pool has to be freed before exiting the
> > I/O scheduler.
> 
> This patch looks dubious to me because:
> - The blk_freeze_queue() call in blk_cleanup_queue() waits for pending
>   requests to finish, so why to move blk_exit_queue() from
>   blk_cleanup_queue() into disk_release()?

scsi disk may be released before calling blk_cleanup_queue(), and we
want to tear down all FS related stuff(cgroup, rqos, elevator) in disk_release().

And FS bios have been drained already when releasing disk.

> - I'm concerned that this patch will break user space, e.g. scripts that
>   try to unload an I/O scheduler kernel module immediately after having
>   removed a request queue.

When removing a request queue, the associated disk has been removed
already, and queue's kobject has been deleted too, so how can userspace
unload I/O scheduler at that time?

> 
> > +static void blk_mq_release_queue(struct request_queue *q)
> > +{
> > +	blk_mq_cancel_work_sync(q);
> > +
> > +	/*
> > +	 * There can't be any non non-passthrough bios in flight here, but
> > +	 * requests stay around longer, including passthrough ones so we
> > +	 * still need to freeze the queue here.
> > +	 */
> > +	blk_mq_freeze_queue(q);
> 
> The above comment should be elaborated since what matters in this context is
> not whether or not any bios are still in flight but what happens with the
> request structures.

Yeah, bios have been done, but request is done after bio is ended, see
blk_update_request(), that is why we added blk_mq_freeze_queue() here.

> As you know blk_queue_enter() fails after the DYING flag
> has been set, a flag that is set by blk_cleanup_queue().blk_cleanup_queue()
> already freezes the queue. So why is it necessary to call
> blk_mq_freeze_queue() from blk_mq_release_queue()?

disk may be released before calling blk_cleanup_queue().

But I admit here the name of blk_mq_release_queue() is very misleading,
maybe blk_mq_release_io_queue() is better?


Thanks,
Ming


  reply	other threads:[~2022-02-23  6:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 14:14 move more work to disk_release Christoph Hellwig
2022-02-22 14:14 ` [PATCH 01/12] blk-mq: do not include passthrough requests in I/O accounting Christoph Hellwig
2022-02-23  2:08   ` Ming Lei
2022-02-23  6:42     ` Christoph Hellwig
2022-02-23  7:02       ` Ming Lei
2022-02-23  7:36         ` Christoph Hellwig
2022-02-22 14:14 ` [PATCH 02/12] blk-mq: handle already freed tags gracefully in blk_mq_free_rqs Christoph Hellwig
2022-02-22 14:14 ` [PATCH 03/12] scsi: don't use disk->private_data to find the scsi_driver Christoph Hellwig
2022-02-22 14:14 ` [PATCH 04/12] sd: make use of ->free_disk to simplify refcounting Christoph Hellwig
2022-02-22 14:14 ` [PATCH 05/12] sd: remove the extra sdev_gendev reference Christoph Hellwig
2022-02-22 14:14 ` [PATCH 06/12] sr: implement ->free_disk Christoph Hellwig
2022-02-22 14:14 ` [PATCH 07/12] block: move blkcg initialization/destroy into disk allocation/release handler Christoph Hellwig
2022-02-22 14:14 ` [PATCH 08/12] block: don't remove hctx debugfs dir from blk_mq_exit_queue Christoph Hellwig
2022-02-23  4:06   ` Bart Van Assche
2022-02-23  6:41     ` Ming Lei
2022-02-22 14:14 ` [PATCH 09/12] block: move q_usage_counter release into blk_queue_release Christoph Hellwig
2022-02-22 14:14 ` [PATCH 10/12] block: move blk_exit_queue into disk_release Christoph Hellwig
2022-02-22 18:29   ` Bart Van Assche
2022-02-23  6:56     ` Ming Lei [this message]
2022-02-23 20:04       ` Bart Van Assche
2022-02-24  7:25         ` Christoph Hellwig
2022-02-25  1:26           ` Ming Lei
2022-02-22 14:14 ` [PATCH 11/12] block: do more work in elevator_exit Christoph Hellwig
2022-02-22 14:14 ` [PATCH 12/12] block: move rq_qos_exit() into disk_release() Christoph Hellwig
2022-02-26  4:46 ` move more work to disk_release Bart Van Assche

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=YhXapc7fuhb8mlwW@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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