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
This commit is contained in:
Jessica Clarke 2025-06-16 22:34:12 +01:00
parent 20aaf0f657
commit b4f9be7fb3
3 changed files with 13 additions and 3 deletions

View file

@ -29,6 +29,7 @@
#ifndef _FREEBSD_ZFS_SYS_ZNODE_IMPL_H
#define _FREEBSD_ZFS_SYS_ZNODE_IMPL_H
#ifdef _KERNEL
#include <sys/list.h>
#include <sys/dmu.h>
#include <sys/sa.h>
@ -42,6 +43,7 @@
#include <sys/zfs_project.h>
#include <vm/vm_object.h>
#include <sys/uio.h>
#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

View file

@ -27,7 +27,7 @@
#ifndef _SYS_ZFS_VFSOPS_H
#define _SYS_ZFS_VFSOPS_H
#ifdef _KERNEL
#if defined(_KERNEL) || defined(_WANT_ZNODE)
#include <sys/zfs_vfsops_os.h>
#endif

View file

@ -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 <sys/zfs_znode_impl.h>
#include <sys/zfs_rlock.h>
/*
* 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)