* [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait
2025-04-10 13:30 [PATCH 00/15] block: unify elevator changing and fix lockdep warning Ming Lei
@ 2025-04-10 13:30 ` Ming Lei
2025-04-14 6:19 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Ming Lei @ 2025-04-10 13:30 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Nilay Shroff, Shinichiro Kawasaki, Thomas Hellström,
Christoph Hellwig, Ming Lei
Move blk_unregister_queue() & device_del() after freeze wait, and prepare
for unifying elevator switch.
This way is just fine, since bdev has been unhashed at the beginning of
del_gendisk(), both blk_unregister_queue() & device_del() are dealing
with kobject & debugfs thing only.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/genhd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index c2bd86cd09de..f426c13edf55 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -721,8 +721,6 @@ void del_gendisk(struct gendisk *disk)
bdi_unregister(disk->bdi);
}
- blk_unregister_queue(disk);
-
kobject_put(disk->part0->bd_holder_dir);
kobject_put(disk->slave_dir);
disk->slave_dir = NULL;
@@ -731,10 +729,12 @@ void del_gendisk(struct gendisk *disk)
disk->part0->bd_stamp = 0;
sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
pm_runtime_set_memalloc_noio(disk_to_dev(disk), false);
- device_del(disk_to_dev(disk));
blk_mq_freeze_queue_wait(q);
+ blk_unregister_queue(disk);
+ device_del(disk_to_dev(disk));
+
blk_throtl_cancel_bios(disk);
blk_sync_queue(q);
--
2.47.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait
2025-04-10 13:30 ` [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait Ming Lei
@ 2025-04-14 6:19 ` Christoph Hellwig
2025-04-15 2:26 ` Ming Lei
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2025-04-14 6:19 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, linux-block, Nilay Shroff, Shinichiro Kawasaki,
Thomas Hellström, Christoph Hellwig
On Thu, Apr 10, 2025 at 09:30:19PM +0800, Ming Lei wrote:
> Move blk_unregister_queue() & device_del() after freeze wait, and prepare
> for unifying elevator switch.
>
> This way is just fine, since bdev has been unhashed at the beginning of
> del_gendisk(), both blk_unregister_queue() & device_del() are dealing
> with kobject & debugfs thing only.
While I believe this is the right thing to do, moving the freeze wait
caused issues in the past, so be careful. Take a look at:
commit 4c66a326b5ab784cddd72de07ac5b6210e9e1b06
Author: Christoph Hellwig <hch@lst.de>
Date: Mon Sep 19 16:40:49 2022 +0200
Revert "block: freeze the queue earlier in del_gendisk"
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait
2025-04-14 6:19 ` Christoph Hellwig
@ 2025-04-15 2:26 ` Ming Lei
0 siblings, 0 replies; 4+ messages in thread
From: Ming Lei @ 2025-04-15 2:26 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Jens Axboe, linux-block, Nilay Shroff, Shinichiro Kawasaki,
Thomas Hellström
On Mon, Apr 14, 2025 at 08:19:10AM +0200, Christoph Hellwig wrote:
> On Thu, Apr 10, 2025 at 09:30:19PM +0800, Ming Lei wrote:
> > Move blk_unregister_queue() & device_del() after freeze wait, and prepare
> > for unifying elevator switch.
> >
> > This way is just fine, since bdev has been unhashed at the beginning of
> > del_gendisk(), both blk_unregister_queue() & device_del() are dealing
> > with kobject & debugfs thing only.
>
> While I believe this is the right thing to do, moving the freeze wait
> caused issues in the past, so be careful. Take a look at:
>
> commit 4c66a326b5ab784cddd72de07ac5b6210e9e1b06
> Author: Christoph Hellwig <hch@lst.de>
> Date: Mon Sep 19 16:40:49 2022 +0200
>
> Revert "block: freeze the queue earlier in del_gendisk"
Yeah, I know this story.
If it is triggered again with this patch, I will help to root cause.
The last thing we still can do is to just moving blk_unregister_queue()
after queue is frozen, or even elevator tear down. It is allowed to delete
children kobjects after their parent is removed. Just the KOBJ_REMOVE
event need to be ordered.
Thanks,
Ming
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait
@ 2025-04-15 2:27 Ming Lei
0 siblings, 0 replies; 4+ messages in thread
From: Ming Lei @ 2025-04-15 2:27 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Jens Axboe, linux-block, Nilay Shroff, Shinichiro Kawasaki,
Thomas Hellström
[-- Attachment #1: Type: text/plain, Size: 193 bytes --]
Sender: ming.lei@redhat.com
Subject: Re: [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait
Message-Id: <Z_3D0PZWolXUdXnK@fedora>
Recipient: yangpanfei@honor.com
[-- Attachment #2: Type: message/rfc822, Size: 10971 bytes --]
From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: "Jens Axboe" <axboe@kernel.dk>, linux-block@vger.kernel.org, "Nilay Shroff" <nilay@linux.ibm.com>, "Shinichiro Kawasaki" <shinichiro.kawasaki@wdc.com>, "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait
Date: Tue, 15 Apr 2025 10:26:24 +0800
Message-ID: <Z_3D0PZWolXUdXnK@fedora>
On Mon, Apr 14, 2025 at 08:19:10AM +0200, Christoph Hellwig wrote:
> On Thu, Apr 10, 2025 at 09:30:19PM +0800, Ming Lei wrote:
> > Move blk_unregister_queue() & device_del() after freeze wait, and prepare
> > for unifying elevator switch.
> >
> > This way is just fine, since bdev has been unhashed at the beginning of
> > del_gendisk(), both blk_unregister_queue() & device_del() are dealing
> > with kobject & debugfs thing only.
>
> While I believe this is the right thing to do, moving the freeze wait
> caused issues in the past, so be careful. Take a look at:
>
> commit 4c66a326b5ab784cddd72de07ac5b6210e9e1b06
> Author: Christoph Hellwig <hch@lst.de>
> Date: Mon Sep 19 16:40:49 2022 +0200
>
> Revert "block: freeze the queue earlier in del_gendisk"
Yeah, I know this story.
If it is triggered again with this patch, I will help to root cause.
The last thing we still can do is to just moving blk_unregister_queue()
after queue is frozen, or even elevator tear down. It is allowed to delete
children kobjects after their parent is removed. Just the KOBJ_REMOVE
event need to be ordered.
Thanks,
Ming
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-18 8:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 2:27 [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait Ming Lei
-- strict thread matches above, loose matches on Subject: below --
2025-04-10 13:30 [PATCH 00/15] block: unify elevator changing and fix lockdep warning Ming Lei
2025-04-10 13:30 ` [PATCH 07/15] block: move blk_unregister_queue() & device_del() after freeze wait Ming Lei
2025-04-14 6:19 ` Christoph Hellwig
2025-04-15 2:26 ` Ming Lei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox