From f57fb5dba08f9143ea05e286c50370a157571f7d Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 21 Jul 2024 13:44:32 +1000 Subject: [PATCH] FreeBSD: remove support for FreeBSD < 13.0-RELEASE This includes the last 12.x release (now EOL) and 13.0 development versions (<1300139). Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Rob Norris --- README.md | 2 +- include/os/freebsd/spl/sys/ccompat.h | 42 --- include/os/freebsd/spl/sys/policy.h | 6 - include/os/freebsd/spl/sys/proc.h | 3 - include/os/freebsd/spl/sys/random.h | 4 +- include/os/freebsd/spl/sys/vm.h | 16 -- include/os/freebsd/spl/sys/vnode.h | 6 +- include/os/freebsd/zfs/sys/zfs_vfsops_os.h | 77 ------ module/os/freebsd/spl/spl_kmem.c | 8 - module/os/freebsd/spl/spl_policy.c | 52 ++-- module/os/freebsd/spl/spl_taskq.c | 5 - module/os/freebsd/spl/spl_vfs.c | 12 +- module/os/freebsd/spl/spl_zone.c | 4 +- module/os/freebsd/zfs/crypto_os.c | 249 ------------------ module/os/freebsd/zfs/dmu_os.c | 27 +- module/os/freebsd/zfs/event_os.c | 19 -- module/os/freebsd/zfs/kmod_core.c | 4 - module/os/freebsd/zfs/vdev_geom.c | 4 - module/os/freebsd/zfs/zfs_ctldir.c | 28 +- module/os/freebsd/zfs/zfs_dir.c | 4 +- module/os/freebsd/zfs/zfs_file_os.c | 10 +- module/os/freebsd/zfs/zfs_ioctl_os.c | 4 - module/os/freebsd/zfs/zfs_vfsops.c | 36 +-- module/os/freebsd/zfs/zfs_vnops_os.c | 292 +++------------------ module/os/freebsd/zfs/zfs_znode.c | 17 +- module/os/freebsd/zfs/zvol_os.c | 8 - module/zfs/zfs_replay.c | 4 +- 27 files changed, 86 insertions(+), 857 deletions(-) diff --git a/README.md b/README.md index af244c1fff14..a90736bb56b7 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ For more details see the NOTICE, LICENSE and COPYRIGHT files; `UCRL-CODE-235197` # Supported Kernels * The `META` file contains the officially recognized supported Linux kernel versions. - * Supported FreeBSD versions are any supported branches and releases starting from 12.4-RELEASE. + * Supported FreeBSD versions are any supported branches and releases starting from 13.0-RELEASE. diff --git a/include/os/freebsd/spl/sys/ccompat.h b/include/os/freebsd/spl/sys/ccompat.h index e34bab7e896d..48749fb8eea2 100644 --- a/include/os/freebsd/spl/sys/ccompat.h +++ b/include/os/freebsd/spl/sys/ccompat.h @@ -28,48 +28,6 @@ #ifndef _SYS_CCOMPAT_H #define _SYS_CCOMPAT_H -#if __FreeBSD_version < 1300051 -#define vm_page_valid(m) (m)->valid = VM_PAGE_BITS_ALL -#define vm_page_do_sunbusy(m) -#define vm_page_none_valid(m) ((m)->valid == 0) -#else -#define vm_page_do_sunbusy(m) vm_page_sunbusy(m) -#endif - -#if __FreeBSD_version < 1300074 -#define VOP_UNLOCK1(x) VOP_UNLOCK(x, 0) -#else -#define VOP_UNLOCK1(x) VOP_UNLOCK(x) -#endif - -#if __FreeBSD_version < 1300064 -#define VN_IS_DOOMED(vp) ((vp)->v_iflag & VI_DOOMED) -#endif - -#if __FreeBSD_version < 1300068 -#define VFS_VOP_VECTOR_REGISTER(x) -#endif - -#if __FreeBSD_version >= 1300076 -#define getnewvnode_reserve_() getnewvnode_reserve() -#else -#define getnewvnode_reserve_() getnewvnode_reserve(1) -#endif - -#if __FreeBSD_version < 1300102 -#define ASSERT_VOP_IN_SEQC(zp) -#define MNTK_FPLOOKUP 0 -#define vn_seqc_write_begin(vp) -#define vn_seqc_write_end(vp) - -#ifndef VFS_SMR_DECLARE -#define VFS_SMR_DECLARE -#endif -#ifndef VFS_SMR_ZONE_SET -#define VFS_SMR_ZONE_SET(zone) -#endif -#endif - struct hlist_node { struct hlist_node *next, **pprev; }; diff --git a/include/os/freebsd/spl/sys/policy.h b/include/os/freebsd/spl/sys/policy.h index 909ae3886e9c..32c10bdca90e 100644 --- a/include/os/freebsd/spl/sys/policy.h +++ b/include/os/freebsd/spl/sys/policy.h @@ -70,10 +70,4 @@ int secpolicy_xvattr(vnode_t *vp, xvattr_t *xvap, uid_t owner, cred_t *cr, vtype_t vtype); int secpolicy_smb(cred_t *cr); - -#if __FreeBSD_version >= 1300005 -#define spl_priv_check_cred(a, b) priv_check_cred((a), (b)) -#else -#define spl_priv_check_cred(a, b) priv_check_cred((a), (b), 0) -#endif #endif /* _OPENSOLARIS_SYS_POLICY_H_ */ diff --git a/include/os/freebsd/spl/sys/proc.h b/include/os/freebsd/spl/sys/proc.h index 8583df509b55..96ba10e5679e 100644 --- a/include/os/freebsd/spl/sys/proc.h +++ b/include/os/freebsd/spl/sys/proc.h @@ -88,9 +88,6 @@ do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg, thread_lock(td); sched_prio(td, pri); sched_add(td, SRQ_BORING); -#if __FreeBSD_version < 1300068 - thread_unlock(td); -#endif } return (td); } diff --git a/include/os/freebsd/spl/sys/random.h b/include/os/freebsd/spl/sys/random.h index 7583166e727b..146fa9e5d133 100644 --- a/include/os/freebsd/spl/sys/random.h +++ b/include/os/freebsd/spl/sys/random.h @@ -30,9 +30,7 @@ #define _OPENSOLARIS_SYS_RANDOM_H_ #include_next -#if __FreeBSD_version >= 1300108 #include -#endif static inline int random_get_bytes(uint8_t *p, size_t s) @@ -51,7 +49,7 @@ random_get_pseudo_bytes(uint8_t *p, size_t s) static inline uint32_t random_in_range(uint32_t range) { -#if defined(_KERNEL) && __FreeBSD_version >= 1300108 +#if defined(_KERNEL) return (prng32_bounded(range)); #else uint32_t r; diff --git a/include/os/freebsd/spl/sys/vm.h b/include/os/freebsd/spl/sys/vm.h index 7b3830be8a57..07ee6bc191a7 100644 --- a/include/os/freebsd/spl/sys/vm.h +++ b/include/os/freebsd/spl/sys/vm.h @@ -41,22 +41,6 @@ void zfs_vmobject_assert_wlocked(vm_object_t object); void zfs_vmobject_wlock(vm_object_t object); void zfs_vmobject_wunlock(vm_object_t object); -#if __FreeBSD_version >= 1300081 -#define zfs_vmobject_assert_wlocked_12(x) -#define zfs_vmobject_wlock_12(x) -#define zfs_vmobject_wunlock_12(x) -#else -#define zfs_vmobject_assert_wlocked_12(x) \ - zfs_vmobject_assert_wlocked((x)) -#define zfs_vmobject_wlock_12(x) \ - zfs_vmobject_wlock(x) -#define zfs_vmobject_wunlock_12(x) \ - zfs_vmobject_wunlock(x) -#define vm_page_grab_unlocked(obj, idx, flags) \ - vm_page_grab((obj), (idx), (flags)) -#define vm_page_grab_valid_unlocked(m, obj, idx, flags) \ - vm_page_grab_valid((m), (obj), (idx), (flags)) -#endif static inline caddr_t zfs_map_page(vm_page_t pp, struct sf_buf **sfp) { diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h index 75c32f221ffd..76ea3eff3792 100644 --- a/include/os/freebsd/spl/sys/vnode.h +++ b/include/os/freebsd/spl/sys/vnode.h @@ -95,17 +95,13 @@ vn_is_readonly(vnode_t *vp) static __inline void vn_flush_cached_data(vnode_t *vp, boolean_t sync) { -#if __FreeBSD_version > 1300054 if (vm_object_mightbedirty(vp->v_object)) { -#else - if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) { -#endif int flags = sync ? OBJPC_SYNC : 0; vn_lock(vp, LK_SHARED | LK_RETRY); zfs_vmobject_wlock(vp->v_object); vm_object_page_clean(vp->v_object, 0, 0, flags); zfs_vmobject_wunlock(vp->v_object); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); } } #endif diff --git a/include/os/freebsd/zfs/sys/zfs_vfsops_os.h b/include/os/freebsd/zfs/sys/zfs_vfsops_os.h index 7f0f24325d59..3e54f3e846f7 100644 --- a/include/os/freebsd/zfs/sys/zfs_vfsops_os.h +++ b/include/os/freebsd/zfs/sys/zfs_vfsops_os.h @@ -27,40 +27,21 @@ #ifndef _SYS_FS_ZFS_VFSOPS_H #define _SYS_FS_ZFS_VFSOPS_H -#if __FreeBSD_version >= 1300125 -#define TEARDOWN_RMS -#endif - -#if __FreeBSD_version >= 1300109 -#define TEARDOWN_INACTIVE_RMS -#endif - #include #include #include #include #include #include -#ifdef TEARDOWN_INACTIVE_RMS #include -#endif #include #ifdef __cplusplus extern "C" { #endif -#ifdef TEARDOWN_RMS typedef struct rmslock zfs_teardown_lock_t; -#else -#define zfs_teardown_lock_t rrmlock_t -#endif - -#ifdef TEARDOWN_INACTIVE_RMS typedef struct rmslock zfs_teardown_inactive_lock_t; -#else -#define zfs_teardown_inactive_lock_t krwlock_t -#endif typedef struct zfsvfs zfsvfs_t; struct znode; @@ -120,7 +101,6 @@ struct zfsvfs { struct task z_unlinked_drain_task; }; -#ifdef TEARDOWN_RMS #define ZFS_TEARDOWN_INIT(zfsvfs) \ rms_init(&(zfsvfs)->z_teardown_lock, "zfs teardown") @@ -150,39 +130,7 @@ struct zfsvfs { #define ZFS_TEARDOWN_HELD(zfsvfs) \ rms_owned_any(&(zfsvfs)->z_teardown_lock) -#else -#define ZFS_TEARDOWN_INIT(zfsvfs) \ - rrm_init(&(zfsvfs)->z_teardown_lock, B_FALSE) - -#define ZFS_TEARDOWN_DESTROY(zfsvfs) \ - rrm_destroy(&(zfsvfs)->z_teardown_lock) - -#define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag) \ - rrm_enter_read(&(zfsvfs)->z_teardown_lock, tag); - -#define ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag) \ - rrm_exit(&(zfsvfs)->z_teardown_lock, tag) - -#define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag) \ - rrm_enter(&(zfsvfs)->z_teardown_lock, RW_WRITER, tag) - -#define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs) \ - rrm_exit(&(zfsvfs)->z_teardown_lock, tag) - -#define ZFS_TEARDOWN_EXIT(zfsvfs, tag) \ - rrm_exit(&(zfsvfs)->z_teardown_lock, tag) - -#define ZFS_TEARDOWN_READ_HELD(zfsvfs) \ - RRM_READ_HELD(&(zfsvfs)->z_teardown_lock) - -#define ZFS_TEARDOWN_WRITE_HELD(zfsvfs) \ - RRM_WRITE_HELD(&(zfsvfs)->z_teardown_lock) - -#define ZFS_TEARDOWN_HELD(zfsvfs) \ - RRM_LOCK_HELD(&(zfsvfs)->z_teardown_lock) -#endif -#ifdef TEARDOWN_INACTIVE_RMS #define ZFS_TEARDOWN_INACTIVE_INIT(zfsvfs) \ rms_init(&(zfsvfs)->z_teardown_inactive_lock, "zfs teardown inactive") @@ -206,31 +154,6 @@ struct zfsvfs { #define ZFS_TEARDOWN_INACTIVE_WRITE_HELD(zfsvfs) \ rms_wowned(&(zfsvfs)->z_teardown_inactive_lock) -#else -#define ZFS_TEARDOWN_INACTIVE_INIT(zfsvfs) \ - rw_init(&(zfsvfs)->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL) - -#define ZFS_TEARDOWN_INACTIVE_DESTROY(zfsvfs) \ - rw_destroy(&(zfsvfs)->z_teardown_inactive_lock) - -#define ZFS_TEARDOWN_INACTIVE_TRY_ENTER_READ(zfsvfs) \ - rw_tryenter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER) - -#define ZFS_TEARDOWN_INACTIVE_ENTER_READ(zfsvfs) \ - rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER) - -#define ZFS_TEARDOWN_INACTIVE_EXIT_READ(zfsvfs) \ - rw_exit(&(zfsvfs)->z_teardown_inactive_lock) - -#define ZFS_TEARDOWN_INACTIVE_ENTER_WRITE(zfsvfs) \ - rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_WRITER) - -#define ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs) \ - rw_exit(&(zfsvfs)->z_teardown_inactive_lock) - -#define ZFS_TEARDOWN_INACTIVE_WRITE_HELD(zfsvfs) \ - RW_WRITE_HELD(&(zfsvfs)->z_teardown_inactive_lock) -#endif #define ZSB_XATTR 0x0001 /* Enable user xattrs */ /* diff --git a/module/os/freebsd/spl/spl_kmem.c b/module/os/freebsd/spl/spl_kmem.c index 95af6200cd01..ceaa2b40beae 100644 --- a/module/os/freebsd/spl/spl_kmem.c +++ b/module/os/freebsd/spl/spl_kmem.c @@ -240,22 +240,14 @@ void kmem_cache_reap_soon(kmem_cache_t *cache) { #ifndef KMEM_DEBUG -#if __FreeBSD_version >= 1300043 uma_zone_reclaim(cache->kc_zone, UMA_RECLAIM_DRAIN); -#else - zone_drain(cache->kc_zone); -#endif #endif } void kmem_reap(void) { -#if __FreeBSD_version >= 1300043 uma_reclaim(UMA_RECLAIM_TRIM); -#else - uma_reclaim(); -#endif } #else void diff --git a/module/os/freebsd/spl/spl_policy.c b/module/os/freebsd/spl/spl_policy.c index f2dd7c8e7f8a..42a693b073d1 100644 --- a/module/os/freebsd/spl/spl_policy.c +++ b/module/os/freebsd/spl/spl_policy.c @@ -41,42 +41,42 @@ int secpolicy_nfs(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_NFS_DAEMON)); + return (priv_check_cred(cr, PRIV_NFS_DAEMON)); } int secpolicy_zfs(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT)); } int secpolicy_zfs_proc(cred_t *cr, proc_t *proc) { - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT)); } int secpolicy_sys_config(cred_t *cr, int checkonly __unused) { - return (spl_priv_check_cred(cr, PRIV_ZFS_POOL_CONFIG)); + return (priv_check_cred(cr, PRIV_ZFS_POOL_CONFIG)); } int secpolicy_zinject(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_ZFS_INJECT)); + return (priv_check_cred(cr, PRIV_ZFS_INJECT)); } int secpolicy_fs_unmount(cred_t *cr, struct mount *vfsp __unused) { - return (spl_priv_check_cred(cr, PRIV_VFS_UNMOUNT)); + return (priv_check_cred(cr, PRIV_VFS_UNMOUNT)); } int @@ -104,7 +104,7 @@ secpolicy_basic_link(vnode_t *vp, cred_t *cr) return (0); if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_LINK)); + return (priv_check_cred(cr, PRIV_VFS_LINK)); } int @@ -120,7 +120,7 @@ secpolicy_vnode_remove(vnode_t *vp, cred_t *cr) if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_ADMIN)); + return (priv_check_cred(cr, PRIV_VFS_ADMIN)); } int @@ -130,18 +130,18 @@ secpolicy_vnode_access(cred_t *cr, vnode_t *vp, uid_t owner, accmode_t accmode) if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - if ((accmode & VREAD) && spl_priv_check_cred(cr, PRIV_VFS_READ) != 0) + if ((accmode & VREAD) && priv_check_cred(cr, PRIV_VFS_READ) != 0) return (EACCES); if ((accmode & VWRITE) && - spl_priv_check_cred(cr, PRIV_VFS_WRITE) != 0) { + priv_check_cred(cr, PRIV_VFS_WRITE) != 0) { return (EACCES); } if (accmode & VEXEC) { if (vp->v_type == VDIR) { - if (spl_priv_check_cred(cr, PRIV_VFS_LOOKUP) != 0) + if (priv_check_cred(cr, PRIV_VFS_LOOKUP) != 0) return (EACCES); } else { - if (spl_priv_check_cred(cr, PRIV_VFS_EXEC) != 0) + if (priv_check_cred(cr, PRIV_VFS_EXEC) != 0) return (EACCES); } } @@ -198,7 +198,7 @@ secpolicy_vnode_any_access(cred_t *cr, vnode_t *vp, uid_t owner) continue; break; } - if (spl_priv_check_cred(cr, priv) == 0) + if (priv_check_cred(cr, priv) == 0) return (0); } return (EPERM); @@ -212,7 +212,7 @@ secpolicy_vnode_setdac(vnode_t *vp, cred_t *cr, uid_t owner) return (0); if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_ADMIN)); + return (priv_check_cred(cr, PRIV_VFS_ADMIN)); } int @@ -262,7 +262,7 @@ secpolicy_vnode_setattr(cred_t *cr, vnode_t *vp, struct vattr *vap, ((mask & AT_GID) && vap->va_gid != ovap->va_gid && !groupmember(vap->va_gid, cr))) { if (secpolicy_fs_owner(vp->v_mount, cr) != 0) { - error = spl_priv_check_cred(cr, PRIV_VFS_CHOWN); + error = priv_check_cred(cr, PRIV_VFS_CHOWN); if (error) return (error); } @@ -306,7 +306,7 @@ secpolicy_vnode_setids_setgids(vnode_t *vp, cred_t *cr, gid_t gid) return (0); if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_SETGID)); + return (priv_check_cred(cr, PRIV_VFS_SETGID)); } int @@ -316,7 +316,7 @@ secpolicy_vnode_setid_retain(znode_t *zp, cred_t *cr, if (secpolicy_fs_owner(ZTOV(zp)->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_RETAINSUGID)); + return (priv_check_cred(cr, PRIV_VFS_RETAINSUGID)); } void @@ -327,7 +327,7 @@ secpolicy_setid_clear(struct vattr *vap, vnode_t *vp, cred_t *cr) return; if ((vap->va_mode & (S_ISUID | S_ISGID)) != 0) { - if (spl_priv_check_cred(cr, PRIV_VFS_RETAINSUGID)) { + if (priv_check_cred(cr, PRIV_VFS_RETAINSUGID)) { vap->va_mask |= AT_MODE; vap->va_mode &= ~(S_ISUID|S_ISGID); } @@ -349,7 +349,7 @@ secpolicy_setid_setsticky_clear(vnode_t *vp, struct vattr *vap, * is not a member of. Both of these are allowed in jail(8). */ if (vp->v_type != VDIR && (vap->va_mode & S_ISTXT)) { - if (spl_priv_check_cred(cr, PRIV_VFS_STICKYFILE)) + if (priv_check_cred(cr, PRIV_VFS_STICKYFILE)) return (EFTYPE); } /* @@ -365,7 +365,7 @@ secpolicy_setid_setsticky_clear(vnode_t *vp, struct vattr *vap, * Deny setting setuid if we are not the file owner. */ if ((vap->va_mode & S_ISUID) && ovap->va_uid != cr->cr_uid) { - error = spl_priv_check_cred(cr, PRIV_VFS_ADMIN); + error = priv_check_cred(cr, PRIV_VFS_ADMIN); if (error) return (error); } @@ -376,7 +376,7 @@ int secpolicy_fs_mount(cred_t *cr, vnode_t *mvp, struct mount *vfsp) { - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT)); } int @@ -389,7 +389,7 @@ secpolicy_vnode_owner(vnode_t *vp, cred_t *cr, uid_t owner) return (0); /* XXX: vfs_suser()? */ - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT_OWNER)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT_OWNER)); } int @@ -398,14 +398,14 @@ secpolicy_vnode_chown(vnode_t *vp, cred_t *cr, uid_t owner) if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_CHOWN)); + return (priv_check_cred(cr, PRIV_VFS_CHOWN)); } void secpolicy_fs_mount_clearopts(cred_t *cr, struct mount *vfsp) { - if (spl_priv_check_cred(cr, PRIV_VFS_MOUNT_NONUSER) != 0) { + if (priv_check_cred(cr, PRIV_VFS_MOUNT_NONUSER) != 0) { MNT_ILOCK(vfsp); vfsp->vfs_flag |= VFS_NOSETUID | MNT_USER; vfs_clearmntopt(vfsp, MNTOPT_SETUID); @@ -424,12 +424,12 @@ secpolicy_xvattr(vnode_t *vp, xvattr_t *xvap, uid_t owner, cred_t *cr, if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_SYSFLAGS)); + return (priv_check_cred(cr, PRIV_VFS_SYSFLAGS)); } int secpolicy_smb(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_NETSMB)); + return (priv_check_cred(cr, PRIV_NETSMB)); } diff --git a/module/os/freebsd/spl/spl_taskq.c b/module/os/freebsd/spl/spl_taskq.c index 67c0a4c94134..e4b75f91b8fc 100644 --- a/module/os/freebsd/spl/spl_taskq.c +++ b/module/os/freebsd/spl/spl_taskq.c @@ -42,11 +42,6 @@ #include -#if __FreeBSD_version < 1201522 -#define taskqueue_start_threads_in_proc(tqp, count, pri, proc, name, ...) \ - taskqueue_start_threads(tqp, count, pri, name, __VA_ARGS__) -#endif - static uint_t taskq_tsd; static uma_zone_t taskq_zone; diff --git a/module/os/freebsd/spl/spl_vfs.c b/module/os/freebsd/spl/spl_vfs.c index 724709ddee9d..6af3da138f8d 100644 --- a/module/os/freebsd/spl/spl_vfs.c +++ b/module/os/freebsd/spl/spl_vfs.c @@ -158,7 +158,7 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath, return (error); } vn_seqc_write_begin(vp); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); /* * Allocate and initialize the filesystem. @@ -249,10 +249,8 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath, if (VFS_ROOT(mp, LK_EXCLUSIVE, &mvp)) panic("mount: lost mount"); vn_seqc_write_end(vp); - VOP_UNLOCK1(vp); -#if __FreeBSD_version >= 1300048 + VOP_UNLOCK(vp); vfs_op_exit(mp); -#endif vfs_unbusy(mp); *vpp = mvp; return (0); @@ -272,12 +270,8 @@ void vn_rele_async(vnode_t *vp, taskq_t *taskq) { VERIFY3U(vp->v_usecount, >, 0); - if (refcount_release_if_not_last(&vp->v_usecount)) { -#if __FreeBSD_version < 1300045 - vdrop(vp); -#endif + if (refcount_release_if_not_last(&vp->v_usecount)) return; - } VERIFY3U(taskq_dispatch((taskq_t *)taskq, (task_func_t *)vrele, vp, TQ_SLEEP), !=, 0); } diff --git a/module/os/freebsd/spl/spl_zone.c b/module/os/freebsd/spl/spl_zone.c index 7f2b5c712c42..e3896517bd61 100644 --- a/module/os/freebsd/spl/spl_zone.c +++ b/module/os/freebsd/spl/spl_zone.c @@ -63,7 +63,7 @@ zone_dataset_attach(struct ucred *cred, const char *dataset, int jailid) struct prison *pr; int dofree, error; - if ((error = spl_priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) + if ((error = priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) return (error); /* Allocate memory before we grab prison's mutex. */ @@ -116,7 +116,7 @@ zone_dataset_detach(struct ucred *cred, const char *dataset, int jailid) struct prison *pr; int error; - if ((error = spl_priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) + if ((error = priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) return (error); sx_slock(&allprison_lock); diff --git a/module/os/freebsd/zfs/crypto_os.c b/module/os/freebsd/zfs/crypto_os.c index ed8d2407613e..4d8493743ef1 100644 --- a/module/os/freebsd/zfs/crypto_os.c +++ b/module/os/freebsd/zfs/crypto_os.c @@ -197,13 +197,6 @@ zfs_crypto_dispatch(freebsd_crypt_session_t *session, struct cryptop *crp) crp->crp_etype = 0; crp->crp_flags &= ~CRYPTO_F_DONE; session->fs_done = false; -#if __FreeBSD_version < 1300087 - /* - * Session ID changed, so we should record that, - * and try again - */ - session->fs_sid = crp->crp_session; -#endif } return (error); } @@ -250,7 +243,6 @@ freebsd_crypt_uio_debug_log(boolean_t encrypt, * happen every time the key changes (including when * it's first loaded). */ -#if __FreeBSD_version >= 1300087 int freebsd_crypt_newsession(freebsd_crypt_session_t *sessp, const struct zio_crypt_info *c_info, crypto_key_t *key) @@ -389,244 +381,3 @@ freebsd_crypt_uio(boolean_t encrypt, } return (error); } - -#else -int -freebsd_crypt_newsession(freebsd_crypt_session_t *sessp, - const struct zio_crypt_info *c_info, crypto_key_t *key) -{ - struct cryptoini cria = {0}, crie = {0}, *crip; - struct enc_xform *xform; - struct auth_hash *xauth; - int error = 0; - crypto_session_t sid; - -#ifdef FCRYPTO_DEBUG - printf("%s(%p, { %s, %d, %d, %s }, { %p, %u })\n", - __FUNCTION__, sessp, - c_info->ci_algname, c_info->ci_crypt_type, - (unsigned int)c_info->ci_keylen, c_info->ci_name, - key->ck_data, (unsigned int)key->ck_length); - printf("\tkey = { "); - for (int i = 0; i < key->ck_length / 8; i++) { - uint8_t *b = (uint8_t *)key->ck_data; - printf("%02x ", b[i]); - } - printf("}\n"); -#endif - switch (c_info->ci_crypt_type) { - case ZC_TYPE_GCM: - xform = &enc_xform_aes_nist_gcm; - switch (key->ck_length/8) { - case AES_128_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_128; - break; - case AES_192_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_192; - break; - case AES_256_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_256; - break; - default: - error = EINVAL; - goto bad; - } - break; - case ZC_TYPE_CCM: - xform = &enc_xform_ccm; - switch (key->ck_length/8) { - case AES_128_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_128; - break; - case AES_192_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_192; - break; - case AES_256_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_256; - break; - default: - error = EINVAL; - goto bad; - break; - } - break; - default: - error = ENOTSUP; - goto bad; - } -#ifdef FCRYPTO_DEBUG - printf("%s(%d): Using crypt %s (key length %u [%u bytes]), " - "auth %s (key length %d)\n", - __FUNCTION__, __LINE__, - xform->name, (unsigned int)key->ck_length, - (unsigned int)key->ck_length/8, - xauth->name, xauth->keysize); -#endif - - crie.cri_alg = xform->type; - crie.cri_key = key->ck_data; - crie.cri_klen = key->ck_length; - - cria.cri_alg = xauth->type; - cria.cri_key = key->ck_data; - cria.cri_klen = key->ck_length; - - cria.cri_next = &crie; - crie.cri_next = NULL; - crip = &cria; - // Everything else is zero-initialised - - error = crypto_newsession(&sid, crip, - CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE); - if (error != 0) { - printf("%s(%d): crypto_newsession failed with %d\n", - __FUNCTION__, __LINE__, error); - goto bad; - } - sessp->fs_sid = sid; - mtx_init(&sessp->fs_lock, "FreeBSD Cryptographic Session Lock", - NULL, MTX_DEF); - crypt_sessions++; -bad: - return (error); -} - -/* - * The meat of encryption/decryption. - * If sessp is NULL, then it will create a - * temporary cryptographic session, and release - * it when done. - */ -int -freebsd_crypt_uio(boolean_t encrypt, - freebsd_crypt_session_t *input_sessionp, - const struct zio_crypt_info *c_info, - zfs_uio_t *data_uio, - crypto_key_t *key, - uint8_t *ivbuf, - size_t datalen, - size_t auth_len) -{ - struct cryptop *crp; - struct cryptodesc *enc_desc, *auth_desc; - struct enc_xform *xform; - struct auth_hash *xauth; - freebsd_crypt_session_t *session = NULL; - int error; - - freebsd_crypt_uio_debug_log(encrypt, input_sessionp, c_info, data_uio, - key, ivbuf, datalen, auth_len); - switch (c_info->ci_crypt_type) { - case ZC_TYPE_GCM: - xform = &enc_xform_aes_nist_gcm; - switch (key->ck_length/8) { - case AES_128_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_128; - break; - case AES_192_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_192; - break; - case AES_256_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_256; - break; - default: - error = EINVAL; - goto bad; - } - break; - case ZC_TYPE_CCM: - xform = &enc_xform_ccm; - switch (key->ck_length/8) { - case AES_128_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_128; - break; - case AES_192_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_192; - break; - case AES_256_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_256; - break; - default: - error = EINVAL; - goto bad; - break; - } - break; - default: - error = ENOTSUP; - goto bad; - } - -#ifdef FCRYPTO_DEBUG - printf("%s(%d): Using crypt %s (key length %u [%u bytes]), " - "auth %s (key length %d)\n", - __FUNCTION__, __LINE__, - xform->name, (unsigned int)key->ck_length, - (unsigned int)key->ck_length/8, - xauth->name, xauth->keysize); -#endif - - if (input_sessionp == NULL) { - session = kmem_zalloc(sizeof (*session), KM_SLEEP); - error = freebsd_crypt_newsession(session, c_info, key); - if (error) - goto out; - } else - session = input_sessionp; - - crp = crypto_getreq(2); - if (crp == NULL) { - error = ENOMEM; - goto bad; - } - - auth_desc = crp->crp_desc; - enc_desc = auth_desc->crd_next; - - crp->crp_session = session->fs_sid; - crp->crp_ilen = auth_len + datalen; - crp->crp_buf = (void*)GET_UIO_STRUCT(data_uio); - crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIFSYNC; - - auth_desc->crd_skip = 0; - auth_desc->crd_len = auth_len; - auth_desc->crd_inject = auth_len + datalen; - auth_desc->crd_alg = xauth->type; -#ifdef FCRYPTO_DEBUG - printf("%s: auth: skip = %u, len = %u, inject = %u\n", - __FUNCTION__, auth_desc->crd_skip, auth_desc->crd_len, - auth_desc->crd_inject); -#endif - - enc_desc->crd_skip = auth_len; - enc_desc->crd_len = datalen; - enc_desc->crd_inject = auth_len; - enc_desc->crd_alg = xform->type; - enc_desc->crd_flags = CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; - memcpy(enc_desc->crd_iv, ivbuf, ZIO_DATA_IV_LEN); - enc_desc->crd_next = NULL; - -#ifdef FCRYPTO_DEBUG - printf("%s: enc: skip = %u, len = %u, inject = %u\n", - __FUNCTION__, enc_desc->crd_skip, enc_desc->crd_len, - enc_desc->crd_inject); -#endif - - if (encrypt) - enc_desc->crd_flags |= CRD_F_ENCRYPT; - - error = zfs_crypto_dispatch(session, crp); - crypto_freereq(crp); -out: - if (input_sessionp == NULL) { - freebsd_crypt_freesession(session); - kmem_free(session, sizeof (*session)); - } -bad: -#ifdef FCRYPTO_DEBUG - if (error) - printf("%s: returning error %d\n", __FUNCTION__, error); -#endif - return (error); -} -#endif diff --git a/module/os/freebsd/zfs/dmu_os.c b/module/os/freebsd/zfs/dmu_os.c index 48ea37cbad59..0a0af102ea82 100644 --- a/module/os/freebsd/zfs/dmu_os.c +++ b/module/os/freebsd/zfs/dmu_os.c @@ -60,20 +60,7 @@ #define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT) #endif -#if __FreeBSD_version < 1300051 -#define VM_ALLOC_BUSY_FLAGS VM_ALLOC_NOBUSY -#else #define VM_ALLOC_BUSY_FLAGS VM_ALLOC_SBUSY | VM_ALLOC_IGN_SBUSY -#endif - - -#if __FreeBSD_version < 1300072 -#define dmu_page_lock(m) vm_page_lock(m) -#define dmu_page_unlock(m) vm_page_unlock(m) -#else -#define dmu_page_lock(m) -#define dmu_page_unlock(m) -#endif int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, @@ -167,7 +154,6 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, #endif vmobj = ma[0]->object; - zfs_vmobject_wlock_12(vmobj); db = dbp[0]; for (i = 0; i < *rbehind; i++) { @@ -177,7 +163,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, break; if (!vm_page_none_valid(m)) { ASSERT3U(m->valid, ==, VM_PAGE_BITS_ALL); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); break; } ASSERT3U(m->dirty, ==, 0); @@ -189,13 +175,11 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, memcpy(va, (char *)db->db_data + bufoff, PAGESIZE); zfs_unmap_page(sf); vm_page_valid(m); - dmu_page_lock(m); if ((m->busy_lock & VPB_BIT_WAITERS) != 0) vm_page_activate(m); else vm_page_deactivate(m); - dmu_page_unlock(m); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); } *rbehind = i; @@ -296,7 +280,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, break; if (!vm_page_none_valid(m)) { ASSERT3U(m->valid, ==, VM_PAGE_BITS_ALL); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); break; } ASSERT3U(m->dirty, ==, 0); @@ -314,16 +298,13 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, } zfs_unmap_page(sf); vm_page_valid(m); - dmu_page_lock(m); if ((m->busy_lock & VPB_BIT_WAITERS) != 0) vm_page_activate(m); else vm_page_deactivate(m); - dmu_page_unlock(m); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); } *rahead = i; - zfs_vmobject_wunlock_12(vmobj); dmu_buf_rele_array(dbp, numbufs, FTAG); return (0); diff --git a/module/os/freebsd/zfs/event_os.c b/module/os/freebsd/zfs/event_os.c index e774fbaaf867..ace0fa734013 100644 --- a/module/os/freebsd/zfs/event_os.c +++ b/module/os/freebsd/zfs/event_os.c @@ -46,7 +46,6 @@ knlist_sx_xunlock(void *arg) sx_xunlock((struct sx *)arg); } -#if __FreeBSD_version >= 1300128 static void knlist_sx_assert_lock(void *arg, int what) { @@ -56,28 +55,10 @@ knlist_sx_assert_lock(void *arg, int what) else sx_assert((struct sx *)arg, SX_UNLOCKED); } -#else -static void -knlist_sx_assert_locked(void *arg) -{ - sx_assert((struct sx *)arg, SX_LOCKED); -} -static void -knlist_sx_assert_unlocked(void *arg) -{ - sx_assert((struct sx *)arg, SX_UNLOCKED); -} -#endif void knlist_init_sx(struct knlist *knl, struct sx *lock) { - -#if __FreeBSD_version >= 1300128 knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock, knlist_sx_assert_lock); -#else - knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock, - knlist_sx_assert_locked, knlist_sx_assert_unlocked); -#endif } diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index 9bd0c9ed81af..f883599f2dad 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -345,11 +345,7 @@ FEATURE(zfs, "OpenZFS support"); DECLARE_MODULE(zfsctrl, zfs_mod, SI_SUB_CLOCKS, SI_ORDER_ANY); MODULE_VERSION(zfsctrl, 1); -#if __FreeBSD_version > 1300092 MODULE_DEPEND(zfsctrl, xdr, 1, 1, 1); -#else -MODULE_DEPEND(zfsctrl, krpc, 1, 1, 1); -#endif MODULE_DEPEND(zfsctrl, acl_nfs4, 1, 1, 1); MODULE_DEPEND(zfsctrl, crypto, 1, 1, 1); MODULE_DEPEND(zfsctrl, zlib, 1, 1, 1); diff --git a/module/os/freebsd/zfs/vdev_geom.c b/module/os/freebsd/zfs/vdev_geom.c index 38c1d8e9e464..b7ff1063b089 100644 --- a/module/os/freebsd/zfs/vdev_geom.c +++ b/module/os/freebsd/zfs/vdev_geom.c @@ -379,11 +379,7 @@ vdev_geom_io(struct g_consumer *cp, int *cmds, void **datas, off_t *offsets, int i, n_bios, j; size_t bios_size; -#if __FreeBSD_version > 1300130 maxio = maxphys - (maxphys % cp->provider->sectorsize); -#else - maxio = MAXPHYS - (MAXPHYS % cp->provider->sectorsize); -#endif n_bios = 0; /* How many bios are required for all commands ? */ diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c index a753e91da4fe..4d539461886b 100644 --- a/module/os/freebsd/zfs/zfs_ctldir.c +++ b/module/os/freebsd/zfs/zfs_ctldir.c @@ -733,7 +733,7 @@ zfsctl_root_vptocnp(struct vop_vptocnp_args *ap) if (error != 0) return (SET_ERROR(error)); - VOP_UNLOCK1(dvp); + VOP_UNLOCK(dvp); *ap->a_vpp = dvp; *ap->a_buflen -= sizeof (dotzfs_name); memcpy(ap->a_buf + *ap->a_buflen, dotzfs_name, sizeof (dotzfs_name)); @@ -814,12 +814,8 @@ zfsctl_common_getacl(struct vop_getacl_args *ap) static struct vop_vector zfsctl_ops_root = { .vop_default = &default_vnodeops, -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_open = zfsctl_common_open, .vop_close = zfsctl_common_close, .vop_ioctl = VOP_EINVAL, @@ -1146,12 +1142,8 @@ zfsctl_snapdir_getattr(struct vop_getattr_args *ap) static struct vop_vector zfsctl_ops_snapdir = { .vop_default = &default_vnodeops, -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_open = zfsctl_common_open, .vop_close = zfsctl_common_close, .vop_getattr = zfsctl_snapdir_getattr, @@ -1226,27 +1218,19 @@ zfsctl_snapshot_vptocnp(struct vop_vptocnp_args *ap) * before we can lock the vnode again. */ locked = VOP_ISLOCKED(vp); -#if __FreeBSD_version >= 1300045 enum vgetstate vs = vget_prep(vp); -#else - vhold(vp); -#endif vput(vp); /* Look up .zfs/snapshot, our parent. */ error = zfsctl_snapdir_vnode(vp->v_mount, NULL, LK_SHARED, &dvp); if (error == 0) { - VOP_UNLOCK1(dvp); + VOP_UNLOCK(dvp); *ap->a_vpp = dvp; *ap->a_buflen -= len; memcpy(ap->a_buf + *ap->a_buflen, node->sn_name, len); } vfs_unbusy(mp); -#if __FreeBSD_version >= 1300045 vget_finish(vp, locked | LK_RETRY, vs); -#else - vget(vp, locked | LK_VNHELD | LK_RETRY, curthread); -#endif return (error); } @@ -1256,18 +1240,12 @@ zfsctl_snapshot_vptocnp(struct vop_vptocnp_args *ap) */ static struct vop_vector zfsctl_ops_snapshot = { .vop_default = NULL, /* ensure very restricted access */ -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_open = zfsctl_common_open, .vop_close = zfsctl_common_close, .vop_inactive = zfsctl_snapshot_inactive, -#if __FreeBSD_version >= 1300045 - .vop_need_inactive = vop_stdneed_inactive, -#endif + .vop_need_inactive = vop_stdneed_inactive, .vop_reclaim = zfsctl_snapshot_reclaim, .vop_vptocnp = zfsctl_snapshot_vptocnp, .vop_lock1 = vop_stdlock, diff --git a/module/os/freebsd/zfs/zfs_dir.c b/module/os/freebsd/zfs/zfs_dir.c index 3cdb94d6cd53..00d499c8c63e 100644 --- a/module/os/freebsd/zfs/zfs_dir.c +++ b/module/os/freebsd/zfs/zfs_dir.c @@ -824,7 +824,7 @@ zfs_make_xattrdir(znode_t *zp, vattr_t *vap, znode_t **xvpp, cred_t *cr) return (SET_ERROR(EDQUOT)); } - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(zfsvfs->z_os); dmu_tx_hold_sa_create(tx, acl_ids.z_aclp->z_acl_bytes + @@ -926,7 +926,7 @@ zfs_get_xattrdir(znode_t *zp, znode_t **xzpp, cred_t *cr, int flags) goto top; } if (error == 0) - VOP_UNLOCK1(ZTOV(*xzpp)); + VOP_UNLOCK(ZTOV(*xzpp)); return (error); } diff --git a/module/os/freebsd/zfs/zfs_file_os.c b/module/os/freebsd/zfs/zfs_file_os.c index b337932b9dcc..bdb8c4fac774 100644 --- a/module/os/freebsd/zfs/zfs_file_os.c +++ b/module/os/freebsd/zfs/zfs_file_os.c @@ -270,7 +270,7 @@ zfs_vop_fsync(vnode_t *vp) goto drop; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_FSYNC(vp, MNT_WAIT, curthread); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); vn_finished_write(mp); drop: return (SET_ERROR(error)); @@ -330,14 +330,6 @@ zfs_file_unlink(const char *fnamep) zfs_uio_seg_t seg = UIO_SYSSPACE; int rc; -#if __FreeBSD_version >= 1300018 rc = kern_funlinkat(curthread, AT_FDCWD, fnamep, FD_NONE, seg, 0, 0); -#elif __FreeBSD_version >= 1202504 || defined(AT_BENEATH) - rc = kern_unlinkat(curthread, AT_FDCWD, __DECONST(char *, fnamep), - seg, 0, 0); -#else - rc = kern_unlinkat(curthread, AT_FDCWD, __DECONST(char *, fnamep), - seg, 0); -#endif return (SET_ERROR(rc)); } diff --git a/module/os/freebsd/zfs/zfs_ioctl_os.c b/module/os/freebsd/zfs/zfs_ioctl_os.c index b8f5fa4e7543..928cf25e940f 100644 --- a/module/os/freebsd/zfs/zfs_ioctl_os.c +++ b/module/os/freebsd/zfs/zfs_ioctl_os.c @@ -36,10 +36,6 @@ #include -#if __FreeBSD_version < 1201517 -#define vm_page_max_user_wired vm_page_max_wired -#endif - int zfs_vfs_ref(zfsvfs_t **zfvp) { diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index a972c720dfdb..a60195493550 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -126,25 +126,16 @@ static int zfs_root(vfs_t *vfsp, int flags, vnode_t **vpp); static int zfs_statfs(vfs_t *vfsp, struct statfs *statp); static int zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp); static int zfs_sync(vfs_t *vfsp, int waitfor); -#if __FreeBSD_version >= 1300098 static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, struct ucred **credanonp, int *numsecflavors, int *secflavors); -#else -static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, - struct ucred **credanonp, int *numsecflavors, int **secflavors); -#endif static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp); static void zfs_freevfs(vfs_t *vfsp); struct vfsops zfs_vfsops = { .vfs_mount = zfs_mount, .vfs_unmount = zfs_umount, -#if __FreeBSD_version >= 1300049 .vfs_root = vfs_cache_root, - .vfs_cachedroot = zfs_root, -#else - .vfs_root = zfs_root, -#endif + .vfs_cachedroot = zfs_root, .vfs_statfs = zfs_statfs, .vfs_vget = zfs_vget, .vfs_sync = zfs_sync, @@ -1357,16 +1348,16 @@ zfs_mount(vfs_t *vfsp) vn_lock(mvp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(mvp, &vattr, cr)) { - VOP_UNLOCK1(mvp); + VOP_UNLOCK(mvp); goto out; } if (secpolicy_vnode_owner(mvp, cr, vattr.va_uid) != 0 && VOP_ACCESS(mvp, VWRITE, cr, td) != 0) { - VOP_UNLOCK1(mvp); + VOP_UNLOCK(mvp); goto out; } - VOP_UNLOCK1(mvp); + VOP_UNLOCK(mvp); } secpolicy_fs_mount_clearopts(cr, vfsp); @@ -1578,11 +1569,7 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting) * 'z_parent' is self referential for non-snapshots. */ #ifdef FREEBSD_NAMECACHE -#if __FreeBSD_version >= 1300117 cache_purgevfs(zfsvfs->z_parent->z_vfs); -#else - cache_purgevfs(zfsvfs->z_parent->z_vfs, true); -#endif #endif } @@ -1775,13 +1762,8 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp) } static int -#if __FreeBSD_version >= 1300098 zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, struct ucred **credanonp, int *numsecflavors, int *secflavors) -#else -zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, - struct ucred **credanonp, int *numsecflavors, int **secflavors) -#endif { zfsvfs_t *zfsvfs = vfsp->vfs_data; @@ -2070,10 +2052,8 @@ zfs_vnodes_adjust_back(void) #endif } -#if __FreeBSD_version >= 1300139 static struct sx zfs_vnlru_lock; static struct vnode *zfs_vnlru_marker; -#endif static arc_prune_t *zfs_prune; static void @@ -2081,13 +2061,9 @@ zfs_prune_task(uint64_t nr_to_scan, void *arg __unused) { if (nr_to_scan > INT_MAX) nr_to_scan = INT_MAX; -#if __FreeBSD_version >= 1300139 sx_xlock(&zfs_vnlru_lock); vnlru_free_vfsops(nr_to_scan, &zfs_vfsops, zfs_vnlru_marker); sx_xunlock(&zfs_vnlru_lock); -#else - vnlru_free(nr_to_scan, &zfs_vfsops); -#endif } void @@ -2117,10 +2093,8 @@ zfs_init(void) zfsvfs_taskq = taskq_create("zfsvfs", 1, minclsyspri, 0, 0, 0); -#if __FreeBSD_version >= 1300139 zfs_vnlru_marker = vnlru_alloc_marker(); sx_init(&zfs_vnlru_lock, "zfs vnlru lock"); -#endif zfs_prune = arc_add_prune_callback(zfs_prune_task, NULL); } @@ -2128,10 +2102,8 @@ void zfs_fini(void) { arc_remove_prune_callback(zfs_prune); -#if __FreeBSD_version >= 1300139 vnlru_free_marker(zfs_vnlru_marker); sx_destroy(&zfs_vnlru_lock); -#endif taskq_destroy(zfsvfs_taskq); zfsctl_fini(); diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index b9b332434bd2..fd36dbd30037 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -39,9 +39,7 @@ #include #include #include -#if __FreeBSD_version >= 1300102 #include -#endif #include #include #include @@ -100,18 +98,6 @@ VFS_SMR_DECLARE; -#if __FreeBSD_version < 1300103 -#define NDFREE_PNBUF(ndp) NDFREE((ndp), NDF_ONLY_PNBUF) -#endif - -#if __FreeBSD_version >= 1300047 -#define vm_page_wire_lock(pp) -#define vm_page_wire_unlock(pp) -#else -#define vm_page_wire_lock(pp) vm_page_lock(pp) -#define vm_page_wire_unlock(pp) vm_page_unlock(pp) -#endif - #ifdef DEBUG_VFS_LOCKS #define VNCHECKREF(vp) \ VNASSERT((vp)->v_holdcnt > 0 && (vp)->v_usecount > 0, vp, \ @@ -338,39 +324,6 @@ page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t nbytes) nbytes = end - off; obj = vp->v_object; - zfs_vmobject_assert_wlocked_12(obj); -#if __FreeBSD_version < 1300050 - for (;;) { - if ((pp = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL && - pp->valid) { - if (vm_page_xbusied(pp)) { - /* - * Reference the page before unlocking and - * sleeping so that the page daemon is less - * likely to reclaim it. - */ - vm_page_reference(pp); - vm_page_lock(pp); - zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb", true); - zfs_vmobject_wlock(obj); - continue; - } - vm_page_sbusy(pp); - } else if (pp != NULL) { - ASSERT(!pp->valid); - pp = NULL; - } - if (pp != NULL) { - ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL); - vm_object_pip_add(obj, 1); - pmap_remove_write(pp); - if (nbytes != 0) - vm_page_clear_dirty(pp, off, nbytes); - } - break; - } -#else vm_page_grab_valid_unlocked(&pp, obj, OFF_TO_IDX(start), VM_ALLOC_NOCREAT | VM_ALLOC_SBUSY | VM_ALLOC_NORMAL | VM_ALLOC_IGN_SBUSY); @@ -381,7 +334,6 @@ page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t nbytes) if (nbytes != 0) vm_page_clear_dirty(pp, off, nbytes); } -#endif return (pp); } @@ -390,14 +342,9 @@ page_unbusy(vm_page_t pp) { vm_page_sunbusy(pp); -#if __FreeBSD_version >= 1300041 vm_object_pip_wakeup(pp->object); -#else - vm_object_pip_subtract(pp->object, 1); -#endif } -#if __FreeBSD_version > 1300051 static vm_page_t page_hold(vnode_t *vp, int64_t start) { @@ -410,57 +357,11 @@ page_hold(vnode_t *vp, int64_t start) VM_ALLOC_NOBUSY); return (m); } -#else -static vm_page_t -page_hold(vnode_t *vp, int64_t start) -{ - vm_object_t obj; - vm_page_t pp; - - obj = vp->v_object; - zfs_vmobject_assert_wlocked(obj); - - for (;;) { - if ((pp = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL && - pp->valid) { - if (vm_page_xbusied(pp)) { - /* - * Reference the page before unlocking and - * sleeping so that the page daemon is less - * likely to reclaim it. - */ - vm_page_reference(pp); - vm_page_lock(pp); - zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb", true); - zfs_vmobject_wlock(obj); - continue; - } - - ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL); - vm_page_wire_lock(pp); - vm_page_hold(pp); - vm_page_wire_unlock(pp); - - } else - pp = NULL; - break; - } - return (pp); -} -#endif static void page_unhold(vm_page_t pp) { - - vm_page_wire_lock(pp); -#if __FreeBSD_version >= 1300035 vm_page_unwire(pp, PQ_ACTIVE); -#else - vm_page_unhold(pp); -#endif - vm_page_wire_unlock(pp); } /* @@ -484,34 +385,22 @@ update_pages(znode_t *zp, int64_t start, int len, objset_t *os) ASSERT3P(obj, !=, NULL); off = start & PAGEOFFSET; - zfs_vmobject_wlock_12(obj); -#if __FreeBSD_version >= 1300041 vm_object_pip_add(obj, 1); -#endif for (start &= PAGEMASK; len > 0; start += PAGESIZE) { vm_page_t pp; int nbytes = imin(PAGESIZE - off, len); if ((pp = page_busy(vp, start, off, nbytes)) != NULL) { - zfs_vmobject_wunlock_12(obj); - va = zfs_map_page(pp, &sf); (void) dmu_read(os, zp->z_id, start + off, nbytes, va + off, DMU_READ_PREFETCH); zfs_unmap_page(sf); - - zfs_vmobject_wlock_12(obj); page_unbusy(pp); } len -= nbytes; off = 0; } -#if __FreeBSD_version >= 1300041 vm_object_pip_wakeup(obj); -#else - vm_object_pip_wakeupn(obj, 0); -#endif - zfs_vmobject_wunlock_12(obj); } /* @@ -542,26 +431,22 @@ mappedread_sf(znode_t *zp, int nbytes, zfs_uio_t *uio) ASSERT3P(obj, !=, NULL); ASSERT0(zfs_uio_offset(uio) & PAGEOFFSET); - zfs_vmobject_wlock_12(obj); for (start = zfs_uio_offset(uio); len > 0; start += PAGESIZE) { int bytes = MIN(PAGESIZE, len); pp = vm_page_grab_unlocked(obj, OFF_TO_IDX(start), VM_ALLOC_SBUSY | VM_ALLOC_NORMAL | VM_ALLOC_IGN_SBUSY); if (vm_page_none_valid(pp)) { - zfs_vmobject_wunlock_12(obj); va = zfs_map_page(pp, &sf); error = dmu_read(os, zp->z_id, start, bytes, va, DMU_READ_PREFETCH); if (bytes != PAGESIZE && error == 0) memset(va + bytes, 0, PAGESIZE - bytes); zfs_unmap_page(sf); - zfs_vmobject_wlock_12(obj); -#if __FreeBSD_version >= 1300081 if (error == 0) { vm_page_valid(pp); vm_page_activate(pp); - vm_page_do_sunbusy(pp); + vm_page_sunbusy(pp); } else { zfs_vmobject_wlock(obj); if (!vm_page_wired(pp) && pp->valid == 0 && @@ -571,29 +456,15 @@ mappedread_sf(znode_t *zp, int nbytes, zfs_uio_t *uio) vm_page_sunbusy(pp); zfs_vmobject_wunlock(obj); } -#else - vm_page_do_sunbusy(pp); - vm_page_lock(pp); - if (error) { - if (pp->wire_count == 0 && pp->valid == 0 && - !vm_page_busied(pp)) - vm_page_free(pp); - } else { - pp->valid = VM_PAGE_BITS_ALL; - vm_page_activate(pp); - } - vm_page_unlock(pp); -#endif } else { ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL); - vm_page_do_sunbusy(pp); + vm_page_sunbusy(pp); } if (error) break; zfs_uio_advance(uio, bytes); len -= bytes; } - zfs_vmobject_wunlock_12(obj); return (error); } @@ -623,7 +494,6 @@ mappedread(znode_t *zp, int nbytes, zfs_uio_t *uio) start = zfs_uio_offset(uio); off = start & PAGEOFFSET; - zfs_vmobject_wlock_12(obj); for (start &= PAGEMASK; len > 0; start += PAGESIZE) { vm_page_t pp; uint64_t bytes = MIN(PAGESIZE - off, len); @@ -632,25 +502,20 @@ mappedread(znode_t *zp, int nbytes, zfs_uio_t *uio) struct sf_buf *sf; caddr_t va; - zfs_vmobject_wunlock_12(obj); va = zfs_map_page(pp, &sf); error = vn_io_fault_uiomove(va + off, bytes, GET_UIO_STRUCT(uio)); zfs_unmap_page(sf); - zfs_vmobject_wlock_12(obj); page_unhold(pp); } else { - zfs_vmobject_wunlock_12(obj); error = dmu_read_uio_dbuf(sa_get_db(zp->z_sa_hdl), uio, bytes); - zfs_vmobject_wlock_12(obj); } len -= bytes; off = 0; if (error) break; } - zfs_vmobject_wunlock_12(obj); return (error); } @@ -786,9 +651,7 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, znode_t *zdp = VTOZ(dvp); znode_t *zp; zfsvfs_t *zfsvfs = zdp->z_zfsvfs; -#if __FreeBSD_version > 1300124 seqc_t dvp_seqc; -#endif int error = 0; /* @@ -814,9 +677,7 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, if ((error = zfs_enter_verify_zp(zfsvfs, zdp, FTAG)) != 0) return (error); -#if __FreeBSD_version > 1300124 dvp_seqc = vn_seqc_read_notmodify(dvp); -#endif *vpp = NULL; @@ -895,7 +756,7 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, zfs_exit(zfsvfs, FTAG); ltype = VOP_ISLOCKED(dvp); - VOP_UNLOCK1(dvp); + VOP_UNLOCK(dvp); error = zfsctl_root(zfsvfs->z_parent, LK_SHARED, &zfsctl_vp); if (error == 0) { @@ -996,7 +857,6 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, } } -#if __FreeBSD_version > 1300124 if ((cnp->cn_flags & ISDOTDOT) != 0) { /* * FIXME: zfs_lookup_lock relocks vnodes and does nothing to @@ -1014,7 +874,6 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, cnp->cn_flags &= ~MAKEENTRY; } } -#endif /* Insert name into cache (as non-existent) if appropriate. */ if (zfsvfs->z_use_namecache && !zfsvfs->z_replay && @@ -1149,7 +1008,7 @@ zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode, goto out; } - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(os); @@ -1183,7 +1042,7 @@ zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode, * delete the newly created dnode. */ zfs_znode_delete(zp, tx); - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); zrele(zp); zfs_acl_ids_free(&acl_ids); dmu_tx_commit(tx); @@ -1512,7 +1371,7 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp, /* * Add a new entry to the directory. */ - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(zfsvfs->z_os); dmu_tx_hold_zap(tx, dzp->z_id, TRUE, dirname); dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL); @@ -1547,7 +1406,7 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp, error = zfs_link_create(dzp, dirname, zp, tx, ZNEW); if (error != 0) { zfs_znode_delete(zp, tx); - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); zrele(zp); goto out; } @@ -1575,16 +1434,6 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp, return (error); } -#if __FreeBSD_version < 1300124 -static void -cache_vop_rmdir(struct vnode *dvp, struct vnode *vp) -{ - - cache_purge(dvp); - cache_purge(vp); -} -#endif - /* * Remove a directory subdir entry. If the current working * directory is the same as the subdir to be removed, the @@ -2984,9 +2833,9 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, znode_t *sdzp, *tdzp, *szp, *tzp; int error; - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); if (*tvpp != NULL && *tvpp != tdvp) - VOP_UNLOCK1(*tvpp); + VOP_UNLOCK(*tvpp); relock: error = vn_lock(sdvp, LK_EXCLUSIVE); @@ -2994,13 +2843,13 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, goto out; error = vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { - VOP_UNLOCK1(sdvp); + VOP_UNLOCK(sdvp); if (error != EBUSY) goto out; error = vn_lock(tdvp, LK_EXCLUSIVE); if (error) goto out; - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); goto relock; } tdzp = VTOZ(tdvp); @@ -3008,8 +2857,8 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, error = zfs_rename_relock_lookup(sdzp, scnp, &szp, tdzp, tcnp, &tzp); if (error != 0) { - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(tdvp); goto out; } svp = ZTOV(szp); @@ -3021,8 +2870,8 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, nvp = svp; error = vn_lock(nvp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(tdvp); if (tvp != NULL) vrele(tvp); if (error != EBUSY) { @@ -3034,7 +2883,7 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, vrele(nvp); goto out; } - VOP_UNLOCK1(nvp); + VOP_UNLOCK(nvp); /* * Concurrent rename race. * XXX ? @@ -3058,9 +2907,9 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, nvp = tvp; error = vn_lock(nvp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); - VOP_UNLOCK1(*svpp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(*svpp); if (error != EBUSY) { vrele(nvp); goto out; @@ -3137,19 +2986,6 @@ zfs_rename_check(znode_t *szp, znode_t *sdzp, znode_t *tdzp) return (error); } -#if __FreeBSD_version < 1300124 -static void -cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp, - struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp) -{ - - cache_purge(fvp); - if (tvp != NULL) - cache_purge(tvp); - cache_purge_negative(tdvp); -} -#endif - static int zfs_do_rename_impl(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, vnode_t *tdvp, vnode_t **tvpp, struct componentname *tcnp, @@ -3205,13 +3041,13 @@ zfs_do_rename(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, } error = zfs_do_rename_impl(sdvp, svpp, scnp, tdvp, tvpp, tcnp, cr); - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(*svpp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(*svpp); out: if (*tvpp != NULL) - VOP_UNLOCK1(*tvpp); + VOP_UNLOCK(*tvpp); if (tdvp != *tvpp) - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); return (error); } @@ -3463,17 +3299,17 @@ zfs_rename(znode_t *sdzp, const char *sname, znode_t *tdzp, const char *tname, tdvp = ZTOV(tdzp); error = zfs_lookup_internal(sdzp, sname, &svp, &scn, DELETE); if (sdzp->z_zfsvfs->z_replay == B_FALSE) - VOP_UNLOCK1(sdvp); + VOP_UNLOCK(sdvp); if (error != 0) goto fail; - VOP_UNLOCK1(svp); + VOP_UNLOCK(svp); vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY); error = zfs_lookup_internal(tdzp, tname, &tvp, &tcn, RENAME); if (error == EJUSTRETURN) tvp = NULL; else if (error != 0) { - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); goto fail; } @@ -3564,7 +3400,7 @@ zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap, return (SET_ERROR(EDQUOT)); } - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(zfsvfs->z_os); fuid_dirtied = zfsvfs->z_fuid_dirty; dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, MAX(1, len)); @@ -3611,7 +3447,7 @@ zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap, error = zfs_link_create(dzp, name, zp, tx, ZNEW); if (error != 0) { zfs_znode_delete(zp, tx); - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); zrele(zp); } else { zfs_log_symlink(zilog, tx, txtype, dzp, zp, name, link); @@ -4472,7 +4308,6 @@ zfs_freebsd_write(struct vop_write_args *ap) ap->a_cred)); } -#if __FreeBSD_version >= 1300102 /* * VOP_FPLOOKUP_VEXEC routines are subject to special circumstances, see * the comment above cache_fplookup for details. @@ -4497,9 +4332,7 @@ zfs_freebsd_fplookup_vexec(struct vop_fplookup_vexec_args *v) return (EAGAIN); return (0); } -#endif -#if __FreeBSD_version >= 1300139 static int zfs_freebsd_fplookup_symlink(struct vop_fplookup_symlink_args *v) { @@ -4519,7 +4352,6 @@ zfs_freebsd_fplookup_symlink(struct vop_fplookup_symlink_args *v) } return (cache_symlink_resolve(v->a_fpl, target, strlen(target))); } -#endif #ifndef _SYS_SYSPROTO_H_ struct vop_access_args { @@ -4557,13 +4389,8 @@ zfs_freebsd_access(struct vop_access_args *ap) if (error == 0) { accmode = ap->a_accmode & ~(VREAD|VWRITE|VEXEC|VAPPEND); if (accmode != 0) { -#if __FreeBSD_version >= 1300105 error = vaccess(vp->v_type, zp->z_mode, zp->z_uid, zp->z_gid, accmode, ap->a_cred); -#else - error = vaccess(vp->v_type, zp->z_mode, zp->z_uid, - zp->z_gid, accmode, ap->a_cred, NULL); -#endif } } @@ -4898,7 +4725,7 @@ zfs_freebsd_setattr(struct vop_setattr_args *ap) * otherwise, they behave like unprivileged processes. */ if (secpolicy_fs_owner(vp->v_mount, cred) == 0 || - spl_priv_check_cred(cred, PRIV_VFS_SYSFLAGS) == 0) { + priv_check_cred(cred, PRIV_VFS_SYSFLAGS) == 0) { if (zflags & (ZFS_IMMUTABLE | ZFS_APPENDONLY | ZFS_NOUNLINK)) { error = securelevel_gt(cred, 0); @@ -5017,10 +4844,8 @@ zfs_freebsd_symlink(struct vop_symlink_args *ap) struct componentname *cnp = ap->a_cnp; vattr_t *vap = ap->a_vap; znode_t *zp = NULL; -#if __FreeBSD_version >= 1300139 char *symlink; size_t symlink_len; -#endif int rc; #if __FreeBSD_version < 1400068 @@ -5036,7 +4861,6 @@ zfs_freebsd_symlink(struct vop_symlink_args *ap) if (rc == 0) { *ap->a_vpp = ZTOV(zp); ASSERT_VOP_ELOCKED(ZTOV(zp), __func__); -#if __FreeBSD_version >= 1300139 MPASS(zp->z_cached_symlink == NULL); symlink_len = strlen(ap->a_target); symlink = cache_symlink_alloc(symlink_len + 1, M_WAITOK); @@ -5046,7 +4870,6 @@ zfs_freebsd_symlink(struct vop_symlink_args *ap) atomic_store_rel_ptr((uintptr_t *)&zp->z_cached_symlink, (uintptr_t)symlink); } -#endif } return (rc); } @@ -5064,15 +4887,12 @@ zfs_freebsd_readlink(struct vop_readlink_args *ap) { zfs_uio_t uio; int error; -#if __FreeBSD_version >= 1300139 znode_t *zp = VTOZ(ap->a_vp); char *symlink, *base; size_t symlink_len; bool trycache; -#endif zfs_uio_init(&uio, ap->a_uio); -#if __FreeBSD_version >= 1300139 trycache = false; if (zfs_uio_segflg(&uio) == UIO_SYSSPACE && zfs_uio_iovcnt(&uio) == 1) { @@ -5080,9 +4900,7 @@ zfs_freebsd_readlink(struct vop_readlink_args *ap) symlink_len = zfs_uio_iovlen(&uio, 0); trycache = true; } -#endif error = zfs_readlink(ap->a_vp, &uio, ap->a_cred, NULL); -#if __FreeBSD_version >= 1300139 if (atomic_load_ptr(&zp->z_cached_symlink) != NULL || error != 0 || !trycache) { return (error); @@ -5097,7 +4915,6 @@ zfs_freebsd_readlink(struct vop_readlink_args *ap) cache_symlink_free(symlink, symlink_len + 1); } } -#endif return (error); } @@ -5139,15 +4956,10 @@ zfs_freebsd_inactive(struct vop_inactive_args *ap) { vnode_t *vp = ap->a_vp; -#if __FreeBSD_version >= 1300123 zfs_inactive(vp, curthread->td_ucred, NULL); -#else - zfs_inactive(vp, ap->a_td->td_ucred, NULL); -#endif return (0); } -#if __FreeBSD_version >= 1300042 #ifndef _SYS_SYSPROTO_H_ struct vop_need_inactive_args { struct vnode *a_vp; @@ -5173,7 +4985,6 @@ zfs_freebsd_need_inactive(struct vop_need_inactive_args *ap) return (need); } -#endif #ifndef _SYS_SYSPROTO_H_ struct vop_reclaim_args { @@ -5191,10 +5002,6 @@ zfs_freebsd_reclaim(struct vop_reclaim_args *ap) ASSERT3P(zp, !=, NULL); -#if __FreeBSD_version < 1300042 - /* Destroy the vm object and flush associated pages. */ - vnode_destroy_vobject(vp); -#endif /* * z_teardown_inactive_lock protects from a race with * zfs_znode_dmu_fini in zfsvfs_teardown during @@ -5405,7 +5212,7 @@ zfs_getextattr_dir(struct vop_getextattr_args *ap, const char *attrname) } else if (ap->a_uio != NULL) error = VOP_READ(vp, ap->a_uio, IO_UNIT, ap->a_cred); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); vn_close(vp, flags, ap->a_cred, td); return (error); } @@ -5692,7 +5499,7 @@ zfs_setextattr_dir(struct vop_setextattr_args *ap, const char *attrname) if (error == 0) VOP_WRITE(vp, ap->a_uio, IO_UNIT, ap->a_cred); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); vn_close(vp, flags, ap->a_cred, td); return (error); } @@ -6175,26 +5982,13 @@ zfs_vptocnp(struct vop_vptocnp_args *ap) zfs_exit(zfsvfs, FTAG); covered_vp = vp->v_mount->mnt_vnodecovered; -#if __FreeBSD_version >= 1300045 enum vgetstate vs = vget_prep(covered_vp); -#else - vhold(covered_vp); -#endif ltype = VOP_ISLOCKED(vp); - VOP_UNLOCK1(vp); -#if __FreeBSD_version >= 1300045 + VOP_UNLOCK(vp); error = vget_finish(covered_vp, LK_SHARED, vs); -#else - error = vget(covered_vp, LK_SHARED | LK_VNHELD, curthread); -#endif if (error == 0) { -#if __FreeBSD_version >= 1300123 error = VOP_VPTOCNP(covered_vp, ap->a_vpp, ap->a_buf, ap->a_buflen); -#else - error = VOP_VPTOCNP(covered_vp, ap->a_vpp, ap->a_cred, - ap->a_buf, ap->a_buflen); -#endif vput(covered_vp); } vn_lock(vp, ltype | LK_RETRY); @@ -6252,7 +6046,6 @@ zfs_deallocate(struct vop_deallocate_args *ap) } #endif -#if __FreeBSD_version >= 1300039 #ifndef _SYS_SYSPROTO_H_ struct vop_copy_file_range_args { struct vnode *a_invp; @@ -6359,7 +6152,6 @@ zfs_freebsd_copy_file_range(struct vop_copy_file_range_args *ap) ap->a_incred, ap->a_outcred, ap->a_fsizetd); return (error); } -#endif struct vop_vector zfs_vnodeops; struct vop_vector zfs_fifoops; @@ -6368,16 +6160,10 @@ struct vop_vector zfs_shareops; struct vop_vector zfs_vnodeops = { .vop_default = &default_vnodeops, .vop_inactive = zfs_freebsd_inactive, -#if __FreeBSD_version >= 1300042 .vop_need_inactive = zfs_freebsd_need_inactive, -#endif .vop_reclaim = zfs_freebsd_reclaim, -#if __FreeBSD_version >= 1300102 .vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = zfs_freebsd_fplookup_symlink, -#endif .vop_access = zfs_freebsd_access, .vop_allocate = VOP_EINVAL, #if __FreeBSD_version >= 1400032 @@ -6416,29 +6202,21 @@ struct vop_vector zfs_vnodeops = { .vop_getpages = zfs_freebsd_getpages, .vop_putpages = zfs_freebsd_putpages, .vop_vptocnp = zfs_vptocnp, -#if __FreeBSD_version >= 1300064 .vop_lock1 = vop_lock, .vop_unlock = vop_unlock, .vop_islocked = vop_islocked, -#endif #if __FreeBSD_version >= 1400043 .vop_add_writecount = vop_stdadd_writecount_nomsync, #endif -#if __FreeBSD_version >= 1300039 .vop_copy_file_range = zfs_freebsd_copy_file_range, -#endif }; VFS_VOP_VECTOR_REGISTER(zfs_vnodeops); struct vop_vector zfs_fifoops = { .vop_default = &fifo_specops, .vop_fsync = zfs_freebsd_fsync, -#if __FreeBSD_version >= 1300102 - .vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, -#endif -#if __FreeBSD_version >= 1300139 + .vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, .vop_fplookup_symlink = zfs_freebsd_fplookup_symlink, -#endif .vop_access = zfs_freebsd_access, .vop_getattr = zfs_freebsd_getattr, .vop_inactive = zfs_freebsd_inactive, @@ -6462,12 +6240,8 @@ VFS_VOP_VECTOR_REGISTER(zfs_fifoops); */ struct vop_vector zfs_shareops = { .vop_default = &default_vnodeops, -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_access = zfs_freebsd_access, .vop_inactive = zfs_freebsd_inactive, .vop_reclaim = zfs_freebsd_reclaim, diff --git a/module/os/freebsd/zfs/zfs_znode.c b/module/os/freebsd/zfs/zfs_znode.c index 0eea2a849416..33b6b33c9237 100644 --- a/module/os/freebsd/zfs/zfs_znode.c +++ b/module/os/freebsd/zfs/zfs_znode.c @@ -92,7 +92,7 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, znode, CTLFLAG_RD, * (such as VFS logic) that will not compile easily in userland. */ #ifdef _KERNEL -#if !defined(KMEM_DEBUG) && __FreeBSD_version >= 1300102 +#if !defined(KMEM_DEBUG) #define _ZFS_USE_SMR static uma_zone_t znode_uma_zone; #else @@ -434,13 +434,8 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, ("%s: fast path lookup enabled without smr", __func__)); #endif -#if __FreeBSD_version >= 1300076 KASSERT(curthread->td_vp_reserved != NULL, ("zfs_znode_alloc: getnewvnode without any vnodes reserved")); -#else - KASSERT(curthread->td_vp_reserv > 0, - ("zfs_znode_alloc: getnewvnode without any vnodes reserved")); -#endif error = getnewvnode("zfs", zfsvfs->z_parent->z_vfs, &zfs_vnodeops, &vp); if (error != 0) { zfs_znode_free_kmem(zp); @@ -468,9 +463,7 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, zp->z_sync_cnt = 0; zp->z_sync_writes_cnt = 0; zp->z_async_writes_cnt = 0; -#if __FreeBSD_version >= 1300139 atomic_store_ptr(&zp->z_cached_symlink, NULL); -#endif zfs_znode_sa_init(zfsvfs, zp, db, obj_type, hdl); @@ -942,7 +935,7 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp) int locked; int err; - getnewvnode_reserve_(); + getnewvnode_reserve(); again: *zpp = NULL; ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num); @@ -1055,7 +1048,7 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp) err = insmntque(vp, zfsvfs->z_vfs); if (err == 0) { vp->v_hash = obj_num; - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); } else { zp->z_vnode = NULL; zfs_znode_dmu_fini(zp); @@ -1275,9 +1268,7 @@ void zfs_znode_free(znode_t *zp) { zfsvfs_t *zfsvfs = zp->z_zfsvfs; -#if __FreeBSD_version >= 1300139 char *symlink; -#endif ASSERT3P(zp->z_sa_hdl, ==, NULL); zp->z_vnode = NULL; @@ -1286,14 +1277,12 @@ zfs_znode_free(znode_t *zp) list_remove(&zfsvfs->z_all_znodes, zp); mutex_exit(&zfsvfs->z_znodes_lock); -#if __FreeBSD_version >= 1300139 symlink = atomic_load_ptr(&zp->z_cached_symlink); if (symlink != NULL) { atomic_store_rel_ptr((uintptr_t *)&zp->z_cached_symlink, (uintptr_t)NULL); cache_symlink_free(symlink, strlen(symlink) + 1); } -#endif if (zp->z_acl_cached) { zfs_acl_free(zp->z_acl_cached); diff --git a/module/os/freebsd/zfs/zvol_os.c b/module/os/freebsd/zfs/zvol_os.c index 38e9debbe877..a53a54141461 100644 --- a/module/os/freebsd/zfs/zvol_os.c +++ b/module/os/freebsd/zfs/zvol_os.c @@ -1312,11 +1312,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname) args.mda_si_drv2 = zv; if (make_dev_s(&args, &dev, "%s/%s", ZVOL_DRIVER, newname) == 0) { -#if __FreeBSD_version > 1300130 dev->si_iosize_max = maxphys; -#else - dev->si_iosize_max = MAXPHYS; -#endif zsd->zsd_cdev = dev; } } @@ -1456,11 +1452,7 @@ zvol_os_create_minor(const char *name) args.mda_si_drv2 = zv; if (make_dev_s(&args, &dev, "%s/%s", ZVOL_DRIVER, name) == 0) { -#if __FreeBSD_version > 1300130 dev->si_iosize_max = maxphys; -#else - dev->si_iosize_max = MAXPHYS; -#endif zsd->zsd_cdev = dev; knlist_init_sx(&zsd->zsd_selinfo.si_note, &zv->zv_state_lock); diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c index 2e0af60f6db4..810550161f8b 100644 --- a/module/zfs/zfs_replay.c +++ b/module/zfs/zfs_replay.c @@ -439,7 +439,7 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) bail: if (error == 0 && zp != NULL) { #ifdef __FreeBSD__ - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); #endif zrele(zp); } @@ -595,7 +595,7 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) out: if (error == 0 && zp != NULL) { #ifdef __FreeBSD__ - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); #endif zrele(zp); }