aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/include/os
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/include/os')
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/Makefile.am6
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h4
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h5
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/mod.h (renamed from sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h)3
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h4
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/time.h11
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/vm.h1
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode_impl.h1
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/zfs/sys/trace_zfs.h (renamed from sys/contrib/openzfs/include/os/freebsd/spl/sys/trace_zfs.h)0
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_debug_os.h (renamed from sys/contrib/openzfs/include/os/freebsd/spl/sys/sdt.h)9
-rw-r--r--sys/contrib/openzfs/include/os/linux/Makefile.am4
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h18
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/dcache_compat.h26
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/simd_x86.h47
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/vfs_compat.h7
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h32
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/debug.h4
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h61
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/misc.h6
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/mod.h (renamed from sys/contrib/openzfs/include/os/linux/spl/sys/mod_os.h)0
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h2
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/rwlock.h2
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/stat.h2
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h8
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/time.h8
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h7
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_common.h8
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h6
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_debug_os.h29
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h1
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h1
31 files changed, 178 insertions, 145 deletions
diff --git a/sys/contrib/openzfs/include/os/freebsd/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/Makefile.am
index d975c4fe69fa..47cf6756ab7d 100644
--- a/sys/contrib/openzfs/include/os/freebsd/Makefile.am
+++ b/sys/contrib/openzfs/include/os/freebsd/Makefile.am
@@ -33,7 +33,7 @@ noinst_HEADERS = \
%D%/spl/sys/list_impl.h \
%D%/spl/sys/lock.h \
%D%/spl/sys/misc.h \
- %D%/spl/sys/mod_os.h \
+ %D%/spl/sys/mod.h \
%D%/spl/sys/mode.h \
%D%/spl/sys/mount.h \
%D%/spl/sys/mutex.h \
@@ -44,7 +44,6 @@ noinst_HEADERS = \
%D%/spl/sys/procfs_list.h \
%D%/spl/sys/random.h \
%D%/spl/sys/rwlock.h \
- %D%/spl/sys/sdt.h \
%D%/spl/sys/sid.h \
%D%/spl/sys/sig.h \
%D%/spl/sys/simd.h \
@@ -63,7 +62,6 @@ noinst_HEADERS = \
%D%/spl/sys/time.h \
%D%/spl/sys/timer.h \
%D%/spl/sys/trace.h \
- %D%/spl/sys/trace_zfs.h \
%D%/spl/sys/types.h \
%D%/spl/sys/types32.h \
%D%/spl/sys/uio.h \
@@ -82,10 +80,12 @@ noinst_HEADERS = \
%D%/zfs/sys/arc_os.h \
%D%/zfs/sys/freebsd_crypto.h \
%D%/zfs/sys/freebsd_event.h \
+ %D%/zfs/sys/trace_zfs.h \
%D%/zfs/sys/vdev_os.h \
%D%/zfs/sys/zfs_bootenv_os.h \
%D%/zfs/sys/zfs_context_os.h \
%D%/zfs/sys/zfs_ctldir.h \
+ %D%/zfs/sys/zfs_debug_os.h \
%D%/zfs/sys/zfs_dir.h \
%D%/zfs/sys/zfs_ioctl_compat.h \
%D%/zfs/sys/zfs_vfsops_os.h \
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h
index 974704e92bbd..32bc02f3dc86 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h
@@ -69,6 +69,10 @@
#define __maybe_unused __attribute__((unused))
#endif
+#ifndef __must_check
+#define __must_check __attribute__((__warn_unused_result__))
+#endif
+
/*
* Without this, we see warnings from objtool during normal Linux builds when
* the kernel is built with CONFIG_STACK_VALIDATION=y:
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h
index 091ebe772810..acce8734b2c5 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h
@@ -56,4 +56,9 @@ struct opensolaris_utsname {
#define task_io_account_read(n)
#define task_io_account_write(n)
+/*
+ * Check if the current thread is a memory reclaim thread.
+ */
+extern int current_is_reclaim_thread(void);
+
#endif /* _OPENSOLARIS_SYS_MISC_H_ */
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod.h
index 4214189c32df..2aa66bbe19b7 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod.h
@@ -104,6 +104,9 @@
#define spa_taskq_write_param_set_args(var) \
CTLTYPE_STRING, NULL, 0, spa_taskq_write_param, "A"
+#define spa_taskq_free_param_set_args(var) \
+ CTLTYPE_STRING, NULL, 0, spa_taskq_free_param, "A"
+
#define fletcher_4_param_set_args(var) \
CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A"
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
index c6bc10d6babe..1cbd79ec893f 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
@@ -77,8 +77,8 @@ do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg,
/*
* Be sure there are no surprises.
*/
- ASSERT(stk == NULL);
- ASSERT(len == 0);
+ ASSERT0P(stk);
+ ASSERT0(len);
ASSERT(state == TS_RUN);
if (pp == &p0)
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/time.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/time.h
index 2f5fe4619ef7..14b42f2e7087 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/time.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/time.h
@@ -63,6 +63,17 @@ typedef longlong_t hrtime_t;
#define NSEC_TO_TICK(nsec) ((nsec) / (NANOSEC / hz))
static __inline hrtime_t
+getlrtime(void)
+{
+ struct timespec ts;
+ hrtime_t nsec;
+
+ getnanouptime(&ts);
+ nsec = ((hrtime_t)ts.tv_sec * NANOSEC) + ts.tv_nsec;
+ return (nsec);
+}
+
+static __inline hrtime_t
gethrtime(void)
{
struct timespec ts;
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vm.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vm.h
index 454078f0fe79..d36bee881d0b 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vm.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vm.h
@@ -35,6 +35,7 @@
extern const int zfs_vm_pagerret_bad;
extern const int zfs_vm_pagerret_error;
extern const int zfs_vm_pagerret_ok;
+extern const int zfs_vm_pagerret_pend;
extern const int zfs_vm_pagerput_sync;
extern const int zfs_vm_pagerput_inval;
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode_impl.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode_impl.h
index 0df3378c23e7..b18836aa563e 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode_impl.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode_impl.h
@@ -227,6 +227,7 @@ struct taskq;
#define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */
#define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */
#define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */
+#define LOOKUP_NAMED_ATTR 0x10 /* Lookup a named attribute */
/*
* Public vnode manipulation functions.
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/trace_zfs.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/trace_zfs.h
index d9639d27b60e..d9639d27b60e 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/trace_zfs.h
+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/trace_zfs.h
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sdt.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_debug_os.h
index ef1dad6c14c9..cc7540c4f83c 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sdt.h
+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_debug_os.h
@@ -27,10 +27,11 @@
* $FreeBSD$
*/
-#ifndef _OPENSOLARIS_SYS_SDT_H_
-#define _OPENSOLARIS_SYS_SDT_H_
+#ifndef _SYS_ZFS_DEBUG_OS_H
+#define _SYS_ZFS_DEBUG_OS_H
+
+#include <sys/sdt.h>
-#include_next <sys/sdt.h>
#ifdef KDTRACE_HOOKS
SDT_PROBE_DECLARE(sdt, , , set__error);
@@ -44,4 +45,4 @@ SDT_PROBE_DECLARE(sdt, , , set__error);
#define SET_ERROR(err) (err)
#endif
-#endif /* _OPENSOLARIS_SYS_SDT_H_ */
+#endif /* _SYS_ZFS_DEBUG_OS_H */
diff --git a/sys/contrib/openzfs/include/os/linux/Makefile.am b/sys/contrib/openzfs/include/os/linux/Makefile.am
index 4fe6705defe5..9188a974cc22 100644
--- a/sys/contrib/openzfs/include/os/linux/Makefile.am
+++ b/sys/contrib/openzfs/include/os/linux/Makefile.am
@@ -41,6 +41,7 @@ kernel_sys_HEADERS = \
%D%/zfs/sys/zfs_bootenv_os.h \
%D%/zfs/sys/zfs_context_os.h \
%D%/zfs/sys/zfs_ctldir.h \
+ %D%/zfs/sys/zfs_debug_os.h \
%D%/zfs/sys/zfs_dir.h \
%D%/zfs/sys/zfs_vfsops_os.h \
%D%/zfs/sys/zfs_vnops_os.h \
@@ -75,7 +76,7 @@ kernel_spl_sys_HEADERS = \
%D%/spl/sys/kstat.h \
%D%/spl/sys/list.h \
%D%/spl/sys/misc.h \
- %D%/spl/sys/mod_os.h \
+ %D%/spl/sys/mod.h \
%D%/spl/sys/mutex.h \
%D%/spl/sys/param.h \
%D%/spl/sys/proc.h \
@@ -97,7 +98,6 @@ kernel_spl_sys_HEADERS = \
%D%/spl/sys/time.h \
%D%/spl/sys/timer.h \
%D%/spl/sys/trace.h \
- %D%/spl/sys/trace_spl.h \
%D%/spl/sys/trace_taskq.h \
%D%/spl/sys/tsd.h \
%D%/spl/sys/types.h \
diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h
index 076dab8ba6dc..214f3ea0e787 100644
--- a/sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h
+++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h
@@ -542,24 +542,6 @@ blk_generic_alloc_queue(make_request_fn make_request, int node_id)
}
#endif /* !HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS */
-/*
- * All the io_*() helper functions below can operate on a bio, or a rq, but
- * not both. The older submit_bio() codepath will pass a bio, and the
- * newer blk-mq codepath will pass a rq.
- */
-static inline int
-io_data_dir(struct bio *bio, struct request *rq)
-{
- if (rq != NULL) {
- if (op_is_write(req_op(rq))) {
- return (WRITE);
- } else {
- return (READ);
- }
- }
- return (bio_data_dir(bio));
-}
-
static inline int
io_is_flush(struct bio *bio, struct request *rq)
{
diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/dcache_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/dcache_compat.h
index 16e8a319a5f8..152e5a606f0e 100644
--- a/sys/contrib/openzfs/include/os/linux/kernel/linux/dcache_compat.h
+++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/dcache_compat.h
@@ -61,32 +61,6 @@
#endif
/*
- * 2.6.30 API change,
- * The const keyword was added to the 'struct dentry_operations' in
- * the dentry structure. To handle this we define an appropriate
- * dentry_operations_t typedef which can be used.
- */
-typedef const struct dentry_operations dentry_operations_t;
-
-/*
- * 2.6.38 API addition,
- * Added d_clear_d_op() helper function which clears some flags and the
- * registered dentry->d_op table. This is required because d_set_d_op()
- * issues a warning when the dentry operations table is already set.
- * For the .zfs control directory to work properly we must be able to
- * override the default operations table and register custom .d_automount
- * and .d_revalidate callbacks.
- */
-static inline void
-d_clear_d_op(struct dentry *dentry)
-{
- dentry->d_op = NULL;
- dentry->d_flags &= ~(
- DCACHE_OP_HASH | DCACHE_OP_COMPARE |
- DCACHE_OP_REVALIDATE | DCACHE_OP_DELETE);
-}
-
-/*
* Walk and invalidate all dentry aliases of an inode
* unless it's a mountpoint
*/
diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/simd_x86.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/simd_x86.h
index cd245a5f0135..326f471d7c9b 100644
--- a/sys/contrib/openzfs/include/os/linux/kernel/linux/simd_x86.h
+++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/simd_x86.h
@@ -139,15 +139,6 @@
*/
#if defined(HAVE_KERNEL_FPU_INTERNAL)
-/*
- * For kernels not exporting *kfpu_{begin,end} we have to use inline assembly
- * with the XSAVE{,OPT,S} instructions, so we need the toolchain to support at
- * least XSAVE.
- */
-#if !defined(HAVE_XSAVE)
-#error "Toolchain needs to support the XSAVE assembler instruction"
-#endif
-
#ifndef XFEATURE_MASK_XTILE
/*
* For kernels where this doesn't exist yet, we still don't want to break
@@ -335,9 +326,13 @@ kfpu_begin(void)
return;
}
#endif
+#if defined(HAVE_XSAVE)
if (static_cpu_has(X86_FEATURE_XSAVE)) {
kfpu_do_xsave("xsave", state, ~XFEATURE_MASK_XTILE);
- } else if (static_cpu_has(X86_FEATURE_FXSR)) {
+ return;
+ }
+#endif
+ if (static_cpu_has(X86_FEATURE_FXSR)) {
kfpu_save_fxsr(state);
} else {
kfpu_save_fsave(state);
@@ -390,9 +385,13 @@ kfpu_end(void)
goto out;
}
#endif
+#if defined(HAVE_XSAVE)
if (static_cpu_has(X86_FEATURE_XSAVE)) {
kfpu_do_xrstor("xrstor", state, ~XFEATURE_MASK_XTILE);
- } else if (static_cpu_has(X86_FEATURE_FXSR)) {
+ goto out;
+ }
+#endif
+ if (static_cpu_has(X86_FEATURE_FXSR)) {
kfpu_restore_fxsr(state);
} else {
kfpu_restore_fsave(state);
@@ -599,6 +598,32 @@ zfs_movbe_available(void)
}
/*
+ * Check if VAES instruction set is available
+ */
+static inline boolean_t
+zfs_vaes_available(void)
+{
+#if defined(X86_FEATURE_VAES)
+ return (!!boot_cpu_has(X86_FEATURE_VAES));
+#else
+ return (B_FALSE);
+#endif
+}
+
+/*
+ * Check if VPCLMULQDQ instruction set is available
+ */
+static inline boolean_t
+zfs_vpclmulqdq_available(void)
+{
+#if defined(X86_FEATURE_VPCLMULQDQ)
+ return (!!boot_cpu_has(X86_FEATURE_VPCLMULQDQ));
+#else
+ return (B_FALSE);
+#endif
+}
+
+/*
* Check if SHA_NI instruction set is available
*/
static inline boolean_t
diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/vfs_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/vfs_compat.h
index cbf14e28371f..d9dc904bc322 100644
--- a/sys/contrib/openzfs/include/os/linux/kernel/linux/vfs_compat.h
+++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/vfs_compat.h
@@ -23,6 +23,7 @@
/*
* Copyright (C) 2011 Lawrence Livermore National Security, LLC.
* Copyright (C) 2015 Jörg Thalheim.
+ * Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
*/
#ifndef _ZFS_VFS_H
@@ -262,4 +263,10 @@ zpl_is_32bit_api(void)
#define zpl_generic_fillattr(user_ns, ip, sp) generic_fillattr(ip, sp)
#endif
+#ifdef HAVE_INODE_GENERIC_DROP
+/* 6.18 API change. These were renamed, alias the old names to the new. */
+#define generic_delete_inode(ip) inode_just_drop(ip)
+#define generic_drop_inode(ip) inode_generic_drop(ip)
+#endif
+
#endif /* _ZFS_VFS_H */
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h b/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h
index b2a39d7d6cbf..f4bcd58bd281 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h
@@ -71,6 +71,22 @@ atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
return ((void *)atomic_cas_64((volatile uint64_t *)target,
(uint64_t)cmp, (uint64_t)newval));
}
+static __inline__ void *
+atomic_swap_ptr(volatile void *target, void *newval)
+{
+ return ((void *)atomic_swap_64((volatile uint64_t *)target,
+ (uint64_t)newval));
+}
+static __inline__ void *
+atomic_load_ptr(volatile void *target)
+{
+ return ((void *)atomic_load_64((volatile uint64_t *)target));
+}
+static __inline__ void
+atomic_store_ptr(volatile void *target, void *newval)
+{
+ atomic_store_64((volatile uint64_t *)target, (uint64_t)newval);
+}
#else /* _LP64 */
static __inline__ void *
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
@@ -78,6 +94,22 @@ atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
return ((void *)atomic_cas_32((volatile uint32_t *)target,
(uint32_t)cmp, (uint32_t)newval));
}
+static __inline__ void *
+atomic_swap_ptr(volatile void *target, void *newval)
+{
+ return ((void *)atomic_swap_32((volatile uint32_t *)target,
+ (uint32_t)newval));
+}
+static __inline__ void *
+atomic_load_ptr(volatile void *target)
+{
+ return ((void *)atomic_load_32((volatile uint32_t *)target));
+}
+static __inline__ void
+atomic_store_ptr(volatile void *target, void *newval)
+{
+ atomic_store_32((volatile uint32_t *)target, (uint32_t)newval);
+}
#endif /* _LP64 */
#endif /* _SPL_ATOMIC_H */
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h b/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h
index 1671ba4074da..85b96e1e23a7 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h
@@ -69,6 +69,10 @@
#define __maybe_unused __attribute__((unused))
#endif
+#ifndef __must_check
+#define __must_check __attribute__((__warn_unused_result__))
+#endif
+
/*
* Without this, we see warnings from objtool during normal Linux builds when
* the kernel is built with CONFIG_STACK_VALIDATION=y:
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h b/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h
index 995236117dd4..fe34de9c179e 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h
@@ -61,7 +61,7 @@ void *spl_kvmalloc(size_t size, gfp_t flags);
/*
* Convert a KM_* flags mask to its Linux GFP_* counterpart. The conversion
* function is context aware which means that KM_SLEEP allocations can be
- * safely used in syncing contexts which have set PF_FSTRANS.
+ * safely used in syncing contexts which have set SPL_FSTRANS.
*/
static inline gfp_t
kmem_flags_convert(int flags)
@@ -91,25 +91,11 @@ typedef struct {
} fstrans_cookie_t;
/*
- * Introduced in Linux 3.9, however this cannot be solely relied on before
- * Linux 3.18 as it doesn't turn off __GFP_FS as it should.
+ * SPL_FSTRANS is the set of flags that indicate that the task is in a
+ * filesystem or IO codepath, and so any allocation must not call back into
+ * those codepaths (eg to swap).
*/
-#ifdef PF_MEMALLOC_NOIO
-#define __SPL_PF_MEMALLOC_NOIO (PF_MEMALLOC_NOIO)
-#else
-#define __SPL_PF_MEMALLOC_NOIO (0)
-#endif
-
-/*
- * PF_FSTRANS is removed from Linux 4.12
- */
-#ifdef PF_FSTRANS
-#define __SPL_PF_FSTRANS (PF_FSTRANS)
-#else
-#define __SPL_PF_FSTRANS (0)
-#endif
-
-#define SPL_FSTRANS (__SPL_PF_FSTRANS|__SPL_PF_MEMALLOC_NOIO)
+#define SPL_FSTRANS (PF_MEMALLOC_NOIO)
static inline fstrans_cookie_t
spl_fstrans_mark(void)
@@ -141,43 +127,8 @@ spl_fstrans_check(void)
return (current->flags & SPL_FSTRANS);
}
-/*
- * specifically used to check PF_FSTRANS flag, cannot be relied on for
- * checking spl_fstrans_mark().
- */
-static inline int
-__spl_pf_fstrans_check(void)
-{
- return (current->flags & __SPL_PF_FSTRANS);
-}
-
-/*
- * Kernel compatibility for GFP flags
- */
-/* < 4.13 */
-#ifndef __GFP_RETRY_MAYFAIL
-#define __GFP_RETRY_MAYFAIL __GFP_REPEAT
-#endif
-/* < 4.4 */
-#ifndef __GFP_RECLAIM
-#define __GFP_RECLAIM __GFP_WAIT
-#endif
-
-#ifdef HAVE_ATOMIC64_T
-#define kmem_alloc_used_add(size) atomic64_add(size, &kmem_alloc_used)
-#define kmem_alloc_used_sub(size) atomic64_sub(size, &kmem_alloc_used)
-#define kmem_alloc_used_read() atomic64_read(&kmem_alloc_used)
-#define kmem_alloc_used_set(size) atomic64_set(&kmem_alloc_used, size)
extern atomic64_t kmem_alloc_used;
-extern unsigned long long kmem_alloc_max;
-#else /* HAVE_ATOMIC64_T */
-#define kmem_alloc_used_add(size) atomic_add(size, &kmem_alloc_used)
-#define kmem_alloc_used_sub(size) atomic_sub(size, &kmem_alloc_used)
-#define kmem_alloc_used_read() atomic_read(&kmem_alloc_used)
-#define kmem_alloc_used_set(size) atomic_set(&kmem_alloc_used, size)
-extern atomic_t kmem_alloc_used;
-extern unsigned long long kmem_alloc_max;
-#endif /* HAVE_ATOMIC64_T */
+extern uint64_t kmem_alloc_max;
extern unsigned int spl_kmem_alloc_warn;
extern unsigned int spl_kmem_alloc_max;
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h b/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h
index 0b44786f8a6e..fbaaf229bd1a 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h
@@ -24,7 +24,13 @@
#define _OS_LINUX_SPL_MISC_H
#include <linux/kobject.h>
+#include <linux/swap.h>
extern void spl_signal_kobj_evt(struct block_device *bdev);
+/*
+ * Check if the current thread is a memory reclaim thread.
+ */
+extern int current_is_reclaim_thread(void);
+
#endif
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/mod_os.h b/sys/contrib/openzfs/include/os/linux/spl/sys/mod.h
index eaeb9255039e..eaeb9255039e 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/mod_os.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/mod.h
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h b/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h
index f000f53ab9b6..4eca2414fc5b 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h
@@ -111,7 +111,7 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
#undef mutex_destroy
#define mutex_destroy(mp) \
{ \
- VERIFY3P(mutex_owner(mp), ==, NULL); \
+ VERIFY0P(mutex_owner(mp)); \
}
#define mutex_tryenter(mp) \
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/rwlock.h b/sys/contrib/openzfs/include/os/linux/spl/sys/rwlock.h
index 563e0a19663d..c883836c2f83 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/rwlock.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/rwlock.h
@@ -130,7 +130,7 @@ RW_READ_HELD(krwlock_t *rwp)
/*
* The Linux rwsem implementation does not require a matching destroy.
*/
-#define rw_destroy(rwp) ((void) 0)
+#define rw_destroy(rwp) ASSERT(!(RW_LOCK_HELD(rwp)))
/*
* Upgrading a rwsem from a reader to a writer is not supported by the
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/stat.h b/sys/contrib/openzfs/include/os/linux/spl/sys/stat.h
index 087389b57b34..ad2815e46394 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/stat.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/stat.h
@@ -25,6 +25,6 @@
#ifndef _SPL_STAT_H
#define _SPL_STAT_H
-#include <linux/stat.h>
+#include <sys/stat.h>
#endif /* SPL_STAT_H */
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h b/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h
index db48222b712a..dc9e9e492ae4 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h
@@ -34,11 +34,6 @@
#include <sys/signal.h>
#include <asm/page.h>
-
-#ifndef _KERNEL
-#define _KERNEL __KERNEL__
-#endif
-
#define FALSE 0
#define TRUE 1
@@ -202,9 +197,6 @@ makedev(unsigned int major, unsigned int minor)
#define P2SAMEHIGHBIT_TYPED(x, y, type) \
(((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
-#define SET_ERROR(err) \
- (__set_error(__FILE__, __func__, __LINE__, err), err)
-
#include <linux/sort.h>
#define qsort(base, num, size, cmp) \
sort(base, num, size, cmp, NULL)
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/time.h b/sys/contrib/openzfs/include/os/linux/spl/sys/time.h
index 33b273b53996..4edc42a8aef9 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/time.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/time.h
@@ -80,6 +80,14 @@ gethrestime_sec(void)
}
static inline hrtime_t
+getlrtime(void)
+{
+ inode_timespec_t ts;
+ ktime_get_coarse_ts64(&ts);
+ return (((hrtime_t)ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec);
+}
+
+static inline hrtime_t
gethrtime(void)
{
struct timespec64 ts;
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
index 8923657daf02..d88b4937ef08 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h
@@ -59,8 +59,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__field(uint64_t, z_size)
__field(uint64_t, z_pflags)
__field(uint32_t, z_sync_cnt)
- __field(uint32_t, z_sync_writes_cnt)
- __field(uint32_t, z_async_writes_cnt)
__field(mode_t, z_mode)
__field(boolean_t, z_is_sa)
__field(boolean_t, z_is_ctldir)
@@ -92,8 +90,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__entry->z_size = zn->z_size;
__entry->z_pflags = zn->z_pflags;
__entry->z_sync_cnt = zn->z_sync_cnt;
- __entry->z_sync_writes_cnt = zn->z_sync_writes_cnt;
- __entry->z_async_writes_cnt = zn->z_async_writes_cnt;
__entry->z_mode = zn->z_mode;
__entry->z_is_sa = zn->z_is_sa;
__entry->z_is_ctldir = zn->z_is_ctldir;
@@ -117,7 +113,7 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
TP_printk("zn { id %llu unlinked %u atime_dirty %u "
"zn_prefetch %u blksz %u seq %u "
"mapcnt %llu size %llu pflags %llu "
- "sync_cnt %u sync_writes_cnt %u async_writes_cnt %u "
+ "sync_cnt %u "
"mode 0x%x is_sa %d is_ctldir %d "
"inode { uid %u gid %u ino %lu nlink %u size %lli "
"blkbits %u bytes %u mode 0x%x generation %x } } "
@@ -126,7 +122,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__entry->z_zn_prefetch, __entry->z_blksz,
__entry->z_seq, __entry->z_mapcnt, __entry->z_size,
__entry->z_pflags, __entry->z_sync_cnt,
- __entry->z_sync_writes_cnt, __entry->z_async_writes_cnt,
__entry->z_mode, __entry->z_is_sa, __entry->z_is_ctldir,
__entry->i_uid, __entry->i_gid, __entry->i_ino, __entry->i_nlink,
__entry->i_size, __entry->i_blkbits,
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
index 85cf8cc20b09..e1b6d61099b9 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_common.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_common.h
@@ -45,7 +45,7 @@
__field(zio_flag_t, zio_orig_flags) \
__field(enum zio_stage, zio_orig_stage) \
__field(enum zio_stage, zio_orig_pipeline) \
- __field(uint8_t, zio_reexecute) \
+ __field(uint8_t, zio_post) \
__field(uint64_t, zio_txg) \
__field(int, zio_error) \
__field(uint64_t, zio_ena) \
@@ -74,7 +74,7 @@
__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_post = zio->io_post; \
__entry->zio_txg = zio->io_txg; \
__entry->zio_error = zio->io_error; \
__entry->zio_ena = zio->io_ena; \
@@ -92,7 +92,7 @@
"zio { type %u prio %u size %llu orig_size %llu " \
"offset %llu timestamp %llu delta %llu delay %llu " \
"flags 0x%llx stage 0x%x pipeline 0x%x orig_flags 0x%llx " \
- "orig_stage 0x%x orig_pipeline 0x%x reexecute %u " \
+ "orig_stage 0x%x orig_pipeline 0x%x post %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 } }"
@@ -102,7 +102,7 @@
__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_orig_pipeline, __entry->zio_post, \
__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, \
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
index 955462c85d10..e34ea46b3fe8 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h
@@ -139,18 +139,18 @@
#define ZCW_TP_STRUCT_ENTRY \
__field(lwb_t *, zcw_lwb) \
__field(boolean_t, zcw_done) \
- __field(int, zcw_zio_error) \
+ __field(int, zcw_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;
+ __entry->zcw_error = zcw->zcw_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
+ __entry->zcw_lwb, __entry->zcw_done, __entry->zcw_error
/*
* Generic support for two argument tracepoints of the form:
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_debug_os.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_debug_os.h
new file mode 100644
index 000000000000..2841809528b6
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_debug_os.h
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: CDDL-1.0
+/*
+ * 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 https://opensource.org/licenses/CDDL-1.0.
+ * 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 _SYS_ZFS_DEBUG_OS_H
+#define _SYS_ZFS_DEBUG_OS_H
+
+#define SET_ERROR(err) \
+ (__set_error(__FILE__, __func__, __LINE__, err), err)
+
+#endif /* _SYS_ZFS_DEBUG_OS_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
index b38847b20462..6a77e40abe10 100644
--- 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
@@ -157,6 +157,7 @@ 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_free(struct inode *);
extern void zfs_inode_destroy(struct inode *);
extern void zfs_mark_inode_dirty(struct inode *);
extern boolean_t zfs_relatime_need_update(const struct inode *);
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h
index f5a9105cd885..8994aab889fe 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h
@@ -55,6 +55,7 @@ extern const struct file_operations zpl_dir_file_operations;
extern void zpl_prune_sb(uint64_t nr_to_scan, void *arg);
extern const struct super_operations zpl_super_operations;
+extern const struct dentry_operations zpl_dentry_operations;
extern const struct export_operations zpl_export_operations;
extern struct file_system_type zpl_fs_type;