From f2cc4f7d829e1b849e78bdf6c38b7bd6e234c600 Mon Sep 17 00:00:00 2001 From: Alexey Obitotskiy Date: Tue, 9 May 2017 12:25:45 +0200 Subject: [PATCH] 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 Signed-off-by: Tomasz Majchrzak Signed-off-by: Jes Sorensen --- super-intel.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) Index: mdadm/super-intel.c =================================================================== --- mdadm.orig/super-intel.c +++ mdadm/super-intel.c @@ -5487,6 +5487,22 @@ static int init_super_imsm(struct supert 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) @@ -5527,6 +5543,11 @@ static int add_to_super_imsm_volume(stru 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; @@ -8490,6 +8511,9 @@ static struct dl *imsm_add_spare(struct 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 */