From nobody Mon Jun 16 20:49:31 2025 X-Original-To: dev-commits-src-main@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 4bLhvH6Vx6z5yPK8; Mon, 16 Jun 2025 20:49:31 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bLhvH2kgjz3h3w; Mon, 16 Jun 2025 20:49:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750106971; 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=8Jn8ts08pKGFU1PaI8hxOiet37Ebpf2BPrZ/pDwtWHE=; b=XxZnLnDYZIr4qYG+8uoeP0KVotF3W9mHn8jFO6nZ10wzP1pBeykoXhIJLkKO3EBLGqpruL 1drkaQErnAxOwvjXqNR24JS5/OPzRZ73tKdn19+I7pA+VMqBYIlE5A7h7f++pZ30PT/0nl nsMNK5xrct20nu3JCJH7uBL11KemykJH5f55DLnwK7CiPXYMCaTcjNFr8y2Kte98q3C8DN UcTFDJksNdKvfNl1k+O0RLCZAqL85X5KsBZYGP18o431FOFf259AMiuwhjUTRh9ZCLn5SI D/0lR4wGcqpG/I0vnMhkX4U+KnSwVHHJNjQhvjiPU2jfWo6l1x9HWinQ+zcgeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750106971; 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=8Jn8ts08pKGFU1PaI8hxOiet37Ebpf2BPrZ/pDwtWHE=; b=uFbF4BIOr93bq4VBDHvRem/SXuwnO/l5UWScAEW5JHFpGe2CXwiTtx6vqxPQxFrDBk9vlW w4p2EOuiwuXzeFRV17l6fnuNPnOm3pZmz9MRRcDoXJaZHkpofTlvVpPAZGqxTbTF95XvMH j3frbNVSURO9DrfuyZBb4NM9t5Z2DjyzTlkF6HzZYXHHZ6klOckHvHT8r6jHaNtkg6+Ogw 4vw4nRJkUnmHujE/ucoXUFvoTpZBt4zTNifW/cqdNpmDFOY+qk6usHoIT9658aGbvYng99 23sKdf/WfGf0KI8Rop6Z8bMR267HutY5672a1zDo2CNIPKDC0uqIJCmKWgydlQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750106971; a=rsa-sha256; cv=none; b=HoqIE6mrT+AHAsIqY6Dz/2dJ/aGTUSFiEiLpiirhnqcvF/rS5X9SE5vsk/oZIfLLmL+S3W MUhuGyQg8/qFX2PasvrVaVzkasW6wK2ATep1p5xtCtcxiziF/IiuexMbASaOE7kqV9DlIH b4NPhIcz0PrNCrdyfRzlPPad/bsTHTOYHTp2QAUBS310K+LJCxE7r0VWqvdX9ilflMZuFX CueoYvUmRCRxKnnyEMCMB9ZTu7HiXk7GG4b+LjSC7Gc48Cq6VtVgYlqVcY3Kktiovedzhy z3LKbuZtWLDS7Z6+4W9OMtf8WtVEPRrGnp4ObJbzXZbQ/+Zc5TEThJSLJIlLqw== 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 4bLhvH2663z1Bwg; Mon, 16 Jun 2025 20:49:31 +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 55GKnVbG080399; Mon, 16 Jun 2025 20:49:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55GKnVxD080396; Mon, 16 Jun 2025 20:49:31 GMT (envelope-from git) Date: Mon, 16 Jun 2025 20:49:31 GMT Message-Id: <202506162049.55GKnVxD080396@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 64e0b2e8f752 - main - makefs: Implement the collision differentiator for micro ZAPs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 64e0b2e8f75286f9f4d85a86fbb6815b435c7096 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=64e0b2e8f75286f9f4d85a86fbb6815b435c7096 commit 64e0b2e8f75286f9f4d85a86fbb6815b435c7096 Author: Mark Johnston AuthorDate: 2025-06-16 20:33:14 +0000 Commit: Mark Johnston CommitDate: 2025-06-16 20:49:07 +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 --- 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++; }