From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: axboe@kernel.dk, shinichiro.kawasaki@wdc.com,
dan.j.williams@intel.com, yukuai3@huawei.com,
linux-block@vger.kernel.org,
syzbot+3e3f419f4a7816471838@syzkaller.appspotmail.com
Subject: Re: [PATCH 1/4] block: disable the elevator int del_gendisk
Date: Tue, 14 Jun 2022 19:27:59 +0800 [thread overview]
Message-ID: <Yqhwv0POjMi1TNo3@T590> (raw)
In-Reply-To: <20220614083453.GA6999@lst.de>
On Tue, Jun 14, 2022 at 10:34:53AM +0200, Christoph Hellwig wrote:
> On Tue, Jun 14, 2022 at 04:23:36PM +0800, Ming Lei wrote:
> > > blk_sync_queue(q);
> > > blk_flush_integrity();
> > > + blk_mq_cancel_work_sync(q);
> > > +
> > > + blk_mq_quiesce_queue(q);
> >
> > quiesce queue adds a bit long delay in del_gendisk, not sure if this way may
> > cause regression in big machines with lots of disks.
>
> It does. But at least we remove a freeze in the queue teardown path.
> But either way I'd really like to get things correct first before
> looking into optimizations.
The removed one works at atomic mode and it is super fast.
>
> >
> > > + if (q->elevator) {
> > > + mutex_lock(&q->sysfs_lock);
> > > + elevator_exit(q);
> > > + mutex_unlock(&q->sysfs_lock);
> > > + }
> > > + rq_qos_exit(q);
> > > + blk_mq_unquiesce_queue(q);
> >
> > Also tearing down elevator here has to be carefully, that means any
> > elevator reference has to hold rcu read lock or .q_usage_counter,
> > meantime it has to be checked, otherwise use-after-free may be caused.
>
> This is not a new pattern. We have the same locking here as a
> sysfs-induced change of the elevator to none which also clears
> q->elevator under a queue that is frozen and quiesced.
Then looks this pattern has problem in dealing with the examples I
mentioned.
And the elevator usage in __blk_mq_update_nr_hw_queues() looks one
old problem, but easy to fix by protecting it via sysfs_lock.
And fixing blk_mq_has_sqsched() should be easy too.
I will send patches later.
Thanks,
Ming
next prev parent reply other threads:[~2022-06-14 11:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-14 7:48 fix tag freeing use after free and debugfs name reuse Christoph Hellwig
2022-06-14 7:48 ` [PATCH 1/4] block: disable the elevator int del_gendisk Christoph Hellwig
2022-06-14 8:23 ` Ming Lei
2022-06-14 8:34 ` Christoph Hellwig
2022-06-14 11:27 ` Ming Lei [this message]
2022-06-17 12:50 ` Jens Axboe
2022-06-17 13:26 ` Christoph Hellwig
2022-06-17 13:27 ` Jens Axboe
2022-06-14 7:48 ` [PATCH 2/4] block: serialize all debugfs operations using q->debugfs_mutex Christoph Hellwig
2022-06-14 7:48 ` [PATCH 3/4] block: remove per-disk debugfs files in blk_unregister_queue Christoph Hellwig
2022-06-14 7:48 ` [PATCH 4/4] block: freeze the queue earlier in del_gendisk Christoph Hellwig
2022-07-08 5:41 ` REGRESSION: " Logan Gunthorpe
2022-07-08 6:01 ` Christoph Hellwig
2022-07-08 15:55 ` Logan Gunthorpe
2022-07-09 8:17 ` Christoph Hellwig
2022-07-11 3:33 ` Logan Gunthorpe
2022-07-11 4:33 ` Christoph Hellwig
2022-06-17 13:31 ` fix tag freeing use after free and debugfs name reuse 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=Yqhwv0POjMi1TNo3@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=dan.j.williams@intel.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=syzbot+3e3f419f4a7816471838@syzkaller.appspotmail.com \
--cc=yukuai3@huawei.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