From: Ming Lei <ming.lei@redhat.com>
To: Martin Wilck <martin.wilck@suse.com>
Cc: Mike Snitzer <snitzer@redhat.com>,
Mikulas Patocka <mpatocka@redhat.com>,
Alasdair G Kergon <agk@redhat.com>,
dm-devel@lists.linux.dev, Martin Wilck <mwilck@suse.com>,
Hannes Reinecke <hare@suse.de>,
Vasilis Liaskovitis <vliaskovitis@suse.com>,
ming.lei@redhat.com
Subject: Re: [RFC Patch] dm: make sure to wait for all dispatched requests in __dm_suspend()
Date: Tue, 19 Mar 2024 21:04:12 +0800 [thread overview]
Message-ID: <ZfmNTK9uODx9YrLL@fedora> (raw)
In-Reply-To: <20240315231035.26046-1-mwilck@suse.com>
Hello Martin,
On Sat, Mar 16, 2024 at 12:10:35AM +0100, Martin Wilck wrote:
> In a recent kernel dump analysis, we found that the kernel crashed because
> dm_rq_target_io tio->ti was pointing to invalid memory in dm_end_request(),
> in a situation where multipathd was doing map reloads because of a storage
> failover. The map of the respective mapped_device had been replaced by a
> different struct dm_table.
>
> We obverved this with a 5.3.18 distro kernel, but the code in question
> hasn't change much since then. Basically, we were only missing
> b4459b11e840 ("dm rq: don't queue request to blk-mq during DM suspend"),
> which doesn't guarantee that the race I'm thinking of (see below) can't
> happen.
>
> When a map is resumed after a table reload, the live table is swapped, and
> the tio->ti member of any live request becomes stale. __dm_resume() avoids
> this by quiescing the queue and calling dm_wait_for_completion(), which
> waits until blk_mq_queue_inflight() doesn't report any in-flight requests.
>
> However, blk_mq_queue_inflight() counts only "started" requests. So, if a
> request is dispatched before the queue was quiesced, but
> dm_wait_for_completion() doesn't observe MQ_RQ_IN_FLIGHT for this request
> because of memory ordering effects, __dm_suspend() may finish successfully,
Can you explain a bit about the exact memory order which causes MQ_RQ_IN_FLIGHT
not observed?
blk-mq quiesce includes synchronize_rcu() which drains all in-flight
dispatch, so after blk_mq_quiesce_queue() returns,
if blk_mq_queue_inflight() returns 0, it does mean there isn't any
active inflight requests.
If there is bug in this pattern, I guess more drivers may have such
'risk'.
BTW, what is the underlying disks in your dm-mpath setting?
Thanks,
Ming
next prev parent reply other threads:[~2024-03-19 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 23:10 [RFC Patch] dm: make sure to wait for all dispatched requests in __dm_suspend() Martin Wilck
2024-03-19 13:04 ` Ming Lei [this message]
2024-03-19 15:41 ` Martin Wilck
2024-03-19 16:53 ` Mike Snitzer
2024-03-19 21:01 ` Martin Wilck
2024-03-20 3:03 ` Ming Lei
2024-03-20 9:51 ` Martin Wilck
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=ZfmNTK9uODx9YrLL@fedora \
--to=ming.lei@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=hare@suse.de \
--cc=martin.wilck@suse.com \
--cc=mpatocka@redhat.com \
--cc=mwilck@suse.com \
--cc=snitzer@redhat.com \
--cc=vliaskovitis@suse.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.