From: Mike Snitzer <snitzer@redhat.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: dm-devel@redhat.com, "Alasdair G. Kergon" <agk@redhat.com>
Subject: Re: device mapper ioctl handling
Date: Wed, 4 Apr 2018 10:02:28 -0400 [thread overview]
Message-ID: <20180404140228.GB14708@redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1804040905340.19168@file01.intranet.prod.int.rdu2.redhat.com>
On Wed, Apr 04 2018 at 9:34am -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:
> Hi
>
> I was thinking about that ioctl handling - and the problem is that the
> current code is broken too. The current code does:
>
> 1. dm_get_live_table
> 2. call the "prepare_ioctl" method on the first target, that returns the
> block device where the ioctl should be forwarded
> 3. call bdgrab on the block device
> 4. call blkdev_get on the block device
> 5. call dm_put_live_table
> 6. call __blkdev_driver_ioctl to forward the ioctl to the target device
> 7. call blkdev_put
>
> One problem: bdgrab is not paired with bdput, so it introduces a memory
> leak? Perhaps it should be deleted.
No, bdgrab() is required prior to blkdev_get().
blkdev_get()'s error path will bdput(). Otherwise, blkdev_put() will
bdput() via __blkdev_put().
So no, this aspect of the code is correct. Looks funny for sure (but
that is just a quirk of the block interfaces).
> The second problem: it may call ioctl on a device that is not part of a dm
> table. Between step 5 and step 6, the table may be reloaded with a
> different target, but it still calls the ioctl on the old device.
>
> So - we need to prevent table reload while the ioctl is in progress.
But it _was_ part of a DM table. Hard to assert that this race on table
unload is reason for alarm. Even if ioctl is successful, what is the
_real_ harm associated with losing that race?
I mean I agree that ideally we wouldn't issue the ioctl if the table
were unload just prior. A deeper mutual exclussion is needed.
> But there is another possible problem - there is multipath flag
> MPATHF_QUEUE_IF_NO_PATH and the ioctl may take indefinite time if the flag
> is set and there is no active path. In this situation it would prevent
> reloading the upper targets above the multipath target. But I think this
> is acceptable - if the multipath device has MPATHF_QUEUE_IF_NO_PATH set,
> bios sent to the device are queued indefinitely and these queued bios
> would already prevent suspending the upper layer device mapper devices.
> So, if a stuck ioctl prevents suspending the upper layer devices, it
> doesn't make it worse.
Except that it is possible to suspend _without_ flush (and multipathd
does do that to be able to reload a multipath table that has no valid
paths and queue_if_no_path is configured).
We discussed this MPATHF_QUEUE_IF_NO_PATH case yesterday in the context
of holding the live DM table for the duration of the ioctl (via
dm_get_live_table). The MPATHF_QUEUE_IF_NO_PATH case is particularly
problematic for this dm_get_live_table based solution:
https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.17&id=7e3990b5e0a2ac6f980adeb030d230b600ecdc4d
Meaning I'll need to drop that patch.
But above, you're saying that case is a problem even for the code that
is currently in upstream v4.16?
Not following, how.. given no-flush suspend + reload allows multipathd
to recover. In addition, dm_get_bdev_for_ioctl()'s 'goto retry' will
recheck if there is a valid table (via dm_get_live_table). SO that race
isn't a concern there. But even without that case, the ioctl won't
prevent a reload from happening. Unless I'm stil missing something?...
Mike
next prev parent reply other threads:[~2018-04-04 14:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-04 13:34 device mapper ioctl handling Mikulas Patocka
2018-04-04 14:02 ` Mike Snitzer [this message]
2018-04-04 14:20 ` Mikulas Patocka
2018-04-04 14:36 ` Mike Snitzer
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=20180404140228.GB14708@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=mpatocka@redhat.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.