Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/raidframe If we are autoconfiguring root, then only ...



details:   https://anonhg.NetBSD.org/src/rev/7f2ac65b484a
branches:  trunk
changeset: 328390:7f2ac65b484a
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 02 02:17:01 2014 +0000

description:
If we are autoconfiguring root, then only change the booted_device if
we booted from one of the components of the root raid set. This allows
us to boot from other media, without forcing the found raid to always
be root. Allow the old behavior with RAIDFRAME_FORCE_ROOT.
XXX: cpu_rootconf() is called twice now, which prints the booted device
message twice. Perhaps we can remember that cpu_rootconf has been called
and avoid calling it twice to avoid that.

diffstat:

 sys/dev/raidframe/rf_netbsdkintf.c |  45 ++++++++++++++++++++++++++-----------
 1 files changed, 31 insertions(+), 14 deletions(-)

diffs (92 lines):

diff -r 6ec8f3e6c7b2 -r 7f2ac65b484a sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Wed Apr 02 02:14:08 2014 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Wed Apr 02 02:17:01 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.305 2014/03/16 05:20:29 dholland Exp $    */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.306 2014/04/02 02:17:01 christos Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.305 2014/03/16 05:20:29 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.306 2014/04/02 02:17:01 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -447,14 +447,30 @@
        return 1;
 }
 
+static int
+rf_containsboot(RF_Raid_t *r, device_t dv) {
+       const char *bootname = device_xname(dv);
+       size_t len = strlen(bootname);
+
+       for (int col = 0; col < r->numCol; col++) {
+               char *devname = r->Disks[col].devname;
+               devname += sizeof("/dev/") - 1;
+               if (strncmp(devname, bootname, len) == 0) {
+                       struct raid_softc *sc = r->softc;
+                       aprint_debug("raid%d includes boot device %s\n",
+                           sc->sc_unit, devname);
+                       return 1;
+               }
+       }
+       return 0;
+}
+
 void
 rf_buildroothack(RF_ConfigSet_t *config_sets)
 {
        RF_ConfigSet_t *cset;
        RF_ConfigSet_t *next_cset;
-       int col;
        int num_root;
-       char *devname;
        struct raid_softc *sc, *rsc;
 
        sc = rsc = NULL;
@@ -496,14 +512,22 @@
        /* we found something bootable... */
 
        if (num_root == 1) {
+               device_t candidate_root;
                if (rsc->sc_dkdev.dk_nwedges != 0) {
                        /* XXX: How do we find the real root partition? */
                        char cname[sizeof(cset->ac->devname)];
                        snprintf(cname, sizeof(cname), "%s%c",
                            device_xname(rsc->sc_dev), 'a');
-                       booted_device = dkwedge_find_by_wname(cname);
+                       candidate_root = dkwedge_find_by_wname(cname);
                } else
-                       booted_device = rsc->sc_dev;
+                       candidate_root = rsc->sc_dev;
+#ifndef RAIDFRAME_FORCE_ROOT
+               if (booted_device == NULL)
+                       cpu_rootconf();
+               if (booted_device == NULL
+                   || rf_containsboot(&rsc->sc_r, booted_device))
+#endif
+               booted_device = candidate_root;
        } else if (num_root > 1) {
 
                /* 
@@ -528,14 +552,7 @@
                        if (r->root_partition == 0)
                                continue;
 
-                       for (col = 0; col < r->numCol; col++) {
-                               devname = r->Disks[col].devname;
-                               devname += sizeof("/dev/") - 1;
-                               if (strncmp(devname, device_xname(booted_device), 
-                                           strlen(device_xname(booted_device))) != 0)
-                                       continue;
-                               aprint_debug("raid%d includes boot device %s\n",
-                                      sc->sc_unit, devname);
+                       if (rf_containsboot(r, booted_device)) {
                                num_root++;
                                rsc = sc;
                        }



Home | Main Index | Thread Index | Old Index