From owner-svn-src-all@freebsd.org Fri Mar 22 23:39:17 2019 Return-Path: Delivered-To: svn-src-all@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 7A8DE1554DFC; Fri, 22 Mar 2019 23:39:17 +0000 (UTC) (envelope-from marcel@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 21CDA69A08; Fri, 22 Mar 2019 23:39:17 +0000 (UTC) (envelope-from marcel@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 F0D9927799; Fri, 22 Mar 2019 23:39:16 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2MNdGBb044016; Fri, 22 Mar 2019 23:39:16 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2MNdGRf044015; Fri, 22 Mar 2019 23:39:16 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201903222339.x2MNdGRf044015@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 22 Mar 2019 23:39:16 +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: r345427 - stable/12/sys/geom/part X-SVN-Group: stable-12 X-SVN-Commit-Author: marcel X-SVN-Commit-Paths: stable/12/sys/geom/part X-SVN-Commit-Revision: 345427 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 21CDA69A08 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.950,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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: Fri, 22 Mar 2019 23:39:17 -0000 Author: marcel Date: Fri Mar 22 23:39:16 2019 New Revision: 345427 URL: https://svnweb.freebsd.org/changeset/base/345427 Log: MFC 344790: Revert revision 254095 In revision 254095, gpt_entries is not set to match the on-disk hdr_entries, but rather is computed based on available space. There are 2 problems with this: 1. The GPT backend respects hdr_entries and only reads and writes that number of partition entries. On top of that, CRC32 is computed over the table that has hdr_entries elements. When the common code works on what is possibly a larger number, the behaviour becomes inconsistent and problematic. In particular, it would be possible to add a new partition that on a reboot isn't there anymore. 2. The calculation of gpt_entries is based on flawed assumptions. The GPT specification does not dictate that sectors are layed out in a particular way that the available space can be determined by looking at LBAs. In practice, implementations do the same thing, because there's no reason to do it any other way. Still, GPT allows certain freedoms that can be exploited in some form or shape if the need arises. PR: 229977 Differential Revision: https://reviews.freebsd.org/D19438 Modified: stable/12/sys/geom/part/g_part_gpt.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/geom/part/g_part_gpt.c ============================================================================== --- stable/12/sys/geom/part/g_part_gpt.c Fri Mar 22 22:14:14 2019 (r345426) +++ stable/12/sys/geom/part/g_part_gpt.c Fri Mar 22 23:39:16 2019 (r345427) @@ -990,10 +990,9 @@ g_part_gpt_read(struct g_part_table *basetable, struct basetable->gpt_first = table->hdr->hdr_lba_start; basetable->gpt_last = table->hdr->hdr_lba_end; - basetable->gpt_entries = (table->hdr->hdr_lba_start - 2) * - pp->sectorsize / table->hdr->hdr_entsz; + basetable->gpt_entries = table->hdr->hdr_entries; - for (index = table->hdr->hdr_entries - 1; index >= 0; index--) { + for (index = basetable->gpt_entries - 1; index >= 0; index--) { if (EQUUID(&tbl[index].ent_type, &gpt_uuid_unused)) continue; entry = (struct g_part_gpt_entry *)g_part_new_entry(