From: Mike Snitzer <snitzer@redhat.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: device-mapper development <dm-devel@redhat.com>,
"Bryn M. Reeves" <breeves@redhat.com>,
ejt@redhat.com, Alasdair G Kergon <agk@redhat.com>,
Zdenek Kabelac <zkabelac@redhat.com>
Subject: Re: staged dm_internal_{suspend, resume} related changes for wider review
Date: Wed, 5 Nov 2014 11:56:11 -0500 [thread overview]
Message-ID: <20141105165611.GA19885@redhat.com> (raw)
In-Reply-To: <20141105161015.GD14285@redhat.com>
On Wed, Nov 05 2014 at 11:10am -0500,
Mike Snitzer <snitzer@redhat.com> wrote:
> On Wed, Nov 05 2014 at 9:37am -0500,
> Mikulas Patocka <mpatocka@redhat.com> wrote:
>
> >
> >
> > On Wed, 5 Nov 2014, Mike Snitzer wrote:
> >
> > > On Wed, Nov 05 2014 at 8:05am -0500,
> > > Mikulas Patocka <mpatocka@redhat.com> wrote:
> > >
> > > > On Wed, 5 Nov 2014, Mikulas Patocka wrote:
> > > >
> > > > > You can for example set the flag in the prison meaning that the prison is
> > > > > suspended and then call dm_internal_suspend immediatelly followed by
> > > > > dm_internal_resume - that will clear in-progress bios and prevent new bios
> > > > > from coming in (and we don't need to change dm_internal_suspend and
> > > > > dm_internal_resume to become so big).
> > >
> > > It may _seem_ like they have gotten big given the code was refactored to
> > > share code with dm_suspend and dm_resume. BUT I know you see that the
> > > actual code complexity isn't big. I especially wanted you (and/or Bryn)
> > > to evaluate the performance implications that my changes had on
> > > dm-stats. I'm pretty confident there won't be much if any performance
> > > difference (given the code is identical to what you had, except some
> > > extra checks are made but ultimately not used, e.g. lockfs/unlockfs).
> >
> > This is not about performance, it is about unclear behavior.
> >
> > If someone does internal_suspend followed by remove, what should be the
> > correct behavior? The current code deadlocks in this case.
>
> You need to be specific, if internal suspend was used by the thin-pool
> suspend to suspend thin devices you'll need the thin-pool resumed before
> you can remove any thin device!
>
> Like any interface there is a right way and a wrong way to use it.
> dm_internal_suspend must always be followed by dm_internal_resume.
> I cannot yet see a hole where properly written code is exposed here.
But thinking further about what you said, you're correctly concerned
about the potential for dm-stats to have used dm_internal_suspend and
then someone attempting to remove that device while it is internally
suspended.
We just need a patch like this:
drivers/md/dm.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index ac0dcad..ffa6763 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -448,6 +448,17 @@ int dm_lock_for_deletion(struct mapped_device *md, bool mark_deferred, bool only
{
int r = 0;
+retry:
+ mutex_lock(&md->suspend_lock);
+ if (dm_suspended_internally_md(md)) {
+ /* already internally suspended, wait for internal resume */
+ mutex_unlock(&md->suspend_lock);
+ r = wait_on_bit(&md->flags, DMF_SUSPENDED_INTERNALLY, TASK_INTERRUPTIBLE);
+ if (r)
+ return r;
+ goto retry;
+ }
+
spin_lock(&_minor_lock);
if (dm_open_count(md)) {
@@ -461,6 +472,8 @@ int dm_lock_for_deletion(struct mapped_device *md, bool mark_deferred, bool only
spin_unlock(&_minor_lock);
+ mutex_unlock(&md->suspend_lock);
+
return r;
}
next prev parent reply other threads:[~2014-11-05 16:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20141028014825.GA21949@redhat.com>
[not found] ` <544F988D.7090901@redhat.com>
[not found] ` <20141028134012.GA25229@redhat.com>
[not found] ` <20141028141749.GD25229@redhat.com>
[not found] ` <20141028143742.GE25229@redhat.com>
[not found] ` <20141028171003.GG25229@redhat.com>
[not found] ` <20141028224753.GA29288@redhat.com>
[not found] ` <20141028232638.GB29288@redhat.com>
[not found] ` <20141029002125.GC29288@redhat.com>
2014-10-29 1:22 ` staged dm_internal_{suspend, resume} related changes for wider review Mike Snitzer
2014-10-29 19:06 ` Mike Snitzer
2014-10-29 20:49 ` Mike Snitzer
2014-11-03 23:25 ` Mikulas Patocka
2014-11-04 0:17 ` Mike Snitzer
2014-11-05 1:16 ` Mike Snitzer
2014-11-05 12:43 ` Mikulas Patocka
2014-11-05 13:05 ` Mikulas Patocka
2014-11-05 14:11 ` Mike Snitzer
2014-11-05 14:37 ` Mikulas Patocka
2014-11-05 14:50 ` Zdenek Kabelac
2014-11-05 16:10 ` Mike Snitzer
2014-11-05 16:56 ` Mike Snitzer [this message]
2014-11-05 20:16 ` Mike Snitzer
2014-11-05 16:29 ` Mike Snitzer
2014-11-07 16:20 ` Mikulas Patocka
2014-11-07 18:33 ` Mike Snitzer
2015-01-02 22:56 ` Mikulas Patocka
2015-01-05 15:50 ` Mike Snitzer
2015-01-08 23:52 ` [PATCH] dm: handle multiple internal suspends correctly (was: staged dm_internal_{suspend, resume} related changes for wider review) Mikulas Patocka
2014-11-07 23:16 ` [PATCH] Suspend all active bios when the pool is suspended " Mikulas Patocka
2014-11-07 23:29 ` Mike Snitzer
2014-11-09 1:17 ` [PATCH] " 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=20141105165611.GA19885@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=breeves@redhat.com \
--cc=dm-devel@redhat.com \
--cc=ejt@redhat.com \
--cc=mpatocka@redhat.com \
--cc=zkabelac@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.