From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
YangYang <yang.yang@vivo.com>,
linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: Re: block: del_gendisk() vs blk_queue_enter() race condition
Date: Tue, 8 Oct 2024 15:10:53 +0900 [thread overview]
Message-ID: <20241008061053.GE10794@google.com> (raw)
In-Reply-To: <ZwTJj5__g-4K8Hjz@infradead.org>
On (24/10/07 22:56), Christoph Hellwig wrote:
> On Tue, Oct 08, 2024 at 02:26:17PM +0900, Sergey Senozhatsky wrote:
> > Didn't copy one more backtrace here, there are two mutexes involved.
> >
> > schedule+0x554/0x1218
> > schedule_preempt_disabled+0x30/0x50
> > mutex_lock+0x3c/0x70
> > sr_block_release+0x2c/0x60 [sr_mod (HASH:d5f2 4)]
> > blkdev_put+0x184/0x290
> > blkdev_release+0x34/0x50
> > __fput_sync+0xa8/0x2d8
> > __arm64_sys_close+0x6c/0xd8
> > invoke_syscall+0x78/0xf0
> >
> > So process A holds cd->lock and sleeps in blk_queue_enter()
> > process B holds ->open_mutex and sleeps on cd->lock, which is owned by A
> > process C sleeps on ->open_mutex, which is owned by B.
>
> Oh, cd->mutex is a bit of a problem. And looking into the generic
> CD layer code this can be relatively easily avoided while cleaning
> a lot of the code up. Give me a little time to cook something up.
Sure, thanks. I can't test the patch, tho. At least not yet.
CD layer is in several reports, I also have reports with SD, and
a bunch of reports that I still have to look at. E.g.
schedule
blk_queue_enter
blk_mq_alloc_request
scsi_execute_cmd
ioctl_internal_command
scsi_set_medium_removal
sd_release
blkdev_put
cd->lock still falls a victim of
"blk_queue_enter() and blk_queue_start_drain() are both called under ->open_mutex"
thingy, which seems like a primary problem here. No matter why
blk_queue_enter() sleeps, draining under ->open_mutex, given that what we
want to drain can hold ->open_mutex, sometimes isn't going to drain.
> I also wonder if simulating a cdrom removal might be possible using
> qemu to help reproducing some of this.
Hmm, that's an interesting idea. I've only tried to "unsafely"
remove a USB stick out of my laptop so far, with no success.
next prev parent reply other threads:[~2024-10-08 6:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 8:56 block: del_gendisk() vs blk_queue_enter() race condition Sergey Senozhatsky
2024-10-03 13:36 ` 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 [this message]
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=20241008061053.GE10794@google.com \
--to=senozhatsky@chromium.org \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=yang.yang@vivo.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 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.