linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Ross Boylan <ross@biostat.ucsf.edu>
Cc: linux-raid@vger.kernel.org
Subject: Re: mdadm --wait returns while array under construction? [patch question]
Date: Wed, 28 Nov 2012 08:30:46 +1100	[thread overview]
Message-ID: <20121128083046.31bfa6e4@notabene.brown> (raw)
In-Reply-To: <1354040913.27664.11.camel@corn.betterworld.us>

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

On Tue, 27 Nov 2012 10:28:33 -0800 Ross Boylan <ross@biostat.ucsf.edu> wrote:

> On Wed, 2012-11-21 at 08:43 +1100, NeilBrown wrote:
> > On Tue, 20 Nov 2012 09:55:41 -0800 Ross Boylan <ross@biostat.ucsf.edu> wrote:
> > 
> > > While switching the disks a RAID 1 is based on I used the --wait command
> > > to wait for the rebuild to finish.  It returned immediately, but a
> > > subsequent query showed it had not been rebuilt.  Have I misunderstood
> > > something, or is this an error?
> > > 
> > > While doing these commands a much larger rebuild was going on with a
> > > different array, involving some of the same physical disks but different
> > > partitions.  The partitions being rebuilt are on different physical
> > > disks for the different arrays.
> > > 
> > > Here are the logs, with version info at the end (Debian Lenny + more
> > > recent kernel):
> > ....
> > 
> > > markov:~# uname -a
> > > Linux markov 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux
> > > markov:~# mdadm --version
> > > mdadm - v2.6.7.2 - 14th November 2008
> > > 
> > > 
> > > I notice that in this case, unlike the other array, the message during
> > > the rebuild (the last detail report) does not include a line like
> > > Rebuild Status : 0% complete
> > > 
> > > I just tried --wait again to see if there was some kind of race, but
> > > once again it returned immediately, though detail says the spare is
> > > rebuilding.
> > 
> > Can you test this patch to see if it fixes the problem?
> > 
> > diff --git a/Monitor.c b/Monitor.c
> > index c4d57c3..a5e7aaa 100644
> > --- a/Monitor.c
> > +++ b/Monitor.c
> > @@ -973,7 +973,7 @@ int Wait(char *dev)
> >  			if (e->devnum == devnum)
> >  				break;
> >  
> > -		if (!e || e->percent < 0) {
> > +		if (!e || e->percent == RESYNC_NONE) {
> >  			if (e && e->metadata_version &&
> >  			    strncmp(e->metadata_version, "external:", 9) == 0) {
> >  				if (is_subarray(&e->metadata_version[9]))
> > 
> > 
> > NeilBrown
> My source for 2.6.7.2 looks somewhat different.  It only has 627 lines;
> I think this is the relevant code (at the end of the file):
> /* Not really Monitor but ... */
> int Wait(char *dev)
> {
>         struct stat stb;
>         int devnum;
>         int rv = 1;
> 
>         if (stat(dev, &stb) != 0) {
>                 fprintf(stderr, Name ": Cannot find %s: %s\n", dev,
>                         strerror(errno));
>                 return 2;
>         }
>         if (major(stb.st_rdev) == MD_MAJOR)
>                 devnum = minor(stb.st_rdev);
>         else
>                 devnum = -1-(minor(stb.st_rdev)/64);
> 
>         while(1) {
>                 struct mdstat_ent *ms = mdstat_read(1, 0);
>                 struct mdstat_ent *e;
> 
>                 for (e=ms ; e; e=e->next)
>                         if (e->devnum == devnum)
>                                 break;
> 
>                 if (!e || e->percent < 0) {
>                         free_mdstat(ms);
>                         return rv;
>                 }
>                 free(ms);
>                 rv = 0;
>                 mdstat_wait(5);
>         }
> }
> 
> 
> The section
>                 if (!e || e->percent < 0) {
>                         free_mdstat(ms);
>                         return rv;
>  is the only one with e->percent < 0.  Is it OK to change that to 
> if (!e || e->percent == RESYNC_NONE) {?
> 
>

That's the right place to make the change, bit it won't compile.
RESYNC_NONE isn't defined in that version of mdadm, and you would need to
make some changes in mdstat.c where ent->percent is set.
Current code has


				if (l > 8 && strcmp(w+l-8, "=DELAYED") == 0)
					ent->percent = RESYNC_DELAYED;
				if (l > 8 && strcmp(w+l-8, "=PENDING") == 0)
					ent->percent = RESYNC_PENDING;

which is completely missing from 2.6.7.2.  You'd be a lot better off starting
with 3.2.6 and adding the patch to that.

NeilBrown

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

  reply	other threads:[~2012-11-27 21:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-20 17:55 mdadm --wait returns while array under construction? Ross Boylan
2012-11-20 18:22 ` Ross Boylan
2012-11-20 21:43 ` NeilBrown
2012-11-21 16:43   ` Ross Boylan
2012-11-22  6:09     ` NeilBrown
2012-11-27 18:28   ` mdadm --wait returns while array under construction? [patch question] Ross Boylan
2012-11-27 21:30     ` NeilBrown [this message]
2012-11-28  2:10       ` Ross Boylan
2012-11-29  1:35         ` 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=20121128083046.31bfa6e4@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    --cc=ross@biostat.ucsf.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).