From nobody Fri Oct 08 16:09:00 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8C76D17E95FA; Fri, 8 Oct 2021 16:09:01 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HQtRJ2q4mz4jql; Fri, 8 Oct 2021 16:09:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 159822193; Fri, 8 Oct 2021 16:09:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 198G90O5001963; Fri, 8 Oct 2021 16:09:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 198G90cD001962; Fri, 8 Oct 2021 16:09:00 GMT (envelope-from git) Date: Fri, 8 Oct 2021 16:09:00 GMT Message-Id: <202110081609.198G90cD001962@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 85baf98bbb36 - stable/12 - loader: update zfsimpl.c from illumos review suggestions List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 85baf98bbb3632b89a6f2a7ebdf419681021f2a1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=85baf98bbb3632b89a6f2a7ebdf419681021f2a1 commit 85baf98bbb3632b89a6f2a7ebdf419681021f2a1 Author: Toomas Soome AuthorDate: 2020-01-06 19:35:22 +0000 Commit: Kyle Evans CommitDate: 2021-10-08 08:09:39 +0000 loader: update zfsimpl.c from illumos review suggestions Add extra comments and update error handling. (cherry picked from commit 653c3383c7287535e75a94563455b48f177bc803) --- stand/libsa/zfs/zfsimpl.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c index 70e44d7f0e8b..6c46bfdaea9c 100644 --- a/stand/libsa/zfs/zfsimpl.c +++ b/stand/libsa/zfs/zfsimpl.c @@ -849,7 +849,8 @@ vdev_create(uint64_t guid, vdev_read_t *_read) vdev->v_read = _read; /* - * root vdev has no read function. + * root vdev has no read function, we use this fact to + * skip setting up data we do not need for root vdev. * We only point root vdev from spa. */ if (_read != NULL) { @@ -894,7 +895,7 @@ vdev_set_initial_state(vdev_t *vdev, const nvlist_t *nvlist) else if (isnt_present != 0) vdev->v_state = VDEV_STATE_CANT_OPEN; - vdev->v_islog = is_log == 1; + vdev->v_islog = is_log != 0; } static int @@ -998,9 +999,8 @@ vdev_init(uint64_t guid, const nvlist_t *nvlist, vdev_t **vdevp) if (memcmp(type, VDEV_TYPE_RAIDZ, len) == 0) { if (vdev->v_nparity < 1 || vdev->v_nparity > 3) { - printf("ZFS: can only boot from disk, " - "mirror, raidz1, raidz2 and raidz3 " - "vdevs\n"); + printf("ZFS: invalid raidz parity: %d\n", + vdev->v_nparity); return (EIO); } (void) asprintf(&name, "%.*s%d-%" PRIu64, len, type, @@ -1074,16 +1074,17 @@ vdev_insert(vdev_t *top_vdev, vdev_t *vdev) if (previous == NULL) { STAILQ_INSERT_HEAD(&top_vdev->v_children, vdev, v_childlink); - count = vdev_child_count(top_vdev); - if (top_vdev->v_nchildren < count) - top_vdev->v_nchildren = count; + } else if (previous->v_id == vdev->v_id) { + /* + * This vdev was configured from label config, + * do not insert duplicate. + */ return; + } else { + STAILQ_INSERT_AFTER(&top_vdev->v_children, previous, vdev, + v_childlink); } - if (previous->v_id == vdev->v_id) - return; - - STAILQ_INSERT_AFTER(&top_vdev->v_children, previous, vdev, v_childlink); count = vdev_child_count(top_vdev); if (top_vdev->v_nchildren < count) top_vdev->v_nchildren = count; @@ -1137,6 +1138,10 @@ vdev_from_nvlist(spa_t *spa, uint64_t top_guid, const nvlist_t *nvlist) } } } else { + /* + * When there are no children, nvlist_find() does return + * error, reset it because leaf devices have no children. + */ rc = 0; } nvlist_destroy(kids); @@ -1284,7 +1289,7 @@ vdev_init_from_nvlist(spa_t *spa, const nvlist_t *nvlist) * MOS config has at least one child for root vdev. */ if (rc != 0) - return (EIO); + return (rc); for (int i = 0; i < nkids; i++) { uint64_t guid; @@ -3207,7 +3212,10 @@ zfs_spa_init(spa_t *spa) if (rc != 0) return (rc); - /* Update vdevs from MOS config. */ + /* + * Update vdevs from MOS config. Note, we do skip encoding bytes + * here. See also vdev_label_read_config(). + */ rc = vdev_init_from_nvlist(spa, nvlist); nvlist_destroy(nvlist); return (rc);