The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=cd4b9dac1a0dc6b868aa4376ac355aaf25430a77

commit cd4b9dac1a0dc6b868aa4376ac355aaf25430a77
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2025-07-21 13:41:40 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2025-07-21 14:57:58 +0000

    makefs/zfs: Allow the user to specify the pool GUID
    
    This will be used by the test suite to enable running makefs/zfs tests
    in parallel.
    
    MFC after:      1 month
---
 usr.sbin/makefs/makefs.8 | 6 ++++++
 usr.sbin/makefs/zfs.c    | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index c46f283f90a8..d20f69d87559 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -550,6 +550,12 @@ 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 poolguid
+Use the specified 64-bit integer as the pool GUID.
+If this option is not specified, the pool GUID will be random but fixed
+across multiple identical invocations of
+.Nm .
+This option is useful for testing but not required for reproducibility.
 .It poolname
 The name of the ZFS pool.
 This option must be specified.
diff --git a/usr.sbin/makefs/zfs.c b/usr.sbin/makefs/zfs.c
index 66e7f8dafc9c..8d50c450541b 100644
--- a/usr.sbin/makefs/zfs.c
+++ b/usr.sbin/makefs/zfs.c
@@ -38,6 +38,7 @@
 #include <stdalign.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -85,6 +86,8 @@ zfs_prep_opts(fsinfo_t *fsopts)
                  0, 0, "Bootable dataset" },
                { '\0', "mssize", &zfs->mssize, OPT_INT64,
                  MINMSSIZE, MAXMSSIZE, "Metaslab size" },
+               { '\0', "poolguid", &zfs->poolguid, OPT_INT64,
+                 0, INT64_MAX, "ZFS pool GUID" },
                { '\0', "poolname", &zfs->poolname, OPT_STRPTR,
                  0, 0, "ZFS pool name" },
                { '\0', "rootpath", &zfs->rootpath, OPT_STRPTR,
@@ -547,7 +550,8 @@ pool_init(zfs_opt_t *zfs)
 {
        uint64_t dnid;
 
-       zfs->poolguid = randomguid();
+       if (zfs->poolguid == 0)
+               zfs->poolguid = randomguid();
        zfs->vdevguid = randomguid();
 
        zfs->mos = objset_alloc(zfs, DMU_OST_META);

Reply via email to