All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shaohua Li <shli@kernel.org>
To: NeilBrown <neilb@suse.com>
Cc: Linux Raid <linux-raid@vger.kernel.org>, Xiao Ni <xni@redhat.com>
Subject: Re: [PATCH] md: fix deadlock error in recent patch.
Date: Thu, 5 Oct 2017 10:00:48 -0700	[thread overview]
Message-ID: <20171005170048.7kirlvlvbnqtx4me@kernel.org> (raw)
In-Reply-To: <87shey183f.fsf@notabene.neil.brown.name>

On Thu, Oct 05, 2017 at 04:23:16PM +1100, Neil Brown wrote:
> 
> A recent patch aimed to cause md_write_start() to fail (rather than
> block) when the mddev was suspending, so as to avoid deadlocks.
> Unfortunately the test in wait_event() was wrong, and it didn't change
> behaviour at all.
> 
> We wait_event() must wait until the metadata is written OR the array is
> suspending.

Ouch, probably suspended isn't set normally, so it doesn't get caught. Applied, thanks Neil and Xiao!
 
> Fixes: cc27b0c78c79 ("md: fix deadlock between mddev_suspend() and md_write_start()")
> Cc: stable@vger.kernel.org
> Reported-by: Xiao Ni <xni@redhat.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/md/md.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 0ff1bbf6c90e..8b2eb0f4122f 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -8039,7 +8039,8 @@ bool md_write_start(struct mddev *mddev, struct bio *bi)
>  	if (did_change)
>  		sysfs_notify_dirent_safe(mddev->sysfs_state);
>  	wait_event(mddev->sb_wait,
> -		   !test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags) && !mddev->suspended);
> +		   !test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags) ||
> +		   mddev->suspended);
>  	if (test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags)) {
>  		percpu_ref_put(&mddev->writes_pending);
>  		return false;
> -- 
> 2.14.0.rc0.dirty
> 



      reply	other threads:[~2017-10-05 17:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-05  5:23 [PATCH] md: fix deadlock error in recent patch NeilBrown
2017-10-05 17:00 ` Shaohua Li [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=20171005170048.7kirlvlvbnqtx4me@kernel.org \
    --to=shli@kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=xni@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.