From 4601438be1c74650fba791b0603c6111b7570a66acf2e8a5a39f0e54bcf9c1a5 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sun, 5 Sep 2021 22:27:54 +0000 Subject: [PATCH] Accepting request 915689 from home:colyli:branches:Base:System - Remove Spare drives line from details for external metadata (bsc#1180661, bsc#1182642) 0118-Remove-Spare-drives-line-from-details-for-external-m.patch - Don't associate spares with other arrays during RAID Examine (bsc#1180661, bsc#1182642) 0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch OBS-URL: https://build.opensuse.org/request/show/915689 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=199 --- ...ves-line-from-details-for-external-m.patch | 38 ++++ ...spares-with-other-arrays-during-RAID.patch | 168 ++++++++++++++++++ mdadm.changes | 10 ++ mdadm.spec | 4 + 4 files changed, 220 insertions(+) create mode 100644 0118-Remove-Spare-drives-line-from-details-for-external-m.patch create mode 100644 0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch diff --git a/0118-Remove-Spare-drives-line-from-details-for-external-m.patch b/0118-Remove-Spare-drives-line-from-details-for-external-m.patch new file mode 100644 index 0000000..5a3eb88 --- /dev/null +++ b/0118-Remove-Spare-drives-line-from-details-for-external-m.patch @@ -0,0 +1,38 @@ +From 8d69bf147ec77447c5d45c17bed7dc017808cc44 Mon Sep 17 00:00:00 2001 +From: Oleksandr Shchirskyi +Date: Fri, 18 Jun 2021 15:53:31 +0200 +Subject: [PATCH] Remove Spare drives line from details for external metadata +Git-commit: 8d69bf147ec77447c5d45c17bed7dc017808cc44 +Patch-mainline: mdadm-4.1+ +References: bsc#1180661, bsc#1182642 + +Arrays with external metadata do not have spare disks directly +assigned to volumes; spare disks belong to containers and are +moved to arrays when the array is degraded/reshaping. +Thus, the display of zero spare disks in volume details is +incorrect and can be confusing. + +Signed-off-by: Oleksandr Shchirskyi +Signed-off-by: Jes Sorensen +Acked-by: Coly Li +--- + Detail.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/Detail.c b/Detail.c +index cd26fb0..ad56344 100644 +--- a/Detail.c ++++ b/Detail.c +@@ -548,7 +548,8 @@ int Detail(char *dev, struct context *c) + array.working_disks); + if (array.raid_disks) { + printf(" Failed Devices : %d\n", array.failed_disks); +- printf(" Spare Devices : %d\n", array.spare_disks); ++ if (!external) ++ printf(" Spare Devices : %d\n", array.spare_disks); + } + printf("\n"); + if (array.level == 5) { +-- +2.31.1 + diff --git a/0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch b/0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch new file mode 100644 index 0000000..1bb609a --- /dev/null +++ b/0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch @@ -0,0 +1,168 @@ +From 601ffa784f03cea843b9b732e561ffea0b8c036f Mon Sep 17 00:00:00 2001 +From: Oleksandr Shchirskyi +Date: Fri, 18 Jun 2021 15:53:32 +0200 +Subject: [PATCH] Don't associate spares with other arrays during RAID Examine +Git-commit: 601ffa784f03cea843b9b732e561ffea0b8c036f +Patch-mainline: mdadm-4.1+ +References: bsc#1180661, bsc#1182642 + +Spares in imsm belong to containers, not volumes, and must go into +a separate container when assembling the RAID. +Remove association spares with other arrays and make Examine print +separate containers for spares. +Auto assemble without config file already works like this. So make +creating a config file and assembling from it consistent with auto +assemble. +With this change, mdadm -Es will add this line to output if spares +are found: +ARRAY metadata=imsm UUID=00000000:00000000:00000000:00000000 + +Signed-off-by: Oleksandr Shchirskyi +Signed-off-by: Jes Sorensen +Acked-by: Coly Li +--- + Examine.c | 2 +- + super-intel.c | 74 +++++++++++++-------------------------------------- + 2 files changed, 20 insertions(+), 56 deletions(-) + +Index: mdadm-4.1/Examine.c +=================================================================== +--- mdadm-4.1.orig/Examine.c ++++ mdadm-4.1/Examine.c +@@ -166,7 +166,7 @@ int Examine(struct mddev_dev *devlist, + int newline = 0; + + ap->st->ss->brief_examine_super(ap->st, c->verbose > 0); +- if (ap->spares) ++ if (ap->spares && !ap->st->ss->external) + newline += printf(" spares=%d", ap->spares); + if (c->verbose > 0) { + newline += printf(" devices"); +Index: mdadm-4.1/super-intel.c +=================================================================== +--- mdadm-4.1.orig/super-intel.c ++++ mdadm-4.1/super-intel.c +@@ -2084,12 +2084,6 @@ static void brief_examine_super_imsm(str + /* We just write a generic IMSM ARRAY entry */ + struct mdinfo info; + char nbuf[64]; +- struct intel_super *super = st->sb; +- +- if (!super->anchor->num_raid_devs) { +- printf("ARRAY metadata=imsm\n"); +- return; +- } + + getinfo_super_imsm(st, &info, NULL); + fname_from_uuid(st, &info, nbuf, ':'); +@@ -3835,12 +3829,9 @@ static void imsm_copy_dev(struct imsm_de + + static int compare_super_imsm(struct supertype *st, struct supertype *tst) + { +- /* +- * return: ++ /* return: + * 0 same, or first was empty, and second was copied +- * 1 second had wrong number +- * 2 wrong uuid +- * 3 wrong other info ++ * 1 sb are different + */ + struct intel_super *first = st->sb; + struct intel_super *sec = tst->sb; +@@ -3852,27 +3843,27 @@ static int compare_super_imsm(struct sup + } + /* in platform dependent environment test if the disks + * use the same Intel hba +- * If not on Intel hba at all, allow anything. ++ * if not on Intel hba at all, allow anything. ++ * doesn't check HBAs if num_raid_devs is not set, as it means ++ * it is a free floating spare, and all spares regardless of HBA type ++ * will fall into separate container during the assembly + */ +- if (!check_env("IMSM_NO_PLATFORM") && first->hba && sec->hba) { ++ if (first->hba && sec->hba && first->anchor->num_raid_devs != 0) { + if (first->hba->type != sec->hba->type) { + fprintf(stderr, + "HBAs of devices do not match %s != %s\n", + get_sys_dev_type(first->hba->type), + get_sys_dev_type(sec->hba->type)); +- return 3; ++ return 1; + } + if (first->orom != sec->orom) { + fprintf(stderr, + "HBAs of devices do not match %s != %s\n", + first->hba->pci_id, sec->hba->pci_id); +- return 3; ++ return 1; + } + } + +- /* if an anchor does not have num_raid_devs set then it is a free +- * floating spare +- */ + if (first->anchor->num_raid_devs > 0 && + sec->anchor->num_raid_devs > 0) { + /* Determine if these disks might ever have been +@@ -3884,7 +3875,7 @@ static int compare_super_imsm(struct sup + + if (memcmp(first->anchor->sig, sec->anchor->sig, + MAX_SIGNATURE_LENGTH) != 0) +- return 3; ++ return 1; + + if (first_family == 0) + first_family = first->anchor->family_num; +@@ -3892,43 +3883,17 @@ static int compare_super_imsm(struct sup + sec_family = sec->anchor->family_num; + + if (first_family != sec_family) +- return 3; ++ return 1; + + } + +- /* if 'first' is a spare promote it to a populated mpb with sec's +- * family number +- */ +- if (first->anchor->num_raid_devs == 0 && +- sec->anchor->num_raid_devs > 0) { +- int i; +- struct intel_dev *dv; +- struct imsm_dev *dev; +- +- /* we need to copy raid device info from sec if an allocation +- * fails here we don't associate the spare +- */ +- for (i = 0; i < sec->anchor->num_raid_devs; i++) { +- dv = xmalloc(sizeof(*dv)); +- dev = xmalloc(sizeof_imsm_dev(get_imsm_dev(sec, i), 1)); +- dv->dev = dev; +- dv->index = i; +- dv->next = first->devlist; +- first->devlist = dv; +- } +- if (i < sec->anchor->num_raid_devs) { +- /* allocation failure */ +- free_devlist(first); +- pr_err("imsm: failed to associate spare\n"); +- return 3; +- } +- first->anchor->num_raid_devs = sec->anchor->num_raid_devs; +- first->anchor->orig_family_num = sec->anchor->orig_family_num; +- first->anchor->family_num = sec->anchor->family_num; +- memcpy(first->anchor->sig, sec->anchor->sig, MAX_SIGNATURE_LENGTH); +- for (i = 0; i < sec->anchor->num_raid_devs; i++) +- imsm_copy_dev(get_imsm_dev(first, i), get_imsm_dev(sec, i)); +- } ++ /* if an anchor does not have num_raid_devs set then it is a free ++ * floating spare. don't assosiate spare with any array, as during assembly ++ * spares shall fall into separate container, from which they can be moved ++ * when necessary ++ */ ++ if (first->anchor->num_raid_devs ^ sec->anchor->num_raid_devs) ++ return 1; + + return 0; + } diff --git a/mdadm.changes b/mdadm.changes index 485d665..53b60f3 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Sep 2 05:17:18 UTC 2021 - Coly Li + +- Remove Spare drives line from details for external metadata + (bsc#1180661, bsc#1182642) + 0118-Remove-Spare-drives-line-from-details-for-external-m.patch +- Don't associate spares with other arrays during RAID Examine + (bsc#1180661, bsc#1182642) + 0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch + ------------------------------------------------------------------- Fri May 14 14:40:40 UTC 2021 - Coly Li diff --git a/mdadm.spec b/mdadm.spec index 9743525..7151a40 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -154,6 +154,8 @@ Patch114: 0114-super1-fix-Floating-point-exception.patch Patch115: 0115-super1.c-avoid-useless-sync-when-bitmap-switches-fro.patch Patch116: 0116-imsm-nvme-multipath-support.patch Patch117: 0117-Grow-be-careful-of-corrupt-dev_roles-list.patch +Patch118: 0118-Remove-Spare-drives-line-from-details-for-external-m.patch +Patch119: 0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch Patch1001: 1001-display-timeout-status.patch Patch1002: 1002-OnCalendar-format-fix-of-mdcheck_start-timer.patch Patch1003: 1003-mdadm-treat-the-Dell-softraid-array-as-local-array.patch @@ -278,6 +280,8 @@ mdadm is a program that can be used to control Linux md devices. %patch115 -p1 %patch116 -p1 %patch117 -p1 +%patch118 -p1 +%patch119 -p1 %patch1001 -p1 %patch1002 -p1 %patch1003 -p1