From owner-svn-src-all@freebsd.org Wed Sep 23 08:22:15 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B7F93F2A54; Wed, 23 Sep 2020 08:22:15 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BxB471pvrz4TLt; Wed, 23 Sep 2020 08:22:15 +0000 (UTC) (envelope-from tsoome@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 22C2DDC05; Wed, 23 Sep 2020 08:22:15 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08N8MFdY025665; Wed, 23 Sep 2020 08:22:15 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08N8MEac025664; Wed, 23 Sep 2020 08:22:14 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <202009230822.08N8MEac025664@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Wed, 23 Sep 2020 08:22:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366066 - in head/stand: efi/libefi libsa/zfs X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: in head/stand: efi/libefi libsa/zfs X-SVN-Commit-Revision: 366066 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2020 08:22:15 -0000 Author: tsoome Date: Wed Sep 23 08:22:14 2020 New Revision: 366066 URL: https://svnweb.freebsd.org/changeset/base/366066 Log: loader: zfs_probe_dev should pick first matching zfs pool During devswitch probe, we pick boot pool based on boot disk, if the boot disk happens to have multiple pools in freebsd-zfs partitions, the current code does pick last pool from boot disk as boot pool. While there is no way at that stage to test, the more logical approach would be to pick first matching pool. This patch is assuming we do pass pool guid pointer with guid value 0, this will help us to determine, if the guid value is already set or not. The general suggestion would be not to share disk between different pools. Reported by: Alexander Leidinger Modified: head/stand/efi/libefi/efizfs.c head/stand/libsa/zfs/zfs.c Modified: head/stand/efi/libefi/efizfs.c ============================================================================== --- head/stand/efi/libefi/efizfs.c Wed Sep 23 07:27:12 2020 (r366065) +++ head/stand/efi/libefi/efizfs.c Wed Sep 23 08:22:14 2020 (r366066) @@ -99,7 +99,7 @@ efi_zfs_probe(void) pdinfo_list_t *hdi; pdinfo_t *hd, *pd = NULL; char devname[SPECNAMELEN + 1]; - uint64_t guid; + uint64_t guid; hdi = efiblk_get_pdinfo_list(&efipart_hddev); STAILQ_INIT(&zfsinfo); @@ -114,6 +114,7 @@ efi_zfs_probe(void) STAILQ_FOREACH(pd, &hd->pd_part, pd_link) { snprintf(devname, sizeof(devname), "%s%dp%d:", efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit); + guid = 0; if (zfs_probe_dev(devname, &guid) == 0) { insert_zfs(pd->pd_handle, guid); if (pd->pd_handle == boot_img->DeviceHandle) Modified: head/stand/libsa/zfs/zfs.c ============================================================================== --- head/stand/libsa/zfs/zfs.c Wed Sep 23 07:27:12 2020 (r366065) +++ head/stand/libsa/zfs/zfs.c Wed Sep 23 08:22:14 2020 (r366066) @@ -651,7 +651,8 @@ zfs_probe(int fd, uint64_t *pool_guid) spa = NULL; ret = vdev_probe(vdev_read, vdev_write, (void *)(uintptr_t)fd, &spa); if (ret == 0 && pool_guid != NULL) - *pool_guid = spa->spa_guid; + if (*pool_guid == 0) + *pool_guid = spa->spa_guid; return (ret); }