linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Marc Smith <marc.smith@mcc.edu>
Cc: linux-raid@vger.kernel.org
Subject: Re: MD Remnants After --stop
Date: Mon, 05 Dec 2016 11:41:12 +1100	[thread overview]
Message-ID: <87r35n5hsn.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <CAHkw+Lfncgkdb8HnbtfGaX0P_KmLmicj3E64JK7oY+1Pv6g_iw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]

On Sat, Dec 03 2016, Marc Smith wrote:

> Finally, I got it! Why is it when I want it to break, it doesn't. =)

welcome to my world :-)


>
> I will say, using the modified mdadm that prevents the synthesized
> CHANGE event, it seems to not induce the problem as regularly.
>
> Below are the kernel logs after stopping an array:

Thank you so much for persisting with this.
The logs you provide make it clear that two separate processes (494 and
31178) increment the ->active count by opening the device, but never
decrement that count by closing the device.
It seems too unlikely that either process would be holding the
file descriptor open indefinitely, so something must be going wrong
either as part of 'open', or as part of 'close'.

Now that I know where to look, the bug is obvious.  Why didn't I see
that before?

The open request is failing, almost certainly because MD_CLOSING is set,
but the ->active count isn't being decremented on failure.
This patch should fix it.

Please test and report results.

Thanks,
NeilBrown

Fixes: af8d8e6f0315 ("md: changes for MD_STILL_CLOSED flag" v4.9-rc1)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2089d46b0eb8..a8e07eb2ca5f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7087,11 +7087,14 @@ static int md_open(struct block_device *bdev, fmode_t mode)
 	}
 	BUG_ON(mddev != bdev->bd_disk->private_data);
 
-	if ((err = mutex_lock_interruptible(&mddev->open_mutex)))
+	if ((err = mutex_lock_interruptible(&mddev->open_mutex))) {
+		mddev_put(mddev);
 		goto out;
+	}
 
 	if (test_bit(MD_CLOSING, &mddev->flags)) {
 		mutex_unlock(&mddev->open_mutex);
+		mddev_put(mddev);
 		return -ENODEV;
 	}
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2016-12-05  0:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04 15:35 MD Remnants After --stop Marc Smith
2016-11-07  5:44 ` NeilBrown
2016-11-18 19:31   ` Marc Smith
2016-11-21  3:42     ` NeilBrown
2016-11-21 14:08       ` Marc Smith
2016-11-22 15:12         ` Marc Smith
2016-11-22 23:51           ` NeilBrown
2016-11-23 15:21             ` Marc Smith
2016-11-23 23:38               ` NeilBrown
2016-11-26 16:41                 ` Marc Smith
2016-11-27 22:20                   ` NeilBrown
2016-11-28  2:25                     ` Marc Smith
2016-12-01  2:52                       ` NeilBrown
2016-12-01 19:40                         ` Marc Smith
2016-12-01 22:35                           ` NeilBrown
2016-12-02 18:18                             ` Stephane Thiell
2016-12-02 19:12                             ` Marc Smith
2016-12-02 20:22                               ` Marc Smith
2016-12-05  0:41                                 ` NeilBrown [this message]
2016-12-05 21:37                                   ` Marc Smith

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=87r35n5hsn.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=marc.smith@mcc.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).