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.am2
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h5
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h75
-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)0
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h1
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h8
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_powerpc.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/zfs_vfsops_os.h8
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h9
-rw-r--r--sys/contrib/openzfs/include/os/linux/Makefile.am3
-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/mod_compat.h65
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h4
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/pagemap_compat.h36
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/simd_x86.h47
-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.h71
-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.h4
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/time.h8
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/uio.h4
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h1
-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_vfsops_os.h8
-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.h36
38 files changed, 277 insertions, 311 deletions
diff --git a/sys/contrib/openzfs/include/os/freebsd/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/Makefile.am
index d975c4fe69fa..d6b6923d033f 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 \
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
index 112f7bc32849..51238dd1c8fd 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
@@ -43,10 +43,7 @@ extern "C" {
#endif
#define EXPORT_SYMBOL(x)
-#define module_param(a, b, c)
-#define module_param_call(a, b, c, d, e)
-#define module_param_named(a, b, c, d)
-#define MODULE_PARM_DESC(a, b)
+
#define asm __asm
#ifdef ZFS_DEBUG
#undef NDEBUG
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 c1a7cfdeca51..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:
@@ -112,14 +116,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
} while (0)
#define VERIFY3B(LEFT, OP, RIGHT) do { \
- const boolean_t _verify3_left = (boolean_t)(LEFT); \
- const boolean_t _verify3_right = (boolean_t)(RIGHT); \
+ const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
+ const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d)\n", \
- (boolean_t)_verify3_left, \
- (boolean_t)_verify3_right); \
+ _verify3_left, _verify3_right); \
} while (0)
#define VERIFY3S(LEFT, OP, RIGHT) do { \
@@ -127,7 +130,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld)\n", \
(long long)_verify3_left, \
(long long)_verify3_right); \
@@ -138,7 +141,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu)\n", \
(unsigned long long)_verify3_left, \
(unsigned long long)_verify3_right); \
@@ -149,8 +152,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
- "failed (%px " #OP " %px)\n", \
+ "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
+ "failed (%p " #OP " %p)\n", \
(void *)_verify3_left, \
(void *)_verify3_right); \
} while (0)
@@ -159,8 +162,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify0_right = (int64_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0(" #RIGHT ") " \
- "failed (0 == %lld)\n", \
+ "VERIFY0(" #RIGHT ") failed (%lld)\n", \
(long long)_verify0_right); \
} while (0)
@@ -168,8 +170,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify0_right = (uintptr_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0P(" #RIGHT ") " \
- "failed (NULL == %px)\n", \
+ "VERIFY0P(" #RIGHT ") failed (%p)\n", \
(void *)_verify0_right); \
} while (0)
@@ -182,14 +183,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
*/
#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \
- const boolean_t _verify3_left = (boolean_t)(LEFT); \
- const boolean_t _verify3_right = (boolean_t)(RIGHT); \
+ const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
+ const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d) " STR "\n", \
- (boolean_t)(_verify3_left), \
- (boolean_t)(_verify3_right), \
+ _verify3_left, _verify3_right, \
__VA_ARGS__); \
} while (0)
@@ -198,10 +198,9 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld) " STR "\n", \
- (long long)(_verify3_left), \
- (long long)(_verify3_right), \
+ (long long)_verify3_left, (long long)_verify3_right,\
__VA_ARGS__); \
} while (0)
@@ -210,10 +209,10 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu) " STR "\n", \
- (unsigned long long)(_verify3_left), \
- (unsigned long long)(_verify3_right), \
+ (unsigned long long)_verify3_left, \
+ (unsigned long long)_verify3_right, \
__VA_ARGS__); \
} while (0)
@@ -222,32 +221,27 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
- "failed (%px " #OP " %px) " STR "\n", \
- (void *) (_verify3_left), \
- (void *) (_verify3_right), \
+ "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
+ "failed (%p " #OP " %p) " STR "\n", \
+ (void *)_verify3_left, (void *)_verify3_right, \
__VA_ARGS__); \
} while (0)
#define VERIFY0PF(RIGHT, STR, ...) do { \
- const uintptr_t _verify3_left = (uintptr_t)(0); \
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
- if (unlikely(!(_verify3_left == _verify3_right))) \
+ if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0(0 == " #RIGHT ") " \
- "failed (0 == %px) " STR "\n", \
- (long long) (_verify3_right), \
+ "VERIFY0P(" #RIGHT ") failed (%p) " STR "\n", \
+ (void *)_verify3_right, \
__VA_ARGS__); \
} while (0)
#define VERIFY0F(RIGHT, STR, ...) do { \
- const int64_t _verify3_left = (int64_t)(0); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
- if (unlikely(!(_verify3_left == _verify3_right))) \
+ if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0(0 == " #RIGHT ") " \
- "failed (0 == %lld) " STR "\n", \
- (long long) (_verify3_right), \
+ "VERIFY0(" #RIGHT ") failed (%lld) " STR "\n", \
+ (long long)_verify3_right, \
__VA_ARGS__); \
} while (0)
@@ -256,10 +250,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
spl_assert("(" #A ") implies (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))
-#define VERIFY_EQUIV(A, B) \
- ((void)(likely(!!(A) == !!(B)) || \
- spl_assert("(" #A ") is equivalent to (" #B ")", \
- __FILE__, __FUNCTION__, __LINE__)))
+#define VERIFY_EQUIV(A, B) VERIFY3B(A, ==, B)
/*
* Debugging disabled (--disable-debug)
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..4214189c32df 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod.h
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h
index 639ade831c28..48bc4f3d5b0f 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h
@@ -39,7 +39,6 @@ struct znode;
int secpolicy_nfs(cred_t *cr);
int secpolicy_zfs(cred_t *crd);
-int secpolicy_zfs_proc(cred_t *cr, proc_t *proc);
int secpolicy_sys_config(cred_t *cr, int checkonly);
int secpolicy_zinject(cred_t *cr);
int secpolicy_fs_unmount(cred_t *cr, struct mount *vfsp);
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 a03b815a22a6..1cbd79ec893f 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
@@ -45,7 +45,9 @@
#ifdef _KERNEL
#define CPU curcpu
#define minclsyspri PRIBIO
-#define defclsyspri minclsyspri
+#define defclsyspri minclsyspri
+/* Write issue taskq priority. */
+#define wtqclsyspri ((PVM + PRIBIO) / 2)
#define maxclsyspri PVM
#define max_ncpus (mp_maxid + 1)
#define boot_max_ncpus (mp_maxid + 1)
@@ -75,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/simd_powerpc.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_powerpc.h
index 0be9257e40cb..5596f35a66d1 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_powerpc.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_powerpc.h
@@ -53,11 +53,11 @@
#define kfpu_allowed() 1
#define kfpu_initialize(tsk) do {} while (0)
-#define kfpu_begin() { \
+#define kfpu_begin() { \
if (__predict_false(!is_fpu_kern_thread(0))) \
fpu_kern_enter(PCPU_GET(curthread), NULL, FPU_KERN_NOCTX);\
}
-#define kfpu_end() { \
+#define kfpu_end() { \
if (__predict_false(PCPU_GET(curpcb)->pcb_flags & PCB_KERN_FPU_NOSAVE))\
fpu_kern_leave(PCPU_GET(curthread), NULL); \
}
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/zfs/sys/zfs_vfsops_os.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h
index 289b64759382..3ed311d49cc6 100644
--- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h
+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h
@@ -96,6 +96,12 @@ struct zfsvfs {
uint64_t z_groupobjquota_obj;
uint64_t z_projectquota_obj;
uint64_t z_projectobjquota_obj;
+ uint64_t z_defaultuserquota;
+ uint64_t z_defaultgroupquota;
+ uint64_t z_defaultprojectquota;
+ uint64_t z_defaultuserobjquota;
+ uint64_t z_defaultgroupobjquota;
+ uint64_t z_defaultprojectobjquota;
uint64_t z_replay_eof; /* New end of file - replay only */
sa_attr_type_t *z_attr_table; /* SA attr mapping->id */
#define ZFS_OBJ_MTX_SZ 64
@@ -226,6 +232,8 @@ extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs);
extern int zfs_get_temporary_prop(struct dsl_dataset *ds, zfs_prop_t zfs_prop,
uint64_t *val, char *setpoint);
extern int zfs_busy(void);
+extern int zfs_set_default_quota(zfsvfs_t *zfsvfs, zfs_prop_t zfs_prop,
+ uint64_t quota);
#ifdef __cplusplus
}
diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h
index b292818750d9..15e3affba0e8 100644
--- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h
+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h
@@ -29,6 +29,7 @@
#ifndef _FREEBSD_ZFS_SYS_ZNODE_IMPL_H
#define _FREEBSD_ZFS_SYS_ZNODE_IMPL_H
+#ifdef _KERNEL
#include <sys/list.h>
#include <sys/dmu.h>
#include <sys/sa.h>
@@ -42,6 +43,7 @@
#include <sys/zfs_project.h>
#include <vm/vm_object.h>
#include <sys/uio.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -54,7 +56,7 @@ extern "C" {
*/
#define ZNODE_OS_FIELDS \
struct zfsvfs *z_zfsvfs; \
- vnode_t *z_vnode; \
+ struct vnode *z_vnode; \
char *z_cached_symlink; \
uint64_t z_uid; \
uint64_t z_gid; \
@@ -62,6 +64,8 @@ extern "C" {
uint64_t z_atime[2]; \
uint64_t z_links;
+#ifdef _KERNEL
+
#define ZFS_LINK_MAX UINT64_MAX
/*
@@ -183,6 +187,9 @@ extern int zfs_znode_parent_and_name(struct znode *zp, struct znode **dzpp,
char *buf, uint64_t buflen);
extern int zfs_rlimit_fsize(off_t fsize);
+
+#endif /* _KERNEL */
+
#ifdef __cplusplus
}
#endif
diff --git a/sys/contrib/openzfs/include/os/linux/Makefile.am b/sys/contrib/openzfs/include/os/linux/Makefile.am
index b7bdd892ec1d..e156ca183dbd 100644
--- a/sys/contrib/openzfs/include/os/linux/Makefile.am
+++ b/sys/contrib/openzfs/include/os/linux/Makefile.am
@@ -8,6 +8,7 @@ kernel_linux_HEADERS = \
%D%/kernel/linux/mm_compat.h \
%D%/kernel/linux/mod_compat.h \
%D%/kernel/linux/page_compat.h \
+ %D%/kernel/linux/pagemap_compat.h \
%D%/kernel/linux/simd.h \
%D%/kernel/linux/simd_aarch64.h \
%D%/kernel/linux/simd_arm.h \
@@ -74,7 +75,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 \
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/mod_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h
index 110cdfa259be..e49ada399694 100644
--- a/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h
+++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h
@@ -31,15 +31,6 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
-/*
- * Despite constifying struct kernel_param_ops, some older kernels define a
- * `__check_old_set_param()` function in their headers that checks for a
- * non-constified `->set()`. This has long been fixed in Linux mainline, but
- * since we support older kernels, we workaround it by using a preprocessor
- * definition to disable it.
- */
-#define __check_old_set_param(_) (0)
-
typedef const struct kernel_param zfs_kernel_param_t;
#define ZMOD_RW 0644
@@ -72,6 +63,7 @@ enum scope_prefix_types {
zfs_vdev_disk,
zfs_vdev_file,
zfs_vdev_mirror,
+ zfs_vol,
zfs_vnops,
zfs_zevent,
zfs_zio,
@@ -79,48 +71,23 @@ enum scope_prefix_types {
};
/*
- * While we define our own s64/u64 types, there is no reason to reimplement the
- * existing Linux kernel types, so we use the preprocessor to remap our
- * "custom" implementations to the kernel ones. This is done because the CPP
- * does not allow us to write conditional definitions. The fourth definition
- * exists because the CPP will not allow us to replace things like INT with int
- * before string concatenation.
+ * Our uint64 params are called U64 in part because we had them before Linux
+ * provided ULLONG param ops. Now it does, and we use them, but we retain the
+ * U64 name to keep many existing tunables working without issue.
*/
+#define spl_param_set_u64 param_set_ullong
+#define spl_param_get_u64 param_get_ullong
+#define spl_param_ops_U64 param_ops_ullong
-#define spl_param_set_int param_set_int
-#define spl_param_get_int param_get_int
-#define spl_param_ops_int param_ops_int
-#define spl_param_ops_INT param_ops_int
-
-#define spl_param_set_long param_set_long
-#define spl_param_get_long param_get_long
-#define spl_param_ops_long param_ops_long
-#define spl_param_ops_LONG param_ops_long
-
-#define spl_param_set_uint param_set_uint
-#define spl_param_get_uint param_get_uint
-#define spl_param_ops_uint param_ops_uint
-#define spl_param_ops_UINT param_ops_uint
-
-#define spl_param_set_ulong param_set_ulong
-#define spl_param_get_ulong param_get_ulong
-#define spl_param_ops_ulong param_ops_ulong
-#define spl_param_ops_ULONG param_ops_ulong
-
-#define spl_param_set_charp param_set_charp
-#define spl_param_get_charp param_get_charp
-#define spl_param_ops_charp param_ops_charp
-#define spl_param_ops_STRING param_ops_charp
-
-int spl_param_set_s64(const char *val, zfs_kernel_param_t *kp);
-extern int spl_param_get_s64(char *buffer, zfs_kernel_param_t *kp);
-extern const struct kernel_param_ops spl_param_ops_s64;
-#define spl_param_ops_S64 spl_param_ops_s64
-
-extern int spl_param_set_u64(const char *val, zfs_kernel_param_t *kp);
-extern int spl_param_get_u64(char *buffer, zfs_kernel_param_t *kp);
-extern const struct kernel_param_ops spl_param_ops_u64;
-#define spl_param_ops_U64 spl_param_ops_u64
+/*
+ * We keep our own names for param ops to make expanding them in
+ * ZFS_MODULE_PARAM easy.
+ */
+#define spl_param_ops_INT param_ops_int
+#define spl_param_ops_LONG param_ops_long
+#define spl_param_ops_UINT param_ops_uint
+#define spl_param_ops_ULONG param_ops_ulong
+#define spl_param_ops_STRING param_ops_charp
/*
* Declare a module parameter / sysctl node
diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h
index 963b96ba6351..7dcf53bbea47 100644
--- a/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h
+++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h
@@ -4,8 +4,8 @@
/*
* Create our own accessor functions to follow the Linux API changes
*/
-#define nr_file_pages() global_node_page_state(NR_FILE_PAGES)
-#define nr_inactive_anon_pages() global_node_page_state(NR_INACTIVE_ANON)
+#define nr_file_pages() (global_node_page_state(NR_ACTIVE_FILE) + \
+ global_node_page_state(NR_INACTIVE_FILE))
#define nr_inactive_file_pages() global_node_page_state(NR_INACTIVE_FILE)
#endif /* _ZFS_PAGE_COMPAT_H */
diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/pagemap_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/pagemap_compat.h
new file mode 100644
index 000000000000..a0465ede0105
--- /dev/null
+++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/pagemap_compat.h
@@ -0,0 +1,36 @@
+// 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
+ */
+
+/*
+ * Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
+ */
+
+#ifndef _ZFS_PAGEMAP_COMPAT_H
+#define _ZFS_PAGEMAP_COMPAT_H
+
+#include <linux/pagemap.h>
+
+#ifndef HAVE_PAGEMAP_READAHEAD_PAGE
+#define readahead_page(ractl) (&(__readahead_folio(ractl)->page))
+#endif
+
+#endif
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/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 700cc85b60b6..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:
@@ -116,14 +120,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
} while (0)
#define VERIFY3B(LEFT, OP, RIGHT) do { \
- const boolean_t _verify3_left = (boolean_t)(LEFT); \
- const boolean_t _verify3_right = (boolean_t)(RIGHT); \
+ const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
+ const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d)\n", \
- (boolean_t)_verify3_left, \
- (boolean_t)_verify3_right); \
+ _verify3_left, _verify3_right); \
} while (0)
#define VERIFY3S(LEFT, OP, RIGHT) do { \
@@ -131,7 +134,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld)\n", \
(long long)_verify3_left, \
(long long)_verify3_right); \
@@ -142,7 +145,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu)\n", \
(unsigned long long)_verify3_left, \
(unsigned long long)_verify3_right); \
@@ -153,7 +156,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%px " #OP " %px)\n", \
(void *)_verify3_left, \
(void *)_verify3_right); \
@@ -163,8 +166,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify0_right = (int64_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0(" #RIGHT ") " \
- "failed (0 == %lld)\n", \
+ "VERIFY0(" #RIGHT ") failed (%lld)\n", \
(long long)_verify0_right); \
} while (0)
@@ -172,8 +174,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify0_right = (uintptr_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0P(" #RIGHT ") " \
- "failed (NULL == %px)\n", \
+ "VERIFY0P(" #RIGHT ") failed (%px)\n", \
(void *)_verify0_right); \
} while (0)
@@ -186,14 +187,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
*/
#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \
- const boolean_t _verify3_left = (boolean_t)(LEFT); \
- const boolean_t _verify3_right = (boolean_t)(RIGHT); \
+ const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
+ const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d) " STR "\n", \
- (boolean_t)(_verify3_left), \
- (boolean_t)(_verify3_right), \
+ _verify3_left, _verify3_right, \
__VA_ARGS__); \
} while (0)
@@ -202,10 +202,9 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld) " STR "\n", \
- (long long)(_verify3_left), \
- (long long)(_verify3_right), \
+ (long long)_verify3_left, (long long)_verify3_right,\
__VA_ARGS__); \
} while (0)
@@ -214,10 +213,10 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu) " STR "\n", \
- (unsigned long long)(_verify3_left), \
- (unsigned long long)(_verify3_right), \
+ (unsigned long long)_verify3_left, \
+ (unsigned long long)_verify3_right, \
__VA_ARGS__); \
} while (0)
@@ -226,32 +225,27 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%px " #OP " %px) " STR "\n", \
- (void *) (_verify3_left), \
- (void *) (_verify3_right), \
+ (void *)_verify3_left, (void *)_verify3_right, \
__VA_ARGS__); \
} while (0)
#define VERIFY0PF(RIGHT, STR, ...) do { \
- const uintptr_t _verify3_left = (uintptr_t)(0); \
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
- if (unlikely(!(_verify3_left == _verify3_right))) \
+ if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0(0 == " #RIGHT ") " \
- "failed (0 == %px) " STR "\n", \
- (long long) (_verify3_right), \
+ "VERIFY0P(" #RIGHT ") failed (%px) " STR "\n", \
+ (void *)_verify3_right, \
__VA_ARGS__); \
} while (0)
#define VERIFY0F(RIGHT, STR, ...) do { \
- const int64_t _verify3_left = (int64_t)(0); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
- if (unlikely(!(_verify3_left == _verify3_right))) \
+ if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY0(0 == " #RIGHT ") " \
- "failed (0 == %lld) " STR "\n", \
- (long long) (_verify3_right), \
+ "VERIFY0(" #RIGHT ") failed (%lld) " STR "\n", \
+ (long long)_verify3_right, \
__VA_ARGS__); \
} while (0)
@@ -260,10 +254,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
spl_assert("(" #A ") implies (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))
-#define VERIFY_EQUIV(A, B) \
- ((void)(likely(!!(A) == !!(B)) || \
- spl_assert("(" #A ") is equivalent to (" #B ")", \
- __FILE__, __FUNCTION__, __LINE__)))
+#define VERIFY_EQUIV(A, B) VERIFY3B(A, ==, B)
/*
* Debugging disabled (--disable-debug)
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 e932ea72f1be..db48222b712a 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h
@@ -92,8 +92,10 @@
* Treat shim tasks as SCHED_NORMAL tasks
*/
#define minclsyspri (MAX_PRIO-1)
-#define maxclsyspri (MAX_RT_PRIO)
#define defclsyspri (DEFAULT_PRIO)
+/* Write issue taskq priority. */
+#define wtqclsyspri (MAX_RT_PRIO + 1)
+#define maxclsyspri (MAX_RT_PRIO)
#ifndef NICE_TO_PRIO
#define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20)
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/spl/sys/uio.h b/sys/contrib/openzfs/include/os/linux/spl/sys/uio.h
index f66da5d5af57..26c2c387caa3 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/uio.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/uio.h
@@ -174,7 +174,7 @@ zfs_uio_bvec_init(zfs_uio_t *uio, struct bio *bio, struct request *rq)
static inline void
zfs_uio_iov_iter_init(zfs_uio_t *uio, struct iov_iter *iter, offset_t offset,
- ssize_t resid, size_t skip)
+ ssize_t resid)
{
uio->uio_iter = iter;
uio->uio_iovcnt = iter->nr_segs;
@@ -184,7 +184,7 @@ zfs_uio_iov_iter_init(zfs_uio_t *uio, struct iov_iter *iter, offset_t offset,
uio->uio_fmode = 0;
uio->uio_extflg = 0;
uio->uio_resid = resid;
- uio->uio_skip = skip;
+ uio->uio_skip = 0;
uio->uio_soffset = uio->uio_loffset;
memset(&uio->uio_dio, 0, sizeof (zfs_uio_dio_t));
}
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h
index 77d0cdef5d2f..8fa6ab01d1ad 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h
@@ -52,7 +52,6 @@ int secpolicy_vnode_setids_setgids(const cred_t *, gid_t, zidmap_t *,
struct user_namespace *);
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 *, zidmap_t *, struct user_namespace *);
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_vfsops_os.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h
index 4a73712e959d..ab46d5f8ca08 100644
--- 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
@@ -131,6 +131,12 @@ struct zfsvfs {
uint64_t z_groupobjquota_obj;
uint64_t z_projectquota_obj;
uint64_t z_projectobjquota_obj;
+ uint64_t z_defaultuserquota;
+ uint64_t z_defaultgroupquota;
+ uint64_t z_defaultprojectquota;
+ uint64_t z_defaultuserobjquota;
+ uint64_t z_defaultgroupobjquota;
+ uint64_t z_defaultprojectobjquota;
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 */
@@ -250,6 +256,8 @@ 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);
+extern int zfs_set_default_quota(zfsvfs_t *zfsvfs, zfs_prop_t zfs_prop,
+ uint64_t quota);
#ifdef __cplusplus
}
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 39f1310aadf2..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;
@@ -123,41 +124,6 @@ extern int zpl_clone_file_range(struct file *src_file, loff_t src_off,
extern int zpl_dedupe_file_range(struct file *src_file, loff_t src_off,
struct file *dst_file, loff_t dst_off, uint64_t len);
-/* compat for FICLONE/FICLONERANGE/FIDEDUPERANGE ioctls */
-typedef struct {
- int64_t fcr_src_fd;
- uint64_t fcr_src_offset;
- uint64_t fcr_src_length;
- uint64_t fcr_dest_offset;
-} zfs_ioc_compat_file_clone_range_t;
-
-typedef struct {
- int64_t fdri_dest_fd;
- uint64_t fdri_dest_offset;
- uint64_t fdri_bytes_deduped;
- int32_t fdri_status;
- uint32_t fdri_reserved;
-} zfs_ioc_compat_dedupe_range_info_t;
-
-typedef struct {
- uint64_t fdr_src_offset;
- uint64_t fdr_src_length;
- uint16_t fdr_dest_count;
- uint16_t fdr_reserved1;
- uint32_t fdr_reserved2;
- zfs_ioc_compat_dedupe_range_info_t fdr_info[];
-} zfs_ioc_compat_dedupe_range_t;
-
-#define ZFS_IOC_COMPAT_FICLONE _IOW(0x94, 9, int)
-#define ZFS_IOC_COMPAT_FICLONERANGE \
- _IOW(0x94, 13, zfs_ioc_compat_file_clone_range_t)
-#define ZFS_IOC_COMPAT_FIDEDUPERANGE \
- _IOWR(0x94, 54, zfs_ioc_compat_dedupe_range_t)
-
-extern long zpl_ioctl_ficlone(struct file *filp, void *arg);
-extern long zpl_ioctl_ficlonerange(struct file *filp, void *arg);
-extern long zpl_ioctl_fideduperange(struct file *filp, void *arg);
-
#if defined(HAVE_INODE_TIMESTAMP_TRUNCATE)
#define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip)