linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Zeroing multiple superblocks
@ 2010-01-22 20:09 Jim Paris
  2010-01-25  9:52 ` Andre Noll
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Paris @ 2010-01-22 20:09 UTC (permalink / raw)
  To: linux-raid

Should --zero-superblock be changed to clear all superblocks,
or at least warn when not all superblocks are cleared?

I ran into a problem a year ago where I had a disk with both 0.90 and
1.0 format metadata.  The wrong one was scanned at boot, causing a
"doesn't match others - assembly aborted" error.  At the time, I
thought I fixed it by doing a --zero-superblock and re-adding the
disk, but it turns out the disk still had two, causing the same
problem (reboots are rare on this machine).

For example:
  # dd if=/dev/zero of=diskimage bs=1M count=8
  # losetup -fv diskimage
  Loop device is /dev/loop0
  # mdadm --create /dev/md0 --level=1 --metadata=0.90 --raid-devices=2 /dev/loop0 missing
  mdadm: array /dev/md0 started.
  # mdadm --stop /dev/md0
  mdadm: stopped /dev/md0
  # mdadm --create /dev/md0 --level=1 --metadata=1.0 --raid-devices=2 /dev/loop0 missing
  mdadm: /dev/loop0 appears to be part of a raid array:
      level=raid1 devices=2 ctime=Fri Jan 22 14:55:26 2010
  Continue creating array? y
  mdadm: array /dev/md0 started.
  # mdadm --stop /dev/md0

Now notice how --zero-superblock has to be run twice before it starts
complaining that no superblock was found:
  # mdadm --zero-superblock /dev/loop0
  # mdadm --zero-superblock /dev/loop0
  # mdadm --zero-superblock /dev/loop0
  mdadm: Unrecognised md component device - /dev/loop0

I guess the only way to be fully safe with the current approach is to
do a zero-superblock over and over until it complains.

-jim

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zeroing multiple superblocks
  2010-01-22 20:09 Zeroing multiple superblocks Jim Paris
@ 2010-01-25  9:52 ` Andre Noll
  2010-01-29 12:31   ` Neil Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Andre Noll @ 2010-01-25  9:52 UTC (permalink / raw)
  To: Jim Paris; +Cc: linux-raid

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

On 15:09, Jim Paris wrote:

> I guess the only way to be fully safe with the current approach is to
> do a zero-superblock over and over until it complains.

mdadm --zero-superblock tries to guess the location of the superblock.
If more than one superblock is found, the one with the latest creation
time is being zeroed. So yes, the method you describe works and I think
it is the most reliable way to remove all superblocks of a device.

Maybe we could teach mdadm --zero-superblock to honor the --metadata=x
option which would zero-out the region of the device where the
version-x superblock is located.

Andre
-- 
The only person who always got his work done by Friday was Robinson Crusoe

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zeroing multiple superblocks
  2010-01-25  9:52 ` Andre Noll
@ 2010-01-29 12:31   ` Neil Brown
  2010-02-01 21:22     ` Bill Davidsen
  0 siblings, 1 reply; 5+ messages in thread
From: Neil Brown @ 2010-01-29 12:31 UTC (permalink / raw)
  To: Andre Noll; +Cc: Jim Paris, linux-raid

On Mon, 25 Jan 2010 10:52:21 +0100
Andre Noll <maan@systemlinux.org> wrote:

> On 15:09, Jim Paris wrote:
> 
> > I guess the only way to be fully safe with the current approach is to
> > do a zero-superblock over and over until it complains.
> 
> mdadm --zero-superblock tries to guess the location of the superblock.
> If more than one superblock is found, the one with the latest creation
> time is being zeroed. So yes, the method you describe works and I think
> it is the most reliable way to remove all superblocks of a device.
> 
> Maybe we could teach mdadm --zero-superblock to honor the --metadata=x
> option which would zero-out the region of the device where the
> version-x superblock is located.

Latest mdadm has this feature.
And if --metadata= isn't given, it repeatedly trying to find and zero a
superblock until no more superblocks can be found.

