From owner-svn-src-stable-8@FreeBSD.ORG Mon Jul 30 11:29:06 2012 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49D0D1065672; Mon, 30 Jul 2012 11:29:06 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2A5808FC0C; Mon, 30 Jul 2012 11:29:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6UBT6fN087724; Mon, 30 Jul 2012 11:29:06 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6UBT5H9087721; Mon, 30 Jul 2012 11:29:05 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201207301129.q6UBT5H9087721@svn.freebsd.org> From: Marius Strobl Date: Mon, 30 Jul 2012 11:29:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238905 - in stable/8: . sys/boot/sparc64/loader X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2012 11:29:06 -0000 Author: marius Date: Mon Jul 30 11:29:05 2012 New Revision: 238905 URL: http://svn.freebsd.org/changeset/base/238905 Log: Pull the tier-2 card and change the sparc64 ZFS loader to no longer probe all diskN aliases for providers (which more or less corresponds to how the x86 version behaves) but instead probe only those listed in the boot-device OFW environment variable. This has the following advantages: - avoids otherwise unavoidable OFW warnings about failures to open disks for which aliases exist but no actual hardware is connected - avoids issues due to different diskN naming schemes - aligns us with Solaris Modified: stable/8/UPDATING (contents, props changed) stable/8/sys/boot/sparc64/loader/main.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/boot/ (props changed) stable/8/sys/cddl/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/e1000/ (props changed) stable/8/sys/dev/sound/ (props changed) stable/8/sys/dev/sound/pci/ (props changed) Modified: stable/8/UPDATING ============================================================================== --- stable/8/UPDATING Mon Jul 30 11:11:05 2012 (r238904) +++ stable/8/UPDATING Mon Jul 30 11:29:05 2012 (r238905) @@ -15,6 +15,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. debugging tools present in HEAD were left in place because sun4v support still needs work to become production ready. +20120727: + The sparc64 ZFS loader has been changed to no longer try to auto- + detect ZFS providers based on diskN aliases but now requires these + to be explicitly listed in the OFW boot-device environment variable. + 20120411: 8.3-RELEASE. Modified: stable/8/sys/boot/sparc64/loader/main.c ============================================================================== --- stable/8/sys/boot/sparc64/loader/main.c Mon Jul 30 11:11:05 2012 (r238904) +++ stable/8/sys/boot/sparc64/loader/main.c Mon Jul 30 11:29:05 2012 (r238905) @@ -7,7 +7,7 @@ * unchanged, you can do what ever you want with this file. */ /*- - * Copyright (c) 2008 Marius Strobl + * Copyright (c) 2008 - 2012 Marius Strobl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,8 +75,6 @@ __FBSDID("$FreeBSD$"); #include "libofw.h" #include "dev_net.h" -#define MAXDEV 31 - extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; enum { @@ -842,18 +840,52 @@ sparc64_zfs_probe(void) { struct vtoc8 vtoc; struct zfs_devdesc zfs_currdev; - char devname[32]; + char alias[64], devname[sizeof(alias) + sizeof(":x") - 1]; + char type[sizeof("device_type")]; + char *bdev, *dev, *odev; uint64_t guid; - int fd, part, unit; + int fd, len, part; + phandle_t aliases, options; /* Get the GUID of the ZFS pool on the boot device. */ guid = 0; zfs_probe_dev(bootpath, &guid); - for (unit = 0; unit < MAXDEV; unit++) { + /* + * Get the GUIDs of the ZFS pools on any additional disks listed in + * the boot-device environment variable. + */ + if ((aliases = OF_finddevice("/aliases")) == -1) + goto out; + options = OF_finddevice("/options"); + len = OF_getproplen(options, "boot-device"); + if (len <= 0) + goto out; + bdev = odev = malloc(len + 1); + if (bdev == NULL) + goto out; + if (OF_getprop(options, "boot-device", bdev, len) <= 0) + goto out; + bdev[len] = '\0'; + while ((dev = strsep(&bdev, " ")) != NULL) { + if (*dev == '\0') + continue; + strcpy(alias, dev); + (void)OF_getprop(aliases, dev, alias, sizeof(alias)); + /* + * Don't probe the boot disk twice. Note that bootpath + * includes the partition specifier. + */ + if (strncmp(alias, bootpath, strlen(alias)) == 0) + continue; + if (OF_getprop(OF_finddevice(alias), "device_type", type, + sizeof(type)) == -1) + continue; + if (strcmp(type, "block") != 0) + continue; + /* Find freebsd-zfs slices in the VTOC. */ - sprintf(devname, "disk%d:", unit); - fd = open(devname, O_RDONLY); + fd = open(alias, O_RDONLY); if (fd == -1) continue; lseek(fd, 0, SEEK_SET); @@ -867,12 +899,14 @@ sparc64_zfs_probe(void) if (part == 2 || vtoc.part[part].tag != VTOC_TAG_FREEBSD_ZFS) continue; - sprintf(devname, "disk%d:%c", unit, part + 'a'); + (void)sprintf(devname, "%s:%c", alias, part + 'a'); if (zfs_probe_dev(devname, NULL) == ENXIO) break; } } + free(odev); + out: if (guid != 0) { zfs_currdev.pool_guid = guid; zfs_currdev.root_guid = 0;