From 43cbe5bff6629c463463325cebb7e87b291b4a73 Mon Sep 17 00:00:00 2001 From: kn Date: Thu, 4 Aug 2022 09:16:53 +0000 Subject: [PATCH] Default to softraid on boot-device iff found root on softraid on sparc64 currently requires explicitly passing the volume name as part of the boot arguments, e.g. boot-file=sr0 boot-file=sr0a:/bsd or {ok} boot my-devalias sr0: (ofwboot always probes for softraid devices, assembles them but continues to ignore such volumes unless specified.) This is inconsistent with softraid support on other platforms and has further drawbacks when it comes to sysupgrade logic. Unless an explicit root disk was given, make ofwboot default to the softraid volume on the boot device to make root on softraid work out of the box without having to set variables or pass arguments in OpenBoot. Eventually, ofwboot's disk discovery and softraid assembly machinery will be fixed and boot-file won't be misused for softraid purposes anymore. Remove the quirky softraid paragraph from boot_sparc64(8) now that it is purely optional, expecting users from now on to either leave boot-file empty or pass a kernel filename alone. Tested on T4-2 guest domains with and without root on softraid. Feedback claudio kettenis stsp OK kettenis (previous diff) OK stsp --- share/man/man8/man8.sparc64/boot_sparc64.8 | 23 +++-------------- sys/arch/sparc64/stand/ofwboot/boot.c | 29 ++++++++++++++++++++-- sys/arch/sparc64/stand/ofwboot/vers.c | 2 +- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/share/man/man8/man8.sparc64/boot_sparc64.8 b/share/man/man8/man8.sparc64/boot_sparc64.8 index 9705046704a..90d9339f93c 100644 --- a/share/man/man8/man8.sparc64/boot_sparc64.8 +++ b/share/man/man8/man8.sparc64/boot_sparc64.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: boot_sparc64.8,v 1.16 2015/10/03 13:22:06 stsp Exp $ +.\" $OpenBSD: boot_sparc64.8,v 1.17 2022/08/04 09:16:53 kn Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)boot_sparc.8 8.2 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: October 3 2015 $ +.Dd $Mdocdate: August 4 2022 $ .Dt BOOT_SPARC64 8 sparc64 .Os .Sh NAME @@ -90,29 +90,12 @@ bootloader will then look for a kernel named .Pa bsd by default, unless the .Va boot-file -variable is set, or a different filename has been specified +variable contains a filename, or a different filename has been specified in the boot command. To reset this variable to its default, empty, value, type the following: .Pp .D1 Sy ok Li set-default boot-file .Pp -To boot from a -.Xr softraid 4 -volume by default, -.Va boot-device -must be set to a disk device hosting a chunk of the softraid volume: -.Pp -.D1 Sy ok Li setenv boot-device disk0 -.Pp -and -.Va boot-file -must contain the -.Pq Pa sr -device name of the softraid volume and optionally a partition letter -and/or kernel: -.Pp -.D1 Sy ok Li setenv boot-file sr0a:/bsd -.Pp Autoboot is enabled by setting the .Va auto-boot?\& variable to diff --git a/sys/arch/sparc64/stand/ofwboot/boot.c b/sys/arch/sparc64/stand/ofwboot/boot.c index bcb5062578c..24036d9d4d3 100644 --- a/sys/arch/sparc64/stand/ofwboot/boot.c +++ b/sys/arch/sparc64/stand/ofwboot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.38 2021/10/26 10:45:55 patrick Exp $ */ +/* $OpenBSD: boot.c,v 1.39 2022/08/04 09:16:53 kn Exp $ */ /* $NetBSD: boot.c,v 1.3 2001/05/31 08:55:19 mrg Exp $ */ /* * Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved. @@ -310,7 +310,10 @@ done: } #ifdef SOFTRAID -/* Set bootdev_dip to the softraid boot volume, if specified. */ +/* + * Set bootdev_dip to the softraid boot volume, if specified. + * Otherwise default to the softraid volume on the boot device, if any. + */ static int srbootdev(const char *bootline) { @@ -335,7 +338,29 @@ srbootdev(const char *bootline) printf("Unknown device: sr%d\n", unit); return ENODEV; } + } else { + struct sr_boot_chunk *bc; + + /* + * Check if the boot device is a member of any of the assembled + * softraid volumes. + */ + SLIST_FOREACH(bv, &sr_volumes, sbv_link) { + if ((bv->sbv_flags & BIOC_SCBOOTABLE) == 0) + continue; + + SLIST_FOREACH(bc, &bv->sbv_chunks, sbc_link) { + struct diskinfo *dip = bc->sbc_diskinfo; + + if (!strcmp(dip->path, bootdev)) + break; + } + if (bc != NULL) + break; + } + } + if (bv != NULL) { if ((bv->sbv_flags & BIOC_SCBOOTABLE) == 0) { printf("device sr%d is not bootable\n", unit); return ENODEV; diff --git a/sys/arch/sparc64/stand/ofwboot/vers.c b/sys/arch/sparc64/stand/ofwboot/vers.c index 78466bad3c0..c431a3be21d 100644 --- a/sys/arch/sparc64/stand/ofwboot/vers.c +++ b/sys/arch/sparc64/stand/ofwboot/vers.c @@ -1 +1 @@ -const char version[] = "1.22"; +const char version[] = "1.23"; -- 2.20.1