mdadm/0128-imsm-imsm_get_free_size-refactor.patch
Xiao Ni 7552580e17 Rhel9.4 Update mdadm to latest upstream
Update to latest upstream and remove disable error patch. In upstream patch
55a1150c7, it adds more flags to let errors come out.

Signed-off-by: Xiao Ni <xni@redhat.com>
2023-11-03 13:40:19 +08:00

73 lines
2.2 KiB
Diff

From 5f027b9357c011ca0421400e258a777d97f18d17 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Mon, 29 May 2023 15:52:34 +0200
Subject: [PATCH 128/165] imsm: imsm_get_free_size() refactor.
Move minsize calculations up. Add error message if free size is too small.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
---
super-intel.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 26b20313..16a30ba7 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -7600,7 +7600,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level,
* @super: &intel_super pointer, not NULL.
* @raiddisks: number of raid disks.
* @size: requested size, could be 0 (means max size).
- * @chunk: requested chunk.
+ * @chunk: requested chunk size in KiB.
* @freesize: pointer for returned size value.
*
* Return: &IMSM_STATUS_OK or &IMSM_STATUS_ERROR.
@@ -7620,14 +7620,15 @@ static imsm_status_t imsm_get_free_size(struct intel_super *super,
struct dl *dl;
int i;
struct extent *e;
+ int cnt = 0;
+ int used = 0;
unsigned long long maxsize;
- unsigned long long minsize;
- int cnt;
- int used;
+ unsigned long long minsize = size;
+
+ if (minsize == 0)
+ minsize = chunk * 2;
/* find the largest common start free region of the possible disks */
- used = 0;
- cnt = 0;
for (dl = super->disks; dl; dl = dl->next) {
dl->raiddisk = -1;
@@ -7651,14 +7652,14 @@ static imsm_status_t imsm_get_free_size(struct intel_super *super,
}
maxsize = merge_extents(super);
- minsize = size;
- if (size == 0)
- /* chunk is in K */
- minsize = chunk * 2;
+ if (maxsize < minsize) {
+ pr_err("imsm: Free space is %llu but must be equal or larger than %llu.\n",
+ maxsize, minsize);
+ return IMSM_STATUS_ERROR;
+ }
- if (cnt < raiddisks || (super->orom && used && used != raiddisks) ||
- maxsize < minsize || maxsize == 0) {
- pr_err("not enough devices with space to create array.\n");
+ if (cnt < raiddisks || (super->orom && used && used != raiddisks)) {
+ pr_err("imsm: Not enough devices with space to create array.\n");
return IMSM_STATUS_ERROR;
}
--
2.40.1