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 <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #10635
This commit is contained in:
Matthew Macy 2020-07-31 21:30:31 -07:00 committed by GitHub
parent 0cc3454821
commit 47ed79ff60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 79 additions and 29 deletions

View File

@ -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);

View File

@ -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)))

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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 */

View File

@ -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.

View File

@ -208,7 +208,7 @@ extern "C" {
#error MIPS no endian specified
#endif
#ifndef _LP64
#if !defined(_LP64) && !defined(_ILP32)
#define _ILP32
#endif

View File

@ -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)++;
}

View File

@ -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>

View File

@ -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;

View File

@ -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);
}

View File

@ -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 */

View File

@ -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 {

View File

@ -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;

View File

@ -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 *