dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/dont-allow-disks-with-different-sector-size-in-one.patch

dd3a91
commit f2cc4f7d829e1b849e78bdf6c38b7bd6e234c600
dd3a91
Author: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
dd3a91
Date:   Tue May 9 12:25:45 2017 +0200
dd3a91
dd3a91
    imsm: don't allow disks with different sector size in one array
dd3a91
    
dd3a91
    As there is no support in IMSM for arrays including disks with different
dd3a91
    sector sizes, don't allow to create such configuration. Also skip the
dd3a91
    disk with unsuitable sector size when looking for spares in the same
dd3a91
    container.
dd3a91
    
dd3a91
    Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
dd3a91
    Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
dd3a91
    Signed-off-by: Jes Sorensen <jsorensen@fb.com>
dd3a91
dd3a91
diff --git a/super-intel.c b/super-intel.c
dd3a91
index cfb10d5..e88fe82 100644
dd3a91
--- a/super-intel.c
dd3a91
+++ b/super-intel.c
dd3a91
@@ -5483,6 +5483,22 @@
dd3a91
 	return 1;
dd3a91
 }
dd3a91
 
dd3a91
+static int drive_validate_sector_size(struct intel_super *super, struct dl *dl)
dd3a91
+{
dd3a91
+	unsigned int member_sector_size;
dd3a91
+
dd3a91
+	if (dl->fd < 0) {
dd3a91
+		pr_err("Invalid file descriptor for %s\n", dl->devname);
dd3a91
+		return 0;
dd3a91
+	}
dd3a91
+
dd3a91
+	if (!get_dev_sector_size(dl->fd, dl->devname, &member_sector_size))
dd3a91
+		return 0;
dd3a91
+	if (member_sector_size != super->sector_size)
dd3a91
+		return 0;
dd3a91
+	return 1;
dd3a91
+}
dd3a91
+
dd3a91
 #ifndef MDASSEMBLE
dd3a91
 static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
dd3a91
 				     int fd, char *devname)
dd3a91
@@ -5523,6 +5539,11 @@
dd3a91
 		return 1;
dd3a91
 	}
dd3a91
 
dd3a91
+	if (!drive_validate_sector_size(super, dl)) {
dd3a91
+		pr_err("Combining drives of different sector size in one volume is not allowed\n");
dd3a91
+		return 1;
dd3a91
+	}
dd3a91
+
dd3a91
 	/* add a pristine spare to the metadata */
dd3a91
 	if (dl->index < 0) {
dd3a91
 		dl->index = super->anchor->num_disks;
dd3a91
@@ -8484,6 +8505,9 @@
dd3a91
 		if (dl->index == -1 && !activate_new)
dd3a91
 			continue;
dd3a91
 
dd3a91
+		if (!drive_validate_sector_size(super, dl))
dd3a91
+			continue;
dd3a91
+
dd3a91
 		/* Does this unused device have the requisite free space?
dd3a91
 		 * It needs to be able to cover all member volumes
dd3a91
 		 */