aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/include/os/linux/zfs/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/include/os/linux/zfs/sys')
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am30
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h61
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/sha2.h151
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h164
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_arc.h419
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_common.h112
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbgmsg.h89
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbuf.h169
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dmu.h136
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dnode.h129
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_multilist.h89
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_rrwlock.h31
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_txg.h89
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_vdev.h140
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zfs.h53
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h229
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zio.h97
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zrlock.h94
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_context_os.h30
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_ctldir.h103
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_dir.h76
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h227
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops.h91
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h168
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h183
25 files changed, 3160 insertions, 0 deletions
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am b/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am
new file mode 100644
index 000000000000..b56e6771d28a
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am
@@ -0,0 +1,30 @@
+KERNEL_H = \
+ policy.h \
+ sha2.h \
+ trace_acl.h \
+ trace_arc.h \
+ trace_common.h \
+ trace_zfs.h \
+ trace_dbgmsg.h \
+ trace_dbuf.h \
+ trace_dmu.h \
+ trace_dnode.h \
+ trace_multilist.h \
+ trace_rrwlock.h \
+ trace_txg.h \
+ trace_vdev.h \
+ trace_zil.h \
+ trace_zio.h \
+ trace_zrlock.h \
+ zfs_context_os.h \
+ zfs_ctldir.h \
+ zfs_dir.h \
+ zfs_vfsops_os.h \
+ zfs_vnops.h \
+ zfs_znode_impl.h \
+ zpl.h
+
+if CONFIG_KERNEL
+kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys
+kernel_HEADERS = $(KERNEL_H)
+endif
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h
new file mode 100644
index 000000000000..77a73ad149c5
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h
@@ -0,0 +1,61 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2015, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2016, Lawrence Livermore National Security, LLC.
+ */
+
+#ifndef _SYS_POLICY_H
+#define _SYS_POLICY_H
+
+#ifdef _KERNEL
+
+#include <sys/cred.h>
+#include <sys/types.h>
+#include <sys/xvattr.h>
+#include <sys/zpl.h>
+
+int secpolicy_nfs(const cred_t *);
+int secpolicy_sys_config(const cred_t *, boolean_t);
+int secpolicy_vnode_access2(const cred_t *, struct inode *,
+ uid_t, mode_t, mode_t);
+int secpolicy_vnode_any_access(const cred_t *, struct inode *, uid_t);
+int secpolicy_vnode_chown(const cred_t *, uid_t);
+int secpolicy_vnode_create_gid(const cred_t *);
+int secpolicy_vnode_remove(const cred_t *);
+int secpolicy_vnode_setdac(const cred_t *, uid_t);
+int secpolicy_vnode_setid_retain(const cred_t *, boolean_t);
+int secpolicy_vnode_setids_setgids(const cred_t *, gid_t);
+int secpolicy_zinject(const cred_t *);
+int secpolicy_zfs(const cred_t *);
+int secpolicy_zfs_proc(const cred_t *, proc_t *);
+void secpolicy_setid_clear(vattr_t *, cred_t *);
+int secpolicy_setid_setsticky_clear(struct inode *, vattr_t *,
+ const vattr_t *, cred_t *);
+int secpolicy_xvattr(xvattr_t *, uid_t, cred_t *, mode_t);
+int secpolicy_vnode_setattr(cred_t *, struct inode *, struct vattr *,
+ const struct vattr *, int, int (void *, int, cred_t *), void *);
+int secpolicy_basic_link(const cred_t *);
+
+#endif /* _KERNEL */
+#endif /* _SYS_POLICY_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/sha2.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/sha2.h
new file mode 100644
index 000000000000..4dd966b6cab3
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/sha2.h
@@ -0,0 +1,151 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+/* Copyright 2013 Saso Kiselkov. All rights reserved. */
+
+#ifndef _SYS_SHA2_H
+#define _SYS_SHA2_H
+
+#include <sys/types.h> /* for uint_* */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SHA2_HMAC_MIN_KEY_LEN 1 /* SHA2-HMAC min key length in bytes */
+#define SHA2_HMAC_MAX_KEY_LEN INT_MAX /* SHA2-HMAC max key length in bytes */
+
+#define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */
+#define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */
+#define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */
+
+/* Truncated versions of SHA-512 according to FIPS-180-4, section 5.3.6 */
+#define SHA512_224_DIGEST_LENGTH 28 /* SHA512/224 digest length */
+#define SHA512_256_DIGEST_LENGTH 32 /* SHA512/256 digest length */
+
+#define SHA256_HMAC_BLOCK_SIZE 64 /* SHA256-HMAC block size */
+#define SHA512_HMAC_BLOCK_SIZE 128 /* SHA512-HMAC block size */
+
+#define SHA256 0
+#define SHA256_HMAC 1
+#define SHA256_HMAC_GEN 2
+#define SHA384 3
+#define SHA384_HMAC 4
+#define SHA384_HMAC_GEN 5
+#define SHA512 6
+#define SHA512_HMAC 7
+#define SHA512_HMAC_GEN 8
+#define SHA512_224 9
+#define SHA512_256 10
+
+/*
+ * SHA2 context.
+ * The contents of this structure are a private interface between the
+ * Init/Update/Final calls of the functions defined below.
+ * Callers must never attempt to read or write any of the fields
+ * in this structure directly.
+ */
+typedef struct {
+ uint32_t algotype; /* Algorithm Type */
+
+ /* state (ABCDEFGH) */
+ union {
+ uint32_t s32[8]; /* for SHA256 */
+ uint64_t s64[8]; /* for SHA384/512 */
+ } state;
+ /* number of bits */
+ union {
+ uint32_t c32[2]; /* for SHA256 , modulo 2^64 */
+ uint64_t c64[2]; /* for SHA384/512, modulo 2^128 */
+ } count;
+ union {
+ uint8_t buf8[128]; /* undigested input */
+ uint32_t buf32[32]; /* realigned input */
+ uint64_t buf64[16]; /* realigned input */
+ } buf_un;
+} SHA2_CTX;
+
+typedef SHA2_CTX SHA256_CTX;
+typedef SHA2_CTX SHA384_CTX;
+typedef SHA2_CTX SHA512_CTX;
+
+extern void SHA2Init(uint64_t mech, SHA2_CTX *);
+
+extern void SHA2Update(SHA2_CTX *, const void *, size_t);
+
+extern void SHA2Final(void *, SHA2_CTX *);
+
+extern void SHA256Init(SHA256_CTX *);
+
+extern void SHA256Update(SHA256_CTX *, const void *, size_t);
+
+extern void SHA256Final(void *, SHA256_CTX *);
+
+extern void SHA384Init(SHA384_CTX *);
+
+extern void SHA384Update(SHA384_CTX *, const void *, size_t);
+
+extern void SHA384Final(void *, SHA384_CTX *);
+
+extern void SHA512Init(SHA512_CTX *);
+
+extern void SHA512Update(SHA512_CTX *, const void *, size_t);
+
+extern void SHA512Final(void *, SHA512_CTX *);
+
+#ifdef _SHA2_IMPL
+/*
+ * The following types/functions are all private to the implementation
+ * of the SHA2 functions and must not be used by consumers of the interface
+ */
+
+/*
+ * List of support mechanisms in this module.
+ *
+ * It is important to note that in the module, division or modulus calculations
+ * are used on the enumerated type to determine which mechanism is being used;
+ * therefore, changing the order or additional mechanisms should be done
+ * carefully
+ */
+typedef enum sha2_mech_type {
+ SHA256_MECH_INFO_TYPE, /* SUN_CKM_SHA256 */
+ SHA256_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA256_HMAC */
+ SHA256_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA256_HMAC_GENERAL */
+ SHA384_MECH_INFO_TYPE, /* SUN_CKM_SHA384 */
+ SHA384_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA384_HMAC */
+ SHA384_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA384_HMAC_GENERAL */
+ SHA512_MECH_INFO_TYPE, /* SUN_CKM_SHA512 */
+ SHA512_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA512_HMAC */
+ SHA512_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA512_HMAC_GENERAL */
+ SHA512_224_MECH_INFO_TYPE, /* SUN_CKM_SHA512_224 */
+ SHA512_256_MECH_INFO_TYPE /* SUN_CKM_SHA512_256 */
+} sha2_mech_type_t;
+
+#endif /* _SHA2_IMPL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_SHA2_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h
new file mode 100644
index 000000000000..083560952f0b
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h
@@ -0,0 +1,164 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_acl
+
+#if !defined(_TRACE_ACL_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ACL_H
+
+#include <linux/tracepoint.h>
+#include <linux/vfs_compat.h>
+#include <sys/types.h>
+
+/*
+ * Generic support for three argument tracepoints of the form:
+ *
+ * DTRACE_PROBE3(...,
+ * znode_t *, ...,
+ * zfs_ace_hdr_t *, ...,
+ * uint32_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_ace_class,
+ TP_PROTO(znode_t *zn, zfs_ace_hdr_t *ace, uint32_t mask_matched),
+ TP_ARGS(zn, ace, mask_matched),
+ TP_STRUCT__entry(
+ __field(uint64_t, z_id)
+ __field(uint8_t, z_unlinked)
+ __field(uint8_t, z_atime_dirty)
+ __field(uint8_t, z_zn_prefetch)
+ __field(uint8_t, z_moved)
+ __field(uint_t, z_blksz)
+ __field(uint_t, z_seq)
+ __field(uint64_t, z_mapcnt)
+ __field(uint64_t, z_size)
+ __field(uint64_t, z_pflags)
+ __field(uint32_t, z_sync_cnt)
+ __field(mode_t, z_mode)
+ __field(boolean_t, z_is_sa)
+ __field(boolean_t, z_is_mapped)
+ __field(boolean_t, z_is_ctldir)
+ __field(boolean_t, z_is_stale)
+
+ __field(uint32_t, i_uid)
+ __field(uint32_t, i_gid)
+ __field(unsigned long, i_ino)
+ __field(unsigned int, i_nlink)
+ __field(loff_t, i_size)
+ __field(unsigned int, i_blkbits)
+ __field(unsigned short, i_bytes)
+ __field(umode_t, i_mode)
+ __field(__u32, i_generation)
+
+ __field(uint16_t, z_type)
+ __field(uint16_t, z_flags)
+ __field(uint32_t, z_access_mask)
+
+ __field(uint32_t, mask_matched)
+ ),
+ TP_fast_assign(
+ __entry->z_id = zn->z_id;
+ __entry->z_unlinked = zn->z_unlinked;
+ __entry->z_atime_dirty = zn->z_atime_dirty;
+ __entry->z_zn_prefetch = zn->z_zn_prefetch;
+ __entry->z_moved = zn->z_moved;
+ __entry->z_blksz = zn->z_blksz;
+ __entry->z_seq = zn->z_seq;
+ __entry->z_mapcnt = zn->z_mapcnt;
+ __entry->z_size = zn->z_size;
+ __entry->z_pflags = zn->z_pflags;
+ __entry->z_sync_cnt = zn->z_sync_cnt;
+ __entry->z_mode = zn->z_mode;
+ __entry->z_is_sa = zn->z_is_sa;
+ __entry->z_is_mapped = zn->z_is_mapped;
+ __entry->z_is_ctldir = zn->z_is_ctldir;
+ __entry->z_is_stale = zn->z_is_stale;
+
+ __entry->i_uid = KUID_TO_SUID(ZTOI(zn)->i_uid);
+ __entry->i_gid = KGID_TO_SGID(ZTOI(zn)->i_gid);
+ __entry->i_ino = zn->z_inode.i_ino;
+ __entry->i_nlink = zn->z_inode.i_nlink;
+ __entry->i_size = zn->z_inode.i_size;
+ __entry->i_blkbits = zn->z_inode.i_blkbits;
+ __entry->i_bytes = zn->z_inode.i_bytes;
+ __entry->i_mode = zn->z_inode.i_mode;
+ __entry->i_generation = zn->z_inode.i_generation;
+
+ __entry->z_type = ace->z_type;
+ __entry->z_flags = ace->z_flags;
+ __entry->z_access_mask = ace->z_access_mask;
+
+ __entry->mask_matched = mask_matched;
+ ),
+ TP_printk("zn { id %llu unlinked %u atime_dirty %u "
+ "zn_prefetch %u moved %u blksz %u seq %u "
+ "mapcnt %llu size %llu pflags %llu "
+ "sync_cnt %u mode 0x%x is_sa %d "
+ "is_mapped %d is_ctldir %d is_stale %d inode { "
+ "uid %u gid %u ino %lu nlink %u size %lli "
+ "blkbits %u bytes %u mode 0x%x generation %x } } "
+ "ace { type %u flags %u access_mask %u } mask_matched %u",
+ __entry->z_id, __entry->z_unlinked, __entry->z_atime_dirty,
+ __entry->z_zn_prefetch, __entry->z_moved, __entry->z_blksz,
+ __entry->z_seq, __entry->z_mapcnt, __entry->z_size,
+ __entry->z_pflags, __entry->z_sync_cnt, __entry->z_mode,
+ __entry->z_is_sa, __entry->z_is_mapped,
+ __entry->z_is_ctldir, __entry->z_is_stale, __entry->i_uid,
+ __entry->i_gid, __entry->i_ino, __entry->i_nlink,
+ __entry->i_size, __entry->i_blkbits,
+ __entry->i_bytes, __entry->i_mode, __entry->i_generation,
+ __entry->z_type, __entry->z_flags, __entry->z_access_mask,
+ __entry->mask_matched)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_ACE_EVENT(name) \
+DEFINE_EVENT(zfs_ace_class, name, \
+ TP_PROTO(znode_t *zn, zfs_ace_hdr_t *ace, uint32_t mask_matched), \
+ TP_ARGS(zn, ace, mask_matched))
+/* END CSTYLED */
+DEFINE_ACE_EVENT(zfs_zfs__ace__denies);
+DEFINE_ACE_EVENT(zfs_zfs__ace__allows);
+
+#endif /* _TRACE_ACL_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_acl
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE3(zfs__ace__denies);
+DEFINE_DTRACE_PROBE3(zfs__ace__allows);
+DEFINE_DTRACE_PROBE(zfs__fastpath__execute__access__miss);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_arc.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_arc.h
new file mode 100644
index 000000000000..3df491f8b392
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_arc.h
@@ -0,0 +1,419 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#include <sys/list.h>
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_arc
+
+#if !defined(_TRACE_ARC_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ARC_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+#include <sys/trace_common.h> /* For ZIO macros */
+
+/*
+ * Generic support for one argument tracepoints of the form:
+ *
+ * DTRACE_PROBE1(...,
+ * arc_buf_hdr_t *, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_arc_buf_hdr_class,
+ TP_PROTO(arc_buf_hdr_t *ab),
+ TP_ARGS(ab),
+ TP_STRUCT__entry(
+ __array(uint64_t, hdr_dva_word, 2)
+ __field(uint64_t, hdr_birth)
+ __field(uint32_t, hdr_flags)
+ __field(uint32_t, hdr_bufcnt)
+ __field(arc_buf_contents_t, hdr_type)
+ __field(uint16_t, hdr_psize)
+ __field(uint16_t, hdr_lsize)
+ __field(uint64_t, hdr_spa)
+ __field(arc_state_type_t, hdr_state_type)
+ __field(clock_t, hdr_access)
+ __field(uint32_t, hdr_mru_hits)
+ __field(uint32_t, hdr_mru_ghost_hits)
+ __field(uint32_t, hdr_mfu_hits)
+ __field(uint32_t, hdr_mfu_ghost_hits)
+ __field(uint32_t, hdr_l2_hits)
+ __field(int64_t, hdr_refcount)
+ ),
+ TP_fast_assign(
+ __entry->hdr_dva_word[0] = ab->b_dva.dva_word[0];
+ __entry->hdr_dva_word[1] = ab->b_dva.dva_word[1];
+ __entry->hdr_birth = ab->b_birth;
+ __entry->hdr_flags = ab->b_flags;
+ __entry->hdr_bufcnt = ab->b_l1hdr.b_bufcnt;
+ __entry->hdr_psize = ab->b_psize;
+ __entry->hdr_lsize = ab->b_lsize;
+ __entry->hdr_spa = ab->b_spa;
+ __entry->hdr_state_type = ab->b_l1hdr.b_state->arcs_state;
+ __entry->hdr_access = ab->b_l1hdr.b_arc_access;
+ __entry->hdr_mru_hits = ab->b_l1hdr.b_mru_hits;
+ __entry->hdr_mru_ghost_hits = ab->b_l1hdr.b_mru_ghost_hits;
+ __entry->hdr_mfu_hits = ab->b_l1hdr.b_mfu_hits;
+ __entry->hdr_mfu_ghost_hits = ab->b_l1hdr.b_mfu_ghost_hits;
+ __entry->hdr_l2_hits = ab->b_l1hdr.b_l2_hits;
+ __entry->hdr_refcount = ab->b_l1hdr.b_refcnt.rc_count;
+ ),
+ TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
+ "flags 0x%x bufcnt %u type %u psize %u lsize %u spa %llu "
+ "state_type %u access %lu mru_hits %u mru_ghost_hits %u "
+ "mfu_hits %u mfu_ghost_hits %u l2_hits %u refcount %lli }",
+ __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
+ __entry->hdr_birth, __entry->hdr_flags,
+ __entry->hdr_bufcnt, __entry->hdr_type, __entry->hdr_psize,
+ __entry->hdr_lsize, __entry->hdr_spa, __entry->hdr_state_type,
+ __entry->hdr_access, __entry->hdr_mru_hits,
+ __entry->hdr_mru_ghost_hits, __entry->hdr_mfu_hits,
+ __entry->hdr_mfu_ghost_hits, __entry->hdr_l2_hits,
+ __entry->hdr_refcount)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_ARC_BUF_HDR_EVENT(name) \
+DEFINE_EVENT(zfs_arc_buf_hdr_class, name, \
+ TP_PROTO(arc_buf_hdr_t *ab), \
+ TP_ARGS(ab))
+/* END CSTYLED */
+DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__hit);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__evict);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__delete);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mru);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mfu);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__async__upgrade__sync);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__demand__hit__predictive__prefetch);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__hit);
+DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__miss);
+
+/*
+ * Generic support for two argument tracepoints of the form:
+ *
+ * DTRACE_PROBE2(...,
+ * vdev_t *, ...,
+ * zio_t *, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_l2arc_rw_class,
+ TP_PROTO(vdev_t *vd, zio_t *zio),
+ TP_ARGS(vd, zio),
+ TP_STRUCT__entry(
+ __field(uint64_t, vdev_id)
+ __field(uint64_t, vdev_guid)
+ __field(uint64_t, vdev_state)
+ ZIO_TP_STRUCT_ENTRY
+ ),
+ TP_fast_assign(
+ __entry->vdev_id = vd->vdev_id;
+ __entry->vdev_guid = vd->vdev_guid;
+ __entry->vdev_state = vd->vdev_state;
+ ZIO_TP_FAST_ASSIGN
+ ),
+ TP_printk("vdev { id %llu guid %llu state %llu } "
+ ZIO_TP_PRINTK_FMT, __entry->vdev_id, __entry->vdev_guid,
+ __entry->vdev_state, ZIO_TP_PRINTK_ARGS)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_L2ARC_RW_EVENT(name) \
+DEFINE_EVENT(zfs_l2arc_rw_class, name, \
+ TP_PROTO(vdev_t *vd, zio_t *zio), \
+ TP_ARGS(vd, zio))
+/* END CSTYLED */
+DEFINE_L2ARC_RW_EVENT(zfs_l2arc__read);
+DEFINE_L2ARC_RW_EVENT(zfs_l2arc__write);
+
+
+/*
+ * Generic support for two argument tracepoints of the form:
+ *
+ * DTRACE_PROBE2(...,
+ * zio_t *, ...,
+ * l2arc_write_callback_t *, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_l2arc_iodone_class,
+ TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb),
+ TP_ARGS(zio, cb),
+ TP_STRUCT__entry(ZIO_TP_STRUCT_ENTRY),
+ TP_fast_assign(ZIO_TP_FAST_ASSIGN),
+ TP_printk(ZIO_TP_PRINTK_FMT, ZIO_TP_PRINTK_ARGS)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_L2ARC_IODONE_EVENT(name) \
+DEFINE_EVENT(zfs_l2arc_iodone_class, name, \
+ TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb), \
+ TP_ARGS(zio, cb))
+/* END CSTYLED */
+DEFINE_L2ARC_IODONE_EVENT(zfs_l2arc__iodone);
+
+
+/*
+ * Generic support for four argument tracepoints of the form:
+ *
+ * DTRACE_PROBE4(...,
+ * arc_buf_hdr_t *, ...,
+ * const blkptr_t *,
+ * uint64_t,
+ * const zbookmark_phys_t *);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_arc_miss_class,
+ TP_PROTO(arc_buf_hdr_t *hdr,
+ const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb),
+ TP_ARGS(hdr, bp, size, zb),
+ TP_STRUCT__entry(
+ __array(uint64_t, hdr_dva_word, 2)
+ __field(uint64_t, hdr_birth)
+ __field(uint32_t, hdr_flags)
+ __field(uint32_t, hdr_bufcnt)
+ __field(arc_buf_contents_t, hdr_type)
+ __field(uint16_t, hdr_psize)
+ __field(uint16_t, hdr_lsize)
+ __field(uint64_t, hdr_spa)
+ __field(arc_state_type_t, hdr_state_type)
+ __field(clock_t, hdr_access)
+ __field(uint32_t, hdr_mru_hits)
+ __field(uint32_t, hdr_mru_ghost_hits)
+ __field(uint32_t, hdr_mfu_hits)
+ __field(uint32_t, hdr_mfu_ghost_hits)
+ __field(uint32_t, hdr_l2_hits)
+ __field(int64_t, hdr_refcount)
+
+ __array(uint64_t, bp_dva0, 2)
+ __array(uint64_t, bp_dva1, 2)
+ __array(uint64_t, bp_dva2, 2)
+ __array(uint64_t, bp_cksum, 4)
+
+ __field(uint64_t, bp_lsize)
+
+ __field(uint64_t, zb_objset)
+ __field(uint64_t, zb_object)
+ __field(int64_t, zb_level)
+ __field(uint64_t, zb_blkid)
+ ),
+ TP_fast_assign(
+ __entry->hdr_dva_word[0] = hdr->b_dva.dva_word[0];
+ __entry->hdr_dva_word[1] = hdr->b_dva.dva_word[1];
+ __entry->hdr_birth = hdr->b_birth;
+ __entry->hdr_flags = hdr->b_flags;
+ __entry->hdr_bufcnt = hdr->b_l1hdr.b_bufcnt;
+ __entry->hdr_psize = hdr->b_psize;
+ __entry->hdr_lsize = hdr->b_lsize;
+ __entry->hdr_spa = hdr->b_spa;
+ __entry->hdr_state_type = hdr->b_l1hdr.b_state->arcs_state;
+ __entry->hdr_access = hdr->b_l1hdr.b_arc_access;
+ __entry->hdr_mru_hits = hdr->b_l1hdr.b_mru_hits;
+ __entry->hdr_mru_ghost_hits = hdr->b_l1hdr.b_mru_ghost_hits;
+ __entry->hdr_mfu_hits = hdr->b_l1hdr.b_mfu_hits;
+ __entry->hdr_mfu_ghost_hits = hdr->b_l1hdr.b_mfu_ghost_hits;
+ __entry->hdr_l2_hits = hdr->b_l1hdr.b_l2_hits;
+ __entry->hdr_refcount = hdr->b_l1hdr.b_refcnt.rc_count;
+
+ __entry->bp_dva0[0] = bp->blk_dva[0].dva_word[0];
+ __entry->bp_dva0[1] = bp->blk_dva[0].dva_word[1];
+ __entry->bp_dva1[0] = bp->blk_dva[1].dva_word[0];
+ __entry->bp_dva1[1] = bp->blk_dva[1].dva_word[1];
+ __entry->bp_dva2[0] = bp->blk_dva[2].dva_word[0];
+ __entry->bp_dva2[1] = bp->blk_dva[2].dva_word[1];
+ __entry->bp_cksum[0] = bp->blk_cksum.zc_word[0];
+ __entry->bp_cksum[1] = bp->blk_cksum.zc_word[1];
+ __entry->bp_cksum[2] = bp->blk_cksum.zc_word[2];
+ __entry->bp_cksum[3] = bp->blk_cksum.zc_word[3];
+
+ __entry->bp_lsize = size;
+
+ __entry->zb_objset = zb->zb_objset;
+ __entry->zb_object = zb->zb_object;
+ __entry->zb_level = zb->zb_level;
+ __entry->zb_blkid = zb->zb_blkid;
+ ),
+ TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
+ "flags 0x%x bufcnt %u psize %u lsize %u spa %llu state_type %u "
+ "access %lu mru_hits %u mru_ghost_hits %u mfu_hits %u "
+ "mfu_ghost_hits %u l2_hits %u refcount %lli } "
+ "bp { dva0 0x%llx:0x%llx dva1 0x%llx:0x%llx dva2 "
+ "0x%llx:0x%llx cksum 0x%llx:0x%llx:0x%llx:0x%llx "
+ "lsize %llu } zb { objset %llu object %llu level %lli "
+ "blkid %llu }",
+ __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
+ __entry->hdr_birth, __entry->hdr_flags,
+ __entry->hdr_bufcnt, __entry->hdr_psize, __entry->hdr_lsize,
+ __entry->hdr_spa, __entry->hdr_state_type, __entry->hdr_access,
+ __entry->hdr_mru_hits, __entry->hdr_mru_ghost_hits,
+ __entry->hdr_mfu_hits, __entry->hdr_mfu_ghost_hits,
+ __entry->hdr_l2_hits, __entry->hdr_refcount,
+ __entry->bp_dva0[0], __entry->bp_dva0[1],
+ __entry->bp_dva1[0], __entry->bp_dva1[1],
+ __entry->bp_dva2[0], __entry->bp_dva2[1],
+ __entry->bp_cksum[0], __entry->bp_cksum[1],
+ __entry->bp_cksum[2], __entry->bp_cksum[3],
+ __entry->bp_lsize, __entry->zb_objset, __entry->zb_object,
+ __entry->zb_level, __entry->zb_blkid)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_ARC_MISS_EVENT(name) \
+DEFINE_EVENT(zfs_arc_miss_class, name, \
+ TP_PROTO(arc_buf_hdr_t *hdr, \
+ const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb), \
+ TP_ARGS(hdr, bp, size, zb))
+/* END CSTYLED */
+DEFINE_ARC_MISS_EVENT(zfs_arc__miss);
+
+/*
+ * Generic support for four argument tracepoints of the form:
+ *
+ * DTRACE_PROBE4(...,
+ * l2arc_dev_t *, ...,
+ * list_t *, ...,
+ * uint64_t, ...,
+ * boolean_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_l2arc_evict_class,
+ TP_PROTO(l2arc_dev_t *dev,
+ list_t *buflist, uint64_t taddr, boolean_t all),
+ TP_ARGS(dev, buflist, taddr, all),
+ TP_STRUCT__entry(
+ __field(uint64_t, vdev_id)
+ __field(uint64_t, vdev_guid)
+ __field(uint64_t, vdev_state)
+
+ __field(uint64_t, l2ad_hand)
+ __field(uint64_t, l2ad_start)
+ __field(uint64_t, l2ad_end)
+ __field(boolean_t, l2ad_first)
+ __field(boolean_t, l2ad_writing)
+
+ __field(uint64_t, taddr)
+ __field(boolean_t, all)
+ ),
+ TP_fast_assign(
+ __entry->vdev_id = dev->l2ad_vdev->vdev_id;
+ __entry->vdev_guid = dev->l2ad_vdev->vdev_guid;
+ __entry->vdev_state = dev->l2ad_vdev->vdev_state;
+
+ __entry->l2ad_hand = dev->l2ad_hand;
+ __entry->l2ad_start = dev->l2ad_start;
+ __entry->l2ad_end = dev->l2ad_end;
+ __entry->l2ad_first = dev->l2ad_first;
+ __entry->l2ad_writing = dev->l2ad_writing;
+
+ __entry->taddr = taddr;
+ __entry->all = all;
+ ),
+ TP_printk("l2ad { vdev { id %llu guid %llu state %llu } "
+ "hand %llu start %llu end %llu "
+ "first %d writing %d } taddr %llu all %d",
+ __entry->vdev_id, __entry->vdev_guid, __entry->vdev_state,
+ __entry->l2ad_hand, __entry->l2ad_start,
+ __entry->l2ad_end, __entry->l2ad_first, __entry->l2ad_writing,
+ __entry->taddr, __entry->all)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_L2ARC_EVICT_EVENT(name) \
+DEFINE_EVENT(zfs_l2arc_evict_class, name, \
+ TP_PROTO(l2arc_dev_t *dev, \
+ list_t *buflist, uint64_t taddr, boolean_t all), \
+ TP_ARGS(dev, buflist, taddr, all))
+/* END CSTYLED */
+DEFINE_L2ARC_EVICT_EVENT(zfs_l2arc__evict);
+
+/*
+ * Generic support for three argument tracepoints of the form:
+ *
+ * DTRACE_PROBE3(...,
+ * uint64_t, ...,
+ * uint64_t, ...,
+ * uint64_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_arc_wait_for_eviction_class,
+ TP_PROTO(uint64_t amount, uint64_t arc_evict_count, uint64_t aew_count),
+ TP_ARGS(amount, arc_evict_count, aew_count),
+ TP_STRUCT__entry(
+ __field(uint64_t, amount)
+ __field(uint64_t, arc_evict_count)
+ __field(uint64_t, aew_count)
+ ),
+ TP_fast_assign(
+ __entry->amount = amount;
+ __entry->arc_evict_count = arc_evict_count;
+ __entry->aew_count = aew_count;
+ ),
+ TP_printk("amount %llu arc_evict_count %llu aew_count %llu",
+ __entry->amount, __entry->arc_evict_count, __entry->aew_count)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_ARC_WAIT_FOR_EVICTION_EVENT(name) \
+DEFINE_EVENT(zfs_arc_wait_for_eviction_class, name, \
+ TP_PROTO(uint64_t amount, uint64_t arc_evict_count, uint64_t aew_count), \
+ TP_ARGS(amount, arc_evict_count, aew_count))
+/* END CSTYLED */
+DEFINE_ARC_WAIT_FOR_EVICTION_EVENT(zfs_arc__wait__for__eviction);
+
+#endif /* _TRACE_ARC_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_arc
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE1(arc__hit);
+DEFINE_DTRACE_PROBE1(arc__evict);
+DEFINE_DTRACE_PROBE1(arc__delete);
+DEFINE_DTRACE_PROBE1(new_state__mru);
+DEFINE_DTRACE_PROBE1(new_state__mfu);
+DEFINE_DTRACE_PROBE1(arc__async__upgrade__sync);
+DEFINE_DTRACE_PROBE1(arc__demand__hit__predictive__prefetch);
+DEFINE_DTRACE_PROBE1(l2arc__hit);
+DEFINE_DTRACE_PROBE1(l2arc__miss);
+DEFINE_DTRACE_PROBE2(l2arc__read);
+DEFINE_DTRACE_PROBE2(l2arc__write);
+DEFINE_DTRACE_PROBE2(l2arc__iodone);
+DEFINE_DTRACE_PROBE3(arc__wait__for__eviction);
+DEFINE_DTRACE_PROBE4(arc__miss);
+DEFINE_DTRACE_PROBE4(l2arc__evict);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_common.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_common.h
new file mode 100644
index 000000000000..6922d1a1810a
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_common.h
@@ -0,0 +1,112 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * This file contains commonly used trace macros. Feel free to add and use
+ * them in your tracepoint headers.
+ */
+
+#ifndef _SYS_TRACE_COMMON_H
+#define _SYS_TRACE_COMMON_H
+#include <linux/tracepoint.h>
+
+/* ZIO macros */
+#define ZIO_TP_STRUCT_ENTRY \
+ __field(zio_type_t, zio_type) \
+ __field(int, zio_cmd) \
+ __field(zio_priority_t, zio_priority) \
+ __field(uint64_t, zio_size) \
+ __field(uint64_t, zio_orig_size) \
+ __field(uint64_t, zio_offset) \
+ __field(hrtime_t, zio_timestamp) \
+ __field(hrtime_t, zio_delta) \
+ __field(uint64_t, zio_delay) \
+ __field(enum zio_flag, zio_flags) \
+ __field(enum zio_stage, zio_stage) \
+ __field(enum zio_stage, zio_pipeline) \
+ __field(enum zio_flag, zio_orig_flags) \
+ __field(enum zio_stage, zio_orig_stage) \
+ __field(enum zio_stage, zio_orig_pipeline) \
+ __field(uint8_t, zio_reexecute) \
+ __field(uint64_t, zio_txg) \
+ __field(int, zio_error) \
+ __field(uint64_t, zio_ena) \
+ \
+ __field(enum zio_checksum, zp_checksum) \
+ __field(enum zio_compress, zp_compress) \
+ __field(dmu_object_type_t, zp_type) \
+ __field(uint8_t, zp_level) \
+ __field(uint8_t, zp_copies) \
+ __field(boolean_t, zp_dedup) \
+ __field(boolean_t, zp_dedup_verify) \
+ __field(boolean_t, zp_nopwrite)
+
+#define ZIO_TP_FAST_ASSIGN \
+ __entry->zio_type = zio->io_type; \
+ __entry->zio_cmd = zio->io_cmd; \
+ __entry->zio_priority = zio->io_priority; \
+ __entry->zio_size = zio->io_size; \
+ __entry->zio_orig_size = zio->io_orig_size; \
+ __entry->zio_offset = zio->io_offset; \
+ __entry->zio_timestamp = zio->io_timestamp; \
+ __entry->zio_delta = zio->io_delta; \
+ __entry->zio_delay = zio->io_delay; \
+ __entry->zio_flags = zio->io_flags; \
+ __entry->zio_stage = zio->io_stage; \
+ __entry->zio_pipeline = zio->io_pipeline; \
+ __entry->zio_orig_flags = zio->io_orig_flags; \
+ __entry->zio_orig_stage = zio->io_orig_stage; \
+ __entry->zio_orig_pipeline = zio->io_orig_pipeline; \
+ __entry->zio_reexecute = zio->io_reexecute; \
+ __entry->zio_txg = zio->io_txg; \
+ __entry->zio_error = zio->io_error; \
+ __entry->zio_ena = zio->io_ena; \
+ \
+ __entry->zp_checksum = zio->io_prop.zp_checksum; \
+ __entry->zp_compress = zio->io_prop.zp_compress; \
+ __entry->zp_type = zio->io_prop.zp_type; \
+ __entry->zp_level = zio->io_prop.zp_level; \
+ __entry->zp_copies = zio->io_prop.zp_copies; \
+ __entry->zp_dedup = zio->io_prop.zp_dedup; \
+ __entry->zp_nopwrite = zio->io_prop.zp_nopwrite; \
+ __entry->zp_dedup_verify = zio->io_prop.zp_dedup_verify;
+
+#define ZIO_TP_PRINTK_FMT \
+ "zio { type %u cmd %i prio %u size %llu orig_size %llu " \
+ "offset %llu timestamp %llu delta %llu delay %llu " \
+ "flags 0x%x stage 0x%x pipeline 0x%x orig_flags 0x%x " \
+ "orig_stage 0x%x orig_pipeline 0x%x reexecute %u " \
+ "txg %llu error %d ena %llu prop { checksum %u compress %u " \
+ "type %u level %u copies %u dedup %u dedup_verify %u nopwrite %u } }"
+
+#define ZIO_TP_PRINTK_ARGS \
+ __entry->zio_type, __entry->zio_cmd, __entry->zio_priority, \
+ __entry->zio_size, __entry->zio_orig_size, __entry->zio_offset, \
+ __entry->zio_timestamp, __entry->zio_delta, __entry->zio_delay, \
+ __entry->zio_flags, __entry->zio_stage, __entry->zio_pipeline, \
+ __entry->zio_orig_flags, __entry->zio_orig_stage, \
+ __entry->zio_orig_pipeline, __entry->zio_reexecute, \
+ __entry->zio_txg, __entry->zio_error, __entry->zio_ena, \
+ __entry->zp_checksum, __entry->zp_compress, __entry->zp_type, \
+ __entry->zp_level, __entry->zp_copies, __entry->zp_dedup, \
+ __entry->zp_dedup_verify, __entry->zp_nopwrite
+
+#endif /* _SYS_TRACE_COMMON_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbgmsg.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbgmsg.h
new file mode 100644
index 000000000000..513918d004a4
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbgmsg.h
@@ -0,0 +1,89 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_dbgmsg
+
+#if !defined(_TRACE_DBGMSG_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_DBGMSG_H
+
+#include <linux/tracepoint.h>
+
+/*
+ * This file defines tracepoint events for use by the dbgmsg(),
+ * dprintf(), and SET_ERROR() interfaces. These are grouped here because
+ * they all provide a way to store simple messages in the debug log (as
+ * opposed to events used by the DTRACE_PROBE interfaces which typically
+ * dump structured data).
+ *
+ * This header is included inside the trace.h multiple inclusion guard,
+ * and it is guarded above against direct inclusion, so it and need not
+ * be guarded separately.
+ */
+
+/*
+ * Generic support for one argument tracepoints of the form:
+ *
+ * DTRACE_PROBE1(...,
+ * const char *, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_dprintf_class,
+ TP_PROTO(const char *msg),
+ TP_ARGS(msg),
+ TP_STRUCT__entry(
+ __string(msg, msg)
+ ),
+ TP_fast_assign(
+ __assign_str(msg, msg);
+ ),
+ TP_printk("%s", __get_str(msg))
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_DPRINTF_EVENT(name) \
+DEFINE_EVENT(zfs_dprintf_class, name, \
+ TP_PROTO(const char *msg), \
+ TP_ARGS(msg))
+/* END CSTYLED */
+DEFINE_DPRINTF_EVENT(zfs_zfs__dprintf);
+
+#endif /* _TRACE_DBGMSG_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_dbgmsg
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE1(zfs__dprintf);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbuf.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbuf.h
new file mode 100644
index 000000000000..bd7d791a46e7
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbuf.h
@@ -0,0 +1,169 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_dbuf
+
+#if !defined(_TRACE_DBUF_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_DBUF_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+#ifndef TRACE_DBUF_MSG_MAX
+#define TRACE_DBUF_MSG_MAX 512
+#endif
+
+/*
+ * Generic support for two argument tracepoints of the form:
+ *
+ * DTRACE_PROBE2(...,
+ * dmu_buf_impl_t *, ...,
+ * zio_t *, ...);
+ */
+
+#define DBUF_TP_STRUCT_ENTRY \
+ __dynamic_array(char, os_spa, TRACE_DBUF_MSG_MAX) \
+ __field(uint64_t, ds_object) \
+ __field(uint64_t, db_object) \
+ __field(uint64_t, db_level) \
+ __field(uint64_t, db_blkid) \
+ __field(uint64_t, db_offset) \
+ __field(uint64_t, db_size) \
+ __field(uint64_t, db_state) \
+ __field(int64_t, db_holds) \
+ __dynamic_array(char, msg, TRACE_DBUF_MSG_MAX)
+
+#define DBUF_TP_FAST_ASSIGN \
+ if (db != NULL) { \
+ __assign_str(os_spa, \
+ spa_name(DB_DNODE(db)->dn_objset->os_spa)); \
+ \
+ __entry->ds_object = db->db_objset->os_dsl_dataset ? \
+ db->db_objset->os_dsl_dataset->ds_object : 0; \
+ \
+ __entry->db_object = db->db.db_object; \
+ __entry->db_level = db->db_level; \
+ __entry->db_blkid = db->db_blkid; \
+ __entry->db_offset = db->db.db_offset; \
+ __entry->db_size = db->db.db_size; \
+ __entry->db_state = db->db_state; \
+ __entry->db_holds = zfs_refcount_count(&db->db_holds); \
+ snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX, \
+ DBUF_TP_PRINTK_FMT, DBUF_TP_PRINTK_ARGS); \
+ } else { \
+ __assign_str(os_spa, "NULL") \
+ __entry->ds_object = 0; \
+ __entry->db_object = 0; \
+ __entry->db_level = 0; \
+ __entry->db_blkid = 0; \
+ __entry->db_offset = 0; \
+ __entry->db_size = 0; \
+ __entry->db_state = 0; \
+ __entry->db_holds = 0; \
+ snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX, \
+ "dbuf { NULL }"); \
+ }
+
+#define DBUF_TP_PRINTK_FMT \
+ "dbuf { spa \"%s\" objset %llu object %llu level %llu " \
+ "blkid %llu offset %llu size %llu state %llu holds %lld }"
+
+#define DBUF_TP_PRINTK_ARGS \
+ __get_str(os_spa), __entry->ds_object, \
+ __entry->db_object, __entry->db_level, \
+ __entry->db_blkid, __entry->db_offset, \
+ __entry->db_size, __entry->db_state, __entry->db_holds
+
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_dbuf_class,
+ TP_PROTO(dmu_buf_impl_t *db, zio_t *zio),
+ TP_ARGS(db, zio),
+ TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY),
+ TP_fast_assign(DBUF_TP_FAST_ASSIGN),
+ TP_printk("%s", __get_str(msg))
+);
+
+DECLARE_EVENT_CLASS(zfs_dbuf_state_class,
+ TP_PROTO(dmu_buf_impl_t *db, const char *why),
+ TP_ARGS(db, why),
+ TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY),
+ TP_fast_assign(DBUF_TP_FAST_ASSIGN),
+ TP_printk("%s", __get_str(msg))
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_DBUF_EVENT(name) \
+DEFINE_EVENT(zfs_dbuf_class, name, \
+ TP_PROTO(dmu_buf_impl_t *db, zio_t *zio), \
+ TP_ARGS(db, zio))
+/* END CSTYLED */
+DEFINE_DBUF_EVENT(zfs_blocked__read);
+
+/* BEGIN CSTYLED */
+#define DEFINE_DBUF_STATE_EVENT(name) \
+DEFINE_EVENT(zfs_dbuf_state_class, name, \
+ TP_PROTO(dmu_buf_impl_t *db, const char *why), \
+ TP_ARGS(db, why))
+/* END CSTYLED */
+DEFINE_DBUF_STATE_EVENT(zfs_dbuf__state_change);
+
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_dbuf_evict_one_class,
+ TP_PROTO(dmu_buf_impl_t *db, multilist_sublist_t *mls),
+ TP_ARGS(db, mls),
+ TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY),
+ TP_fast_assign(DBUF_TP_FAST_ASSIGN),
+ TP_printk("%s", __get_str(msg))
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_DBUF_EVICT_ONE_EVENT(name) \
+DEFINE_EVENT(zfs_dbuf_evict_one_class, name, \
+ TP_PROTO(dmu_buf_impl_t *db, multilist_sublist_t *mls), \
+ TP_ARGS(db, mls))
+/* END CSTYLED */
+DEFINE_DBUF_EVICT_ONE_EVENT(zfs_dbuf__evict__one);
+
+#endif /* _TRACE_DBUF_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_dbuf
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE2(blocked__read);
+DEFINE_DTRACE_PROBE2(dbuf__evict__one);
+DEFINE_DTRACE_PROBE2(dbuf__state_change);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dmu.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dmu.h
new file mode 100644
index 000000000000..3c64a370f842
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dmu.h
@@ -0,0 +1,136 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_dmu
+
+#if !defined(_TRACE_DMU_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_DMU_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+/*
+ * Generic support for three argument tracepoints of the form:
+ *
+ * DTRACE_PROBE3(...,
+ * dmu_tx_t *, ...,
+ * uint64_t, ...,
+ * uint64_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_delay_mintime_class,
+ TP_PROTO(dmu_tx_t *tx, uint64_t dirty, uint64_t min_tx_time),
+ TP_ARGS(tx, dirty, min_tx_time),
+ TP_STRUCT__entry(
+ __field(uint64_t, tx_txg)
+ __field(uint64_t, tx_lastsnap_txg)
+ __field(uint64_t, tx_lasttried_txg)
+ __field(boolean_t, tx_anyobj)
+ __field(boolean_t, tx_dirty_delayed)
+ __field(hrtime_t, tx_start)
+ __field(boolean_t, tx_wait_dirty)
+ __field(int, tx_err)
+ __field(uint64_t, min_tx_time)
+ __field(uint64_t, dirty)
+ ),
+ TP_fast_assign(
+ __entry->tx_txg = tx->tx_txg;
+ __entry->tx_lastsnap_txg = tx->tx_lastsnap_txg;
+ __entry->tx_lasttried_txg = tx->tx_lasttried_txg;
+ __entry->tx_anyobj = tx->tx_anyobj;
+ __entry->tx_dirty_delayed = tx->tx_dirty_delayed;
+ __entry->tx_start = tx->tx_start;
+ __entry->tx_wait_dirty = tx->tx_wait_dirty;
+ __entry->tx_err = tx->tx_err;
+ __entry->dirty = dirty;
+ __entry->min_tx_time = min_tx_time;
+ ),
+ TP_printk("tx { txg %llu lastsnap_txg %llu tx_lasttried_txg %llu "
+ "anyobj %d dirty_delayed %d start %llu wait_dirty %d err %i "
+ "} dirty %llu min_tx_time %llu",
+ __entry->tx_txg, __entry->tx_lastsnap_txg,
+ __entry->tx_lasttried_txg, __entry->tx_anyobj,
+ __entry->tx_dirty_delayed, __entry->tx_start,
+ __entry->tx_wait_dirty, __entry->tx_err,
+ __entry->dirty, __entry->min_tx_time)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_DELAY_MINTIME_EVENT(name) \
+DEFINE_EVENT(zfs_delay_mintime_class, name, \
+ TP_PROTO(dmu_tx_t *tx, uint64_t dirty, uint64_t min_tx_time), \
+ TP_ARGS(tx, dirty, min_tx_time))
+/* END CSTYLED */
+DEFINE_DELAY_MINTIME_EVENT(zfs_delay__mintime);
+
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_free_long_range_class,
+ TP_PROTO(uint64_t long_free_dirty_all_txgs, uint64_t chunk_len, \
+ uint64_t txg),
+ TP_ARGS(long_free_dirty_all_txgs, chunk_len, txg),
+ TP_STRUCT__entry(
+ __field(uint64_t, long_free_dirty_all_txgs)
+ __field(uint64_t, chunk_len)
+ __field(uint64_t, txg)
+ ),
+ TP_fast_assign(
+ __entry->long_free_dirty_all_txgs = long_free_dirty_all_txgs;
+ __entry->chunk_len = chunk_len;
+ __entry->txg = txg;
+ ),
+ TP_printk("long_free_dirty_all_txgs %llu chunk_len %llu txg %llu",
+ __entry->long_free_dirty_all_txgs,
+ __entry->chunk_len, __entry->txg)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_FREE_LONG_RANGE_EVENT(name) \
+DEFINE_EVENT(zfs_free_long_range_class, name, \
+ TP_PROTO(uint64_t long_free_dirty_all_txgs, \
+ uint64_t chunk_len, uint64_t txg), \
+ TP_ARGS(long_free_dirty_all_txgs, chunk_len, txg))
+/* END CSTYLED */
+DEFINE_FREE_LONG_RANGE_EVENT(zfs_free__long__range);
+
+#endif /* _TRACE_DMU_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_dmu
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE3(delay__mintime);
+DEFINE_DTRACE_PROBE3(free__long__range);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dnode.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dnode.h
new file mode 100644
index 000000000000..27ad6cba16d6
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dnode.h
@@ -0,0 +1,129 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_dnode
+
+#if !defined(_TRACE_DNODE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_DNODE_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+/*
+ * Generic support for three argument tracepoints of the form:
+ *
+ * DTRACE_PROBE3(...,
+ * dnode_t *, ...,
+ * int64_t, ...,
+ * uint32_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_dnode_move_class,
+ TP_PROTO(dnode_t *dn, int64_t refcount, uint32_t dbufs),
+ TP_ARGS(dn, refcount, dbufs),
+ TP_STRUCT__entry(
+ __field(uint64_t, dn_object)
+ __field(dmu_object_type_t, dn_type)
+ __field(uint16_t, dn_bonuslen)
+ __field(uint8_t, dn_bonustype)
+ __field(uint8_t, dn_nblkptr)
+ __field(uint8_t, dn_checksum)
+ __field(uint8_t, dn_compress)
+ __field(uint8_t, dn_nlevels)
+ __field(uint8_t, dn_indblkshift)
+ __field(uint8_t, dn_datablkshift)
+ __field(uint8_t, dn_moved)
+ __field(uint16_t, dn_datablkszsec)
+ __field(uint32_t, dn_datablksz)
+ __field(uint64_t, dn_maxblkid)
+ __field(int64_t, dn_tx_holds)
+ __field(int64_t, dn_holds)
+ __field(boolean_t, dn_have_spill)
+
+ __field(int64_t, refcount)
+ __field(uint32_t, dbufs)
+ ),
+ TP_fast_assign(
+ __entry->dn_object = dn->dn_object;
+ __entry->dn_type = dn->dn_type;
+ __entry->dn_bonuslen = dn->dn_bonuslen;
+ __entry->dn_bonustype = dn->dn_bonustype;
+ __entry->dn_nblkptr = dn->dn_nblkptr;
+ __entry->dn_checksum = dn->dn_checksum;
+ __entry->dn_compress = dn->dn_compress;
+ __entry->dn_nlevels = dn->dn_nlevels;
+ __entry->dn_indblkshift = dn->dn_indblkshift;
+ __entry->dn_datablkshift = dn->dn_datablkshift;
+ __entry->dn_moved = dn->dn_moved;
+ __entry->dn_datablkszsec = dn->dn_datablkszsec;
+ __entry->dn_datablksz = dn->dn_datablksz;
+ __entry->dn_maxblkid = dn->dn_maxblkid;
+ __entry->dn_tx_holds = dn->dn_tx_holds.rc_count;
+ __entry->dn_holds = dn->dn_holds.rc_count;
+ __entry->dn_have_spill = dn->dn_have_spill;
+
+ __entry->refcount = refcount;
+ __entry->dbufs = dbufs;
+ ),
+ TP_printk("dn { object %llu type %d bonuslen %u bonustype %u "
+ "nblkptr %u checksum %u compress %u nlevels %u indblkshift %u "
+ "datablkshift %u moved %u datablkszsec %u datablksz %u "
+ "maxblkid %llu tx_holds %lli holds %lli have_spill %d } "
+ "refcount %lli dbufs %u",
+ __entry->dn_object, __entry->dn_type, __entry->dn_bonuslen,
+ __entry->dn_bonustype, __entry->dn_nblkptr, __entry->dn_checksum,
+ __entry->dn_compress, __entry->dn_nlevels, __entry->dn_indblkshift,
+ __entry->dn_datablkshift, __entry->dn_moved,
+ __entry->dn_datablkszsec, __entry->dn_datablksz,
+ __entry->dn_maxblkid, __entry->dn_tx_holds, __entry->dn_holds,
+ __entry->dn_have_spill, __entry->refcount, __entry->dbufs)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_DNODE_MOVE_EVENT(name) \
+DEFINE_EVENT(zfs_dnode_move_class, name, \
+ TP_PROTO(dnode_t *dn, int64_t refcount, uint32_t dbufs), \
+ TP_ARGS(dn, refcount, dbufs))
+/* END CSTYLED */
+DEFINE_DNODE_MOVE_EVENT(zfs_dnode__move);
+
+#endif /* _TRACE_DNODE_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_dnode
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE3(dnode__move);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_multilist.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_multilist.h
new file mode 100644
index 000000000000..fe68d5296f73
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_multilist.h
@@ -0,0 +1,89 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_multilist
+
+#if !defined(_TRACE_MULTILIST_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_MULTILIST_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+/*
+ * Generic support for three argument tracepoints of the form:
+ *
+ * DTRACE_PROBE3(...,
+ * multilist_t *, ...,
+ * unsigned int, ...,
+ * void *, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_multilist_insert_remove_class,
+ TP_PROTO(multilist_t *ml, unsigned sublist_idx, void *obj),
+ TP_ARGS(ml, sublist_idx, obj),
+ TP_STRUCT__entry(
+ __field(size_t, ml_offset)
+ __field(uint64_t, ml_num_sublists)
+
+ __field(unsigned int, sublist_idx)
+ ),
+ TP_fast_assign(
+ __entry->ml_offset = ml->ml_offset;
+ __entry->ml_num_sublists = ml->ml_num_sublists;
+
+ __entry->sublist_idx = sublist_idx;
+ ),
+ TP_printk("ml { offset %ld numsublists %llu sublistidx %u } ",
+ __entry->ml_offset, __entry->ml_num_sublists, __entry->sublist_idx)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_MULTILIST_INSERT_REMOVE_EVENT(name) \
+DEFINE_EVENT(zfs_multilist_insert_remove_class, name, \
+ TP_PROTO(multilist_t *ml, unsigned int sublist_idx, void *obj), \
+ TP_ARGS(ml, sublist_idx, obj))
+/* END CSTYLED */
+DEFINE_MULTILIST_INSERT_REMOVE_EVENT(zfs_multilist__insert);
+DEFINE_MULTILIST_INSERT_REMOVE_EVENT(zfs_multilist__remove);
+
+#endif /* _TRACE_MULTILIST_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_multilist
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE3(multilist__insert);
+DEFINE_DTRACE_PROBE3(multilist__remove);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_rrwlock.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_rrwlock.h
new file mode 100644
index 000000000000..4c74d6257309
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_rrwlock.h
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#else
+
+DEFINE_DTRACE_PROBE(zfs__rrwfastpath__rdmiss);
+DEFINE_DTRACE_PROBE(zfs__rrwfastpath__exitmiss);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_txg.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_txg.h
new file mode 100644
index 000000000000..23d5d358bc42
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_txg.h
@@ -0,0 +1,89 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_txg
+
+#if !defined(_TRACE_TXG_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TXG_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+/*
+ * Generic support for two argument tracepoints of the form:
+ *
+ * DTRACE_PROBE2(...,
+ * dsl_pool_t *, ...,
+ * uint64_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_txg_class,
+ TP_PROTO(dsl_pool_t *dp, uint64_t txg),
+ TP_ARGS(dp, txg),
+ TP_STRUCT__entry(
+ __field(uint64_t, txg)
+ ),
+ TP_fast_assign(
+ __entry->txg = txg;
+ ),
+ TP_printk("txg %llu", __entry->txg)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_TXG_EVENT(name) \
+DEFINE_EVENT(zfs_txg_class, name, \
+ TP_PROTO(dsl_pool_t *dp, uint64_t txg), \
+ TP_ARGS(dp, txg))
+/* END CSTYLED */
+DEFINE_TXG_EVENT(zfs_dsl_pool_sync__done);
+DEFINE_TXG_EVENT(zfs_txg__quiescing);
+DEFINE_TXG_EVENT(zfs_txg__opened);
+DEFINE_TXG_EVENT(zfs_txg__syncing);
+DEFINE_TXG_EVENT(zfs_txg__synced);
+DEFINE_TXG_EVENT(zfs_txg__quiesced);
+
+#endif /* _TRACE_TXG_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_txg
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE2(dsl_pool_sync__done);
+DEFINE_DTRACE_PROBE2(txg__quiescing);
+DEFINE_DTRACE_PROBE2(txg__opened);
+DEFINE_DTRACE_PROBE2(txg__syncing);
+DEFINE_DTRACE_PROBE2(txg__synced);
+DEFINE_DTRACE_PROBE2(txg__quiesced);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_vdev.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_vdev.h
new file mode 100644
index 000000000000..50711446ffa4
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_vdev.h
@@ -0,0 +1,140 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+/*
+ * If tracepoints are available define dtrace_probe events for vdev
+ * related probes. Definitions in include/os/linux/spl/sys/trace.h
+ * will map DTRACE_PROBE* calls to tracepoints.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_vdev
+
+#if !defined(_TRACE_VDEV_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_VDEV_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+/*
+ * Generic support for three argument tracepoints of the form:
+ *
+ * DTRACE_PROBE3(...,
+ * spa_t *, ...,
+ * uint64_t, ...,
+ * uint64_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_removing_class_3,
+ TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size),
+ TP_ARGS(spa, offset, size),
+ TP_STRUCT__entry(
+ __field(spa_t *, vdev_spa)
+ __field(uint64_t, vdev_offset)
+ __field(uint64_t, vdev_size)
+ ),
+ TP_fast_assign(
+ __entry->vdev_spa = spa;
+ __entry->vdev_offset = offset;
+ __entry->vdev_size = size;
+ ),
+ TP_printk("spa %p offset %llu size %llu",
+ __entry->vdev_spa, __entry->vdev_offset,
+ __entry->vdev_size)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_REMOVE_FREE_EVENT(name) \
+DEFINE_EVENT(zfs_removing_class_3, name, \
+ TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size), \
+ TP_ARGS(spa, offset, size))
+/* END CSTYLED */
+DEFINE_REMOVE_FREE_EVENT(zfs_remove__free__synced);
+DEFINE_REMOVE_FREE_EVENT(zfs_remove__free__unvisited);
+
+/*
+ * Generic support for four argument tracepoints of the form:
+ *
+ * DTRACE_PROBE4(...,
+ * spa_t *, ...,
+ * uint64_t, ...,
+ * uint64_t, ...,
+ * uint64_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_removing_class_4,
+ TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size, uint64_t txg),
+ TP_ARGS(spa, offset, size, txg),
+ TP_STRUCT__entry(
+ __field(spa_t *, vdev_spa)
+ __field(uint64_t, vdev_offset)
+ __field(uint64_t, vdev_size)
+ __field(uint64_t, vdev_txg)
+ ),
+ TP_fast_assign(
+ __entry->vdev_spa = spa;
+ __entry->vdev_offset = offset;
+ __entry->vdev_size = size;
+ __entry->vdev_txg = txg;
+ ),
+ TP_printk("spa %p offset %llu size %llu txg %llu",
+ __entry->vdev_spa, __entry->vdev_offset,
+ __entry->vdev_size, __entry->vdev_txg)
+);
+
+/* BEGIN CSTYLED */
+#define DEFINE_REMOVE_FREE_EVENT_TXG(name) \
+DEFINE_EVENT(zfs_removing_class_4, name, \
+ TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size,uint64_t txg), \
+ TP_ARGS(spa, offset, size, txg))
+/* END CSTYLED */
+DEFINE_REMOVE_FREE_EVENT_TXG(zfs_remove__free__inflight);
+
+#endif /* _TRACE_VDEV_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_vdev
+#include <trace/define_trace.h>
+
+#else
+
+/*
+ * When tracepoints are not available, a DEFINE_DTRACE_PROBE* macro is
+ * needed for each DTRACE_PROBE. These will be used to generate stub
+ * tracing functions and prototypes for those functions. See
+ * include/os/linux/spl/sys/trace.h.
+ */
+
+DEFINE_DTRACE_PROBE3(remove__free__synced);
+DEFINE_DTRACE_PROBE3(remove__free__unvisited);
+DEFINE_DTRACE_PROBE4(remove__free__inflight);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zfs.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zfs.h
new file mode 100644
index 000000000000..0e19f8d186d0
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zfs.h
@@ -0,0 +1,53 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#ifndef _OS_LINUX_ZFS_TRACE_H
+#define _OS_LINUX_ZFS_TRACE_H
+
+#include <sys/multilist.h>
+#include <sys/arc_impl.h>
+#include <sys/vdev_impl.h>
+#include <sys/zio.h>
+#include <sys/dbuf.h>
+#include <sys/dmu_objset.h>
+#include <sys/dsl_dataset.h>
+#include <sys/dmu_tx.h>
+#include <sys/dnode.h>
+#include <sys/zfs_znode.h>
+#include <sys/zil_impl.h>
+#include <sys/zrlock.h>
+
+#include <sys/trace.h>
+#include <sys/trace_acl.h>
+#include <sys/trace_arc.h>
+#include <sys/trace_dbgmsg.h>
+#include <sys/trace_dbuf.h>
+#include <sys/trace_dmu.h>
+#include <sys/trace_dnode.h>
+#include <sys/trace_multilist.h>
+#include <sys/trace_rrwlock.h>
+#include <sys/trace_txg.h>
+#include <sys/trace_vdev.h>
+#include <sys/trace_zil.h>
+#include <sys/trace_zio.h>
+#include <sys/trace_zrlock.h>
+
+#endif
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h
new file mode 100644
index 000000000000..526846e664b2
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h
@@ -0,0 +1,229 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_zil
+
+#if !defined(_TRACE_ZIL_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ZIL_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+#define ZILOG_TP_STRUCT_ENTRY \
+ __field(uint64_t, zl_lr_seq) \
+ __field(uint64_t, zl_commit_lr_seq) \
+ __field(uint64_t, zl_destroy_txg) \
+ __field(uint64_t, zl_replaying_seq) \
+ __field(uint32_t, zl_suspend) \
+ __field(uint8_t, zl_suspending) \
+ __field(uint8_t, zl_keep_first) \
+ __field(uint8_t, zl_replay) \
+ __field(uint8_t, zl_stop_sync) \
+ __field(uint8_t, zl_logbias) \
+ __field(uint8_t, zl_sync) \
+ __field(int, zl_parse_error) \
+ __field(uint64_t, zl_parse_blk_seq) \
+ __field(uint64_t, zl_parse_lr_seq) \
+ __field(uint64_t, zl_parse_blk_count) \
+ __field(uint64_t, zl_parse_lr_count) \
+ __field(uint64_t, zl_cur_used) \
+ __field(clock_t, zl_replay_time) \
+ __field(uint64_t, zl_replay_blks)
+
+#define ZILOG_TP_FAST_ASSIGN \
+ __entry->zl_lr_seq = zilog->zl_lr_seq; \
+ __entry->zl_commit_lr_seq = zilog->zl_commit_lr_seq; \
+ __entry->zl_destroy_txg = zilog->zl_destroy_txg; \
+ __entry->zl_replaying_seq = zilog->zl_replaying_seq; \
+ __entry->zl_suspend = zilog->zl_suspend; \
+ __entry->zl_suspending = zilog->zl_suspending; \
+ __entry->zl_keep_first = zilog->zl_keep_first; \
+ __entry->zl_replay = zilog->zl_replay; \
+ __entry->zl_stop_sync = zilog->zl_stop_sync; \
+ __entry->zl_logbias = zilog->zl_logbias; \
+ __entry->zl_sync = zilog->zl_sync; \
+ __entry->zl_parse_error = zilog->zl_parse_error; \
+ __entry->zl_parse_blk_seq = zilog->zl_parse_blk_seq; \
+ __entry->zl_parse_lr_seq = zilog->zl_parse_lr_seq; \
+ __entry->zl_parse_blk_count = zilog->zl_parse_blk_count;\
+ __entry->zl_parse_lr_count = zilog->zl_parse_lr_count; \
+ __entry->zl_cur_used = zilog->zl_cur_used; \
+ __entry->zl_replay_time = zilog->zl_replay_time; \
+ __entry->zl_replay_blks = zilog->zl_replay_blks;
+
+#define ZILOG_TP_PRINTK_FMT \
+ "zl { lr_seq %llu commit_lr_seq %llu destroy_txg %llu " \
+ "replaying_seq %llu suspend %u suspending %u keep_first %u " \
+ "replay %u stop_sync %u logbias %u sync %u " \
+ "parse_error %u parse_blk_seq %llu parse_lr_seq %llu " \
+ "parse_blk_count %llu parse_lr_count %llu " \
+ "cur_used %llu replay_time %lu replay_blks %llu }"
+
+#define ZILOG_TP_PRINTK_ARGS \
+ __entry->zl_lr_seq, __entry->zl_commit_lr_seq, \
+ __entry->zl_destroy_txg, __entry->zl_replaying_seq, \
+ __entry->zl_suspend, __entry->zl_suspending, \
+ __entry->zl_keep_first, __entry->zl_replay, \
+ __entry->zl_stop_sync, __entry->zl_logbias, __entry->zl_sync, \
+ __entry->zl_parse_error, __entry->zl_parse_blk_seq, \
+ __entry->zl_parse_lr_seq, __entry->zl_parse_blk_count, \
+ __entry->zl_parse_lr_count, __entry->zl_cur_used, \
+ __entry->zl_replay_time, __entry->zl_replay_blks
+
+#define ITX_TP_STRUCT_ENTRY \
+ __field(itx_wr_state_t, itx_wr_state) \
+ __field(uint8_t, itx_sync) \
+ __field(zil_callback_t, itx_callback) \
+ __field(void *, itx_callback_data) \
+ __field(uint64_t, itx_oid) \
+ \
+ __field(uint64_t, lrc_txtype) \
+ __field(uint64_t, lrc_reclen) \
+ __field(uint64_t, lrc_txg) \
+ __field(uint64_t, lrc_seq)
+
+#define ITX_TP_FAST_ASSIGN \
+ __entry->itx_wr_state = itx->itx_wr_state; \
+ __entry->itx_sync = itx->itx_sync; \
+ __entry->itx_callback = itx->itx_callback; \
+ __entry->itx_callback_data = itx->itx_callback_data; \
+ __entry->itx_oid = itx->itx_oid; \
+ \
+ __entry->lrc_txtype = itx->itx_lr.lrc_txtype; \
+ __entry->lrc_reclen = itx->itx_lr.lrc_reclen; \
+ __entry->lrc_txg = itx->itx_lr.lrc_txg; \
+ __entry->lrc_seq = itx->itx_lr.lrc_seq;
+
+#define ITX_TP_PRINTK_FMT \
+ "itx { wr_state %u sync %u callback %p callback_data %p oid %llu" \
+ " { txtype %llu reclen %llu txg %llu seq %llu } }"
+
+#define ITX_TP_PRINTK_ARGS \
+ __entry->itx_wr_state, __entry->itx_sync, __entry->itx_callback,\
+ __entry->itx_callback_data, __entry->itx_oid, \
+ __entry->lrc_txtype, __entry->lrc_reclen, __entry->lrc_txg, \
+ __entry->lrc_seq
+
+#define ZCW_TP_STRUCT_ENTRY \
+ __field(lwb_t *, zcw_lwb) \
+ __field(boolean_t, zcw_done) \
+ __field(int, zcw_zio_error) \
+
+#define ZCW_TP_FAST_ASSIGN \
+ __entry->zcw_lwb = zcw->zcw_lwb; \
+ __entry->zcw_done = zcw->zcw_done; \
+ __entry->zcw_zio_error = zcw->zcw_zio_error;
+
+#define ZCW_TP_PRINTK_FMT \
+ "zcw { lwb %p done %u error %u }"
+
+#define ZCW_TP_PRINTK_ARGS \
+ __entry->zcw_lwb, __entry->zcw_done, __entry->zcw_zio_error
+
+/*
+ * Generic support for two argument tracepoints of the form:
+ *
+ * DTRACE_PROBE2(...,
+ * zilog_t *, ...,
+ * itx_t *, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_zil_process_itx_class,
+ TP_PROTO(zilog_t *zilog, itx_t *itx),
+ TP_ARGS(zilog, itx),
+ TP_STRUCT__entry(
+ ZILOG_TP_STRUCT_ENTRY
+ ITX_TP_STRUCT_ENTRY
+ ),
+ TP_fast_assign(
+ ZILOG_TP_FAST_ASSIGN
+ ITX_TP_FAST_ASSIGN
+ ),
+ TP_printk(
+ ZILOG_TP_PRINTK_FMT " " ITX_TP_PRINTK_FMT,
+ ZILOG_TP_PRINTK_ARGS, ITX_TP_PRINTK_ARGS)
+);
+/* END CSTYLED */
+
+/* BEGIN CSTYLED */
+#define DEFINE_ZIL_PROCESS_ITX_EVENT(name) \
+DEFINE_EVENT(zfs_zil_process_itx_class, name, \
+ TP_PROTO(zilog_t *zilog, itx_t *itx), \
+ TP_ARGS(zilog, itx))
+DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__commit__itx);
+DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__normal__itx);
+/* END CSTYLED */
+
+/*
+ * Generic support for two argument tracepoints of the form:
+ *
+ * DTRACE_PROBE2(...,
+ * zilog_t *, ...,
+ * zil_commit_waiter_t *, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_zil_commit_io_error_class,
+ TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw),
+ TP_ARGS(zilog, zcw),
+ TP_STRUCT__entry(
+ ZILOG_TP_STRUCT_ENTRY
+ ZCW_TP_STRUCT_ENTRY
+ ),
+ TP_fast_assign(
+ ZILOG_TP_FAST_ASSIGN
+ ZCW_TP_FAST_ASSIGN
+ ),
+ TP_printk(
+ ZILOG_TP_PRINTK_FMT " " ZCW_TP_PRINTK_FMT,
+ ZILOG_TP_PRINTK_ARGS, ZCW_TP_PRINTK_ARGS)
+);
+
+/* BEGIN CSTYLED */
+#define DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(name) \
+DEFINE_EVENT(zfs_zil_commit_io_error_class, name, \
+ TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw), \
+ TP_ARGS(zilog, zcw))
+DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(zfs_zil__commit__io__error);
+/* END CSTYLED */
+
+#endif /* _TRACE_ZIL_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_zil
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE2(zil__process__commit__itx);
+DEFINE_DTRACE_PROBE2(zil__process__normal__itx);
+DEFINE_DTRACE_PROBE2(zil__commit__io__error);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zio.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zio.h
new file mode 100644
index 000000000000..8655e245c043
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zio.h
@@ -0,0 +1,97 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#include <sys/list.h>
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_zio
+
+#if !defined(_TRACE_ZIO_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ZIO_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+#include <sys/trace_common.h> /* For ZIO macros */
+
+/* BEGIN CSTYLED */
+TRACE_EVENT(zfs_zio__delay__miss,
+ TP_PROTO(zio_t *zio, hrtime_t now),
+ TP_ARGS(zio, now),
+ TP_STRUCT__entry(
+ ZIO_TP_STRUCT_ENTRY
+ __field(hrtime_t, now)
+ ),
+ TP_fast_assign(
+ ZIO_TP_FAST_ASSIGN
+ __entry->now = now;
+ ),
+ TP_printk("now %llu " ZIO_TP_PRINTK_FMT, __entry->now,
+ ZIO_TP_PRINTK_ARGS)
+);
+
+TRACE_EVENT(zfs_zio__delay__hit,
+ TP_PROTO(zio_t *zio, hrtime_t now, hrtime_t diff),
+ TP_ARGS(zio, now, diff),
+ TP_STRUCT__entry(
+ ZIO_TP_STRUCT_ENTRY
+ __field(hrtime_t, now)
+ __field(hrtime_t, diff)
+ ),
+ TP_fast_assign(
+ ZIO_TP_FAST_ASSIGN
+ __entry->now = now;
+ __entry->diff = diff;
+ ),
+ TP_printk("now %llu diff %llu " ZIO_TP_PRINTK_FMT, __entry->now,
+ __entry->diff, ZIO_TP_PRINTK_ARGS)
+);
+
+TRACE_EVENT(zfs_zio__delay__skip,
+ TP_PROTO(zio_t *zio),
+ TP_ARGS(zio),
+ TP_STRUCT__entry(ZIO_TP_STRUCT_ENTRY),
+ TP_fast_assign(ZIO_TP_FAST_ASSIGN),
+ TP_printk(ZIO_TP_PRINTK_FMT, ZIO_TP_PRINTK_ARGS)
+);
+/* END CSTYLED */
+
+#endif /* _TRACE_ZIO_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_zio
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE2(zio__delay__miss);
+DEFINE_DTRACE_PROBE3(zio__delay__hit);
+DEFINE_DTRACE_PROBE1(zio__delay__skip);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zrlock.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zrlock.h
new file mode 100644
index 000000000000..23f9577ba15f
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zrlock.h
@@ -0,0 +1,94 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#if defined(_KERNEL)
+#if defined(HAVE_DECLARE_EVENT_CLASS)
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM zfs
+
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR zfs_zrlock
+
+#if !defined(_TRACE_ZRLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ZRLOCK_H
+
+#include <linux/tracepoint.h>
+#include <sys/types.h>
+
+/*
+ * Generic support for two argument tracepoints of the form:
+ *
+ * DTRACE_PROBE2(...,
+ * zrlock_t *, ...,
+ * uint32_t, ...);
+ */
+/* BEGIN CSTYLED */
+DECLARE_EVENT_CLASS(zfs_zrlock_class,
+ TP_PROTO(zrlock_t *zrl, kthread_t *owner, uint32_t n),
+ TP_ARGS(zrl, owner, n),
+ TP_STRUCT__entry(
+ __field(int32_t, refcount)
+#ifdef ZFS_DEBUG
+ __field(pid_t, owner_pid)
+ __field(const char *, caller)
+#endif
+ __field(uint32_t, n)
+ ),
+ TP_fast_assign(
+ __entry->refcount = zrl->zr_refcount;
+#ifdef ZFS_DEBUG
+ __entry->owner_pid = owner ? owner->pid : 0;
+ __entry->caller = zrl->zr_caller ? zrl->zr_caller : "(null)";
+#endif
+ __entry->n = n;
+ ),
+#ifdef ZFS_DEBUG
+ TP_printk("zrl { refcount %d owner_pid %d caller %s } n %u",
+ __entry->refcount, __entry->owner_pid, __entry->caller,
+ __entry->n)
+#else
+ TP_printk("zrl { refcount %d } n %u",
+ __entry->refcount, __entry->n)
+#endif
+);
+/* END_CSTYLED */
+
+#define DEFINE_ZRLOCK_EVENT(name) \
+DEFINE_EVENT(zfs_zrlock_class, name, \
+ TP_PROTO(zrlock_t *zrl, kthread_t *owner, uint32_t n), \
+ TP_ARGS(zrl, owner, n))
+DEFINE_ZRLOCK_EVENT(zfs_zrlock__reentry);
+
+#endif /* _TRACE_ZRLOCK_H */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH sys
+#define TRACE_INCLUDE_FILE trace_zrlock
+#include <trace/define_trace.h>
+
+#else
+
+DEFINE_DTRACE_PROBE3(zrlock__reentry);
+
+#endif /* HAVE_DECLARE_EVENT_CLASS */
+#endif /* _KERNEL */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_context_os.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_context_os.h
new file mode 100644
index 000000000000..9e5fdd79f019
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_context_os.h
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#ifndef ZFS_CONTEXT_OS_H
+#define ZFS_CONTEXT_OS_H
+
+#include <sys/uio_impl.h>
+#include <linux/dcache_compat.h>
+#include <linux/utsname_compat.h>
+
+#endif
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_ctldir.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_ctldir.h
new file mode 100644
index 000000000000..51933bc4fe47
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_ctldir.h
@@ -0,0 +1,103 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (C) 2011 Lawrence Livermore National Security, LLC.
+ * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ * LLNL-CODE-403049.
+ * Rewritten for Linux by:
+ * Rohan Puri <rohan.puri15@gmail.com>
+ * Brian Behlendorf <behlendorf1@llnl.gov>
+ */
+
+#ifndef _ZFS_CTLDIR_H
+#define _ZFS_CTLDIR_H
+
+#include <sys/vnode.h>
+#include <sys/pathname.h>
+#include <sys/zfs_vfsops.h>
+#include <sys/zfs_znode.h>
+
+#define ZFS_CTLDIR_NAME ".zfs"
+#define ZFS_SNAPDIR_NAME "snapshot"
+#define ZFS_SHAREDIR_NAME "shares"
+
+#define zfs_has_ctldir(zdp) \
+ ((zdp)->z_id == ZTOZSB(zdp)->z_root && \
+ (ZTOZSB(zdp)->z_ctldir != NULL))
+#define zfs_show_ctldir(zdp) \
+ (zfs_has_ctldir(zdp) && \
+ (ZTOZSB(zdp)->z_show_ctldir))
+
+extern int zfs_expire_snapshot;
+
+/* zfsctl generic functions */
+extern int zfsctl_create(zfsvfs_t *);
+extern void zfsctl_destroy(zfsvfs_t *);
+extern struct inode *zfsctl_root(znode_t *);
+extern void zfsctl_init(void);
+extern void zfsctl_fini(void);
+extern boolean_t zfsctl_is_node(struct inode *ip);
+extern boolean_t zfsctl_is_snapdir(struct inode *ip);
+extern int zfsctl_fid(struct inode *ip, fid_t *fidp);
+
+/* zfsctl '.zfs' functions */
+extern int zfsctl_root_lookup(struct inode *dip, char *name,
+ struct inode **ipp, int flags, cred_t *cr, int *direntflags,
+ pathname_t *realpnp);
+
+/* zfsctl '.zfs/snapshot' functions */
+extern int zfsctl_snapdir_lookup(struct inode *dip, char *name,
+ struct inode **ipp, int flags, cred_t *cr, int *direntflags,
+ pathname_t *realpnp);
+extern int zfsctl_snapdir_rename(struct inode *sdip, char *sname,
+ struct inode *tdip, char *tname, cred_t *cr, int flags);
+extern int zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr,
+ int flags);
+extern int zfsctl_snapdir_mkdir(struct inode *dip, char *dirname, vattr_t *vap,
+ struct inode **ipp, cred_t *cr, int flags);
+extern int zfsctl_snapshot_mount(struct path *path, int flags);
+extern int zfsctl_snapshot_unmount(char *snapname, int flags);
+extern int zfsctl_snapshot_unmount_delay(spa_t *spa, uint64_t objsetid,
+ int delay);
+extern int zfsctl_snapdir_vget(struct super_block *sb, uint64_t objsetid,
+ int gen, struct inode **ipp);
+
+/* zfsctl '.zfs/shares' functions */
+extern int zfsctl_shares_lookup(struct inode *dip, char *name,
+ struct inode **ipp, int flags, cred_t *cr, int *direntflags,
+ pathname_t *realpnp);
+
+/*
+ * These inodes numbers are reserved for the .zfs control directory.
+ * It is important that they be no larger that 48-bits because only
+ * 6 bytes are reserved in the NFS file handle for the object number.
+ * However, they should be as large as possible to avoid conflicts
+ * with the objects which are assigned monotonically by the dmu.
+ */
+#define ZFSCTL_INO_ROOT 0x0000FFFFFFFFFFFFULL
+#define ZFSCTL_INO_SHARES 0x0000FFFFFFFFFFFEULL
+#define ZFSCTL_INO_SNAPDIR 0x0000FFFFFFFFFFFDULL
+#define ZFSCTL_INO_SNAPDIRS 0x0000FFFFFFFFFFFCULL
+
+#define ZFSCTL_EXPIRE_SNAPSHOT 300
+
+#endif /* _ZFS_CTLDIR_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_dir.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_dir.h
new file mode 100644
index 000000000000..0f15e43452b2
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_dir.h
@@ -0,0 +1,76 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_FS_ZFS_DIR_H
+#define _SYS_FS_ZFS_DIR_H
+
+#include <sys/pathname.h>
+#include <sys/dmu.h>
+#include <sys/zfs_znode.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* zfs_dirent_lock() flags */
+#define ZNEW 0x0001 /* entry should not exist */
+#define ZEXISTS 0x0002 /* entry should exist */
+#define ZSHARED 0x0004 /* shared access (zfs_dirlook()) */
+#define ZXATTR 0x0008 /* we want the xattr dir */
+#define ZRENAMING 0x0010 /* znode is being renamed */
+#define ZCILOOK 0x0020 /* case-insensitive lookup requested */
+#define ZCIEXACT 0x0040 /* c-i requires c-s match (rename) */
+#define ZHAVELOCK 0x0080 /* z_name_lock is already held */
+
+/* mknode flags */
+#define IS_ROOT_NODE 0x01 /* create a root node */
+#define IS_XATTR 0x02 /* create an extended attribute node */
+#define IS_TMPFILE 0x04 /* create a tmpfile */
+
+extern int zfs_dirent_lock(zfs_dirlock_t **, znode_t *, char *, znode_t **,
+ int, int *, pathname_t *);
+extern void zfs_dirent_unlock(zfs_dirlock_t *);
+extern int zfs_link_create(zfs_dirlock_t *, znode_t *, dmu_tx_t *, int);
+extern int zfs_link_destroy(zfs_dirlock_t *, znode_t *, dmu_tx_t *, int,
+ boolean_t *);
+extern int zfs_dirlook(znode_t *, char *, znode_t **, int, int *,
+ pathname_t *);
+extern void zfs_mknode(znode_t *, vattr_t *, dmu_tx_t *, cred_t *,
+ uint_t, znode_t **, zfs_acl_ids_t *);
+extern void zfs_rmnode(znode_t *);
+extern void zfs_dl_name_switch(zfs_dirlock_t *dl, char *new, char **old);
+extern boolean_t zfs_dirempty(znode_t *);
+extern void zfs_unlinked_add(znode_t *, dmu_tx_t *);
+extern void zfs_unlinked_drain(zfsvfs_t *zfsvfs);
+extern void zfs_unlinked_drain_stop_wait(zfsvfs_t *zfsvfs);
+extern int zfs_sticky_remove_access(znode_t *, znode_t *, cred_t *cr);
+extern int zfs_get_xattrdir(znode_t *, znode_t **, cred_t *, int);
+extern int zfs_make_xattrdir(znode_t *, vattr_t *, znode_t **, cred_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_FS_ZFS_DIR_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h
new file mode 100644
index 000000000000..24a0a2e6a05f
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h
@@ -0,0 +1,227 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018 by Delphix. All rights reserved.
+ */
+
+#ifndef _SYS_FS_ZFS_VFSOPS_H
+#define _SYS_FS_ZFS_VFSOPS_H
+
+#include <sys/dataset_kstats.h>
+#include <sys/isa_defs.h>
+#include <sys/types32.h>
+#include <sys/list.h>
+#include <sys/vfs.h>
+#include <sys/zil.h>
+#include <sys/sa.h>
+#include <sys/rrwlock.h>
+#include <sys/dsl_dataset.h>
+#include <sys/zfs_ioctl.h>
+#include <sys/objlist.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct zfsvfs zfsvfs_t;
+struct znode;
+
+/*
+ * This structure emulates the vfs_t from other platforms. It's purpose
+ * is to facilitate the handling of mount options and minimize structural
+ * differences between the platforms.
+ */
+typedef struct vfs {
+ struct zfsvfs *vfs_data;
+ char *vfs_mntpoint; /* Primary mount point */
+ uint64_t vfs_xattr;
+ boolean_t vfs_readonly;
+ boolean_t vfs_do_readonly;
+ boolean_t vfs_setuid;
+ boolean_t vfs_do_setuid;
+ boolean_t vfs_exec;
+ boolean_t vfs_do_exec;
+ boolean_t vfs_devices;
+ boolean_t vfs_do_devices;
+ boolean_t vfs_do_xattr;
+ boolean_t vfs_atime;
+ boolean_t vfs_do_atime;
+ boolean_t vfs_relatime;
+ boolean_t vfs_do_relatime;
+ boolean_t vfs_nbmand;
+ boolean_t vfs_do_nbmand;
+} vfs_t;
+
+typedef struct zfs_mnt {
+ const char *mnt_osname; /* Objset name */
+ char *mnt_data; /* Raw mount options */
+} zfs_mnt_t;
+
+struct zfsvfs {
+ vfs_t *z_vfs; /* generic fs struct */
+ struct super_block *z_sb; /* generic super_block */
+ struct zfsvfs *z_parent; /* parent fs */
+ objset_t *z_os; /* objset reference */
+ uint64_t z_flags; /* super_block flags */
+ uint64_t z_root; /* id of root znode */
+ uint64_t z_unlinkedobj; /* id of unlinked zapobj */
+ uint64_t z_max_blksz; /* maximum block size for files */
+ uint64_t z_fuid_obj; /* fuid table object number */
+ uint64_t z_fuid_size; /* fuid table size */
+ avl_tree_t z_fuid_idx; /* fuid tree keyed by index */
+ avl_tree_t z_fuid_domain; /* fuid tree keyed by domain */
+ krwlock_t z_fuid_lock; /* fuid lock */
+ boolean_t z_fuid_loaded; /* fuid tables are loaded */
+ boolean_t z_fuid_dirty; /* need to sync fuid table ? */
+ struct zfs_fuid_info *z_fuid_replay; /* fuid info for replay */
+ zilog_t *z_log; /* intent log pointer */
+ uint_t z_acl_mode; /* acl chmod/mode behavior */
+ uint_t z_acl_inherit; /* acl inheritance behavior */
+ uint_t z_acl_type; /* type of ACL usable on this FS */
+ zfs_case_t z_case; /* case-sense */
+ boolean_t z_utf8; /* utf8-only */
+ int z_norm; /* normalization flags */
+ boolean_t z_relatime; /* enable relatime mount option */
+ boolean_t z_unmounted; /* unmounted */
+ rrmlock_t z_teardown_lock;
+ krwlock_t z_teardown_inactive_lock;
+ list_t z_all_znodes; /* all znodes in the fs */
+ uint64_t z_nr_znodes; /* number of znodes in the fs */
+ unsigned long z_rollback_time; /* last online rollback time */
+ unsigned long z_snap_defer_time; /* last snapshot unmount deferral */
+ kmutex_t z_znodes_lock; /* lock for z_all_znodes */
+ arc_prune_t *z_arc_prune; /* called by ARC to prune caches */
+ struct inode *z_ctldir; /* .zfs directory inode */
+ boolean_t z_show_ctldir; /* expose .zfs in the root dir */
+ boolean_t z_issnap; /* true if this is a snapshot */
+ boolean_t z_vscan; /* virus scan on/off */
+ boolean_t z_use_fuids; /* version allows fuids */
+ boolean_t z_replay; /* set during ZIL replay */
+ boolean_t z_use_sa; /* version allow system attributes */
+ boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */
+ boolean_t z_draining; /* is true when drain is active */
+ boolean_t z_drain_cancel; /* signal the unlinked drain to stop */
+ uint64_t z_version; /* ZPL version */
+ uint64_t z_shares_dir; /* hidden shares dir */
+ dataset_kstats_t z_kstat; /* fs kstats */
+ kmutex_t z_lock;
+ uint64_t z_userquota_obj;
+ uint64_t z_groupquota_obj;
+ uint64_t z_userobjquota_obj;
+ uint64_t z_groupobjquota_obj;
+ uint64_t z_projectquota_obj;
+ uint64_t z_projectobjquota_obj;
+ uint64_t z_replay_eof; /* New end of file - replay only */
+ sa_attr_type_t *z_attr_table; /* SA attr mapping->id */
+ uint64_t z_hold_size; /* znode hold array size */
+ avl_tree_t *z_hold_trees; /* znode hold trees */
+ kmutex_t *z_hold_locks; /* znode hold locks */
+ taskqid_t z_drain_task; /* task id for the unlink drain task */
+};
+
+#define ZSB_XATTR 0x0001 /* Enable user xattrs */
+
+/*
+ * Allow a maximum number of links. While ZFS does not internally limit
+ * this the inode->i_nlink member is defined as an unsigned int. To be
+ * safe we use 2^31-1 as the limit.
+ */
+#define ZFS_LINK_MAX ((1U << 31) - 1U)
+
+/*
+ * Normal filesystems (those not under .zfs/snapshot) have a total
+ * file ID size limited to 12 bytes (including the length field) due to
+ * NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical
+ * reasons, this same limit is being imposed by the Solaris NFSv3 implementation
+ * (although the NFSv3 protocol actually permits a maximum of 64 bytes). It
+ * is not possible to expand beyond 12 bytes without abandoning support
+ * of NFSv2.
+ *
+ * For normal filesystems, we partition up the available space as follows:
+ * 2 bytes fid length (required)
+ * 6 bytes object number (48 bits)
+ * 4 bytes generation number (32 bits)
+ *
+ * We reserve only 48 bits for the object number, as this is the limit
+ * currently defined and imposed by the DMU.
+ */
+typedef struct zfid_short {
+ uint16_t zf_len;
+ uint8_t zf_object[6]; /* obj[i] = obj >> (8 * i) */
+ uint8_t zf_gen[4]; /* gen[i] = gen >> (8 * i) */
+} zfid_short_t;
+
+/*
+ * Filesystems under .zfs/snapshot have a total file ID size of 22 bytes
+ * (including the length field). This makes files under .zfs/snapshot
+ * accessible by NFSv3 and NFSv4, but not NFSv2.
+ *
+ * For files under .zfs/snapshot, we partition up the available space
+ * as follows:
+ * 2 bytes fid length (required)
+ * 6 bytes object number (48 bits)
+ * 4 bytes generation number (32 bits)
+ * 6 bytes objset id (48 bits)
+ * 4 bytes currently just zero (32 bits)
+ *
+ * We reserve only 48 bits for the object number and objset id, as these are
+ * the limits currently defined and imposed by the DMU.
+ */
+typedef struct zfid_long {
+ zfid_short_t z_fid;
+ uint8_t zf_setid[6]; /* obj[i] = obj >> (8 * i) */
+ uint8_t zf_setgen[4]; /* gen[i] = gen >> (8 * i) */
+} zfid_long_t;
+
+#define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t))
+#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))
+
+extern void zfs_init(void);
+extern void zfs_fini(void);
+
+extern int zfs_suspend_fs(zfsvfs_t *zfsvfs);
+extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
+extern int zfs_end_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
+extern void zfs_exit_fs(zfsvfs_t *zfsvfs);
+extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers);
+extern int zfsvfs_create(const char *name, boolean_t readony, zfsvfs_t **zfvp);
+extern int zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os);
+extern void zfsvfs_free(zfsvfs_t *zfsvfs);
+extern int zfs_check_global_label(const char *dsname, const char *hexsl);
+
+extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs);
+extern int zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent);
+extern void zfs_preumount(struct super_block *sb);
+extern int zfs_umount(struct super_block *sb);
+extern int zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm);
+extern int zfs_statvfs(struct inode *ip, struct kstatfs *statp);
+extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp);
+extern int zfs_prune(struct super_block *sb, unsigned long nr_to_scan,
+ int *objects);
+extern int zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop,
+ uint64_t *val, char *setpoint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_FS_ZFS_VFSOPS_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops.h
new file mode 100644
index 000000000000..24a2082d35d6
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops.h
@@ -0,0 +1,91 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _SYS_FS_ZFS_VNOPS_H
+#define _SYS_FS_ZFS_VNOPS_H
+
+#include <sys/vnode.h>
+#include <sys/xvattr.h>
+#include <sys/uio.h>
+#include <sys/cred.h>
+#include <sys/fcntl.h>
+#include <sys/pathname.h>
+#include <sys/zpl.h>
+#include <sys/zfs_file.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int zfs_open(struct inode *ip, int mode, int flag, cred_t *cr);
+extern int zfs_close(struct inode *ip, int flag, cred_t *cr);
+extern int zfs_holey(struct inode *ip, int cmd, loff_t *off);
+extern int zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr);
+extern int zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr);
+extern int zfs_write_simple(znode_t *zp, const void *data, size_t len,
+ loff_t pos, size_t *resid);
+extern int zfs_access(struct inode *ip, int mode, int flag, cred_t *cr);
+extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp,
+ int flags, cred_t *cr, int *direntflags, pathname_t *realpnp);
+extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
+ int mode, znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp);
+extern int zfs_tmpfile(struct inode *dip, vattr_t *vapzfs, int excl,
+ int mode, struct inode **ipp, cred_t *cr, int flag, vsecattr_t *vsecp);
+extern int zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags);
+extern int zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap,
+ znode_t **zpp, cred_t *cr, int flags, vsecattr_t *vsecp);
+extern int zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd,
+ cred_t *cr, int flags);
+extern int zfs_readdir(struct inode *ip, zpl_dir_context_t *ctx, cred_t *cr);
+extern int zfs_fsync(znode_t *zp, int syncflag, cred_t *cr);
+extern int zfs_getattr_fast(struct inode *ip, struct kstat *sp);
+extern int zfs_setattr(znode_t *zp, vattr_t *vap, int flag, cred_t *cr);
+extern int zfs_rename(znode_t *sdzp, char *snm, znode_t *tdzp,
+ char *tnm, cred_t *cr, int flags);
+extern int zfs_symlink(znode_t *dzp, char *name, vattr_t *vap,
+ char *link, znode_t **zpp, cred_t *cr, int flags);
+extern int zfs_readlink(struct inode *ip, uio_t *uio, cred_t *cr);
+extern int zfs_link(znode_t *tdzp, znode_t *szp,
+ char *name, cred_t *cr, int flags);
+extern void zfs_inactive(struct inode *ip);
+extern int zfs_space(znode_t *zp, int cmd, flock64_t *bfp, int flag,
+ offset_t offset, cred_t *cr);
+extern int zfs_fid(struct inode *ip, fid_t *fidp);
+extern int zfs_getsecattr(struct inode *ip, vsecattr_t *vsecp, int flag,
+ cred_t *cr);
+extern int zfs_setsecattr(znode_t *zp, vsecattr_t *vsecp, int flag,
+ cred_t *cr);
+extern int zfs_getpage(struct inode *ip, struct page *pl[], int nr_pages);
+extern int zfs_putpage(struct inode *ip, struct page *pp,
+ struct writeback_control *wbc);
+extern int zfs_dirty_inode(struct inode *ip, int flags);
+extern int zfs_map(struct inode *ip, offset_t off, caddr_t *addrp,
+ size_t len, unsigned long vm_flags);
+extern void zfs_zrele_async(znode_t *zp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_FS_ZFS_VNOPS_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h
new file mode 100644
index 000000000000..39bbd135ac06
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h
@@ -0,0 +1,168 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _SYS_ZFS_ZNODE_IMPL_H
+#define _SYS_ZFS_ZNODE_IMPL_H
+
+#ifndef _KERNEL
+#error "no user serviceable parts within"
+#endif
+
+#include <sys/isa_defs.h>
+#include <sys/types32.h>
+#include <sys/list.h>
+#include <sys/dmu.h>
+#include <sys/sa.h>
+#include <sys/zfs_vfsops.h>
+#include <sys/rrwlock.h>
+#include <sys/zfs_sa.h>
+#include <sys/zfs_stat.h>
+#include <sys/zfs_rlock.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ZNODE_OS_FIELDS \
+ struct inode z_inode;
+
+
+/*
+ * Convert between znode pointers and inode pointers
+ */
+#define ZTOI(znode) (&((znode)->z_inode))
+#define ITOZ(inode) (container_of((inode), znode_t, z_inode))
+#define ZTOZSB(znode) ((zfsvfs_t *)(ZTOI(znode)->i_sb->s_fs_info))
+#define ITOZSB(inode) ((zfsvfs_t *)((inode)->i_sb->s_fs_info))
+
+#define ZTOTYPE(zp) (ZTOI(zp)->i_mode)
+#define ZTOGID(zp) (ZTOI(zp)->i_gid)
+#define ZTOUID(zp) (ZTOI(zp)->i_uid)
+#define ZTONLNK(zp) (ZTOI(zp)->i_nlink)
+
+#define Z_ISBLK(type) S_ISBLK(type)
+#define Z_ISCHR(type) S_ISCHR(type)
+#define Z_ISLNK(type) S_ISLNK(type)
+#define Z_ISDEV(type) (S_ISCHR(type) || S_ISBLK(type) || S_ISFIFO(type))
+
+#define zhold(zp) igrab(ZTOI((zp)))
+#define zrele(zp) iput(ZTOI((zp)))
+
+/* Called on entry to each ZFS inode and vfs operation. */
+#define ZFS_ENTER_ERROR(zfsvfs, error) \
+do { \
+ rrm_enter_read(&(zfsvfs)->z_teardown_lock, FTAG); \
+ if ((zfsvfs)->z_unmounted) { \
+ ZFS_EXIT(zfsvfs); \
+ return (error); \
+ } \
+} while (0)
+#define ZFS_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, EIO)
+#define ZPL_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, -EIO)
+
+/* Must be called before exiting the operation. */
+#define ZFS_EXIT(zfsvfs) \
+do { \
+ zfs_exit_fs(zfsvfs); \
+ rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG); \
+} while (0)
+#define ZPL_EXIT(zfsvfs) ZFS_EXIT(zfsvfs)
+
+/* Verifies the znode is valid. */
+#define ZFS_VERIFY_ZP_ERROR(zp, error) \
+do { \
+ if ((zp)->z_sa_hdl == NULL) { \
+ ZFS_EXIT(ZTOZSB(zp)); \
+ return (error); \
+ } \
+} while (0)
+#define ZFS_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, EIO)
+#define ZPL_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, -EIO)
+
+/*
+ * Macros for dealing with dmu_buf_hold
+ */
+#define ZFS_OBJ_MTX_SZ 64
+#define ZFS_OBJ_MTX_MAX (1024 * 1024)
+#define ZFS_OBJ_HASH(zfsvfs, obj) ((obj) & ((zfsvfs->z_hold_size) - 1))
+
+extern unsigned int zfs_object_mutex_size;
+
+/*
+ * Encode ZFS stored time values from a struct timespec / struct timespec64.
+ */
+#define ZFS_TIME_ENCODE(tp, stmp) \
+do { \
+ (stmp)[0] = (uint64_t)(tp)->tv_sec; \
+ (stmp)[1] = (uint64_t)(tp)->tv_nsec; \
+} while (0)
+
+#if defined(HAVE_INODE_TIMESPEC64_TIMES)
+/*
+ * Decode ZFS stored time values to a struct timespec64
+ * 4.18 and newer kernels.
+ */
+#define ZFS_TIME_DECODE(tp, stmp) \
+do { \
+ (tp)->tv_sec = (time64_t)(stmp)[0]; \
+ (tp)->tv_nsec = (long)(stmp)[1]; \
+} while (0)
+#else
+/*
+ * Decode ZFS stored time values to a struct timespec
+ * 4.17 and older kernels.
+ */
+#define ZFS_TIME_DECODE(tp, stmp) \
+do { \
+ (tp)->tv_sec = (time_t)(stmp)[0]; \
+ (tp)->tv_nsec = (long)(stmp)[1]; \
+} while (0)
+#endif /* HAVE_INODE_TIMESPEC64_TIMES */
+
+struct znode;
+
+extern int zfs_sync(struct super_block *, int, cred_t *);
+extern int zfs_inode_alloc(struct super_block *, struct inode **ip);
+extern void zfs_inode_destroy(struct inode *);
+extern void zfs_inode_update(struct znode *);
+extern void zfs_mark_inode_dirty(struct inode *);
+extern boolean_t zfs_relatime_need_update(const struct inode *);
+
+#if defined(HAVE_UIO_RW)
+extern caddr_t zfs_map_page(page_t *, enum seg_rw);
+extern void zfs_unmap_page(page_t *, caddr_t);
+#endif /* HAVE_UIO_RW */
+
+extern zil_get_data_t zfs_get_data;
+extern zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE];
+extern int zfsfstype;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_ZFS_ZNODE_IMPL_H */
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h
new file mode 100644
index 000000000000..ef5a0b842d09
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h
@@ -0,0 +1,183 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2011, Lawrence Livermore National Security, LLC.
+ */
+
+#ifndef _SYS_ZPL_H
+#define _SYS_ZPL_H
+
+#include <sys/mntent.h>
+#include <sys/vfs.h>
+#include <linux/aio.h>
+#include <linux/dcache_compat.h>
+#include <linux/exportfs.h>
+#include <linux/falloc.h>
+#include <linux/parser.h>
+#include <linux/task_io_accounting_ops.h>
+#include <linux/vfs_compat.h>
+#include <linux/writeback.h>
+#include <linux/xattr_compat.h>
+
+/* zpl_inode.c */
+extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
+ umode_t mode, cred_t *cr);
+
+extern const struct inode_operations zpl_inode_operations;
+extern const struct inode_operations zpl_dir_inode_operations;
+extern const struct inode_operations zpl_symlink_inode_operations;
+extern const struct inode_operations zpl_special_inode_operations;
+extern dentry_operations_t zpl_dentry_operations;
+
+/* zpl_file.c */
+extern ssize_t zpl_read_common(struct inode *ip, const char *buf,
+ size_t len, loff_t *ppos, uio_seg_t segment, int flags,
+ cred_t *cr);
+extern ssize_t zpl_write_common(struct inode *ip, const char *buf,
+ size_t len, loff_t *ppos, uio_seg_t segment, int flags,
+ cred_t *cr);
+
+extern const struct address_space_operations zpl_address_space_operations;
+extern const struct file_operations zpl_file_operations;
+extern const struct file_operations zpl_dir_file_operations;
+
+/* zpl_super.c */
+extern void zpl_prune_sb(int64_t nr_to_scan, void *arg);
+
+extern const struct super_operations zpl_super_operations;
+extern const struct export_operations zpl_export_operations;
+extern struct file_system_type zpl_fs_type;
+
+/* zpl_xattr.c */
+extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
+extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
+ const struct qstr *qstr);
+#if defined(CONFIG_FS_POSIX_ACL)
+#if defined(HAVE_SET_ACL)
+extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type);
+#endif /* HAVE_SET_ACL */
+extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
+extern int zpl_init_acl(struct inode *ip, struct inode *dir);
+extern int zpl_chmod_acl(struct inode *ip);
+#else
+static inline int
+zpl_init_acl(struct inode *ip, struct inode *dir)
+{
+ return (0);
+}
+
+static inline int
+zpl_chmod_acl(struct inode *ip)
+{
+ return (0);
+}
+#endif /* CONFIG_FS_POSIX_ACL */
+
+extern xattr_handler_t *zpl_xattr_handlers[];
+
+/* zpl_ctldir.c */
+extern const struct file_operations zpl_fops_root;
+extern const struct inode_operations zpl_ops_root;
+
+extern const struct file_operations zpl_fops_snapdir;
+extern const struct inode_operations zpl_ops_snapdir;
+extern const struct dentry_operations zpl_dops_snapdirs;
+
+extern const struct file_operations zpl_fops_shares;
+extern const struct inode_operations zpl_ops_shares;
+
+#if defined(HAVE_VFS_ITERATE) || defined(HAVE_VFS_ITERATE_SHARED)
+
+#define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
+ .actor = _actor, \
+ .pos = _pos, \
+}
+
+typedef struct dir_context zpl_dir_context_t;
+
+#define zpl_dir_emit dir_emit
+#define zpl_dir_emit_dot dir_emit_dot
+#define zpl_dir_emit_dotdot dir_emit_dotdot
+#define zpl_dir_emit_dots dir_emit_dots
+
+#else
+
+typedef struct zpl_dir_context {
+ void *dirent;
+ const filldir_t actor;
+ loff_t pos;
+} zpl_dir_context_t;
+
+#define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
+ .dirent = _dirent, \
+ .actor = _actor, \
+ .pos = _pos, \
+}
+
+static inline bool
+zpl_dir_emit(zpl_dir_context_t *ctx, const char *name, int namelen,
+ uint64_t ino, unsigned type)
+{
+ return (!ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type));
+}
+
+static inline bool
+zpl_dir_emit_dot(struct file *file, zpl_dir_context_t *ctx)
+{
+ return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
+ file_inode(file)->i_ino, DT_DIR) == 0);
+}
+
+static inline bool
+zpl_dir_emit_dotdot(struct file *file, zpl_dir_context_t *ctx)
+{
+ return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
+ parent_ino(file_dentry(file)), DT_DIR) == 0);
+}
+
+static inline bool
+zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx)
+{
+ if (ctx->pos == 0) {
+ if (!zpl_dir_emit_dot(file, ctx))
+ return (false);
+ ctx->pos = 1;
+ }
+ if (ctx->pos == 1) {
+ if (!zpl_dir_emit_dotdot(file, ctx))
+ return (false);
+ ctx->pos = 2;
+ }
+ return (true);
+}
+#endif /* HAVE_VFS_ITERATE */
+
+#if defined(HAVE_INODE_TIMESTAMP_TRUNCATE)
+#define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip)
+#elif defined(HAVE_INODE_TIMESPEC64_TIMES)
+#define zpl_inode_timestamp_truncate(ts, ip) \
+ timespec64_trunc(ts, (ip)->i_sb->s_time_gran)
+#else
+#define zpl_inode_timestamp_truncate(ts, ip) \
+ timespec_trunc(ts, (ip)->i_sb->s_time_gran)
+#endif
+
+#endif /* _SYS_ZPL_H */