You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
4.1 KiB
154 lines
4.1 KiB
From 913f07d1db4a0078acc26d6ccabe1c315cf9273c Mon Sep 17 00:00:00 2001
|
|
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
Date: Thu, 20 Jan 2022 13:18:32 +0100
|
|
Subject: [PATCH 10/12] Create, Build: use default_layout()
|
|
|
|
This code is duplicated for Build mode so make default_layout() extern
|
|
and use it. Simplify the function structure.
|
|
|
|
It introduced change for Build mode, now for raid0 RAID0_ORIG_LAYOUT
|
|
will be returned same as for Create.
|
|
|
|
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
---
|
|
Build.c | 23 +------------------
|
|
Create.c | 67 ++++++++++++++++++++++++++++++++++----------------------
|
|
mdadm.h | 1 +
|
|
3 files changed, 43 insertions(+), 48 deletions(-)
|
|
|
|
diff --git a/Build.c b/Build.c
|
|
index 962c2e37..8d6f6f58 100644
|
|
--- a/Build.c
|
|
+++ b/Build.c
|
|
@@ -71,28 +71,7 @@ int Build(char *mddev, struct mddev_dev *devlist,
|
|
}
|
|
|
|
if (s->layout == UnSet)
|
|
- switch(s->level) {
|
|
- default: /* no layout */
|
|
- s->layout = 0;
|
|
- break;
|
|
- case 10:
|
|
- s->layout = 0x102; /* near=2, far=1 */
|
|
- if (c->verbose > 0)
|
|
- pr_err("layout defaults to n1\n");
|
|
- break;
|
|
- case 5:
|
|
- case 6:
|
|
- s->layout = map_name(r5layout, "default");
|
|
- if (c->verbose > 0)
|
|
- pr_err("layout defaults to %s\n", map_num(r5layout, s->layout));
|
|
- break;
|
|
- case LEVEL_FAULTY:
|
|
- s->layout = map_name(faultylayout, "default");
|
|
-
|
|
- if (c->verbose > 0)
|
|
- pr_err("layout defaults to %s\n", map_num(faultylayout, s->layout));
|
|
- break;
|
|
- }
|
|
+ s->layout = default_layout(NULL, s->level, c->verbose);
|
|
|
|
/* We need to create the device. It can have no name. */
|
|
map_lock(&map);
|
|
diff --git a/Create.c b/Create.c
|
|
index 0ff1922d..9ea19de0 100644
|
|
--- a/Create.c
|
|
+++ b/Create.c
|
|
@@ -39,39 +39,54 @@ static int round_size_and_verify(unsigned long long *size, int chunk)
|
|
return 0;
|
|
}
|
|
|
|
-static int default_layout(struct supertype *st, int level, int verbose)
|
|
+/**
|
|
+ * default_layout() - Get default layout for level.
|
|
+ * @st: metadata requested, could be NULL.
|
|
+ * @level: raid level requested.
|
|
+ * @verbose: verbose level.
|
|
+ *
|
|
+ * Try to ask metadata handler first, otherwise use global defaults.
|
|
+ *
|
|
+ * Return: Layout or &UnSet, return value meaning depends of level used.
|
|
+ */
|
|
+int default_layout(struct supertype *st, int level, int verbose)
|
|
{
|
|
int layout = UnSet;
|
|
+ mapping_t *layout_map = NULL;
|
|
+ char *layout_name = NULL;
|
|
|
|
if (st && st->ss->default_geometry)
|
|
st->ss->default_geometry(st, &level, &layout, NULL);
|
|
|
|
- if (layout == UnSet)
|
|
- switch(level) {
|
|
- default: /* no layout */
|
|
- layout = 0;
|
|
- break;
|
|
- case 0:
|
|
- layout = RAID0_ORIG_LAYOUT;
|
|
- break;
|
|
- case 10:
|
|
- layout = 0x102; /* near=2, far=1 */
|
|
- if (verbose > 0)
|
|
- pr_err("layout defaults to n2\n");
|
|
- break;
|
|
- case 5:
|
|
- case 6:
|
|
- layout = map_name(r5layout, "default");
|
|
- if (verbose > 0)
|
|
- pr_err("layout defaults to %s\n", map_num(r5layout, layout));
|
|
- break;
|
|
- case LEVEL_FAULTY:
|
|
- layout = map_name(faultylayout, "default");
|
|
+ if (layout != UnSet)
|
|
+ return layout;
|
|
|
|
- if (verbose > 0)
|
|
- pr_err("layout defaults to %s\n", map_num(faultylayout, layout));
|
|
- break;
|
|
- }
|
|
+ switch (level) {
|
|
+ default: /* no layout */
|
|
+ layout = 0;
|
|
+ break;
|
|
+ case 0:
|
|
+ layout = RAID0_ORIG_LAYOUT;
|
|
+ break;
|
|
+ case 10:
|
|
+ layout = 0x102; /* near=2, far=1 */
|
|
+ layout_name = "n2";
|
|
+ break;
|
|
+ case 5:
|
|
+ case 6:
|
|
+ layout_map = r5layout;
|
|
+ break;
|
|
+ case LEVEL_FAULTY:
|
|
+ layout_map = faultylayout;
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ if (layout_map) {
|
|
+ layout = map_name(layout_map, "default");
|
|
+ layout_name = map_num(layout_map, layout);
|
|
+ }
|
|
+ if (layout_name && verbose > 0)
|
|
+ pr_err("layout defaults to %s\n", layout_name);
|
|
|
|
return layout;
|
|
}
|
|
diff --git a/mdadm.h b/mdadm.h
|
|
index 26e7e5cd..cd72e711 100644
|
|
--- a/mdadm.h
|
|
+++ b/mdadm.h
|
|
@@ -1512,6 +1512,7 @@ extern int get_linux_version(void);
|
|
extern int mdadm_version(char *version);
|
|
extern unsigned long long parse_size(char *size);
|
|
extern int parse_uuid(char *str, int uuid[4]);
|
|
+int default_layout(struct supertype *st, int level, int verbose);
|
|
extern int is_near_layout_10(int layout);
|
|
extern int parse_layout_10(char *layout);
|
|
extern int parse_layout_faulty(char *layout);
|
|
--
|
|
2.31.1
|
|
|