From owner-svn-src-all@freebsd.org Sun Nov 10 09:32:18 2019 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 7BAE91AFD29; Sun, 10 Nov 2019 09:32:18 +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) server-signature RSA-PSS (4096 bits) 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 479pgk2gr4z3JMM; Sun, 10 Nov 2019 09:32:18 +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 3E3242503C; Sun, 10 Nov 2019 09:32:18 +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 xAA9WI1E067083; Sun, 10 Nov 2019 09:32:18 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAA9WHsl067081; Sun, 10 Nov 2019 09:32:17 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911100932.xAA9WHsl067081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 10 Nov 2019 09:32:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354590 - in stable/12: stand/libsa/zfs sys/cddl/boot/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: in stable/12: stand/libsa/zfs sys/cddl/boot/zfs X-SVN-Commit-Revision: 354590 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.29 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: Sun, 10 Nov 2019 09:32:18 -0000 Author: tsoome Date: Sun Nov 10 09:32:17 2019 New Revision: 354590 URL: https://svnweb.freebsd.org/changeset/base/354590 Log: MFC r354279: loader: calculate physical vdev psize from asize Since physical device asize is calculated from psize and the asize is stored in pool label, we can use asize to set the value of psize, which is used to calculate the location of the pool labels. Modified: stable/12/stand/libsa/zfs/zfsimpl.c stable/12/sys/cddl/boot/zfs/zfsimpl.h Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Sun Nov 10 09:28:18 2019 (r354589) +++ stable/12/stand/libsa/zfs/zfsimpl.c Sun Nov 10 09:32:17 2019 (r354590) @@ -1102,7 +1102,7 @@ vdev_init_from_nvlist(const unsigned char *nvlist, vde vdev_t **vdevp, int is_newer) { int rc; - uint64_t guid, id, ashift, nparity; + uint64_t guid, id, ashift, asize, nparity; const char *type; const char *path; vdev_t *vdev, *kid; @@ -1181,6 +1181,11 @@ vdev_init_from_nvlist(const unsigned char *nvlist, vde } else { vdev->v_ashift = 0; } + if (nvlist_find(nvlist, ZPOOL_CONFIG_ASIZE, + DATA_TYPE_UINT64, NULL, &asize) == 0) { + vdev->v_psize = asize + + VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; + } if (nvlist_find(nvlist, ZPOOL_CONFIG_NPARITY, DATA_TYPE_UINT64, NULL, &nparity) == 0) { vdev->v_nparity = nparity; @@ -1547,7 +1552,6 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s uint64_t guid; uint64_t best_txg = 0; uint64_t pool_txg, pool_guid; - uint64_t psize; const char *pool_name; const unsigned char *vdevs; const unsigned char *features; @@ -1562,17 +1566,17 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s memset(&vtmp, 0, sizeof(vtmp)); vtmp.v_phys_read = _read; vtmp.v_read_priv = read_priv; - psize = P2ALIGN(ldi_get_size(read_priv), + vtmp.v_psize = P2ALIGN(ldi_get_size(read_priv), (uint64_t)sizeof (vdev_label_t)); /* Test for minimum pool size. */ - if (psize < SPA_MINDEVSIZE) + if (vtmp.v_psize < SPA_MINDEVSIZE) return (EIO); tmp_label = zfs_alloc(sizeof(vdev_phys_t)); for (l = 0; l < VDEV_LABELS; l++) { - off = vdev_label_offset(psize, l, + off = vdev_label_offset(vtmp.v_psize, l, offsetof(vdev_label_t, vl_vdev_phys)); BP_ZERO(&bp); @@ -1595,8 +1599,20 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s continue; if (best_txg <= pool_txg) { + uint64_t asize; + best_txg = pool_txg; memcpy(vdev_label, tmp_label, sizeof (vdev_phys_t)); + + /* + * Use asize from pool config. We need this + * because we can get bad value from BIOS. + */ + if (nvlist_find(nvlist, ZPOOL_CONFIG_ASIZE, + DATA_TYPE_UINT64, NULL, &asize) == 0) { + vtmp.v_psize = asize + + VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; + } } } @@ -1716,6 +1732,7 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s vdev->v_phys_read = _read; vdev->v_read_priv = read_priv; vdev->v_state = VDEV_STATE_HEALTHY; + vdev->v_psize = vtmp.v_psize; } else { printf("ZFS: inconsistent nvlist contents\n"); return (EIO); @@ -1735,7 +1752,7 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s up = (const struct uberblock *)upbuf; for (l = 0; l < VDEV_LABELS; l++) { for (i = 0; i < VDEV_UBERBLOCK_COUNT(vdev); i++) { - off = vdev_label_offset(psize, l, + off = vdev_label_offset(vdev->v_psize, l, VDEV_UBERBLOCK_OFFSET(vdev, i)); BP_ZERO(&bp); DVA_SET_OFFSET(&bp.blk_dva[0], off); Modified: stable/12/sys/cddl/boot/zfs/zfsimpl.h ============================================================================== --- stable/12/sys/cddl/boot/zfs/zfsimpl.h Sun Nov 10 09:28:18 2019 (r354589) +++ stable/12/sys/cddl/boot/zfs/zfsimpl.h Sun Nov 10 09:32:17 2019 (r354590) @@ -1660,7 +1660,8 @@ typedef struct vdev { vdev_list_t v_children; /* children of this vdev */ const char *v_name; /* vdev name */ uint64_t v_guid; /* vdev guid */ - int v_id; /* index in parent */ + uint64_t v_id; /* index in parent */ + uint64_t v_psize; /* physical device capacity */ int v_ashift; /* offset to block shift */ int v_nparity; /* # parity for raidz */ struct vdev *v_top; /* parent vdev */