Skip to content

Commit 0d96fa2

Browse files
committed
Fix the build on FreeBSD 12
It was broken for several reasons: * VOP_UNLOCK lost an argument in 13.0. So OpenZFS should be using VOP_UNLOCK1, but a few direct calls to VOP_UNLOCK snuck in. * The location of the zlib header moved in 13.0 and 12.1. We can drop support for building on 12.0, which is EoL. * knlist_init lost an argument in 13.0. OpenZFS change 9d08874 assumed 13.0 or later. * FreeBSD 13.0 added copy_file_range, and OpenZFS change 67a1b03 assumed 13.0 or later. Sponsored-by: Axcient Signed-off-by: Alan Somers <[email protected]>
1 parent a94860a commit 0d96fa2

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ For more details see the NOTICE, LICENSE and COPYRIGHT files; `UCRL-CODE-235197`
3232

3333
# Supported Kernels
3434
* The `META` file contains the officially recognized supported Linux kernel versions.
35-
* Supported FreeBSD versions are any supported branches and releases starting from 12.2-RELEASE.
35+
* Supported FreeBSD versions are any supported branches and releases starting from 12.4-RELEASE.

include/os/freebsd/spl/sys/vnode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum symfollow { NO_FOLLOW = NOFOLLOW };
5656
#ifndef IN_BASE
5757
#include_next <sys/vnode.h>
5858
#endif
59+
#include <sys/ccompat.h>
5960
#include <sys/mount.h>
6061
#include <sys/cred.h>
6162
#include <sys/fcntl.h>
@@ -104,7 +105,7 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync)
104105
zfs_vmobject_wlock(vp->v_object);
105106
vm_object_page_clean(vp->v_object, 0, 0, flags);
106107
zfs_vmobject_wunlock(vp->v_object);
107-
VOP_UNLOCK(vp);
108+
VOP_UNLOCK1(vp);
108109
}
109110
}
110111
#endif

module/os/freebsd/spl/spl_zlib.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929
#include <sys/kmem.h>
3030
#include <sys/kmem_cache.h>
3131
#include <sys/zmod.h>
32-
#if __FreeBSD_version >= 1300041
3332
#include <contrib/zlib/zlib.h>
34-
#else
35-
#include <sys/zlib.h>
36-
#endif
3733
#include <sys/kobj.h>
3834

3935

@@ -87,11 +83,7 @@ zlib_inflateInit(z_stream *stream)
8783
static int
8884
zlib_inflate(z_stream *stream, int finish)
8985
{
90-
#if __FreeBSD_version >= 1300024
9186
return (inflate(stream, finish));
92-
#else
93-
return (_zlib104_inflate(stream, finish));
94-
#endif
9587
}
9688

9789

module/os/freebsd/zfs/event_os.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ knlist_sx_xunlock(void *arg)
4646
sx_xunlock((struct sx *)arg);
4747
}
4848

49+
#if __FreeBSD_version >= 1300128
4950
static void
5051
knlist_sx_assert_lock(void *arg, int what)
5152
{
@@ -55,11 +56,28 @@ knlist_sx_assert_lock(void *arg, int what)
5556
else
5657
sx_assert((struct sx *)arg, SX_UNLOCKED);
5758
}
59+
#else
60+
static void
61+
knlist_sx_assert_locked(void *arg)
62+
{
63+
sx_assert((struct sx *)arg, SX_LOCKED);
64+
}
65+
static void
66+
knlist_sx_assert_unlocked(void *arg)
67+
{
68+
sx_assert((struct sx *)arg, SX_UNLOCKED);
69+
}
70+
#endif
5871

5972
void
6073
knlist_init_sx(struct knlist *knl, struct sx *lock)
6174
{
6275

76+
#if __FreeBSD_version >= 1300128
6377
knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock,
6478
knlist_sx_assert_lock);
79+
#else
80+
knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock,
81+
knlist_sx_assert_locked, knlist_sx_assert_unlocked);
82+
#endif
6583
}

module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6220,6 +6220,7 @@ zfs_deallocate(struct vop_deallocate_args *ap)
62206220
}
62216221
#endif
62226222

6223+
#if __FreeBSD_version >= 1300039
62236224
#ifndef _SYS_SYSPROTO_H_
62246225
struct vop_copy_file_range_args {
62256226
struct vnode *a_invp;
@@ -6326,6 +6327,7 @@ zfs_freebsd_copy_file_range(struct vop_copy_file_range_args *ap)
63266327
ap->a_incred, ap->a_outcred, ap->a_fsizetd);
63276328
return (error);
63286329
}
6330+
#endif
63296331

63306332
struct vop_vector zfs_vnodeops;
63316333
struct vop_vector zfs_fifoops;
@@ -6390,7 +6392,9 @@ struct vop_vector zfs_vnodeops = {
63906392
#if __FreeBSD_version >= 1400043
63916393
.vop_add_writecount = vop_stdadd_writecount_nomsync,
63926394
#endif
6395+
#if __FreeBSD_version >= 1300039
63936396
.vop_copy_file_range = zfs_freebsd_copy_file_range,
6397+
#endif
63946398
};
63956399
VFS_VOP_VECTOR_REGISTER(zfs_vnodeops);
63966400

0 commit comments

Comments
 (0)