[PATCH] Do not assemble a duplicate of a running array
Yury Polyanskiy
yp at mit.edu
Thu Jul 14 12:21:05 UTC 2011
Dear Neil,
On Thu, Jul 14, 2011 at 3:30 AM, NeilBrown <neilb at suse.de> wrote:
> I think it is probably much simpler to fix than your attempt.
BTW, I forgot to say that I checked the patch and it works fine of course.
> Something like this:
>
> diff --git a/Assemble.c b/Assemble.c
> index 25cfec1..86b6e95 100644
> --- a/Assemble.c
> +++ b/Assemble.c
> @@ -616,6 +616,17 @@ int Assemble(struct supertype *st, char *mddev,
> if (!st || !st->sb || !content)
> return 2;
>
> + {
> + int uuid[4];
> + struct map_ent *mp = NULL;
> + st->ss->uuid_from_super(st, uuid);
> + if (map_by_uuid(&mp, uuid)) {
> + map_free(mp);
> + fprintf(stderr, Name ": Not assembling array as uuid already in use\n");
> + return 1;
> + }
> + map_free(mp);
> + }
> /* Now need to open the array device. Use create_mddev */
> if (content == &info)
> st->ss->getinfo_super(st, content, NULL);
>
>
I thought about checking via mdmap, but decided against it. The check
is so crucial for data integrity that I think it is not a good idea to
introduce dependence on such an unreliable thing as
availability/coherence of mdmap (what if it is stale? Not synchronized
because of readonly root partition?). Much simpler to document and
more robust is to check an UUID on a physical drive, IMHO.
> is what I'm thinking of - it seems to work for me, I'd appreciate it if you
> can confirm that it works for you.
>
> My concern though is that someone might genuinely want to assemble two arrays
> with the same uuid.
Exactly, that's the reason I didn't include it in the Assemble(),
because somebody might want to do something like this, but he will
have to do it manually (--assemble /dev/md1 <drives>). --assemble
--scan should never find two arrays specified via the same UUIDs in
the config file (hence the check for uuid_set).
Let me know what you think,
Yury
More information about the pkg-mdadm-devel
mailing list