From nobody Tue Jun 24 01:01:05 2025 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 4bR68L1GWlz602rZ; Tue, 24 Jun 2025 01:01:06 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bR68K5bz5z3GWp; Tue, 24 Jun 2025 01:01:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750726865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B8VE59jBRAMKEO3X1wrKBJcwFkrs1TmkAlveinrIItY=; b=tDfeWGSypP8I4JtwD14b49VjOVKeCd0G3heBoRu6vXjFaIyy4WSsECZR78JeCPHwzDyw+O rOA7BXF6NTNa6rCMtBvqU8A7jtOFiwmqVqtxlHvXCEbi6j6MO8iOMX7+rg9iELJe3Dm451 /ULb7ZWDvqw4lvrQPhqsl2usw3iUMd3vrPqPHPZDenLuXszYbc7QgUxuykOrC1JgmiwxuC aMuJF4WIWWnX5xTCFewIFkAhyRejwYsln9p30niyWMLUvTD0z6ifAb63TTLGoBOMsTo9FM dvdJxXlTTg7QuQH3gHhC44+u76MH+4qftvNtI4tICGICDfJsQVNN1aaHjihm3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750726865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B8VE59jBRAMKEO3X1wrKBJcwFkrs1TmkAlveinrIItY=; b=YzpJmLkD24MLsZZD/QeB5orMHeaYy3kdfXkhoAwUYUlI9/KF5gOz04hyom3ptekUAhek23 WpvT84hJsw0ZgJDdDkgNOKvR1J0jGUPPdVamj5CzGwb7wZBKHjHNvfrtFeh2fRl8dB5Ipp kbGEWv2z1Pn/axrnFxVxkbGN/e1fGPKGLzbNs5h8FYKSAKVj0blxA83CS6UQAK3yFZA+8D lcfiQnOHUywKcumApUnB42FBTvwQsusWB/LC6H1smbbMOLNHSILYCKxEWhbWwOSS7xXV04 VCCMEJqqYUVDyVVl/cr8XT914ydMHw8Ql+9HAVgLpDoEo7AR3qDg9rJQveV7Xw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750726865; a=rsa-sha256; cv=none; b=Z5VzSCcfCpQwqCSbA02ZHOjmTfFKe6feFr8PlEsd07rKOO+8uCmiFiFbL4WZS9k2r1G8ex /gmcK2rapuAMzEdhat63EA0c5aAtCw7Nvdez5ftN48y5CaGYsilN9YkcTCjNua/Sf9GOxu 8aklc3GGOHyjcjAAm8OZISXcoRHi5IobzXCEx/aP49TTIEtpHiY3gz+9HIO2HQLmnnxII8 9BxO5uAGZGP82Jn6y/GhgkD19vWvUwxLWhqKM3+szCExnbdm8zm3U5ZDpWSG3gycvL269Z 8yAR2afkLhRIMZzwpZ04qPu3JtN16tjuRw240jIdtRi5pEPBfUIRdPDNDjSZhA== 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 4bR68K570Xz9tp; Tue, 24 Jun 2025 01:01:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55O115GM023917; Tue, 24 Jun 2025 01:01:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55O115sl023903; Tue, 24 Jun 2025 01:01:05 GMT (envelope-from git) Date: Tue, 24 Jun 2025 01:01:05 GMT Message-Id: <202506240101.55O115sl023903@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 97e2915ab98e - stable/14 - makefs: Implement the collision differentiator for micro ZAPs 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 97e2915ab98e786f7310d8477aa48d71a5485e44 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=97e2915ab98e786f7310d8477aa48d71a5485e44 commit 97e2915ab98e786f7310d8477aa48d71a5485e44 Author: Mark Johnston AuthorDate: 2025-06-16 20:33:14 +0000 Commit: Mark Johnston CommitDate: 2025-06-24 00:40:22 +0000 makefs: Implement the collision differentiator for micro ZAPs In the unlikely event of a hash collision, the collision differentiator is used to create a unique lookup key for ZAP entries. While the fat ZAP implementation in makefs implemented this, the micro ZAP implementation did not, so it's possible to end up with collisions in directory entries. These are caught deterministically by OpenZFS, but the result is a panic. Implement a simple differentiator by simply assigning a unique value to each ZAP entry. This scheme works since the 16-bit space of differentiators is larger than the maximum number of entries in a micro ZAP. (While the on-disk encoding provides 32 bits of space for the differentiator, the in-memory representation of micro ZAP entries is smaller.) PR: 287482 MFC after: 1 week (cherry picked from commit 64e0b2e8f75286f9f4d85a86fbb6815b435c7096) --- usr.sbin/makefs/zfs/zap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/usr.sbin/makefs/zfs/zap.c b/usr.sbin/makefs/zfs/zap.c index d01f7527adf9..decf5fc6a473 100644 --- a/usr.sbin/makefs/zfs/zap.c +++ b/usr.sbin/makefs/zfs/zap.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -201,6 +202,10 @@ zap_micro_write(zfs_opt_t *zfs, zfs_zap_t *zap) mzap_phys_t *mzap; mzap_ent_phys_t *ment; off_t bytes, loc; + uint16_t cd; + + _Static_assert(MZAP_ENT_MAX <= UINT16_MAX, + "micro ZAP collision differentiator must fit in 16 bits"); memset(zfs->filebuf, 0, sizeof(zfs->filebuf)); mzap = (mzap_phys_t *)&zfs->filebuf[0]; @@ -211,10 +216,11 @@ zap_micro_write(zfs_opt_t *zfs, zfs_zap_t *zap) bytes = sizeof(*mzap) + (zap->kvpcnt - 1) * sizeof(*ment); assert(bytes <= (off_t)MZAP_MAX_BLKSZ); + cd = 0; ment = &mzap->mz_chunk[0]; STAILQ_FOREACH(ent, &zap->kvps, next) { memcpy(&ment->mze_value, ent->valp, ent->intsz * ent->intcnt); - ment->mze_cd = 0; /* XXX-MJ */ + ment->mze_cd = cd++; strlcpy(ment->mze_name, ent->name, sizeof(ment->mze_name)); ment++; }