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/spl/sys/misc.h8
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h12
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h3
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h1
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/types.h2
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h23
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am2
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h1
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vnops.h5
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h7
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h117
-rw-r--r--sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h14
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h1
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/taskq.h5
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/uio.h115
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/vnode.h6
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am2
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h4
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h6
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops.h13
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h13
-rw-r--r--sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h9
22 files changed, 238 insertions, 131 deletions
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 e39bb07b2f4c..3481507d2c33 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h
@@ -30,6 +30,7 @@
#define _OPENSOLARIS_SYS_MISC_H_
#include <sys/limits.h>
+#include <sys/filio.h>
#define MAXUID UID_MAX
@@ -40,8 +41,8 @@
#define _FIOGDIO (INT_MIN+1)
#define _FIOSDIO (INT_MIN+2)
-#define _FIO_SEEK_DATA FIOSEEKDATA
-#define _FIO_SEEK_HOLE FIOSEEKHOLE
+#define F_SEEK_DATA FIOSEEKDATA
+#define F_SEEK_HOLE FIOSEEKHOLE
struct opensolaris_utsname {
char *sysname;
@@ -53,4 +54,7 @@ struct opensolaris_utsname {
extern char hw_serial[11];
+#define task_io_account_read(n)
+#define task_io_account_write(n)
+
#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_os.h
index ec1da1a46ae6..5b3b3271e39e 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h
@@ -57,6 +57,8 @@
#define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, func, _, perm, desc) \
ZFS_MODULE_PARAM_CALL_IMPL(_vfs_ ## scope_prefix, name, perm, func ## _args(name_prefix ## name), desc)
+#define ZFS_MODULE_VIRTUAL_PARAM_CALL ZFS_MODULE_PARAM_CALL
+
#define param_set_arc_long_args(var) \
CTLTYPE_ULONG, &var, 0, param_set_arc_long, "LU"
@@ -84,6 +86,9 @@
#define param_set_max_auto_ashift_args(var) \
CTLTYPE_U64, &var, 0, param_set_max_auto_ashift, "QU"
+#define fletcher_4_param_set_args(var) \
+ CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A"
+
#include <sys/kernel.h>
#define module_init(fn) \
static void \
@@ -93,6 +98,13 @@ wrap_ ## fn(void *dummy __unused) \
} \
SYSINIT(zfs_ ## fn, SI_SUB_LAST, SI_ORDER_FIRST, wrap_ ## fn, NULL)
+#define module_init_early(fn) \
+static void \
+wrap_ ## fn(void *dummy __unused) \
+{ \
+ fn(); \
+} \
+SYSINIT(zfs_ ## fn, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_FIRST, wrap_ ## fn, NULL)
#define module_exit(fn) \
static void \
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 3a05da12b3aa..909ae3886e9c 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/policy.h
@@ -34,6 +34,7 @@
#include <sys/vnode.h>
struct mount;
struct vattr;
+struct znode;
int secpolicy_nfs(cred_t *cr);
int secpolicy_zfs(cred_t *crd);
@@ -57,7 +58,7 @@ int secpolicy_vnode_setattr(cred_t *cr, vnode_t *vp, struct vattr *vap,
int unlocked_access(void *, int, cred_t *), void *node);
int secpolicy_vnode_create_gid(cred_t *cr);
int secpolicy_vnode_setids_setgids(vnode_t *vp, cred_t *cr, gid_t gid);
-int secpolicy_vnode_setid_retain(vnode_t *vp, cred_t *cr,
+int secpolicy_vnode_setid_retain(struct znode *zp, cred_t *cr,
boolean_t issuidroot);
void secpolicy_setid_clear(struct vattr *vap, vnode_t *vp, cred_t *cr);
int secpolicy_setid_setsticky_clear(vnode_t *vp, struct vattr *vap,
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h
index 2d0164cb129f..7e3ab8915542 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h
@@ -80,6 +80,7 @@ extern "C" {
#define kpreempt_disable() critical_enter()
#define kpreempt_enable() critical_exit()
#define CPU_SEQID curcpu
+#define CPU_SEQID_UNSTABLE curcpu
#define is_system_labeled() 0
/*
* Convert a single byte to/from binary-coded decimal (BCD).
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/types.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/types.h
index 3f895362881a..ecb91fd1bb89 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/types.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/types.h
@@ -64,7 +64,7 @@ typedef u_int uint_t;
typedef u_char uchar_t;
typedef u_short ushort_t;
typedef u_long ulong_t;
-typedef u_int minor_t;
+typedef int minor_t;
/* END CSTYLED */
#ifndef _OFF64_T_DECLARED
#define _OFF64_T_DECLARED
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h
index cb577df105e9..11b2189cda45 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h
@@ -43,27 +43,6 @@ typedef struct uio uio_t;
typedef struct iovec iovec_t;
typedef enum uio_seg uio_seg_t;
-typedef enum xuio_type {
- UIOTYPE_ASYNCIO,
- UIOTYPE_ZEROCOPY
-} xuio_type_t;
-
-typedef struct xuio {
- uio_t xu_uio;
-
- /* Extended uio fields */
- enum xuio_type xu_type; /* What kind of uio structure? */
- union {
- struct {
- int xu_zc_rw;
- void *xu_zc_priv;
- } xu_zc;
- } xu_ext;
-} xuio_t;
-
-#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
-#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
-
static __inline int
zfs_uiomove(void *cp, size_t n, enum uio_rw dir, uio_t *uio)
{
@@ -82,6 +61,8 @@ void uioskip(uio_t *uiop, size_t n);
#define uio_iovcnt(uio) (uio)->uio_iovcnt
#define uio_iovlen(uio, idx) (uio)->uio_iov[(idx)].iov_len
#define uio_iovbase(uio, idx) (uio)->uio_iov[(idx)].iov_base
+#define uio_fault_disable(uio, set)
+#define uio_prefaultpages(size, uio) (0)
static inline void
uio_iov_at_index(uio_t *uio, uint_t idx, void **base, uint64_t *len)
diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am
index bf5cc39eba74..392bb4ae3477 100644
--- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am
+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am
@@ -8,7 +8,7 @@ KERNEL_H = \
zfs_dir.h \
zfs_ioctl_compat.h \
zfs_vfsops_os.h \
- zfs_vnops.h \
+ zfs_vnops_os.h \
zfs_znode_impl.h \
zpl.h
diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h
index 0316f93b27ec..8dbe907d098c 100644
--- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h
+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h
@@ -56,7 +56,6 @@
#define tsd_set(key, value) osd_thread_set(curthread, (key), (value))
#define fm_panic panic
-#define cond_resched() kern_yield(PRI_USER)
extern int zfs_debug_level;
extern struct mtx zfs_debug_mtx;
#define ZFS_LOG(lvl, ...) do { \
diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vnops.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vnops.h
index 587650af6ce3..bf5e03b24c06 100644
--- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vnops.h
+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vnops.h
@@ -26,8 +26,9 @@
* $FreeBSD$
*/
-#ifndef _SYS_ZFS_VNOPS_H_
-#define _SYS_ZFS_VNOPS_H_
+#ifndef _SYS_FS_ZFS_VNOPS_OS_H
+#define _SYS_FS_ZFS_VNOPS_OS_H
+
int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset,
uint64_t size, struct vm_page **ppa, dmu_tx_t *tx);
int dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
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 ff61935e741e..ac2625d9a8ab 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
@@ -39,6 +39,7 @@
#include <sys/zfs_acl.h>
#include <sys/zil.h>
#include <sys/zfs_project.h>
+#include <vm/vm_object.h>
#ifdef __cplusplus
extern "C" {
@@ -113,7 +114,10 @@ extern minor_t zfsdev_minor_alloc(void);
#define Z_ISBLK(type) ((type) == VBLK)
#define Z_ISCHR(type) ((type) == VCHR)
#define Z_ISLNK(type) ((type) == VLNK)
+#define Z_ISDIR(type) ((type) == VDIR)
+#define zn_has_cached_data(zp) vn_has_cached_data(ZTOV(zp))
+#define zn_rlimit_fsize(zp, uio, td) vn_rlimit_fsize(ZTOV(zp), (uio), (td))
/* Called on entry to each ZFS vnode and vfs operation */
#define ZFS_ENTER(zfsvfs) \
@@ -169,13 +173,12 @@ extern void zfs_tstamp_update_setup_ext(struct znode *,
uint_t, uint64_t [2], uint64_t [2], boolean_t have_tx);
extern void zfs_znode_free(struct znode *);
-extern zil_get_data_t zfs_get_data;
extern zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE];
extern int zfsfstype;
extern int zfs_znode_parent_and_name(struct znode *zp, struct znode **dzpp,
char *buf);
-
+extern void zfs_inode_update(struct znode *);
#ifdef __cplusplus
}
#endif
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 1cdc300a6f85..e41b248b0405 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
@@ -99,14 +99,6 @@ blk_queue_set_read_ahead(struct request_queue *q, unsigned long ra_pages)
#endif
}
-#if !defined(HAVE_GET_DISK_AND_MODULE)
-static inline struct kobject *
-get_disk_and_module(struct gendisk *disk)
-{
- return (get_disk(disk));
-}
-#endif
-
#ifdef HAVE_BIO_BVEC_ITER
#define BIO_BI_SECTOR(bio) (bio)->bi_iter.bi_sector
#define BIO_BI_SIZE(bio) (bio)->bi_iter.bi_size
@@ -268,12 +260,48 @@ bio_set_bi_error(struct bio *bio, int error)
*
* For older kernels trigger a re-reading of the partition table by calling
* check_disk_change() which calls flush_disk() to invalidate the device.
+ *
+ * For newer kernels (as of 5.10), bdev_check_media_chage is used, in favor of
+ * check_disk_change(), with the modification that invalidation is no longer
+ * forced.
*/
+#ifdef HAVE_CHECK_DISK_CHANGE
+#define zfs_check_media_change(bdev) check_disk_change(bdev)
#ifdef HAVE_BLKDEV_REREAD_PART
#define vdev_bdev_reread_part(bdev) blkdev_reread_part(bdev)
#else
#define vdev_bdev_reread_part(bdev) check_disk_change(bdev)
#endif /* HAVE_BLKDEV_REREAD_PART */
+#else
+#ifdef HAVE_BDEV_CHECK_MEDIA_CHANGE
+static inline int
+zfs_check_media_change(struct block_device *bdev)
+{
+ struct gendisk *gd = bdev->bd_disk;
+ const struct block_device_operations *bdo = gd->fops;
+
+ if (!bdev_check_media_change(bdev))
+ return (0);
+
+ /*
+ * Force revalidation, to mimic the old behavior of
+ * check_disk_change()
+ */
+ if (bdo->revalidate_disk)
+ bdo->revalidate_disk(gd);
+
+ return (0);
+}
+#define vdev_bdev_reread_part(bdev) zfs_check_media_change(bdev)
+#else
+/*
+ * This is encountered if check_disk_change() and bdev_check_media_change()
+ * are not available in the kernel - likely due to an API change that needs
+ * to be chased down.
+ */
+#error "Unsupported kernel: no usable disk change check"
+#endif /* HAVE_BDEV_CHECK_MEDIA_CHANGE */
+#endif /* HAVE_CHECK_DISK_CHANGE */
/*
* 2.6.27 API change
@@ -282,16 +310,38 @@ bio_set_bi_error(struct bio *bio, int error)
*
* 4.4.0-6.21 API change for Ubuntu
* lookup_bdev() gained a second argument, FMODE_*, to check inode permissions.
+ *
+ * 5.11 API change
+ * Changed to take a dev_t argument which is set on success and return a
+ * non-zero error code on failure.
*/
-#ifdef HAVE_1ARG_LOOKUP_BDEV
-#define vdev_lookup_bdev(path) lookup_bdev(path)
-#else
-#ifdef HAVE_2ARGS_LOOKUP_BDEV
-#define vdev_lookup_bdev(path) lookup_bdev(path, 0)
+static inline int
+vdev_lookup_bdev(const char *path, dev_t *dev)
+{
+#if defined(HAVE_DEVT_LOOKUP_BDEV)
+ return (lookup_bdev(path, dev));
+#elif defined(HAVE_1ARG_LOOKUP_BDEV)
+ struct block_device *bdev = lookup_bdev(path);
+ if (IS_ERR(bdev))
+ return (PTR_ERR(bdev));
+
+ *dev = bdev->bd_dev;
+ bdput(bdev);
+
+ return (0);
+#elif defined(HAVE_MODE_LOOKUP_BDEV)
+ struct block_device *bdev = lookup_bdev(path, FMODE_READ);
+ if (IS_ERR(bdev))
+ return (PTR_ERR(bdev));
+
+ *dev = bdev->bd_dev;
+ bdput(bdev);
+
+ return (0);
#else
#error "Unsupported kernel"
-#endif /* HAVE_2ARGS_LOOKUP_BDEV */
-#endif /* HAVE_1ARG_LOOKUP_BDEV */
+#endif
+}
/*
* Kernels without bio_set_op_attrs use bi_rw for the bio flags.
@@ -465,25 +515,38 @@ blk_queue_discard_secure(struct request_queue *q)
*/
#define VDEV_HOLDER ((void *)0x2401de7)
-static inline void
-blk_generic_start_io_acct(struct request_queue *q, int rw,
- unsigned long sectors, struct hd_struct *part)
+static inline unsigned long
+blk_generic_start_io_acct(struct request_queue *q __attribute__((unused)),
+ struct gendisk *disk __attribute__((unused)),
+ int rw __attribute__((unused)), struct bio *bio)
{
-#if defined(HAVE_GENERIC_IO_ACCT_3ARG)
- generic_start_io_acct(rw, sectors, part);
+#if defined(HAVE_BIO_IO_ACCT)
+ return (bio_start_io_acct(bio));
+#elif defined(HAVE_GENERIC_IO_ACCT_3ARG)
+ unsigned long start_time = jiffies;
+ generic_start_io_acct(rw, bio_sectors(bio), &disk->part0);
+ return (start_time);
#elif defined(HAVE_GENERIC_IO_ACCT_4ARG)
- generic_start_io_acct(q, rw, sectors, part);
+ unsigned long start_time = jiffies;
+ generic_start_io_acct(q, rw, bio_sectors(bio), &disk->part0);
+ return (start_time);
+#else
+ /* Unsupported */
+ return (0);
#endif
}
static inline void
-blk_generic_end_io_acct(struct request_queue *q, int rw,
- struct hd_struct *part, unsigned long start_time)
+blk_generic_end_io_acct(struct request_queue *q __attribute__((unused)),
+ struct gendisk *disk __attribute__((unused)),
+ int rw __attribute__((unused)), struct bio *bio, unsigned long start_time)
{
-#if defined(HAVE_GENERIC_IO_ACCT_3ARG)
- generic_end_io_acct(rw, part, start_time);
+#if defined(HAVE_BIO_IO_ACCT)
+ bio_end_io_acct(bio, start_time);
+#elif defined(HAVE_GENERIC_IO_ACCT_3ARG)
+ generic_end_io_acct(rw, &disk->part0, start_time);
#elif defined(HAVE_GENERIC_IO_ACCT_4ARG)
- generic_end_io_acct(q, rw, part, start_time);
+ generic_end_io_acct(q, rw, &disk->part0, start_time);
#endif
}
@@ -493,6 +556,8 @@ blk_generic_alloc_queue(make_request_fn make_request, int node_id)
{
#if defined(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN)
return (blk_alloc_queue(make_request, node_id));
+#elif defined(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN_RH)
+ return (blk_alloc_queue_rh(make_request, node_id));
#else
struct request_queue *q = blk_alloc_queue(GFP_KERNEL);
if (q != NULL)
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 1c48df5cbd81..e96e95313009 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
@@ -74,6 +74,7 @@ enum scope_prefix_types {
zfs_vdev_cache,
zfs_vdev_file,
zfs_vdev_mirror,
+ zfs_vnops,
zfs_zevent,
zfs_zio,
zfs_zil
@@ -143,6 +144,17 @@ enum scope_prefix_types {
MODULE_PARM_DESC(name_prefix ## name, desc)
/* END CSTYLED */
+/*
+ * As above, but there is no variable with the name name_prefix ## name,
+ * so NULL is passed to module_param_call instead.
+ */
+/* BEGIN CSTYLED */
+#define ZFS_MODULE_VIRTUAL_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
+ CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \
+ module_param_call(name_prefix ## name, setfunc, getfunc, NULL, perm); \
+ MODULE_PARM_DESC(name_prefix ## name, desc)
+/* END CSTYLED */
+
#define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp
#define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s)
@@ -150,4 +162,6 @@ enum scope_prefix_types {
#define ZFS_MODULE_LICENSE(s) MODULE_LICENSE(s)
#define ZFS_MODULE_VERSION(s) MODULE_VERSION(s)
+#define module_init_early(fn) module_init(fn)
+
#endif /* _MOD_COMPAT_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 eb3494bc7904..98d1ab1d7f8a 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/sysmacros.h
@@ -76,6 +76,7 @@
#define max_ncpus num_possible_cpus()
#define boot_ncpus num_online_cpus()
#define CPU_SEQID smp_processor_id()
+#define CPU_SEQID_UNSTABLE raw_smp_processor_id()
#define is_system_labeled() 0
#ifndef RLIM64_INFINITY
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/taskq.h b/sys/contrib/openzfs/include/os/linux/spl/sys/taskq.h
index 16f4349e78e4..b50175a10873 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/taskq.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/taskq.h
@@ -84,6 +84,8 @@ typedef struct taskq {
int tq_nthreads; /* # of existing threads */
int tq_nspawn; /* # of threads being spawned */
int tq_maxthreads; /* # of threads maximum */
+ /* If PERCPU flag is set, percent of NCPUs to have as threads */
+ int tq_cpu_pct;
int tq_pri; /* priority */
int tq_minalloc; /* min taskq_ent_t pool size */
int tq_maxalloc; /* max taskq_ent_t pool size */
@@ -99,6 +101,9 @@ typedef struct taskq {
spl_wait_queue_head_t tq_work_waitq; /* new work waitq */
spl_wait_queue_head_t tq_wait_waitq; /* wait waitq */
tq_lock_role_t tq_lock_class; /* class when taking tq_lock */
+ /* list node for the cpu hotplug callback */
+ struct hlist_node tq_hp_cb_node;
+ boolean_t tq_hp_support;
} taskq_t;
typedef struct taskq_ent {
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 abcd90dd570c..6e850c5fe7b1 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/uio.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/uio.h
@@ -44,14 +44,19 @@ typedef enum uio_rw {
typedef enum uio_seg {
UIO_USERSPACE = 0,
UIO_SYSSPACE = 1,
- UIO_USERISPACE = 2,
- UIO_BVEC = 3,
+ UIO_BVEC = 2,
+#if defined(HAVE_VFS_IOV_ITER)
+ UIO_ITER = 3,
+#endif
} uio_seg_t;
typedef struct uio {
union {
const struct iovec *uio_iov;
const struct bio_vec *uio_bvec;
+#if defined(HAVE_VFS_IOV_ITER)
+ struct iov_iter *uio_iter;
+#endif
};
int uio_iovcnt;
offset_t uio_loffset;
@@ -59,60 +64,17 @@ typedef struct uio {
boolean_t uio_fault_disable;
uint16_t uio_fmode;
uint16_t uio_extflg;
- offset_t uio_limit;
ssize_t uio_resid;
size_t uio_skip;
} uio_t;
-typedef struct aio_req {
- uio_t *aio_uio;
- void *aio_private;
-} aio_req_t;
-
-typedef enum xuio_type {
- UIOTYPE_ASYNCIO,
- UIOTYPE_ZEROCOPY,
-} xuio_type_t;
-
-
-#define UIOA_IOV_MAX 16
-
-typedef struct uioa_page_s {
- int uioa_pfncnt;
- void **uioa_ppp;
- caddr_t uioa_base;
- size_t uioa_len;
-} uioa_page_t;
-
-typedef struct xuio {
- uio_t xu_uio;
- enum xuio_type xu_type;
- union {
- struct {
- uint32_t xu_a_state;
- ssize_t xu_a_mbytes;
- uioa_page_t *xu_a_lcur;
- void **xu_a_lppp;
- void *xu_a_hwst[4];
- uioa_page_t xu_a_locked[UIOA_IOV_MAX];
- } xu_aio;
-
- struct {
- int xu_zc_rw;
- void *xu_zc_priv;
- } xu_zc;
- } xu_ext;
-} xuio_t;
-
-#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
-#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
-
#define uio_segflg(uio) (uio)->uio_segflg
#define uio_offset(uio) (uio)->uio_loffset
#define uio_resid(uio) (uio)->uio_resid
#define uio_iovcnt(uio) (uio)->uio_iovcnt
#define uio_iovlen(uio, idx) (uio)->uio_iov[(idx)].iov_len
#define uio_iovbase(uio, idx) (uio)->uio_iov[(idx)].iov_base
+#define uio_fault_disable(uio, set) (uio)->uio_fault_disable = set
static inline void
uio_iov_at_index(uio_t *uio, uint_t idx, void **base, uint64_t *len)
@@ -140,4 +102,65 @@ uio_index_at_offset(uio_t *uio, offset_t off, uint_t *vec_idx)
return (off);
}
+static inline void
+iov_iter_init_compat(struct iov_iter *iter, unsigned int dir,
+ const struct iovec *iov, unsigned long nr_segs, size_t count)
+{
+#if defined(HAVE_IOV_ITER_INIT)
+ iov_iter_init(iter, dir, iov, nr_segs, count);
+#elif defined(HAVE_IOV_ITER_INIT_LEGACY)
+ iov_iter_init(iter, iov, nr_segs, count, 0);
+#else
+#error "Unsupported kernel"
+#endif
+}
+
+static inline void
+uio_iovec_init(uio_t *uio, const struct iovec *iov, unsigned long nr_segs,
+ offset_t offset, uio_seg_t seg, ssize_t resid, size_t skip)
+{
+ ASSERT(seg == UIO_USERSPACE || seg == UIO_SYSSPACE);
+
+ uio->uio_iov = iov;
+ uio->uio_iovcnt = nr_segs;
+ uio->uio_loffset = offset;
+ uio->uio_segflg = seg;
+ uio->uio_fault_disable = B_FALSE;
+ uio->uio_fmode = 0;
+ uio->uio_extflg = 0;
+ uio->uio_resid = resid;
+ uio->uio_skip = skip;
+}
+
+static inline void
+uio_bvec_init(uio_t *uio, struct bio *bio)
+{
+ uio->uio_bvec = &bio->bi_io_vec[BIO_BI_IDX(bio)];
+ uio->uio_iovcnt = bio->bi_vcnt - BIO_BI_IDX(bio);
+ uio->uio_loffset = BIO_BI_SECTOR(bio) << 9;
+ uio->uio_segflg = UIO_BVEC;
+ uio->uio_fault_disable = B_FALSE;
+ uio->uio_fmode = 0;
+ uio->uio_extflg = 0;
+ uio->uio_resid = BIO_BI_SIZE(bio);
+ uio->uio_skip = BIO_BI_SKIP(bio);
+}
+
+#if defined(HAVE_VFS_IOV_ITER)
+static inline void
+uio_iov_iter_init(uio_t *uio, struct iov_iter *iter, offset_t offset,
+ ssize_t resid, size_t skip)
+{
+ uio->uio_iter = iter;
+ uio->uio_iovcnt = iter->nr_segs;
+ uio->uio_loffset = offset;
+ uio->uio_segflg = UIO_ITER;
+ uio->uio_fault_disable = B_FALSE;
+ uio->uio_fmode = 0;
+ uio->uio_extflg = 0;
+ uio->uio_resid = resid;
+ uio->uio_skip = skip;
+}
+#endif
+
#endif /* SPL_UIO_H */
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/vnode.h b/sys/contrib/openzfs/include/os/linux/spl/sys/vnode.h
index 6f17db89fe53..64c270650225 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/vnode.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/vnode.h
@@ -52,6 +52,12 @@
#define F_FREESP 11 /* Free file space */
+
+#if defined(SEEK_HOLE) && defined(SEEK_DATA)
+#define F_SEEK_DATA SEEK_DATA
+#define F_SEEK_HOLE SEEK_HOLE
+#endif
+
/*
* The vnode AT_ flags are mapped to the Linux ATTR_* flags.
* This allows them to be used safely with an iattr structure.
diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am b/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am
index a5f2502d20e8..a075db476e40 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am
@@ -21,7 +21,7 @@ KERNEL_H = \
zfs_ctldir.h \
zfs_dir.h \
zfs_vfsops_os.h \
- zfs_vnops.h \
+ zfs_vnops_os.h \
zfs_znode_impl.h \
zpl.h
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 77a73ad149c5..61afc3765504 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/policy.h
@@ -35,6 +35,8 @@
#include <sys/xvattr.h>
#include <sys/zpl.h>
+struct znode;
+
int secpolicy_nfs(const cred_t *);
int secpolicy_sys_config(const cred_t *, boolean_t);
int secpolicy_vnode_access2(const cred_t *, struct inode *,
@@ -44,7 +46,7 @@ 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_setid_retain(struct znode *, 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 *);
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 083560952f0b..4707fc6f4112 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
@@ -52,7 +52,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__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)
@@ -86,7 +85,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__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;
@@ -116,7 +114,7 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__entry->mask_matched = mask_matched;
),
TP_printk("zn { id %llu unlinked %u atime_dirty %u "
- "zn_prefetch %u moved %u blksz %u seq %u "
+ "zn_prefetch %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 { "
@@ -124,7 +122,7 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
"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_zn_prefetch, __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,
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
index 2b41f3863425..df307fc0350d 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops.h
@@ -22,8 +22,8 @@
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#ifndef _SYS_FS_ZFS_VNOPS_H
-#define _SYS_FS_ZFS_VNOPS_H
+#ifndef _SYS_FS_ZFS_VNOPS_OS_H
+#define _SYS_FS_ZFS_VNOPS_OS_H
#include <sys/vnode.h>
#include <sys/xvattr.h>
@@ -40,12 +40,8 @@ extern "C" {
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,
@@ -58,7 +54,6 @@ extern int zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap,
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,
@@ -72,10 +67,6 @@ 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);
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 e010970dd540..13e5fb653f5b 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
@@ -68,6 +68,10 @@ extern "C" {
#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 Z_ISDIR(type) S_ISDIR(type)
+
+#define zn_has_cached_data(zp) ((zp)->z_is_mapped)
+#define zn_rlimit_fsize(zp, uio, td) (0)
#define zhold(zp) igrab(ZTOI((zp)))
#define zrele(zp) iput(ZTOI((zp)))
@@ -90,7 +94,11 @@ do { \
zfs_exit_fs(zfsvfs); \
ZFS_EXIT_READ(zfsvfs, FTAG); \
} while (0)
-#define ZPL_EXIT(zfsvfs) ZFS_EXIT(zfsvfs)
+
+#define ZPL_EXIT(zfsvfs) \
+do { \
+ rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG); \
+} while (0)
/* Verifies the znode is valid. */
#define ZFS_VERIFY_ZP_ERROR(zp, error) \
@@ -143,6 +151,8 @@ do { \
} while (0)
#endif /* HAVE_INODE_TIMESPEC64_TIMES */
+#define ZFS_ACCESSTIME_STAMP(zfsvfs, zp)
+
struct znode;
extern int zfs_sync(struct super_block *, int, cred_t *);
@@ -157,7 +167,6 @@ 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;
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 ef5a0b842d09..b0bb9c29c0b4 100644
--- a/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h
+++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zpl.h
@@ -46,15 +46,6 @@ 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;