From: Geoff Back <geoff@demonlair.co.uk>
To: Song Liu <song@kernel.org>
Cc: linux-raid@vger.kernel.org
Subject: Patch to fix boot from RAID-1 partitioned arrays
Date: Wed, 12 May 2021 09:41:53 +0100 [thread overview]
Message-ID: <d9e1f759-3a11-1d63-f16c-8b999190c633@demonlair.co.uk> (raw)
Good morning.
I have had problems in all recent kernels with booting directly from MD
RAID-1 partitioned arrays (i.e. without using an initrd).
All the usual requirements - building md and raid1 into the kernel,
correct partition types, etc - are correct.
Deep investigation has led me to conclude that the issue is caused by
boot-time assembly of the array not reading the partition table, meaning
that the partitions are not visible and cannot be mounted as root
filesystem.
The change to drivers/md/md-autodetect.c in commit
a1d6bc018911390274e3904bdd28240cd96ddc54 appears to be related, although
this only covers some cases not all, so I have not been able to
determine exactly what commit led to this problem.
I have implemented a patch that causes the partition table to be read
immediately after the array is started, for the two boot-time assembly
paths (from autodetect with raid=part, and from assembly with md=d0,...)
which is included below.
Regards,
Geoff.
diff -Naur linux-5.12.2.orig/drivers/md/md-autodetect.c
linux-5.12.2/drivers/md/md-autodetect.c
--- linux-5.12.2.orig/drivers/md/md-autodetect.c 2021-05-12
09:14:07.096442083 +0100
+++ linux-5.12.2/drivers/md/md-autodetect.c 2021-05-12
09:22:07.734653840 +0100
@@ -232,8 +232,24 @@
mddev_unlock(mddev);
out_blkdev_put:
blkdev_put(bdev, FMODE_READ);
-}
+ /*
+ * Need to force read of partition table in order for partitioned
+ * arrays to be bootable. Deliberately done after all cleanup,
+ * and only for successfully loaded arrays.
+ */
+ if (err == 0)
+ {
+ struct block_device *bd;
+
+ bd = blkdev_get_by_dev(mdev, FMODE_READ, NULL);
+ if (IS_ERR(bd))
+ pr_err("md: failed to get md device\n");
+ else
+ blkdev_put(bd, FMODE_READ);
+ }
+}
+
static int __init raid_setup(char *str)
{
int len, pos;
diff -Naur linux-5.12.2.orig/drivers/md/md.c linux-5.12.2/drivers/md/md.c
--- linux-5.12.2.orig/drivers/md/md.c 2021-05-12 09:14:07.127441838 +0100
+++ linux-5.12.2/drivers/md/md.c 2021-05-12 09:34:26.960827487 +0100
@@ -6467,6 +6467,20 @@
pr_warn("md: do_md_run() returned %d\n", err);
do_md_stop(mddev, 0, NULL);
}
+ else
+ {
+ /*
+ * Need to force read of partition table in order for partitioned
+ * arrays to be bootable.
+ */
+ struct block_device *bd;
+
+ bd = blkdev_get_by_dev(mdev, FMODE_READ, NULL);
+ if (IS_ERR(bd))
+ pr_err("md: failed to get md device\n");
+ else
+ blkdev_put(bd, FMODE_READ);
+ }
}
/*
--
Geoff Back
What if we're all just characters in someone's nightmares?
next reply other threads:[~2021-05-12 8:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 8:41 Geoff Back [this message]
2021-05-12 9:11 ` Patch to fix boot from RAID-1 partitioned arrays Geoff Back
2021-05-12 11:07 ` Wols Lists
2021-05-12 10:56 ` Geoff Back
2021-05-12 22:18 ` J. Brian Kelley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9e1f759-3a11-1d63-f16c-8b999190c633@demonlair.co.uk \
--to=geoff@demonlair.co.uk \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.