diff options
author | Matthew Macy <[email protected]> | 2020-07-31 21:30:31 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 21:30:31 -0700 |
commit | 47ed79ff60945e0c5d8ccb56f0d29a893e1261ac (patch) | |
tree | af032038ad66d947e333ea55cf1383ce2627ea8b | |
parent | 0cc3454821879396c38d8c557ab918a70afd919b (diff) |
Changes to make openzfs build within FreeBSD buildworld
A collection of header changes to enable FreeBSD to build
with vendored OpenZFS.
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes #10635
-rw-r--r-- | cmd/zpool/zpool_vdev.c | 2 | ||||
-rw-r--r-- | include/os/freebsd/spl/sys/byteorder.h | 14 | ||||
-rw-r--r-- | include/os/freebsd/spl/sys/ccompile.h | 7 | ||||
-rw-r--r-- | include/os/freebsd/spl/sys/kmem.h | 2 | ||||
-rw-r--r-- | include/os/freebsd/spl/sys/simd_x86.h | 4 | ||||
-rw-r--r-- | include/os/freebsd/spl/sys/types.h | 2 | ||||
-rw-r--r-- | include/os/freebsd/spl/sys/vnode.h | 7 | ||||
-rw-r--r-- | include/os/freebsd/zfs/sys/sha2.h | 2 | ||||
-rw-r--r-- | include/os/freebsd/zfs/sys/zfs_context_os.h | 4 | ||||
-rw-r--r-- | lib/libspl/asm-i386/atomic.S | 6 | ||||
-rw-r--r-- | lib/libspl/include/os/freebsd/sys/param.h | 2 | ||||
-rw-r--r-- | lib/libspl/include/rpc/xdr.h | 7 | ||||
-rw-r--r-- | lib/libspl/include/sys/isa_defs.h | 2 | ||||
-rw-r--r-- | lib/libspl/include/sys/uio.h | 3 | ||||
-rw-r--r-- | module/os/freebsd/spl/spl_vm.c | 2 | ||||
-rw-r--r-- | module/os/freebsd/zfs/arc_os.c | 3 | ||||
-rw-r--r-- | module/os/freebsd/zfs/kmod_core.c | 4 | ||||
-rw-r--r-- | module/os/freebsd/zfs/sysctl_os.c | 15 | ||||
-rw-r--r-- | module/os/freebsd/zfs/zfs_ioctl_compat.c | 3 | ||||
-rw-r--r-- | module/os/freebsd/zfs/zfs_vfsops.c | 11 | ||||
-rw-r--r-- | module/zfs/arc.c | 6 |
21 files changed, 79 insertions, 29 deletions
diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index 9b5f4972f..9aa09b18c 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -624,7 +624,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) */ if (!dontreport && (vdev_size != -1LL && - (labs(size - vdev_size) > + (llabs(size - vdev_size) > ZPOOL_FUZZ))) { if (ret != NULL) free(ret); diff --git a/include/os/freebsd/spl/sys/byteorder.h b/include/os/freebsd/spl/sys/byteorder.h index fd6b0269d..ae767242b 100644 --- a/include/os/freebsd/spl/sys/byteorder.h +++ b/include/os/freebsd/spl/sys/byteorder.h @@ -84,9 +84,23 @@ #define htonll(x) BMASK_64(x) #define ntohll(x) BMASK_64(x) #else +#ifndef __LP64__ +static __inline__ uint64_t +htonll(uint64_t n) +{ + return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32)); +} + +static __inline__ uint64_t +ntohll(uint64_t n) +{ + return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32)); +} +#else #define htonll(x) BSWAP_64(x) #define ntohll(x) BSWAP_64(x) #endif +#endif #define BE_IN32(xa) htonl(*((uint32_t *)(void *)(xa))) diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h index c594c928f..c90813b04 100644 --- a/include/os/freebsd/spl/sys/ccompile.h +++ b/include/os/freebsd/spl/sys/ccompile.h @@ -202,11 +202,14 @@ typedef int enum_t; #define ENODATA EINVAL -#define __XSI_VISIBLE 1000 #define __BSD_VISIBLE 1 +#ifndef IN_BASE #define __POSIX_VISIBLE 201808 +#define __XSI_VISIBLE 1000 +#endif #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) #define open64 open +#define mmap64 mmap #define pwrite64 pwrite #define ftruncate64 ftruncate #define lseek64 lseek @@ -257,7 +260,9 @@ typedef int enum_t; #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #define RLIM64_INFINITY RLIM_INFINITY +#ifndef HAVE_ERESTART #define ERESTART EAGAIN +#endif #define ABS(a) ((a) < 0 ? -(a) : (a)) #endif diff --git a/include/os/freebsd/spl/sys/kmem.h b/include/os/freebsd/spl/sys/kmem.h index 943b18f03..6155ce6b0 100644 --- a/include/os/freebsd/spl/sys/kmem.h +++ b/include/os/freebsd/spl/sys/kmem.h @@ -32,7 +32,7 @@ #include <sys/param.h> #include <sys/malloc.h> #include <sys/vmem.h> -#include <sys/vmmeter.h> +#include <sys/counter.h> #include <vm/uma.h> #include <vm/vm.h> diff --git a/include/os/freebsd/spl/sys/simd_x86.h b/include/os/freebsd/spl/sys/simd_x86.h index da846fcbe..a35e205d5 100644 --- a/include/os/freebsd/spl/sys/simd_x86.h +++ b/include/os/freebsd/spl/sys/simd_x86.h @@ -29,7 +29,11 @@ #include <sys/cdefs.h> #include <sys/types.h> #include <sys/systm.h> +#ifdef __i386__ +#include <x86/fpu.h> +#else #include <machine/fpu.h> +#endif #include <x86/x86_var.h> #include <x86/specialreg.h> diff --git a/include/os/freebsd/spl/sys/types.h b/include/os/freebsd/spl/sys/types.h index c06c963d6..3f8953628 100644 --- a/include/os/freebsd/spl/sys/types.h +++ b/include/os/freebsd/spl/sys/types.h @@ -73,7 +73,7 @@ typedef off_t off64_t; typedef id_t taskid_t; typedef id_t projid_t; typedef id_t poolid_t; -typedef id_t zoneid_t; +typedef uint_t zoneid_t; typedef id_t ctid_t; typedef mode_t o_mode_t; typedef uint64_t pgcnt_t; diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h index b9fae99ad..6a6146132 100644 --- a/include/os/freebsd/spl/sys/vnode.h +++ b/include/os/freebsd/spl/sys/vnode.h @@ -49,7 +49,9 @@ enum symfollow { NO_FOLLOW = NOFOLLOW }; #include <sys/proc.h> #include <sys/vnode_impl.h> +#ifndef IN_BASE #include_next <sys/vnode.h> +#endif #include <sys/mount.h> #include <sys/cred.h> #include <sys/fcntl.h> @@ -70,11 +72,14 @@ typedef struct vop_vector vnodeops_t; #define rootvfs (rootvnode == NULL ? NULL : rootvnode->v_mount) + +#ifndef IN_BASE static __inline int vn_is_readonly(vnode_t *vp) { return (vp->v_mount->mnt_flag & MNT_RDONLY); } +#endif #define vn_vfswlock(vp) (0) #define vn_vfsunlock(vp) do { } while (0) #define vn_ismntpt(vp) \ @@ -166,6 +171,7 @@ vn_is_readonly(vnode_t *vp) #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|\ AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) +#ifndef IN_BASE static __inline void vattr_init_mask(vattr_t *vap) { @@ -187,6 +193,7 @@ vattr_init_mask(vattr_t *vap) if (vap->va_flags != VNOVAL) vap->va_mask |= AT_XVATTR; } +#endif #define RLIM64_INFINITY 0 diff --git a/include/os/freebsd/zfs/sys/sha2.h b/include/os/freebsd/zfs/sys/sha2.h index 9d848e1fc..e3923e4ca 100644 --- a/include/os/freebsd/zfs/sys/sha2.h +++ b/include/os/freebsd/zfs/sys/sha2.h @@ -116,7 +116,7 @@ SHA2Init(uint64_t mech, SHA2_CTX *c) SHA512_256_Init(&c->SHA512_ctx); break; default: - panic("unknown mechanism %lu", mech); + panic("unknown mechanism %ju", (uintmax_t)mech); } c->algotype = (uint32_t)mech; } diff --git a/include/os/freebsd/zfs/sys/zfs_context_os.h b/include/os/freebsd/zfs/sys/zfs_context_os.h index 8da3374a6..7dd298564 100644 --- a/include/os/freebsd/zfs/sys/zfs_context_os.h +++ b/include/os/freebsd/zfs/sys/zfs_context_os.h @@ -88,8 +88,4 @@ typedef int fstrans_cookie_t; typedef struct opensolaris_utsname utsname_t; extern utsname_t *utsname(void); extern int spa_import_rootpool(const char *name); -#else -#if BYTE_ORDER != BIG_ENDIAN -#undef _BIG_ENDIAN -#endif #endif diff --git a/lib/libspl/asm-i386/atomic.S b/lib/libspl/asm-i386/atomic.S index 3086d5543..7a574b0d1 100644 --- a/lib/libspl/asm-i386/atomic.S +++ b/lib/libspl/asm-i386/atomic.S @@ -28,8 +28,12 @@ .file "%M%" #define _ASM +#ifdef __linux__ #include <ia32/sys/asm_linkage.h> - +#elif __FreeBSD__ +#include <machine/asmacros.h> +#define SET_SIZE(x) +#endif ENTRY(atomic_inc_8) ALTENTRY(atomic_inc_uchar) movl 4(%esp), %eax diff --git a/lib/libspl/include/os/freebsd/sys/param.h b/lib/libspl/include/os/freebsd/sys/param.h index e2abef189..7c23b6705 100644 --- a/lib/libspl/include/os/freebsd/sys/param.h +++ b/lib/libspl/include/os/freebsd/sys/param.h @@ -45,8 +45,10 @@ */ #define MAXNAMELEN 256 +#ifndef IN_BASE #define UID_NOBODY 60001 /* user ID no body */ #define GID_NOBODY UID_NOBODY +#endif #define UID_NOACCESS 60002 /* user ID no access */ #define MAXUID UINT32_MAX /* max user id */ diff --git a/lib/libspl/include/rpc/xdr.h b/lib/libspl/include/rpc/xdr.h index 27e4395c7..51d71f693 100644 --- a/lib/libspl/include/rpc/xdr.h +++ b/lib/libspl/include/rpc/xdr.h @@ -40,10 +40,13 @@ #define XDR_GET_BYTES_AVAIL 1 -typedef struct xdr_bytesrec { +#ifndef HAVE_XDR_BYTESREC +struct xdr_bytesrec { bool_t xc_is_last_record; size_t xc_num_avail; -} xdr_bytesrec_t; +}; +#endif +typedef struct xdr_bytesrec xdr_bytesrec_t; /* * This functionality is not required and is disabled in user space. diff --git a/lib/libspl/include/sys/isa_defs.h b/lib/libspl/include/sys/isa_defs.h index 6f242ea77..8c0932f57 100644 --- a/lib/libspl/include/sys/isa_defs.h +++ b/lib/libspl/include/sys/isa_defs.h @@ -208,7 +208,7 @@ extern "C" { #error MIPS no endian specified #endif -#ifndef _LP64 +#if !defined(_LP64) && !defined(_ILP32) #define _ILP32 #endif diff --git a/lib/libspl/include/sys/uio.h b/lib/libspl/include/sys/uio.h index 6d892dd3e..3a834b996 100644 --- a/lib/libspl/include/sys/uio.h +++ b/lib/libspl/include/sys/uio.h @@ -141,7 +141,8 @@ static inline offset_t uio_index_at_offset(uio_t *uio, offset_t off, uint_t *vec_idx) { *vec_idx = 0; - while (*vec_idx < uio_iovcnt(uio) && off >= uio_iovlen(uio, *vec_idx)) { + while (*vec_idx < (uint_t)uio_iovcnt(uio) && + off >= (offset_t)uio_iovlen(uio, *vec_idx)) { off -= uio_iovlen(uio, *vec_idx); (*vec_idx)++; } diff --git a/module/os/freebsd/spl/spl_vm.c b/module/os/freebsd/spl/spl_vm.c index b5649d519..739ddb05e 100644 --- a/module/os/freebsd/spl/spl_vm.c +++ b/module/os/freebsd/spl/spl_vm.c @@ -29,6 +29,8 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/param.h> +#include <sys/counter.h> + #include <sys/byteorder.h> #include <sys/lock.h> #include <sys/freebsd_rwlock.h> diff --git a/module/os/freebsd/zfs/arc_os.c b/module/os/freebsd/zfs/arc_os.c index 5f4b5df4a..94df75003 100644 --- a/module/os/freebsd/zfs/arc_os.c +++ b/module/os/freebsd/zfs/arc_os.c @@ -22,6 +22,7 @@ #include <sys/spa.h> #include <sys/zio.h> #include <sys/spa_impl.h> +#include <sys/counter.h> #include <sys/zio_compress.h> #include <sys/zio_checksum.h> #include <sys/zfs_context.h> @@ -47,6 +48,8 @@ #include <sys/vnode.h> #include <cityhash.h> #include <machine/vmparam.h> +#include <sys/vm.h> +#include <sys/vmmeter.h> extern struct vfsops zfs_vfsops; diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index e6eceacb2..89f499640 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -142,8 +142,8 @@ zfsdev_ioctl(struct cdev *dev, ulong_t zcmd, caddr_t arg, int flag, zcl = NULL; if (len != sizeof (zfs_iocparm_t)) { - printf("len %d vecnum: %d sizeof (zfs_cmd_t) %lu\n", - len, vecnum, sizeof (zfs_cmd_t)); + printf("len %d vecnum: %d sizeof (zfs_cmd_t) %ju\n", + len, vecnum, (uintmax_t)sizeof (zfs_cmd_t)); return (EINVAL); } diff --git a/module/os/freebsd/zfs/sysctl_os.c b/module/os/freebsd/zfs/sysctl_os.c index 945416ebc..d76b49de9 100644 --- a/module/os/freebsd/zfs/sysctl_os.c +++ b/module/os/freebsd/zfs/sysctl_os.c @@ -123,11 +123,10 @@ SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, cache, CTLFLAG_RW, 0, "ZFS VDEV Cache"); SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, mirror, CTLFLAG_RD, 0, "ZFS VDEV mirror"); -#ifdef ZFS_META_VERSION SYSCTL_DECL(_vfs_zfs_version); SYSCTL_CONST_STRING(_vfs_zfs_version, OID_AUTO, module, CTLFLAG_RD, (ZFS_META_VERSION "-" ZFS_META_RELEASE), "OpenZFS module version"); -#endif + extern arc_state_t ARC_anon; extern arc_state_t ARC_mru; extern arc_state_t ARC_mru_ghost; @@ -143,12 +142,12 @@ extern arc_state_t ARC_l2c_only; /* arc.c */ /* legacy compat */ -extern unsigned long l2arc_write_max; /* def max write size */ -extern unsigned long l2arc_write_boost; /* extra warmup write */ -extern unsigned long l2arc_headroom; /* # of dev writes */ -extern unsigned long l2arc_headroom_boost; -extern unsigned long l2arc_feed_secs; /* interval seconds */ -extern unsigned long l2arc_feed_min_ms; /* min interval msecs */ +extern uint64_t l2arc_write_max; /* def max write size */ +extern uint64_t l2arc_write_boost; /* extra warmup write */ +extern uint64_t l2arc_headroom; /* # of dev writes */ +extern uint64_t l2arc_headroom_boost; +extern uint64_t l2arc_feed_secs; /* interval seconds */ +extern uint64_t l2arc_feed_min_ms; /* min interval msecs */ extern int l2arc_noprefetch; /* don't cache prefetch bufs */ extern int l2arc_feed_again; /* turbo warmup */ extern int l2arc_norw; /* no reads during writes */ diff --git a/module/os/freebsd/zfs/zfs_ioctl_compat.c b/module/os/freebsd/zfs/zfs_ioctl_compat.c index 18ab58756..8dec8644c 100644 --- a/module/os/freebsd/zfs/zfs_ioctl_compat.c +++ b/module/os/freebsd/zfs/zfs_ioctl_compat.c @@ -31,15 +31,12 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/param.h> #include <sys/conf.h> -#include <sys/eventhandler.h> #include <sys/kernel.h> #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mutex.h> #include <sys/errno.h> -#include <sys/uio.h> #include <sys/cmn_err.h> -#include <sys/stat.h> #include <sys/zfs_ioctl_compat.h> enum zfs_ioc_legacy { diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index 92a53afc2..cf397ca29 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -2157,6 +2157,13 @@ zfs_freevfs(vfs_t *vfsp) #ifdef __i386__ static int desiredvnodes_backup; +#include <sys/vmmeter.h> + + +#include <vm/vm_page.h> +#include <vm/vm_object.h> +#include <vm/vm_kern.h> +#include <vm/vm_map.h> #endif static void @@ -2321,8 +2328,8 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers) } spa_history_log_internal_ds(dmu_objset_ds(os), "upgrade", tx, - "from %lu to %lu", zfsvfs->z_version, newvers); - + "from %ju to %ju", (uintmax_t)zfsvfs->z_version, + (uintmax_t)newvers); dmu_tx_commit(tx); zfsvfs->z_version = newvers; diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 3ec98917d..9399f9721 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -7447,9 +7447,15 @@ arc_init(void) * zfs_dirty_data_max_percent (default 10%) with a cap at * zfs_dirty_data_max_max (default 4G or 25% of physical memory). */ +#ifdef __LP64__ if (zfs_dirty_data_max_max == 0) zfs_dirty_data_max_max = MIN(4ULL * 1024 * 1024 * 1024, allmem * zfs_dirty_data_max_max_percent / 100); +#else + if (zfs_dirty_data_max_max == 0) + zfs_dirty_data_max_max = MIN(1ULL * 1024 * 1024 * 1024, + allmem * zfs_dirty_data_max_max_percent / 100); +#endif if (zfs_dirty_data_max == 0) { zfs_dirty_data_max = allmem * |