git: 5d42ef55dec1 - main - zfs: workaround panic on rootfs mount

From: Martin Matuska <mm_at_FreeBSD.org>
Date: Thu, 17 Nov 2022 01:03:32 UTC
The branch main has been updated by mm:

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

commit 5d42ef55dec1a8bef758b84905a9b953f86efd8d
Author:     Martin Matuska <mm@FreeBSD.org>
AuthorDate: 2022-11-17 01:00:05 +0000
Commit:     Martin Matuska <mm@FreeBSD.org>
CommitDate: 2022-11-17 01:01:47 +0000

    zfs: workaround panic on rootfs mount
    
    The import of OpenZFS PR 13758 causes a panic in zfsctl_is_node()
    if ZFS is mounting as root filesystem. This implements a workaround
    until the issue is resolved by authors.
---
 sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
index b4c122bdf4c8..b0f4759eea4d 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
@@ -1328,7 +1328,15 @@ zfs_mount(vfs_t *vfsp)
 	}
 
 	fetch_osname_options(osname, &checkpointrewind);
-	isctlsnap = (zfsctl_is_node(mvp) && strchr(osname, '@') != NULL);
+
+	/*
+         * TBD: Mounting ZFS as root causes a panic in zfsctl_is_node()
+         * add temporary workaround until issue is resolved
+         */
+	if ((vfsp->vfs_flag & MNT_ROOTFS) != 0 &&
+	    (vfsp->vfs_flag & MNT_UPDATE) == 0) {
+		isctlsnap = (zfsctl_is_node(mvp) && strchr(osname, '@') != NULL);
+	}
 
 	/*
 	 * Check for mount privilege?