From: mwilck@arcor.de
To: neilb@suse.de, linux-raid@vger.kernel.org
Cc: mwilck@arcor.de
Subject: [PATCH 8/9] DDF: ddf_open_new: check device status for new subarray
Date: Tue, 6 Aug 2013 23:38:02 +0200 [thread overview]
Message-ID: <1375825083-7856-4-git-send-email-mwilck@arcor.de> (raw)
In-Reply-To: <52016A06.8070400@arcor.de>
It is possible that mdadm creates a new subarray containing failed
devices. This may happen if a device has failed, but the meta data
containing that information hasn't been written out yet.
This code tests for this situation, and handles it in the monitor.
Signed-off-by: Martin Wilck <mwilck@arcor.de>
---
super-ddf.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/super-ddf.c b/super-ddf.c
index 23c5439..7f393ff 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -3996,11 +3996,36 @@ static int ddf_open_new(struct supertype *c, struct active_array *a, char *inst)
{
struct ddf_super *ddf = c->sb;
int n = atoi(inst);
+ struct mdinfo *dev;
+ struct dl *dl;
+ static const char faulty[] = "faulty";
+
if (all_ff(ddf->virt->entries[n].guid)) {
pr_err("%s: subarray %d doesn't exist\n", __func__, n);
return -ENODEV;
}
- dprintf("ddf: open_new %d\n", n);
+ dprintf("%s: new subarray %d, GUID: %s\n", __func__, n,
+ guid_str(ddf->virt->entries[n].guid));
+ for (dev = a->info.devs; dev; dev = dev->next) {
+ for (dl = ddf->dlist; dl; dl = dl->next)
+ if (dl->major == dev->disk.major &&
+ dl->minor == dev->disk.minor)
+ break;
+ if (!dl) {
+ pr_err("%s: device %d/%d of subarray %d not found in meta data\n",
+ __func__, dev->disk.major, dev->disk.minor, n);
+ return -1;
+ }
+ if ((be16_to_cpu(ddf->phys->entries[dl->pdnum].state) &
+ (DDF_Online|DDF_Missing|DDF_Failed)) != DDF_Online) {
+ pr_err("%s: new subarray %d contains broken device %d/%d (%02x)\n",
+ __func__, n, dl->major, dl->minor,
+ be16_to_cpu(
+ ddf->phys->entries[dl->pdnum].state));
+ write(dev->state_fd, faulty, sizeof(faulty)-1);
+ dev->curr_state = DS_FAULTY;
+ }
+ }
a->info.container_member = n;
return 0;
}
--
1.7.1
next prev parent reply other threads:[~2013-08-06 21:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-01 19:30 Bugreport ddf rebuild problems Albert Pauw
2013-08-01 19:09 ` Martin Wilck
[not found] ` <CAGkViCFT0+qm9YAnAJM7JGgVg0RTJi8=HAYDTMs-mfhXinqdcg@mail.gmail.com>
2013-08-01 21:13 ` Martin Wilck
2013-08-01 22:09 ` Martin Wilck
2013-08-01 22:37 ` Martin Wilck
2013-08-03 9:43 ` Albert Pauw
2013-08-04 9:47 ` Albert Pauw
2013-08-05 16:55 ` Albert Pauw
2013-08-05 21:24 ` Martin Wilck
2013-08-06 0:16 ` NeilBrown
2013-08-06 21:26 ` Martin Wilck
2013-08-06 21:37 ` Patches related to current discussion mwilck
2013-08-06 21:38 ` [PATCH 6/9] tests/10ddf-fail-spare: more sophisticated result checks mwilck
2013-08-06 21:38 ` [PATCH 7/9] tests/10ddf-fail-create-race: test handling of fail/create race mwilck
2013-08-06 21:38 ` mwilck [this message]
2013-08-06 21:38 ` [PATCH 9/9] Create: set array status to frozen until monitoring starts mwilck
2013-08-08 0:44 ` NeilBrown
2013-08-08 7:31 ` Martin Wilck
2013-08-07 18:07 ` Bugreport ddf rebuild problems Albert Pauw
2013-08-08 0:40 ` NeilBrown
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=1375825083-7856-4-git-send-email-mwilck@arcor.de \
--to=mwilck@arcor.de \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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).