On Wed, Sep 06, 2017 at 07:10:15PM +0200, Patrick Wildt wrote:
> On Wed, Sep 06, 2017 at 05:44:21PM +0200, Patrick Wildt wrote:
> > Hi,
> > 
> > I'm testing some SoftRAID in a Mirroring setup and stumbled upon
> > something.  When I set a disk offline, zero out the disk and the
> > metadata blocks, reboot, and then try to assemble it, it will
> > fail.  Rightfully so, since the metadata information is completely
> > gone from one disk.  That's not a reassemble, that's a rebuild.
> > 
> > Now in the case that I want to actually force a whole new RAID
> > it looks like I have to pass -C force, to clear the metadata and
> > force creation of a new RAID.  Unfortunately this does not work,
> > because sr_meta_native_attach(), which is called by
> > sr_meta_native_attach(), wants to make sure that all devices are
> > either non-SoftRAID or SoftRAID.  Now in my case the disks are
> > kinda both.  One zeroed, one not.  In that case sr && not_sr is
> > true and it will exit with "not all chunks are of the native
> > metadata format".
> > 
> > Is there a reason that sr_meta_attach() has to be called before
> > clearing the metadata on force?
> > 
> > Untested diff below.
> > 
> > Patrick
> 
> Ah, well, sr_meta_clear() memsets sd->sd_meta, which is only later
> allocated during sr_meta_native_attach(), and sr_meta_read() of
> course also makes use of it.  Maybe sr_meta_native_attach() can
> be more lax.

Simply ignoring the "incorrect" metadata format when we are forcing
assembly (and thus clearing the metadata) makes it work.

Opinions?

Patrick

diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 8b75f238072..b46cc9e27a4 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1658,7 +1658,7 @@ sr_meta_native_attach(struct sr_discipline *sd, int force)
                        not_sr++;
        }
 
-       if (sr && not_sr) {
+       if (sr && not_sr && !force) {
                sr_error(sc, "not all chunks are of the native metadata "
                    "format");
                goto bad;

Reply via email to