From nobody Mon Oct 28 16:59:44 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 4Xcfkm6mHYz5bY7K; Mon, 28 Oct 2024 16:59:44 +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 4Xcfkm468gz4Ddt; Mon, 28 Oct 2024 16:59:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730134784; 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=gnrtF2l39thkYI6RhfRAnGA7KYK/uiemtuSbjSiLXQk=; b=B74gtlXAUcW5UvylZu2h7eG1FTk0OLG8VHk7ilU6iEnV9Bva+04v0sFlxAUHh7PYGWd5aB xRP1quzLeGridehEg3WLGkokM9yl0PQO17W2xwOzMCUH2CuGsUNV+67c7X33VxgWDPx07n v/b8UpokYE39zQ8FHVk8q1oMOgzaeMBgw0URhtkj+22X/vIQvzsELCPzOhR2UxKZ/OhYXv 93U/4frDS8swUhOn4b934WsJsL5/8LO86zZpbRDORzn8l5+yh6dEcOlE1etTAit8NEuCEH CS3enFV1ce2qeIh/aQL6sxGTafUFLiXmPF+snql5vK0WR+Qzfupuq1yMp9DSog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730134784; 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=gnrtF2l39thkYI6RhfRAnGA7KYK/uiemtuSbjSiLXQk=; b=CZYHTwxYt3a280NcfgyPlZ/MAHKKb6KzCuSE5xbt6CHEBBEG9EfLCChDjzCQA6j+xIRHq6 ehtiI0PZG1sOMfWQ7HXAHh/ID6rGTmWcwyDGqDVJ4++dBqfV9RCleOm3lMLz9T0cLTiVom mzAWnB3endnpHhOWJwZQ7T9GN+6cD48uBbA8U9rEBtkedvQ8SbYpljdixNGcDVpXLztgH5 cQUh6Y7pSdyQ8qySXB7GFpG6FGcNuYEEbPBOW8y3yUIg/Ml3A/oMCE5+MW4444qtsZB+Dd Tz5YnRl9rt5AkeMPYxr4SX6cBzL26fMSUNpgFp4gw7RI3fETiE1C7Khc2C1xoQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730134784; a=rsa-sha256; cv=none; b=bYkVxmMD5x8BVuk20N/nMEfYaHofIp/XnEp/v8YR5oypPa4+8bv+IoxSnHwdby/Nfzs3Fq N+eV2LgO9IbWEbfiw3qSjaUp3Shr7PoFCIP7zIUB0wknvGxHx8bcHVqBIdBxPjIIBhrDGh uH5QcsTLpi7meLiRwNSD+eCgyEXerjYuWF2VNHrH9GLuA2ljofMXbOnmiPWE0mDptgqfdT mnQAv2frnq6oTYXA3JVE+jhWjSXgHonVcuvGtr7m98xOCHFYfigxY4LuKPA23m5iQC7bBJ apeZ9h291zFRYFE6YYIaMJHiXaJ6iNoJhFGyOO4eJUqVyVi8RwkNj4bWNSK8Wg== 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 4Xcfkm3jjpzmpX; Mon, 28 Oct 2024 16:59:44 +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 49SGxiFR039987; Mon, 28 Oct 2024 16:59:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49SGxiwM039984; Mon, 28 Oct 2024 16:59:44 GMT (envelope-from git) Date: Mon, 28 Oct 2024 16:59:44 GMT Message-Id: <202410281659.49SGxiwM039984@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: 7d3f9eb16890 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 7d3f9eb168904b0f201c6bb377818d238060075a Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7d3f9eb168904b0f201c6bb377818d238060075a commit 7d3f9eb168904b0f201c6bb377818d238060075a Author: Mark Johnston AuthorDate: 2024-10-14 13:08:09 +0000 Commit: Mark Johnston CommitDate: 2024-10-28 16:39:50 +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 (cherry picked from commit 4e15366c6a6907bcd0e2c28885ba5878ed4280d2) --- 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 c6aeae961196..0cc2619e6c89 100644 --- a/usr.sbin/makefs/makefs.8 +++ b/usr.sbin/makefs/makefs.8 @@ -536,6 +536,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 6e20ae33b354..9196232ed3b3 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 -o nowarn=true" +MAKEFS="makefs -t zfs -o verify-txgs=true -o nowarn=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 b16a48564f04..43469c2358be 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, "Suppress warning about experimental ZFS support" }, { .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 ff94c270bbf6..924fad83f63e 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 */