From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: block: del_gendisk() vs blk_queue_enter() race condition
Date: Thu, 3 Oct 2024 17:56:10 +0900 [thread overview]
Message-ID: <20241003085610.GK11458@google.com> (raw)
Hello,
I'm looking at a report from the fleet (don't have a reproducer)
and wondering what you and block folks might think / suggest.
The problem is basically as follows
CPU0
do_syscall
sys_close
__fput
blkdev_release
blkdev_put grabs ->open_mutex
sr_block_release
scsi_set_medium_removal
ioctl_internal_command
scsi_execute_cmd
scsi_alloc_request
blk_mq_alloc_request
blk_queue_enter
schedule
at the same time:
CPU1
usb_disconnect
usb_disable_device
device_del
usb_unbind_interface
usb_stor_disconnect
scsi_remove_host
scsi_forget_host
__scsi_remove_device
device_del
bus_remove_device
device_release_driver_internal
sr_remove
del_gendisk
mutex_lock attempts to grab ->open_mutex
schedule
blk_queue_enter() sleeps forever, under ->open_mutex, there is no
way for it to be woken up and to detect blk_queue_dying(). del_gendisk()
sleeps forever because it attempts to grab ->open_mutex before it calls
__blk_mark_disk_dead(), which would mark the queue QUEUE_FLAG_DYING and
wake up ->mq_freeze_wq (which is blk_queue_enter() in this case).
I wonder how to fix it. My current "patch" is to set QUEUE_FLAG_DYING
and "kick" ->mq_freeze_wq early on in del_gendisk(), before it attempts
to grab ->open_mutex for the first time.
Any suggestions?
next reply other threads:[~2024-10-03 8:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 8:56 Sergey Senozhatsky [this message]
2024-10-03 13:36 ` block: del_gendisk() vs blk_queue_enter() race condition Christoph Hellwig
2024-10-03 13:43 ` Christoph Hellwig
2024-10-03 14:00 ` Sergey Senozhatsky
2024-10-03 14:17 ` Sergey Senozhatsky
2024-10-04 4:21 ` Sergey Senozhatsky
2024-10-04 6:45 ` Christoph Hellwig
2024-10-04 7:48 ` Sergey Senozhatsky
2024-10-04 7:49 ` Sergey Senozhatsky
2024-10-04 12:20 ` Christoph Hellwig
2024-10-04 14:32 ` Sergey Senozhatsky
2024-10-07 6:10 ` Christoph Hellwig
2024-10-07 9:45 ` Sergey Senozhatsky
2024-10-08 5:31 ` Sergey Senozhatsky
2024-10-04 14:41 ` Sergey Senozhatsky
2024-10-03 13:55 ` Sergey Senozhatsky
2024-10-08 4:02 ` YangYang
2024-10-08 5:19 ` Sergey Senozhatsky
2024-10-08 5:26 ` Sergey Senozhatsky
2024-10-08 5:56 ` Christoph Hellwig
2024-10-08 6:04 ` Christoph Hellwig
2024-10-08 6:10 ` Sergey Senozhatsky
2024-10-08 8:13 ` Christoph Hellwig
2024-10-08 8:20 ` Sergey Senozhatsky
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=20241003085610.GK11458@google.com \
--to=senozhatsky@chromium.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.