From nobody Mon Oct 14 13:15:13 2024 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 4XRyQ94cr3z5YYJm; Mon, 14 Oct 2024 13:15:13 +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 4XRyQ93lP5z49dJ; Mon, 14 Oct 2024 13:15:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728911713; 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=S1MijJDbRcvUnT9gJWDPb+OEyrLqF33kcdctiuoUI/I=; b=HnCKoDieKW/mbaJitLFwZn6BCc0+FVt6szIyW25MCTzrxwhAi+Umy+HQDV6ZlKnzEPS3dA qGXAqBYRFAomNs6VfbiBC8WMVa8Uhp2z22YWNDD3L7IGhjc8Xn03QHb+CbDt56b+3F9ewV VFsAT72WYTzGT/EQZKW8IMv1dbc0BZLzjO0fLYM21io5LCWzIQX3qfy2m61sPU7cRtRY30 1C/6uv3dBK/YrxIeAeU1nmTrhTdIAR5rK/ixkYrGL8By4YBRiB5YF2ojuG5HcfFpDHBSnY CDy4XwGrnlF3Ag880jbECgNFQofYzrZvIFNM7qWmWcFySppXt/Prtqn6Gh/VjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728911713; 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=S1MijJDbRcvUnT9gJWDPb+OEyrLqF33kcdctiuoUI/I=; b=lhf5f4EbjOesfplBRqz2i5ZndP+OXjzVEmejib4keVBtSm+NtSqC7kae4YlXJfPVRtwv8j 7yOXWFxGAReoJg5d+DOzdzwNNtPwKixT6KpOOkCRzreO96bOWlarFcQqUAXqYlxidy1kE9 UrN29Kqa3NGnATw/W10XlZwgzWV48hPSpyvzBpUyaakdk9GJq/i4WVEckcThNJrhC/Qgak /cOAEguuhxkEbtUK6zYJVXtlTyWPR5ReY4D0Y2Tmnl8+fstZpm07iA78UUe1wVEKdbd9fp WFG2z92UFjCmXrWT7GNml4BeszJPUjiqlvha88AH/zLaEeljXjGOmZDbvcVr7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728911713; a=rsa-sha256; cv=none; b=s5+99MyEF3l7fJnU26TFg5JlHJtl25Ov79RsoBeW5JQPGTIxpEYhkJGuJcknrY9v1XdmZs T0QgMs5BlXhwwsXjrhsJgudofLE+Nl2ljyJ2Z7G0aVdxHSXLp6FjHIbY8AhQUj+ZFboi3O DktWlSWI2mqI2ezMC7WXd+CXcyv8zv+eq05baoLb4gbtMWzI9IZ9YQkYoBWSyevXzkHErT kbKGAut6iXvTu9lSuchzYOtMCwBOL30acxpaUM32blAjtelgOBhH7OfUVYzD0XCAPqDF12 HXXzC3EmT/SM4Qy8tmzmlkeAaya+ufk5k2ARz+FKaxc3+1l/edxRSDtMJYXI2w== 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 4XRyQ93Lkfzg2Y; Mon, 14 Oct 2024 13:15:13 +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 49EDFDS3057727; Mon, 14 Oct 2024 13:15:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49EDFDLA057724; Mon, 14 Oct 2024 13:15:13 GMT (envelope-from git) Date: Mon, 14 Oct 2024 13:15:13 GMT Message-Id: <202410141315.49EDFDLA057724@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: 4e15366c6a69 - main - makefs: Record a larger TXG number in the uberblock 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/main X-Git-Reftype: branch X-Git-Commit: 4e15366c6a6907bcd0e2c28885ba5878ed4280d2 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4e15366c6a6907bcd0e2c28885ba5878ed4280d2 commit 4e15366c6a6907bcd0e2c28885ba5878ed4280d2 Author: Mark Johnston AuthorDate: 2024-10-14 13:08:09 +0000 Commit: Mark Johnston CommitDate: 2024-10-14 13:14:37 +0000 makefs: Record a larger TXG number in the uberblock By default, OpenZFS will perform metadata verification of the most recent TXGs, but this can be very slow since all data in a pool generated by makefs was logically written in a single transaction. Avoid triggering this verification by default, but add an option to restore the previous behaviour and enable it in regression test cases. Reported by: cperciva Tested by: cperciva (previous version) MFC after: 2 weeks --- usr.sbin/makefs/makefs.8 | 3 +++ usr.sbin/makefs/tests/makefs_zfs_tests.sh | 2 +- usr.sbin/makefs/zfs.c | 13 +++++++++++++ usr.sbin/makefs/zfs/zfs.h | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8 index fdcb94cc4dd0..823334d1b3dc 100644 --- a/usr.sbin/makefs/makefs.8 +++ b/usr.sbin/makefs/makefs.8 @@ -532,6 +532,9 @@ By default, allocates large (up to 512MB) metaslabs with the expectation that the image will be auto-expanded upon first use. This option allows the default heuristic to be overridden. +.It verify-txgs +Prompt OpenZFS to verify pool metadata during import. +This is disabled by default as it may significantly increase import times. .It poolname The name of the ZFS pool. This option must be specified. diff --git a/usr.sbin/makefs/tests/makefs_zfs_tests.sh b/usr.sbin/makefs/tests/makefs_zfs_tests.sh index 7040cf9fd736..aeda889d9a5c 100644 --- a/usr.sbin/makefs/tests/makefs_zfs_tests.sh +++ b/usr.sbin/makefs/tests/makefs_zfs_tests.sh @@ -28,7 +28,7 @@ # SUCH DAMAGE. # -MAKEFS="makefs -t zfs" +MAKEFS="makefs -t zfs -o verify-txgs=true" ZFS_POOL_NAME="makefstest$$" TEST_ZFS_POOL_NAME="$TMPDIR/poolname" diff --git a/usr.sbin/makefs/zfs.c b/usr.sbin/makefs/zfs.c index a0c81f9654ab..66e7f8dafc9c 100644 --- a/usr.sbin/makefs/zfs.c +++ b/usr.sbin/makefs/zfs.c @@ -91,6 +91,8 @@ zfs_prep_opts(fsinfo_t *fsopts) 0, 0, "Prefix for all dataset mount points" }, { '\0', "ashift", &zfs->ashift, OPT_INT32, MINBLOCKSHIFT, MAXBLOCKSHIFT, "ZFS pool ashift" }, + { '\0', "verify-txgs", &zfs->verify_txgs, OPT_BOOL, + 0, 0, "Make OpenZFS verify data upon import" }, { '\0', "nowarn", &zfs->nowarn, OPT_BOOL, 0, 0, "Provided for backwards compatibility, ignored" }, { .name = NULL } @@ -594,7 +596,18 @@ pool_labels_write(zfs_opt_t *zfs) ub = (uberblock_t *)(&label->vl_uberblock[0] + uoff); ub->ub_magic = UBERBLOCK_MAGIC; ub->ub_version = SPA_VERSION; + + /* + * Upon import, OpenZFS will perform metadata verification of + * the last TXG by default. If all data is written in the same + * TXG, it'll all get verified, which can be painfully slow in + * some cases, e.g., initial boot in a cloud environment with + * slow storage. So, fabricate additional TXGs to avoid this + * overhead, unless the user requests otherwise. + */ ub->ub_txg = TXG; + if (!zfs->verify_txgs) + ub->ub_txg += TXG_SIZE; ub->ub_guid_sum = zfs->poolguid + zfs->vdevguid; ub->ub_timestamp = 0; diff --git a/usr.sbin/makefs/zfs/zfs.h b/usr.sbin/makefs/zfs/zfs.h index 5c47b7c3156b..33694e2bdbee 100644 --- a/usr.sbin/makefs/zfs/zfs.h +++ b/usr.sbin/makefs/zfs/zfs.h @@ -55,6 +55,7 @@ _Static_assert(MINBLOCKSIZE == SPA_MINBLOCKSIZE, ""); /* All data was written in this transaction group. */ #define TXG 4 +#define TXG_SIZE 4 typedef struct zfs_dsl_dataset zfs_dsl_dataset_t; typedef struct zfs_dsl_dir zfs_dsl_dir_t; @@ -82,6 +83,7 @@ typedef struct { int ashift; /* vdev block size */ uint64_t mssize; /* metaslab size */ STAILQ_HEAD(, dataset_desc) datasetdescs; /* non-root dataset descrs */ + bool verify_txgs; /* verify data upon import */ /* Pool state. */ uint64_t poolguid; /* pool and root vdev GUID */