NeilBrown

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zeroing multiple superblocks
  2010-01-29 12:31   ` Neil Brown
@ 2010-02-01 21:22     ` Bill Davidsen
  2010-02-01 21:44       ` Neil Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Bill Davidsen @ 2010-02-01 21:22 UTC (permalink / raw)
  To: Neil Brown; +Cc: Andre Noll, Jim Paris, linux-raid

Neil Brown wrote:
> On Mon, 25 Jan 2010 10:52:21 +0100
> Andre Noll <maan@systemlinux.org> wrote:
>
>   
>> On 15:09, Jim Paris wrote:
>>
>>     
>>> I guess the only way to be fully safe with the current approach is to
>>> do a zero-superblock over and over until it complains.
>>>       
>> mdadm --zero-superblock tries to guess the location of the superblock.
>> If more than one superblock is found, the one with the latest creation
>> time is being zeroed. So yes, the method you describe works and I think
>> it is the most reliable way to remove all superblocks of a device.
>>
>> Maybe we could teach mdadm --zero-superblock to honor the --metadata=x
>> option which would zero-out the region of the device where the
>> version-x superblock is located.
>>     
>
> Latest mdadm has this feature.
> And if --metadata= isn't given, it repeatedly trying to find and zero a
> superblock until no more superblocks can be found.
>   

That would be potentially a bad thing, people do run things like RAID1+5 
and might want to clear on block and save the other, still possibly part 
of a running array, one. I'm not sure that's a safe default behavior.

-- 
Bill Davidsen <davidsen@tmr.com>
  "We can't solve today's problems by using the same thinking we
   used in creating them." - Einstein


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zeroing multiple superblocks
  2010-02-01 21:22     ` Bill Davidsen
@ 2010-02-01 21:44       ` Neil Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Neil Brown @ 2010-02-01 21:44 UTC (permalink / raw)
  To: Bill Davidsen; +Cc: Andre Noll, Jim Paris, linux-raid

On Mon, 01 Feb 2010 16:22:25 -0500
Bill Davidsen <davidsen@tmr.com> wrote:

> Neil Brown wrote:
> > On Mon, 25 Jan 2010 10:52:21 +0100
> > Andre Noll <maan@systemlinux.org> wrote:
> >
> >   
> >> On 15:09, Jim Paris wrote:
> >>
> >>     
> >>> I guess the only way to be fully safe with the current approach is to
> >>> do a zero-superblock over and over until it complains.
> >>>       
> >> mdadm --zero-superblock tries to guess the location of the superblock.
> >> If more than one superblock is found, the one with the latest creation
> >> time is being zeroed. So yes, the method you describe works and I think
> >> it is the most reliable way to remove all superblocks of a device.
> >>
> >> Maybe we could teach mdadm --zero-superblock to honor the --metadata=x
> >> option which would zero-out the region of the device where the
> >> version-x superblock is located.
> >>     
> >
> > Latest mdadm has this feature.
> > And if --metadata= isn't given, it repeatedly trying to find and zero a
> > superblock until no more superblocks can be found.
> >   
> 
> That would be potentially a bad thing, people do run things like RAID1+5 
> and might want to clear on block and save the other, still possibly part 
> of a running array, one. I'm not sure that's a safe default behavior.
> 

The situation you describe would not normally cause any problems.
"mdadm --zero-superblock" only erases metadata that looks like valid
metadata at a valid location.
If you have a disk (sda) inside a RAID5 (md0) inside a RAID1 (md1),
then:
   mdadm --zero-superblock /dev/sda
would only see the metadata for the RAID5 and so would only clear that.
   mdadm --zero-superblock /dev/md0
would only see the metadata for the RAID1 and so would only clear that.
   mdadm --zero-superblock /dev/md1
would not see any metadata.

However, if you used v1.0 metadata for the RAID1, and v1.1 metadata for
the RAID5, then
   mdadm --zero-superblock /dev/sda

would see both and could erase both.
But then 
   mdadm --assemble
would also see both and get equally confused.

Also  if you are erasing the RAID5 metadata from sda, then it won't be
inclued in the RAID5, so it won't be included indirectly in the RAID1, so
remove the RAID1 metadata as well is no loss.

So I really don't think there is a problem here.   However if you can
describe a credible case which will cause a problem, I'd be very happy to
consider it.

Thanks,
NeilBrown

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-01 21:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-22 20:09 Zeroing multiple superblocks Jim Paris
2010-01-25  9:52 ` Andre Noll
2010-01-29 12:31   ` Neil Brown
2010-02-01 21:22     ` Bill Davidsen
2010-02-01 21:44       ` Neil Brown

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).