All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: heinzm@redhat.com
Cc: dm-devel@redhat.com
Subject: Re: dm raid: avoid mddev->suspended access
Date: Tue, 25 Jul 2017 14:29:17 -0400	[thread overview]
Message-ID: <20170725182917.GB27077@redhat.com> (raw)
In-Reply-To: <20170725181725.GA27077@redhat.com>

On Tue, Jul 25 2017 at  2:17pm -0400,
Mike Snitzer <snitzer@redhat.com> wrote:

> On Thu, Jul 13 2017 at 11:34am -0400,
> heinzm@redhat.com <heinzm@redhat.com> wrote:
> 
> > From: Heinz Mauelshagen <heinzm@redhat.com>
> > 
> > Use runtime flag to ensure that an mddev gets suspended/resumed just once.
> > 
> > Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
> > ---
> >  drivers/md/dm-raid.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> > index b409015..60c524b 100644
> > --- a/drivers/md/dm-raid.c
> > +++ b/drivers/md/dm-raid.c
> > @@ -3760,7 +3762,7 @@ static int rs_start_reshape(struct raid_set *rs)
> >  		return r;
> >  
> >  	/* Need to be resumed to be able to start reshape, recovery is frozen until raid_resume() though */
> > -	if (mddev->suspended)
> > +	if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags))
> >  		mddev_resume(mddev);
> >  
> >  	/*
> > @@ -3787,8 +3789,8 @@ static int rs_start_reshape(struct raid_set *rs)
> >  	}
> >  
> >  	/* Suspend because a resume will happen in raid_resume() */
> > -	if (!mddev->suspended)
> > -		mddev_suspend(mddev);
> > +	set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags);
> > +	mddev_suspend(mddev);
> >  
> >  	/*
> >  	 * Now reshape got set up, update superblocks to
> 
> Shouldn't this be the following?
> 
> if (!test_and_set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags))
>    mddev_suspend(mddev);

Looking closer, the preceding test_and_clear_bit() should ensure that
the device is always resumed by the time it gets to the code I called
into question.

      reply	other threads:[~2017-07-25 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13 15:34 [PATCH] dm raid: avoid mddev->suspended access heinzm
2017-07-25 18:17 ` Mike Snitzer
2017-07-25 18:29   ` Mike Snitzer [this message]

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=20170725182917.GB27077@redhat.com \
    --to=snitzer@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=heinzm@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.