[PATCH] Forbid merging with partially assembled IMSM array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@xxxxxxxxx>

---
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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux