linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Martin Wilck <mwilck@arcor.de>
Cc: Francis Moreau <francis.moro@gmail.com>, linux-raid@vger.kernel.org
Subject: Re: MD array keeps resyncing after rebooting
Date: Mon, 5 Aug 2013 16:08:28 +1000	[thread overview]
Message-ID: <20130805160828.7c01c21c@notabene.brown> (raw)
In-Reply-To: <51FAA5C3.8030109@arcor.de>

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

On Thu, 01 Aug 2013 20:15:31 +0200 Martin Wilck <mwilck@arcor.de> wrote:

> Hello Francis,
> > 
> > As you noticed the state is "Not Consistent". In my understanding it
> > becomes "Consistent" when  the array is stopped.
> 
> Correct.
> 
> > I checked during the shudown process that the array is correctly
> > stopped since at that point I got:
> > 
> > # mdadm -E /dev/sda | egrep "state"
> >         state[0] : Optimal, Consistent
> >    init state[0] : Fully Initialised
> 
> This looks as it should, actually. This looks as if md is doing what
> it's supposed to.
> 
> > After rebooting, it appears that the BIOS changed a part of VD
> > GUID[0]. I'm not sure if that can confuse the kernel and if it's the
> > reason why the kernel shows:
> > 
> >     [  832.944623] md/raid1:md126: not clean -- starting background
> > reconstruction
> 
> The BIOS obviously changes the meta data. The GUID itself shouldn't be
> the problem as long as it's consistently changed everywhere, but it's
> certainly strange to change it - it's meant to be constant and unique
> for this array.
> 
> It would be important to see the state of the meta data after md
> shutdown and immediately after boot (before md actually starts), so that
> we can exactly see what the BIOS has done.
> 
> > but this is obviously where a resync is triggered during each reboot
> > whatever the initial state of the array. The kernel message is
> > actually issued by drivers/md/raid1.c, in particular:
> > 
> >         if (mddev->recovery_cp != MaxSector)
> >                 printk(KERN_NOTICE "md/raid1:%s: not clean"
> >                        " -- starting background reconstruction\n",
> >                        mdname(mddev));
> > 
> > I don't understand the condition and how a resync can be triggered there.
> 
> The kernel is just reacting to something it has been told by
> mdadm/mdmon. mdadm, in turn, just reads the meta data. It is highly
> likely that the meta data indicated that the array was not, or only
> partially, initialized. In this case mdadm will always start a full
> reconstruction.
> 
> > Oh, this is with kernel 3.4.54.
> > 
> > Can you (or anyone else) spot something wrong with these information ?
> 
> Well, obviously the BIOS made a change to the meta data. Why so? We can
> only guess; perhaps something that mdadm wrote to the meta data didn't
> please the BIOS code, and it "thought" it needed to do something
> differently.
> 
> mdadm -E may not be enough here. We need to inspect the raw meta data
> 1. after BIOS created the array and before mdadm started
> 2. after mdadm shutdown
> 3. after BIOS reboot, before mdadm started.
> 4. (if you have a windows driver, it might be interesting to see how the
> meta data looks after windows has shut down after step 1.)
> 
> You can dump the metadata with mdadm --dump, but the result is difficult
> to handle because it's a sparse image the size of your disk.
> Unless all your tools handle sparse files well, you will get stuck.
> 
> Here is a slightly more type-intensive but safer method:
> 
> Use "sg_readcap /dev/sda" to print the LBA of the last block.
> Using this number, run
> 
>  dd if=/dev/sda of=/tmp/sda bs=1b skip=$LBA
> 
> then do hexdump -C /tmp/sda. You see your "DDF anchor" structure. At
> offsets 0x0060 and 0x0068, you find the LBAs of the primary and
> secondary header, in big endian. Use the smaller number of the two
> (usually the secondary header at 0x0068). In may case the hexdump line reads
> 
> 00000060  00 00 00 00 3a 37 c0 40  00 00 00 00 3a 37 20 50
> 
> The primary LBA is 0x3a37c040, the secondary 3a372050, which is less.
> Next, using the smaller number, run
> 
> dd if=/dev/sda bs=1b skip=$((0x3a372050)) | gzip -c /tmp/sda-ddf.gz
> 

For future reference, with mdadm 3.3 you can
 mkdir /tmp/md
 mdadm --dump /tmp/md /dev/sd*
 tar czSvf /tmp/md.tgz /tmp/md

The files in /tmp/md are sparse (lots of zeros). 
The 'S' flag to tar tells it to handle these well.
So

 tar xvf /tmp/md.tgz

will recover the sparse files which will have the metadata and nothing else.

NeilBrown

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

      parent reply	other threads:[~2013-08-05  6:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23  9:46 MD array keeps resyncing after rebooting Francis Moreau
2013-07-23 12:55 ` Francis Moreau
2013-07-23 18:52   ` Martin Wilck
2013-07-23 18:52     ` Martin Wilck
2013-07-23 20:01       ` Francis Moreau
2013-07-23 21:21         ` Martin Wilck
2013-07-24  4:32           ` Francis Moreau
2013-07-24 13:50             ` Francis Moreau
2013-07-25 18:58               ` Martin Wilck
2013-07-25 19:06                 ` Martin Wilck
2013-07-25 20:23                   ` Francis Moreau
2013-07-29 15:46                     ` Francis Moreau
2013-07-25 20:21                 ` Francis Moreau
2013-07-31 19:36                 ` Francis Moreau
2013-08-01 13:28                   ` Francis Moreau
2013-08-01 18:15                   ` Martin Wilck
2013-08-02 12:49                     ` Francis Moreau
     [not found]                     ` <CAC9WiBhGyE=OJdSeL_OsPxtirhJ2=3WRsk=uBPiOTzMjBCf-dA@mail.gmail.com>
2013-08-02 18:19                       ` Martin Wilck
2013-08-03  0:08                         ` Sam Bingner
2013-08-03 11:02                         ` Francis Moreau
2013-08-08  7:18                         ` Francis Moreau
2013-08-24 18:54                           ` Martin Wilck
2013-08-26  7:44                             ` Francis Moreau
2013-08-31 19:23                             ` Francis Moreau
2013-09-01 17:05                               ` Martin Wilck
2013-08-05  6:08                     ` NeilBrown [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=20130805160828.7c01c21c@notabene.brown \
    --to=neilb@suse.de \
    --cc=francis.moro@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mwilck@arcor.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).