Skip to content

Commit 5e0a4e4

Browse files
mvollmermartinpitt
authored andcommitted
storage: Use mdraid metadata version 1.0 when in Anaconda mode
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2352953
1 parent 7293564 commit 5e0a4e4

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

pkg/storaged/mdraid/create-dialog.jsx

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,45 @@
2020
import cockpit from "cockpit";
2121
import client from "../client";
2222

23-
import { mdraid_name, validate_mdraid_name, get_available_spaces, prepare_available_spaces } from "../utils.js";
23+
import {
24+
mdraid_name, validate_mdraid_name, get_available_spaces, prepare_available_spaces,
25+
encode_filename, decode_filename
26+
} from "../utils.js";
2427
import { dialog_open, TextInput, SelectOne, SelectSpaces } from "../dialog.jsx";
2528

2629
const _ = cockpit.gettext;
2730

31+
async function mdraid_create(members, level, name, chunk, metadata_version) {
32+
if (!metadata_version || client.at_least("2.11")) {
33+
const opts = { };
34+
if (metadata_version)
35+
opts.version = { t: "ay", v: encode_filename(metadata_version) };
36+
await client.manager.MDRaidCreate(members, level, name, chunk, opts);
37+
} else {
38+
// Let's call mdadm explicitly if we need to set the metadata
39+
// version and UDisks2 is older than 2.11.
40+
41+
// The member block devices are all empty already and we don't
42+
// need to wipe them. We need to wait for their D-Bus proxies
43+
// since they might have just been created by
44+
// prepare_available_spaces.
45+
46+
const devs = [];
47+
for (const path of members) {
48+
devs.push(decode_filename((await client.wait_for(() => client.blocks[path])).PreferredDevice));
49+
}
50+
51+
await cockpit.spawn([
52+
"mdadm", "--create", name, "--run",
53+
"--level=" + level,
54+
...(chunk ? ["--chunk=" + String(chunk / 1024)] : []),
55+
"--metadata=" + metadata_version,
56+
"--raid-devices=" + String(devs.length),
57+
...devs
58+
], { superuser: "require", err: "message" });
59+
}
60+
}
61+
2862
export function create_mdraid() {
2963
function mdraid_exists(name) {
3064
for (const p in client.mdraids) {
@@ -111,10 +145,14 @@ export function create_mdraid() {
111145
Action: {
112146
Title: _("Create"),
113147
action: function (vals) {
148+
// When in Anaconda mode, we explicitly use metadata
149+
// version 1.0 since the default doesn't work for
150+
// things that the bootloaders need to access.
151+
//
152+
const metadata_version = client.in_anaconda_mode() ? "1.0" : null;
153+
114154
return prepare_available_spaces(client, vals.disks).then(paths => {
115-
return client.manager.MDRaidCreate(paths, vals.level,
116-
vals.name, (vals.chunk || 0) * 1024,
117-
{ });
155+
return mdraid_create(paths, vals.level, vals.name, (vals.chunk || 0) * 1024, metadata_version);
118156
});
119157
}
120158
}

test/verify/check-storage-anaconda

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ class TestStorageAnaconda(storagelib.StorageCase):
479479

480480
def testMDRaid(self):
481481
b = self.browser
482+
m = self.machine
482483

483484
disk1 = self.add_loopback_disk(name="loop10")
484485
disk2 = self.add_loopback_disk(name="loop11")
@@ -503,6 +504,9 @@ class TestStorageAnaconda(storagelib.StorageCase):
503504
# Stop the raid array in case the test fails otherwise losetup can't release the devices
504505
self.addCleanup(self.machine.execute, "if [ -b /dev/md/raid0 ]; then mdadm --stop /dev/md/raid0; fi;")
505506

507+
# Check that metadata version is "1.0"
508+
self.assertIn("Version : 1.0", m.execute("mdadm --detail /dev/md/raid0"))
509+
506510
# Create a partition with a filesystem on it
507511
self.click_dropdown(self.card_row("Storage", name="md/raid0"), "Create partition table")
508512
self.confirm()

test/verify/check-storage-mdraid

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class TestStorageMdRaid(storagelib.StorageCase):
111111
self.dialog_wait_close()
112112
b.wait_visible(self.card_row("Storage", name="/dev/md/raid0"))
113113

114+
# Check that metadata version is "1.2"
115+
self.assertIn("Version : 1.2", m.execute("mdadm --detail /dev/md/raid0"))
116+
114117
self.addCleanup(m.execute, "if [ -e /dev/md/raid0 ]; then mdadm --stop /dev/md/raid0; fi")
115118
self.addCleanup(m.execute, "mount | grep ^/dev/md | cut -f1 -d' ' | xargs -r umount")
116119

0 commit comments

Comments
 (0)