diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index 9b5f4972f7..9aa09b18c4 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 fd6b0269d8..ae767242bd 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 c594c928f8..c90813b040 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 943b18f039..6155ce6b07 100644 --- a/include/os/freebsd/spl/sys/kmem.h +++ b/include/os/freebsd/spl/sys/kmem.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/os/freebsd/spl/sys/simd_x86.h b/include/os/freebsd/spl/sys/simd_x86.h index da846fcbe6..a35e205d5a 100644 --- a/include/os/freebsd/spl/sys/simd_x86.h +++ b/include/os/freebsd/spl/sys/simd_x86.h @@ -29,7 +29,11 @@ #include #include #include +#ifdef __i386__ +#include +#else #include +#endif #include #include diff --git a/include/os/freebsd/spl/sys/types.h b/include/os/freebsd/spl/sys/types.h index c06c963d64..3f89536288 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 b9fae99ad2..6a61461327 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 #include +#ifndef IN_BASE #include_next +#endif #include #include #include @@ -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 9d848e1fc2..e3923e4ca3 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 8da3374a6f..7dd298564d 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 3086d55439..7a574b0d17 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 - +#elif __FreeBSD__ +#include +#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 e2abef1896..7c23b67059 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 27e4395c73..51d71f693b 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 6f242ea77e..8c0932f576 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 6d892dd3e2..3a834b996a 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 b5649d5197..739ddb05e8 100644 --- a/module/os/freebsd/spl/spl_vm.c +++ b/module/os/freebsd/spl/spl_vm.c @@ -29,6 +29,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include diff --git a/module/os/freebsd/zfs/arc_os.c b/module/os/freebsd/zfs/arc_os.c index 5f4b5df4a9..94df750035 100644 --- a/module/os/freebsd/zfs/arc_os.c +++ b/module/os/freebsd/zfs/arc_os.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,8 @@ #include #include #include +#include +#include extern struct vfsops zfs_vfsops; diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index e6eceacb22..89f4996409 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 945416ebcb..d76b49de9d 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 18ab587563..8dec8644c0 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 #include #include -#include #include #include #include #include #include -#include #include -#include #include enum zfs_ioc_legacy { diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index 92a53afc2b..cf397ca297 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 + + +#include +#include +#include +#include #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 3ec98917d1..9399f97218 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 *