From b4f9be7fb371aa84881d12089d42df5ef14d3e89 Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Mon, 16 Jun 2025 22:34:12 +0100 Subject: [PATCH] openzfs: Add a _WANT_ZNODE that defines struct znode / znode_t for userspace Note that ZNODE_OS_FIELDS needs to change to using struct vnode over vnode_t (matching struct zfsvfs rather than vnode_t) since vnode_t is only defined in the kernel SPL, not the userspace SPL (libspl). Whilst here, tidy up the includes and clarify a comment. Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D50720 --- .../openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h | 9 ++++++++- sys/contrib/openzfs/include/sys/zfs_vfsops.h | 2 +- sys/contrib/openzfs/include/sys/zfs_znode.h | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h index b292818750d..15e3affba0e 100644 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h +++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h @@ -29,6 +29,7 @@ #ifndef _FREEBSD_ZFS_SYS_ZNODE_IMPL_H #define _FREEBSD_ZFS_SYS_ZNODE_IMPL_H +#ifdef _KERNEL #include #include #include @@ -42,6 +43,7 @@ #include #include #include +#endif #ifdef __cplusplus extern "C" { @@ -54,7 +56,7 @@ extern "C" { */ #define ZNODE_OS_FIELDS \ struct zfsvfs *z_zfsvfs; \ - vnode_t *z_vnode; \ + struct vnode *z_vnode; \ char *z_cached_symlink; \ uint64_t z_uid; \ uint64_t z_gid; \ @@ -62,6 +64,8 @@ extern "C" { uint64_t z_atime[2]; \ uint64_t z_links; +#ifdef _KERNEL + #define ZFS_LINK_MAX UINT64_MAX /* @@ -183,6 +187,9 @@ extern int zfs_znode_parent_and_name(struct znode *zp, struct znode **dzpp, char *buf, uint64_t buflen); extern int zfs_rlimit_fsize(off_t fsize); + +#endif /* _KERNEL */ + #ifdef __cplusplus } #endif diff --git a/sys/contrib/openzfs/include/sys/zfs_vfsops.h b/sys/contrib/openzfs/include/sys/zfs_vfsops.h index 18cc31e7183..8b8f73cf354 100644 --- a/sys/contrib/openzfs/include/sys/zfs_vfsops.h +++ b/sys/contrib/openzfs/include/sys/zfs_vfsops.h @@ -27,7 +27,7 @@ #ifndef _SYS_ZFS_VFSOPS_H #define _SYS_ZFS_VFSOPS_H -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_WANT_ZNODE) #include #endif diff --git a/sys/contrib/openzfs/include/sys/zfs_znode.h b/sys/contrib/openzfs/include/sys/zfs_znode.h index b3a267e16f3..2fedaff7853 100644 --- a/sys/contrib/openzfs/include/sys/zfs_znode.h +++ b/sys/contrib/openzfs/include/sys/zfs_znode.h @@ -163,8 +163,9 @@ extern int zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table, uint64_t *pobjp, int *is_xattrdir); extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value); -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_WANT_ZNODE) #include +#include /* * Directory entry locks control access to directory entries. @@ -219,7 +220,9 @@ typedef struct znode { */ ZNODE_OS_FIELDS; } znode_t; +#endif +#ifdef _KERNEL /* Verifies the znode is valid. */ static inline int zfs_verify_zp(znode_t *zp)