linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Forbid merging with partially assembled IMSM array
@ 2014-05-30 14:36 Baldysiak, Pawel
  0 siblings, 0 replies; 10+ messages in thread
From: Baldysiak, Pawel @ 2014-05-30 14:36 UTC (permalink / raw)
  To: neilb@suse.de; +Cc: linux-raid@vger.kernel.org, Paszkiewicz, Artur

Changes introduced in commit:
0431869cec4c673309d9aa30a2df4b778bc0bd24
enabled adding devices to partially assembled array.
It causes assemble process to override checking controller of device.

For example:
If ones created IMSM array will be stopped, and some disks will be
attached to different controller, mdadm will allow to fully assemble this
array as one md device (due to marge one part to another).

This patch resolve this problem by forbidding merge operation
on arrays with IMSM metadata.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>

---
Assemble.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/Assemble.c b/Assemble.c
index a57d384..9fb65e5 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1329,6 +1329,29 @@ try_again:
                                               return 1;
                               }
                               for (dv = pre_exist->devs; dv; dv = dv->next) {
+                                             if (strncmp(mp->metadata, "imsm", 4) == 0 && !c->force) {
+                                                             int dfd;
+                                                             char dn[20];
+                                                             struct supertype *st2;
+                                                             sprintf(dn, "%d:%d", dv->disk.major,
+                                                                                             dv->disk.minor);
+                                                             st2 = dup_super(st);
+                                                             dfd = dev_open(dn, O_RDONLY);
+                                                             if ((dfd > 0) && (st2->ss->load_super(st2, dfd, NULL) ||
+                                                                  (st->ss->compare_super(st, st2) != 0))) {
+                                                                             pr_err("IMSM metadata mismatch!\n");
+                                                                             pr_err("Aborting...\n");
+                                                                             close(dfd);
+                                                             } else {
+                                                                             pr_err("IMSM Array already partially assembled!\n");
+                                                                             pr_err("Aborting...\n");
+                                                             }
+                                                             if (st2) {
+                                                                             st2->ss->free_super(st2);
+                                                                             free(st2);
+                                                             }
+                                                             return 1;
+                                             }
                                               /* We want to add this device to our list,
                                                * but it could already be there if "mdadm -I"
                                                * started *after* we checked for O_EXCL.
-- 
1.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-07-08  2:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <84A53BEA6EAC69439B7E311E9B17A76F07918BDA@IRSMSX105.ger.corp.intel.com>
2014-06-02  2:19 ` [PATCH] Forbid merging with partially assembled IMSM array NeilBrown
2014-06-03  9:03   ` Baldysiak, Pawel
2014-06-04  2:30     ` NeilBrown
2014-06-04  9:25       ` Baldysiak, Pawel
2014-06-05  6:27         ` NeilBrown
2014-06-13  9:48           ` Baldysiak, Pawel
2014-06-25  4:15             ` NeilBrown
2014-06-30 12:22               ` Baldysiak, Pawel
2014-07-08  2:00                 ` NeilBrown
2014-05-30 14:36 Baldysiak, Pawel

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