git: 7377d7440fcd - releng/14.0 - makefs/zfs: Set the objset block pointer fill field correctly

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 05 Oct 2023 15:10:19 UTC
The branch releng/14.0 has been updated by markj:

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

commit 7377d7440fcd60fd58d6a4b51a61f1a7b921eae1
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-09-27 15:56:33 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-05 14:01:23 +0000

    makefs/zfs: Set the objset block pointer fill field correctly
    
    It is supposed to contain the number of objects allocated from the set,
    excluding the meta dnode.
    
    Approved by:    re (gjb)
    Reported by:    mav
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 46402fd21631b7d4686f8c341d92db6bcb190e5d)
    (cherry picked from commit ea5173e5725564da4b95a5b98410b8cd43520dab)
---
 usr.sbin/makefs/zfs/objset.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/makefs/zfs/objset.c b/usr.sbin/makefs/zfs/objset.c
index 22277c150712..3e3dcdeced4b 100644
--- a/usr.sbin/makefs/zfs/objset.c
+++ b/usr.sbin/makefs/zfs/objset.c
@@ -121,6 +121,7 @@ _objset_write(zfs_opt_t *zfs, zfs_objset_t *os, struct dnode_cursor *c,
 	STAILQ_FOREACH_SAFE(chunk, &os->dnodechunks, next, tmp) {
 		unsigned int i;
 
+		assert(chunk->nextfree > 0);
 		assert(chunk->nextfree <= os->dnodecount);
 		assert(chunk->nextfree <= DNODES_PER_CHUNK);
 
@@ -149,8 +150,8 @@ _objset_write(zfs_opt_t *zfs, zfs_objset_t *os, struct dnode_cursor *c,
 	 * Write the object set itself.  The saved block pointer will be copied
 	 * into the referencing DSL dataset or the uberblocks.
 	 */
-	vdev_pwrite_data(zfs, DMU_OT_OBJSET, ZIO_CHECKSUM_FLETCHER_4, 0, 1,
-	    os->phys, os->osblksz, os->osloc, &os->osbp);
+	vdev_pwrite_data(zfs, DMU_OT_OBJSET, ZIO_CHECKSUM_FLETCHER_4, 0,
+	    os->dnodecount - 1, os->phys, os->osblksz, os->osloc, &os->osbp);
 }
 
 void