From owner-svn-src-stable@freebsd.org Fri Apr 6 18:40:26 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CADD6F9DAE0; Fri, 6 Apr 2018 18:40:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7CB416E86B; Fri, 6 Apr 2018 18:40:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 738BD1593C; Fri, 6 Apr 2018 18:40:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36IePBr002425; Fri, 6 Apr 2018 18:40:25 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36IeOwc002415; Fri, 6 Apr 2018 18:40:24 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804061840.w36IeOwc002415@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 6 Apr 2018 18:40:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332128 - in stable/11/stand: . common efi/libefi efi/loader i386/loader sparc64/loader userboot/userboot X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/stand: . common efi/libefi efi/loader i386/loader sparc64/loader userboot/userboot X-SVN-Commit-Revision: 332128 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 18:40:26 -0000 Author: kevans Date: Fri Apr 6 18:40:24 2018 New Revision: 332128 URL: https://svnweb.freebsd.org/changeset/base/332128 Log: MFC r329725, r329831 r329725: Consolidate three copies of ZFS commands into a central location. There's no reason to have multiple copies of lszfs and reloadbe. Consolidate them into one location. Also ldi_get_size is the same everywhere (except sparc64). Make it the same everywhere as the common definition is more general and will work on spar64. r329831: Fix userboot w/ ZFS after r329725 r329725 cleaned up ZFS commands duplicated in multiple places, but userboot was not setting HAVE_ZFS when MK_ZFS != "no". This resulted in a failure to boot (as seen in PR 226118) in bhyve, with the following message: /boot/userboot.so: Undefined symbol "ldi_get_size" Added: stable/11/stand/common/zfs_cmd.c - copied unchanged from r329725, head/stand/common/zfs_cmd.c Modified: stable/11/stand/efi/libefi/efizfs.c stable/11/stand/efi/loader/Makefile stable/11/stand/efi/loader/main.c stable/11/stand/i386/loader/main.c stable/11/stand/loader.mk stable/11/stand/sparc64/loader/Makefile stable/11/stand/sparc64/loader/main.c stable/11/stand/userboot/userboot/Makefile stable/11/stand/userboot/userboot/main.c Directory Properties: stable/11/ (props changed) Copied: stable/11/stand/common/zfs_cmd.c (from r329725, head/stand/common/zfs_cmd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/stand/common/zfs_cmd.c Fri Apr 6 18:40:24 2018 (r332128, copy of r329725, head/stand/common/zfs_cmd.c) @@ -0,0 +1,108 @@ +/*- + * Copyright (c) 2018 Warner Losh + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * MD bootstrap main() and assorted miscellaneous + * commands. + */ + +#include +#include +#include +#include + +#include "bootstrap.h" + +#ifdef LOADER_ZFS_SUPPORT +#include "../zfs/libzfs.h" +#endif + +COMMAND_SET(lszfs, "lszfs", "list child datasets of a zfs dataset", + command_lszfs); + +static int +command_lszfs(int argc, char *argv[]) +{ + int err; + + if (argc != 2) { + command_errmsg = "a single dataset must be supplied"; + return (CMD_ERROR); + } + + err = zfs_list(argv[1]); + if (err != 0) { + command_errmsg = strerror(err); + return (CMD_ERROR); + } + return (CMD_OK); +} + +COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments", + command_reloadbe); + +static int +command_reloadbe(int argc, char *argv[]) +{ + int err; + char *root; + + if (argc > 2) { + command_errmsg = "wrong number of arguments"; + return (CMD_ERROR); + } + + if (argc == 2) { + err = zfs_bootenv(argv[1]); + } else { + root = getenv("zfs_be_root"); + if (root == NULL) { + /* There does not appear to be a ZFS pool here, exit without error */ + return (CMD_OK); + } + err = zfs_bootenv(root); + } + + if (err != 0) { + command_errmsg = strerror(err); + return (CMD_ERROR); + } + + return (CMD_OK); +} + +uint64_t +ldi_get_size(void *priv) +{ + int fd = (uintptr_t) priv; + uint64_t size; + + ioctl(fd, DIOCGMEDIASIZE, &size); + return (size); +} Modified: stable/11/stand/efi/libefi/efizfs.c ============================================================================== --- stable/11/stand/efi/libefi/efizfs.c Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/efi/libefi/efizfs.c Fri Apr 6 18:40:24 2018 (r332128) @@ -109,14 +109,4 @@ efi_zfs_probe(void) } } } - -uint64_t -ldi_get_size(void *priv) -{ - int fd = (uintptr_t) priv; - uint64_t size; - - ioctl(fd, DIOCGMEDIASIZE, &size); - return (size); -} #endif Modified: stable/11/stand/efi/loader/Makefile ============================================================================== --- stable/11/stand/efi/loader/Makefile Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/efi/loader/Makefile Fri Apr 6 18:40:24 2018 (r332128) @@ -28,6 +28,7 @@ SRCS= autoload.c \ LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a CFLAGS+= -I${ZFSSRC} CFLAGS+= -DEFI_ZFS_BOOT +HAVE_ZFS= yes .endif .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 Modified: stable/11/stand/efi/loader/main.c ============================================================================== --- stable/11/stand/efi/loader/main.c Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/efi/loader/main.c Fri Apr 6 18:40:24 2018 (r332128) @@ -747,61 +747,6 @@ command_mode(int argc, char *argv[]) return (CMD_OK); } -#ifdef EFI_ZFS_BOOT -COMMAND_SET(lszfs, "lszfs", "list child datasets of a zfs dataset", - command_lszfs); - -static int -command_lszfs(int argc, char *argv[]) -{ - int err; - - if (argc != 2) { - command_errmsg = "wrong number of arguments"; - return (CMD_ERROR); - } - - err = zfs_list(argv[1]); - if (err != 0) { - command_errmsg = strerror(err); - return (CMD_ERROR); - } - return (CMD_OK); -} - -COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments", - command_reloadbe); - -static int -command_reloadbe(int argc, char *argv[]) -{ - int err; - char *root; - - if (argc > 2) { - command_errmsg = "wrong number of arguments"; - return (CMD_ERROR); - } - - if (argc == 2) { - err = zfs_bootenv(argv[1]); - } else { - root = getenv("zfs_be_root"); - if (root == NULL) { - return (CMD_OK); - } - err = zfs_bootenv(root); - } - - if (err != 0) { - command_errmsg = strerror(err); - return (CMD_ERROR); - } - - return (CMD_OK); -} -#endif - #ifdef LOADER_FDT_SUPPORT extern int command_fdt_internal(int argc, char *argv[]); Modified: stable/11/stand/i386/loader/main.c ============================================================================== --- stable/11/stand/i386/loader/main.c Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/i386/loader/main.c Fri Apr 6 18:40:24 2018 (r332128) @@ -374,63 +374,6 @@ command_heap(int argc, char *argv[]) return(CMD_OK); } -#ifdef LOADER_ZFS_SUPPORT -COMMAND_SET(lszfs, "lszfs", "list child datasets of a zfs dataset", - command_lszfs); - -static int -command_lszfs(int argc, char *argv[]) -{ - int err; - - if (argc != 2) { - command_errmsg = "wrong number of arguments"; - return (CMD_ERROR); - } - - err = zfs_list(argv[1]); - if (err != 0) { - command_errmsg = strerror(err); - return (CMD_ERROR); - } - - return (CMD_OK); -} - -COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments", - command_reloadbe); - -static int -command_reloadbe(int argc, char *argv[]) -{ - int err; - char *root; - - if (argc > 2) { - command_errmsg = "wrong number of arguments"; - return (CMD_ERROR); - } - - if (argc == 2) { - err = zfs_bootenv(argv[1]); - } else { - root = getenv("zfs_be_root"); - if (root == NULL) { - /* There does not appear to be a ZFS pool here, exit without error */ - return (CMD_OK); - } - err = zfs_bootenv(root); - } - - if (err != 0) { - command_errmsg = strerror(err); - return (CMD_ERROR); - } - - return (CMD_OK); -} -#endif - /* ISA bus access functions for PnP. */ static int isa_inb(int port) @@ -463,15 +406,5 @@ i386_zfs_probe(void) sprintf(devname, "disk%d:", unit); zfs_probe_dev(devname, NULL); } -} - -uint64_t -ldi_get_size(void *priv) -{ - int fd = (uintptr_t) priv; - uint64_t size; - - ioctl(fd, DIOCGMEDIASIZE, &size); - return (size); } #endif Modified: stable/11/stand/loader.mk ============================================================================== --- stable/11/stand/loader.mk Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/loader.mk Fri Apr 6 18:40:24 2018 (r332128) @@ -121,7 +121,8 @@ CFLAGS+= -DLOADER_MBR_SUPPORT CFLAGS+= -DLOADER_ZFS_SUPPORT CFLAGS+= -I${ZFSSRC} CFLAGS+= -I${SYSDIR}/cddl/boot/zfs -.if ${MACHINE} == "amd64" +SRCS+= zfs_cmd.c +.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1 # Have to override to use 32-bit version of zfs library... # kinda lame to select that there XXX LIBZFSBOOT= ${BOOTOBJ}/zfs32/libzfsboot.a Modified: stable/11/stand/sparc64/loader/Makefile ============================================================================== --- stable/11/stand/sparc64/loader/Makefile Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/sparc64/loader/Makefile Fri Apr 6 18:40:24 2018 (r332128) @@ -19,6 +19,10 @@ NEWVERSWHAT?= "bootstrap loader" sparc64 VERSION_FILE= ${.CURDIR}/../loader/version INSTALLFLAGS= -b +.if ${MK_ZFS} != "no" +HAVE_ZFS= yes +.endif + # Architecture-specific loader code .PATH: ${BOOTSRC}/sparc64/loader SRCS= locore.S main.c metadata.c vers.c Modified: stable/11/stand/sparc64/loader/main.c ============================================================================== --- stable/11/stand/sparc64/loader/main.c Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/sparc64/loader/main.c Fri Apr 6 18:40:24 2018 (r332128) @@ -735,15 +735,6 @@ tlb_init_sun4u(void) #ifdef LOADER_ZFS_SUPPORT -/* Set by sparc64_zfs_probe to provide partition size. */ -static size_t part_size; - -uint64_t -ldi_get_size(void *priv __unused) -{ - return ((uint64_t)part_size); -} - static void sparc64_zfs_probe(void) { @@ -799,7 +790,6 @@ sparc64_zfs_probe(void) if (part == 2 || vtoc.part[part].tag != VTOC_TAG_FREEBSD_ZFS) continue; - part_size = vtoc.map[part].nblks; (void)sprintf(devname, "%s:%c", alias, part + 'a'); /* Get the GUID of the ZFS pool on the boot device. */ if (strcmp(devname, bootpath) == 0) @@ -948,7 +938,7 @@ static const char *const page_sizes[] = { static void pmap_print_tte_sun4u(tte_t tag, tte_t tte) -{ + printf("%s %s ", page_sizes[(tte >> TD_SIZE_SHIFT) & TD_SIZE_MASK], Modified: stable/11/stand/userboot/userboot/Makefile ============================================================================== --- stable/11/stand/userboot/userboot/Makefile Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/userboot/userboot/Makefile Fri Apr 6 18:40:24 2018 (r332128) @@ -42,6 +42,7 @@ NEWVERSWHAT= "User boot" ${MACHINE_CPUARCH} .if ${MK_ZFS} != "no" CFLAGS+= -DUSERBOOT_ZFS_SUPPORT LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a +HAVE_ZFS=yes .endif # Always add MI sources Modified: stable/11/stand/userboot/userboot/main.c ============================================================================== --- stable/11/stand/userboot/userboot/main.c Fri Apr 6 18:38:25 2018 (r332127) +++ stable/11/stand/userboot/userboot/main.c Fri Apr 6 18:40:24 2018 (r332128) @@ -218,70 +218,7 @@ userboot_zfs_probe(void) userboot_zfs_found = 1; } } - -COMMAND_SET(lszfs, "lszfs", "list child datasets of a zfs dataset", - command_lszfs); - -static int -command_lszfs(int argc, char *argv[]) -{ - int err; - - if (argc != 2) { - command_errmsg = "a single dataset must be supplied"; - return (CMD_ERROR); - } - - err = zfs_list(argv[1]); - if (err != 0) { - command_errmsg = strerror(err); - return (CMD_ERROR); - } - return (CMD_OK); -} - -COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments", - command_reloadbe); - -static int -command_reloadbe(int argc, char *argv[]) -{ - int err; - char *root; - - if (argc > 2) { - command_errmsg = "wrong number of arguments"; - return (CMD_ERROR); - } - - if (argc == 2) { - err = zfs_bootenv(argv[1]); - } else { - root = getenv("zfs_be_root"); - if (root == NULL) { - return (CMD_OK); - } - err = zfs_bootenv(root); - } - - if (err != 0) { - command_errmsg = strerror(err); - return (CMD_ERROR); - } - - return (CMD_OK); -} - -uint64_t -ldi_get_size(void *priv) -{ - int fd = (uintptr_t) priv; - uint64_t size; - - ioctl(fd, DIOCGMEDIASIZE, &size); - return (size); -} -#endif /* USERBOOT_ZFS_SUPPORT */ +#endif COMMAND_SET(quit, "quit", "exit the loader", command_quit);