|
|
5eacff |
From 22dc741f63e6403d59c2c14f56fd4791265f9bbb Mon Sep 17 00:00:00 2001
|
|
|
5eacff |
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
|
|
|
5eacff |
Date: Mon, 1 Apr 2019 16:53:41 +0200
|
|
|
5eacff |
Subject: [RHEL7.7 PATCH 23/24] Create: Block rounding size to max
|
|
|
5eacff |
|
|
|
5eacff |
When passed size is smaller than chunk, mdadm rounds it to 0 but 0 there
|
|
|
5eacff |
means max available space.
|
|
|
5eacff |
Block it for every metadata. Remove the same check from imsm routine.
|
|
|
5eacff |
|
|
|
5eacff |
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
|
|
|
5eacff |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
5eacff |
---
|
|
|
5eacff |
Create.c | 23 ++++++++++++++++++++---
|
|
|
5eacff |
super-intel.c | 5 ++---
|
|
|
5eacff |
2 files changed, 22 insertions(+), 6 deletions(-)
|
|
|
5eacff |
|
|
|
5eacff |
diff --git a/Create.c b/Create.c
|
|
|
5eacff |
index 6f1b228..292f92a 100644
|
|
|
5eacff |
--- a/Create.c
|
|
|
5eacff |
+++ b/Create.c
|
|
|
5eacff |
@@ -27,6 +27,18 @@
|
|
|
5eacff |
#include "md_p.h"
|
|
|
5eacff |
#include <ctype.h>
|
|
|
5eacff |
|
|
|
5eacff |
+static int round_size_and_verify(unsigned long long *size, int chunk)
|
|
|
5eacff |
+{
|
|
|
5eacff |
+ if (*size == 0)
|
|
|
5eacff |
+ return 0;
|
|
|
5eacff |
+ *size &= ~(unsigned long long)(chunk - 1);
|
|
|
5eacff |
+ if (*size == 0) {
|
|
|
5eacff |
+ pr_err("Size cannot be smaller than chunk.\n");
|
|
|
5eacff |
+ return 1;
|
|
|
5eacff |
+ }
|
|
|
5eacff |
+ return 0;
|
|
|
5eacff |
+}
|
|
|
5eacff |
+
|
|
|
5eacff |
static int default_layout(struct supertype *st, int level, int verbose)
|
|
|
5eacff |
{
|
|
|
5eacff |
int layout = UnSet;
|
|
|
5eacff |
@@ -248,11 +260,14 @@ int Create(struct supertype *st, char *mddev,
|
|
|
5eacff |
pr_err("unknown level %d\n", s->level);
|
|
|
5eacff |
return 1;
|
|
|
5eacff |
}
|
|
|
5eacff |
+
|
|
|
5eacff |
if (s->size == MAX_SIZE)
|
|
|
5eacff |
/* use '0' to mean 'max' now... */
|
|
|
5eacff |
s->size = 0;
|
|
|
5eacff |
if (s->size && s->chunk && s->chunk != UnSet)
|
|
|
5eacff |
- s->size &= ~(unsigned long long)(s->chunk - 1);
|
|
|
5eacff |
+ if (round_size_and_verify(&s->size, s->chunk))
|
|
|
5eacff |
+ return 1;
|
|
|
5eacff |
+
|
|
|
5eacff |
newsize = s->size * 2;
|
|
|
5eacff |
if (st && ! st->ss->validate_geometry(st, s->level, s->layout, s->raiddisks,
|
|
|
5eacff |
&s->chunk, s->size*2,
|
|
|
5eacff |
@@ -267,7 +282,8 @@ int Create(struct supertype *st, char *mddev,
|
|
|
5eacff |
/* default chunk was just set */
|
|
|
5eacff |
if (c->verbose > 0)
|
|
|
5eacff |
pr_err("chunk size defaults to %dK\n", s->chunk);
|
|
|
5eacff |
- s->size &= ~(unsigned long long)(s->chunk - 1);
|
|
|
5eacff |
+ if (round_size_and_verify(&s->size, s->chunk))
|
|
|
5eacff |
+ return 1;
|
|
|
5eacff |
do_default_chunk = 0;
|
|
|
5eacff |
}
|
|
|
5eacff |
}
|
|
|
5eacff |
@@ -413,7 +429,8 @@ int Create(struct supertype *st, char *mddev,
|
|
|
5eacff |
/* default chunk was just set */
|
|
|
5eacff |
if (c->verbose > 0)
|
|
|
5eacff |
pr_err("chunk size defaults to %dK\n", s->chunk);
|
|
|
5eacff |
- s->size &= ~(unsigned long long)(s->chunk - 1);
|
|
|
5eacff |
+ if (round_size_and_verify(&s->size, s->chunk))
|
|
|
5eacff |
+ return 1;
|
|
|
5eacff |
do_default_chunk = 0;
|
|
|
5eacff |
}
|
|
|
5eacff |
}
|
|
|
5eacff |
diff --git a/super-intel.c b/super-intel.c
|
|
|
5eacff |
index 5a7c9f8..2ba045a 100644
|
|
|
5eacff |
--- a/super-intel.c
|
|
|
5eacff |
+++ b/super-intel.c
|
|
|
5eacff |
@@ -7455,9 +7455,8 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
|
|
|
5eacff |
verbose);
|
|
|
5eacff |
}
|
|
|
5eacff |
|
|
|
5eacff |
- if (size && ((size < 1024) || (*chunk != UnSet &&
|
|
|
5eacff |
- size < (unsigned long long) *chunk))) {
|
|
|
5eacff |
- pr_err("Given size must be greater than 1M and chunk size.\n");
|
|
|
5eacff |
+ if (size && (size < 1024)) {
|
|
|
5eacff |
+ pr_err("Given size must be greater than 1M.\n");
|
|
|
5eacff |
/* Depends on algorithm in Create.c :
|
|
|
5eacff |
* if container was given (dev == NULL) return -1,
|
|
|
5eacff |
* if block device was given ( dev != NULL) return 0.
|
|
|
5eacff |
--
|
|
|
5eacff |
2.7.5
|
|
|
5eacff |
|