dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone
Blob Blame History Raw
commit f2cc4f7d829e1b849e78bdf6c38b7bd6e234c600
Author: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Date:   Tue May 9 12:25:45 2017 +0200

    imsm: don't allow disks with different sector size in one array
    
    As there is no support in IMSM for arrays including disks with different
    sector sizes, don't allow to create such configuration. Also skip the
    disk with unsuitable sector size when looking for spares in the same
    container.
    
    Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
    Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
    Signed-off-by: Jes Sorensen <jsorensen@fb.com>

diff --git a/super-intel.c b/super-intel.c
index cfb10d5..e88fe82 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5483,6 +5483,22 @@
 	return 1;
 }
 
+static int drive_validate_sector_size(struct intel_super *super, struct dl *dl)
+{
+	unsigned int member_sector_size;
+
+	if (dl->fd < 0) {
+		pr_err("Invalid file descriptor for %s\n", dl->devname);
+		return 0;
+	}
+
+	if (!get_dev_sector_size(dl->fd, dl->devname, &member_sector_size))
+		return 0;
+	if (member_sector_size != super->sector_size)
+		return 0;
+	return 1;
+}
+
 #ifndef MDASSEMBLE
 static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
 				     int fd, char *devname)
@@ -5523,6 +5539,11 @@
 		return 1;
 	}
 
+	if (!drive_validate_sector_size(super, dl)) {
+		pr_err("Combining drives of different sector size in one volume is not allowed\n");
+		return 1;
+	}
+
 	/* add a pristine spare to the metadata */
 	if (dl->index < 0) {
 		dl->index = super->anchor->num_disks;
@@ -8484,6 +8505,9 @@
 		if (dl->index == -1 && !activate_new)
 			continue;
 
+		if (!drive_validate_sector_size(super, dl))
+			continue;
+
 		/* Does this unused device have the requisite free space?
 		 * It needs to be able to cover all member volumes
 		 */