From cdd53fea1e899585f141fb2d4885e88df9d6939f Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 1 Aug 2024 15:25:42 -0400 Subject: [PATCH 1/8] FreeBSD: Add missing memory reclamation accounting Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Reviewed-by: Tino Reichardt Reviewed-by: Umer Saleem Reviewed-by: Ameer Hamza Reviewed-by: Tony Hutter --- module/os/freebsd/zfs/arc_os.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/os/freebsd/zfs/arc_os.c b/module/os/freebsd/zfs/arc_os.c index f52c7bb5af8..dd3da2183a1 100644 --- a/module/os/freebsd/zfs/arc_os.c +++ b/module/os/freebsd/zfs/arc_os.c @@ -166,8 +166,12 @@ arc_lowmem(void *arg __unused, int howto __unused) * here from ARC itself and may hold ARC locks and thus risk a deadlock * with ARC reclaim thread. */ - if (curproc == pageproc) + if (curproc == pageproc) { arc_wait_for_eviction(to_free, B_FALSE, B_FALSE); + ARCSTAT_BUMP(arcstat_memory_indirect_count); + } else { + ARCSTAT_BUMP(arcstat_memory_direct_count); + } } void From 1fdcb653bcdb1dec47703328e2861e58aab84475 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 1 Aug 2024 15:27:29 -0400 Subject: [PATCH 2/8] Once more refactor arc_summary output Before this arc_summary was not reporting any information about evictable ARC memory. As result I've found difficult to analyze behavior of dnode-heavy workload with lots of unevictable buffers. This change adds evictable sizes into states breakdown section. While there, add/refactor sections for global memory statistics, for ARC breakdown between different structures, for data/metadata. Add information about memory reclamation requests. While there, refactor and polish graph mode, neglected for a while. Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Reviewed-by: Tino Reichardt Reviewed-by: Umer Saleem Reviewed-by: Ameer Hamza Reviewed-by: Tony Hutter --- cmd/arc_summary | 147 +++++++++++++++++++++++++++++------------------- 1 file changed, 88 insertions(+), 59 deletions(-) diff --git a/cmd/arc_summary b/cmd/arc_summary index 100fb1987a8..2d0bfddd93a 100755 --- a/cmd/arc_summary +++ b/cmd/arc_summary @@ -260,33 +260,34 @@ def draw_graph(kstats_dict): arc_stats = isolate_section('arcstats', kstats_dict) GRAPH_INDENT = ' '*4 - GRAPH_WIDTH = 60 + GRAPH_WIDTH = 70 + arc_max = int(arc_stats['c_max']) arc_size = f_bytes(arc_stats['size']) - arc_perc = f_perc(arc_stats['size'], arc_stats['c_max']) - mfu_size = f_bytes(arc_stats['mfu_size']) - mru_size = f_bytes(arc_stats['mru_size']) - meta_size = f_bytes(arc_stats['arc_meta_used']) - dnode_limit = f_bytes(arc_stats['arc_dnode_limit']) + arc_perc = f_perc(arc_stats['size'], arc_max) + data_size = f_bytes(arc_stats['data_size']) + meta_size = f_bytes(arc_stats['metadata_size']) dnode_size = f_bytes(arc_stats['dnode_size']) - info_form = ('ARC: {0} ({1}) MFU: {2} MRU: {3} META: {4} ' - 'DNODE {5} ({6})') - info_line = info_form.format(arc_size, arc_perc, mfu_size, mru_size, - meta_size, dnode_size, dnode_limit) + info_form = ('ARC: {0} ({1}) Data: {2} Meta: {3} Dnode: {4}') + info_line = info_form.format(arc_size, arc_perc, data_size, meta_size, + dnode_size) info_spc = ' '*int((GRAPH_WIDTH-len(info_line))/2) info_line = GRAPH_INDENT+info_spc+info_line graph_line = GRAPH_INDENT+'+'+('-'*(GRAPH_WIDTH-2))+'+' - mfu_perc = float(int(arc_stats['mfu_size'])/int(arc_stats['c_max'])) - mru_perc = float(int(arc_stats['mru_size'])/int(arc_stats['c_max'])) - arc_perc = float(int(arc_stats['size'])/int(arc_stats['c_max'])) + arc_perc = float(int(arc_stats['size'])/arc_max) + data_perc = float(int(arc_stats['data_size'])/arc_max) + meta_perc = float(int(arc_stats['metadata_size'])/arc_max) + dnode_perc = float(int(arc_stats['dnode_size'])/arc_max) total_ticks = float(arc_perc)*GRAPH_WIDTH - mfu_ticks = mfu_perc*GRAPH_WIDTH - mru_ticks = mru_perc*GRAPH_WIDTH - other_ticks = total_ticks-(mfu_ticks+mru_ticks) + data_ticks = data_perc*GRAPH_WIDTH + meta_ticks = meta_perc*GRAPH_WIDTH + dnode_ticks = dnode_perc*GRAPH_WIDTH + other_ticks = total_ticks-(data_ticks+meta_ticks+dnode_ticks) - core_form = 'F'*int(mfu_ticks)+'R'*int(mru_ticks)+'O'*int(other_ticks) + core_form = 'D'*int(data_ticks)+'M'*int(meta_ticks)+'N'*int(dnode_ticks)+\ + 'O'*int(other_ticks) core_spc = ' '*(GRAPH_WIDTH-(2+len(core_form))) core_line = GRAPH_INDENT+'|'+core_form+core_spc+'|' @@ -536,56 +537,87 @@ def section_arc(kstats_dict): arc_stats = isolate_section('arcstats', kstats_dict) - throttle = arc_stats['memory_throttle_count'] - - if throttle == '0': - health = 'HEALTHY' - else: - health = 'THROTTLED' - - prt_1('ARC status:', health) - prt_i1('Memory throttle count:', throttle) - print() - + memory_all = arc_stats['memory_all_bytes'] + memory_free = arc_stats['memory_free_bytes'] + memory_avail = arc_stats['memory_available_bytes'] arc_size = arc_stats['size'] arc_target_size = arc_stats['c'] arc_max = arc_stats['c_max'] arc_min = arc_stats['c_min'] + dnode_limit = arc_stats['arc_dnode_limit'] + + print('ARC status:') + prt_i1('Total memory size:', f_bytes(memory_all)) + prt_i2('Min target size:', f_perc(arc_min, memory_all), f_bytes(arc_min)) + prt_i2('Max target size:', f_perc(arc_max, memory_all), f_bytes(arc_max)) + prt_i2('Target size (adaptive):', + f_perc(arc_size, arc_max), f_bytes(arc_target_size)) + prt_i2('Current size:', f_perc(arc_size, arc_max), f_bytes(arc_size)) + prt_i1('Free memory size:', f_bytes(memory_free)) + prt_i1('Available memory size:', f_bytes(memory_avail)) + print() + + compressed_size = arc_stats['compressed_size'] + overhead_size = arc_stats['overhead_size'] + bonus_size = arc_stats['bonus_size'] + dnode_size = arc_stats['dnode_size'] + dbuf_size = arc_stats['dbuf_size'] + hdr_size = arc_stats['hdr_size'] + l2_hdr_size = arc_stats['l2_hdr_size'] + abd_chunk_waste_size = arc_stats['abd_chunk_waste_size'] + + prt_1('ARC structal breakdown (current size):', f_bytes(arc_size)) + prt_i2('Compressed size:', + f_perc(compressed_size, arc_size), f_bytes(compressed_size)) + prt_i2('Overhead size:', + f_perc(overhead_size, arc_size), f_bytes(overhead_size)) + prt_i2('Bonus size:', + f_perc(bonus_size, arc_size), f_bytes(bonus_size)) + prt_i2('Dnode size:', + f_perc(dnode_size, arc_size), f_bytes(dnode_size)) + prt_i2('Dbuf size:', + f_perc(dbuf_size, arc_size), f_bytes(dbuf_size)) + prt_i2('Header size:', + f_perc(hdr_size, arc_size), f_bytes(hdr_size)) + prt_i2('L2 header size:', + f_perc(l2_hdr_size, arc_size), f_bytes(l2_hdr_size)) + prt_i2('ABD chunk waste size:', + f_perc(abd_chunk_waste_size, arc_size), f_bytes(abd_chunk_waste_size)) + print() + meta = arc_stats['meta'] pd = arc_stats['pd'] pm = arc_stats['pm'] + data_size = arc_stats['data_size'] + metadata_size = arc_stats['metadata_size'] anon_data = arc_stats['anon_data'] anon_metadata = arc_stats['anon_metadata'] mfu_data = arc_stats['mfu_data'] mfu_metadata = arc_stats['mfu_metadata'] + mfu_edata = arc_stats['mfu_evictable_data'] + mfu_emetadata = arc_stats['mfu_evictable_metadata'] mru_data = arc_stats['mru_data'] mru_metadata = arc_stats['mru_metadata'] + mru_edata = arc_stats['mru_evictable_data'] + mru_emetadata = arc_stats['mru_evictable_metadata'] mfug_data = arc_stats['mfu_ghost_data'] mfug_metadata = arc_stats['mfu_ghost_metadata'] mrug_data = arc_stats['mru_ghost_data'] mrug_metadata = arc_stats['mru_ghost_metadata'] unc_data = arc_stats['uncached_data'] unc_metadata = arc_stats['uncached_metadata'] - bonus_size = arc_stats['bonus_size'] - dnode_limit = arc_stats['arc_dnode_limit'] - dnode_size = arc_stats['dnode_size'] - dbuf_size = arc_stats['dbuf_size'] - hdr_size = arc_stats['hdr_size'] - l2_hdr_size = arc_stats['l2_hdr_size'] - abd_chunk_waste_size = arc_stats['abd_chunk_waste_size'] - target_size_ratio = '{0}:1'.format(int(arc_max) // int(arc_min)) - - prt_2('ARC size (current):', - f_perc(arc_size, arc_max), f_bytes(arc_size)) - prt_i2('Target size (adaptive):', - f_perc(arc_target_size, arc_max), f_bytes(arc_target_size)) - prt_i2('Min size (hard limit):', - f_perc(arc_min, arc_max), f_bytes(arc_min)) - prt_i2('Max size (high water):', - target_size_ratio, f_bytes(arc_max)) caches_size = int(anon_data)+int(anon_metadata)+\ int(mfu_data)+int(mfu_metadata)+int(mru_data)+int(mru_metadata)+\ int(unc_data)+int(unc_metadata) + + prt_1('ARC types breakdown (compressed + overhead):', f_bytes(caches_size)) + prt_i2('Data size:', + f_perc(data_size, caches_size), f_bytes(data_size)) + prt_i2('Metadata size:', + f_perc(metadata_size, caches_size), f_bytes(metadata_size)) + print() + + prt_1('ARC states breakdown (compressed + overhead):', f_bytes(caches_size)) prt_i2('Anonymous data size:', f_perc(anon_data, caches_size), f_bytes(anon_data)) prt_i2('Anonymous metadata size:', @@ -596,43 +628,37 @@ def section_arc(kstats_dict): f_bytes(v / 65536 * caches_size / 65536)) prt_i2('MFU data size:', f_perc(mfu_data, caches_size), f_bytes(mfu_data)) + prt_i2('MFU evictable data size:', + f_perc(mfu_edata, caches_size), f_bytes(mfu_edata)) prt_i1('MFU ghost data size:', f_bytes(mfug_data)) v = (s-int(pm))*int(meta)/s prt_i2('MFU metadata target:', f_perc(v, s), f_bytes(v / 65536 * caches_size / 65536)) prt_i2('MFU metadata size:', f_perc(mfu_metadata, caches_size), f_bytes(mfu_metadata)) + prt_i2('MFU evictable metadata size:', + f_perc(mfu_emetadata, caches_size), f_bytes(mfu_emetadata)) prt_i1('MFU ghost metadata size:', f_bytes(mfug_metadata)) v = int(pd)*(s-int(meta))/s prt_i2('MRU data target:', f_perc(v, s), f_bytes(v / 65536 * caches_size / 65536)) prt_i2('MRU data size:', f_perc(mru_data, caches_size), f_bytes(mru_data)) + prt_i2('MRU evictable data size:', + f_perc(mru_edata, caches_size), f_bytes(mru_edata)) prt_i1('MRU ghost data size:', f_bytes(mrug_data)) v = int(pm)*int(meta)/s prt_i2('MRU metadata target:', f_perc(v, s), f_bytes(v / 65536 * caches_size / 65536)) prt_i2('MRU metadata size:', f_perc(mru_metadata, caches_size), f_bytes(mru_metadata)) + prt_i2('MRU evictable metadata size:', + f_perc(mru_emetadata, caches_size), f_bytes(mru_emetadata)) prt_i1('MRU ghost metadata size:', f_bytes(mrug_metadata)) prt_i2('Uncached data size:', f_perc(unc_data, caches_size), f_bytes(unc_data)) prt_i2('Uncached metadata size:', f_perc(unc_metadata, caches_size), f_bytes(unc_metadata)) - prt_i2('Bonus size:', - f_perc(bonus_size, arc_size), f_bytes(bonus_size)) - prt_i2('Dnode cache target:', - f_perc(dnode_limit, arc_max), f_bytes(dnode_limit)) - prt_i2('Dnode cache size:', - f_perc(dnode_size, dnode_limit), f_bytes(dnode_size)) - prt_i2('Dbuf size:', - f_perc(dbuf_size, arc_size), f_bytes(dbuf_size)) - prt_i2('Header size:', - f_perc(hdr_size, arc_size), f_bytes(hdr_size)) - prt_i2('L2 header size:', - f_perc(l2_hdr_size, arc_size), f_bytes(l2_hdr_size)) - prt_i2('ABD chunk waste size:', - f_perc(abd_chunk_waste_size, arc_size), f_bytes(abd_chunk_waste_size)) print() print('ARC hash breakdown:') @@ -647,6 +673,9 @@ def section_arc(kstats_dict): print() print('ARC misc:') + prt_i1('Memory throttles:', arc_stats['memory_throttle_count']) + prt_i1('Memory direct reclaims:', arc_stats['memory_direct_count']) + prt_i1('Memory indirect reclaims:', arc_stats['memory_indirect_count']) prt_i1('Deleted:', f_hits(arc_stats['deleted'])) prt_i1('Mutex misses:', f_hits(arc_stats['mutex_miss'])) prt_i1('Eviction skips:', f_hits(arc_stats['evict_skip'])) From 46ebd0af8a4298cb56e48f841e72fa9fbbbbed69 Mon Sep 17 00:00:00 2001 From: Shengqi Chen Date: Tue, 6 Aug 2024 00:44:10 +0800 Subject: [PATCH 3/8] contrib: link zpool to zfs in bash-completion (#16376) Currently user won't have completion of `zpool` command until they trigger completion of `zfs` first. This patch adds a link to `zfs`, thus user can use both to initialize the completion. Fixes: #16320 Signed-off-by: Shengqi Chen Reviewed-by: Tony Hutter Reviewed-by: Rob Norris Reviewed-by: Tino Reichardt --- contrib/bash_completion.d/.gitignore | 1 + contrib/bash_completion.d/Makefile.am | 12 ++++++++---- rpm/generic/zfs.spec.in | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/contrib/bash_completion.d/.gitignore b/contrib/bash_completion.d/.gitignore index 0fd9cc63af2..217893a6bd8 100644 --- a/contrib/bash_completion.d/.gitignore +++ b/contrib/bash_completion.d/.gitignore @@ -1 +1,2 @@ /zfs +/zpool diff --git a/contrib/bash_completion.d/Makefile.am b/contrib/bash_completion.d/Makefile.am index 1ec05ed73d2..d3e6c0e7907 100644 --- a/contrib/bash_completion.d/Makefile.am +++ b/contrib/bash_completion.d/Makefile.am @@ -1,5 +1,9 @@ -nodist_bashcompletion_DATA = %D%/zfs -SUBSTFILES += $(nodist_bashcompletion_DATA) +nodist_bashcompletion_DATA = %D%/zfs %D%/zpool +COMPLETION_FILES = %D%/zfs +SUBSTFILES += $(COMPLETION_FILES) -SHELLCHECKSCRIPTS += $(nodist_bashcompletion_DATA) -$(call SHELLCHECK_OPTS,$(nodist_bashcompletion_DATA)): SHELLCHECK_SHELL = bash +SHELLCHECKSCRIPTS += $(COMPLETION_FILES) +$(call SHELLCHECK_OPTS,$(COMPLETION_FILES)): SHELLCHECK_SHELL = bash + +%D%/zpool: %D%/zfs + $(LN_S) zfs $@ diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in index 2e89abd0edf..c7a00c61f6b 100644 --- a/rpm/generic/zfs.spec.in +++ b/rpm/generic/zfs.spec.in @@ -532,6 +532,7 @@ systemctl --system daemon-reload >/dev/null || true %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/* %config(noreplace) %{_bashcompletiondir}/zfs +%config(noreplace) %{_bashcompletiondir}/zpool %files -n libzpool5 %{_libdir}/libzpool.so.* From 8d4ad5adc7e02283c6a1c75ce4a1a9840ec1382a Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Tue, 6 Aug 2024 01:17:23 +0200 Subject: [PATCH 4/8] ZTS: fix history_007_pos test on Ubuntu 24.04 (#16410) The timezone "US/Mountain" isn't supported on newer linux versions. Using the correct timezone "America/Denver" like it's done in FreeBSD will fix this. Older Linux distros should behave also okay with this. Signed-off-by: Tino Reichardt Reviewed-by: Tony Hutter Reviewed-by: George Melikov --- tests/zfs-tests/tests/functional/history/history.cfg | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/zfs-tests/tests/functional/history/history.cfg b/tests/zfs-tests/tests/functional/history/history.cfg index a508a793568..6020443bcdb 100644 --- a/tests/zfs-tests/tests/functional/history/history.cfg +++ b/tests/zfs-tests/tests/functional/history/history.cfg @@ -37,11 +37,7 @@ export TMP_HISTORY=$TEST_BASE_DIR/tmp_history.$$ export NEW_HISTORY=$TEST_BASE_DIR/new_history.$$ export MIGRATEDPOOLNAME=${MIGRATEDPOOLNAME:-history_pool} -if is_freebsd; then - export TIMEZONE=${TIMEZONE:-America/Denver} -else - export TIMEZONE=${TIMEZONE:-US/Mountain} -fi +export TIMEZONE=${TIMEZONE:-America/Denver} export HIST_USER="huser" export HIST_GROUP="hgroup" From e9f51ebd9482f86a55ceb9fb9e38ba82fd0bb8ba Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Tue, 6 Aug 2024 01:18:07 +0200 Subject: [PATCH 5/8] ZTS: fix zfs_copies_006_pos test on Ubuntu 20.04 (#16409) This test was failing before: - FAIL cli_root/zfs_copies/zfs_copies_006_pos (expected PASS) Signed-off-by: Tino Reichardt Reviewed-by: Tony Hutter Reviewed-by: George Melikov --- .../tests/functional/cli_root/zfs_copies/zfs_copies.kshlib | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib index 9911ccdf536..a7a93a3046d 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib @@ -153,5 +153,7 @@ function do_vol_test log_must umount $mntp fi + # Ubuntu 20.04 wants a sync here + log_must sync log_must zfs destroy $vol } From 6c82951d111bb4c8a426e5f58a87ac80a4996fc1 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 6 Aug 2024 09:56:45 +1000 Subject: [PATCH 6/8] FreeBSD: remove support for FreeBSD < 13.0-RELEASE (#16372) 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 Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Reviewed-by: Tony Hutter --- 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 af244c1fff1..a90736bb56b 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 e34bab7e896..48749fb8eea 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 909ae3886e9..32c10bdca90 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 8583df509b5..96ba10e5679 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 7583166e727..146fa9e5d13 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 7b3830be8a5..07ee6bc191a 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 75c32f221ff..76ea3eff379 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 7f0f24325d5..3e54f3e846f 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 95af6200cd0..ceaa2b40bea 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 f2dd7c8e7f8..42a693b073d 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 67c0a4c9413..e4b75f91b8f 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 724709ddee9..6af3da138f8 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 7f2b5c712c4..e3896517bd6 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 ed8d2407613..4d8493743ef 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 48ea37cbad5..0a0af102ea8 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 e774fbaaf86..ace0fa73401 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 9bd0c9ed81a..f883599f2da 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 38c1d8e9e46..b7ff1063b08 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 a753e91da4f..4d539461886 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 3cdb94d6cd5..00d499c8c63 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 b337932b9dc..bdb8c4fac77 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 b8f5fa4e754..928cf25e940 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 a972c720dfd..a6019549355 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 b9b332434bd..fd36dbd3003 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 afbea9798c3..e5c50874e1d 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 38e9debbe87..a53a5414146 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 2e0af60f6db..810550161f8 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); } From c7f70a017580cce358f39680e553b13ffc2c9864 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Mon, 10 Jun 2024 02:16:58 +0200 Subject: [PATCH 7/8] ZTS: Use QEMU for tests on Linux and FreeBSD This commit adds functional tests for these systems: - AlmaLinux 8, AlmaLinux 9 - ArchLinux - CentOS Stream 9 - Fedora 39, Fedora 40 - Debian 11, Debian 12 - FreeBSD 13, FreeBSD 14, FreeBSD 15 - Ubuntu 20.04, Ubuntu 22.04, Ubuntu 24.04 Workflow for each operating system: - install QEMU on the github runner - download current cloud image - start and init that image via cloud-init - install deps and poweroff system - start system and build openzfs and then poweroff again - clone the system and start qemu workers for parallel testings - do the functional testings, hopefully < 3h Signed-off-by: Tino Reichardt Signed-off-by: Tony Hutter --- .../{checkstyle.yaml => checkstyle.bak} | 0 .github/workflows/{codeql.yml => codeql.bak} | 0 .github/workflows/scripts/README.md | 9 + .github/workflows/scripts/merge_summary.awk | 109 ++++++++++ .github/workflows/scripts/qemu-1-setup.sh | 46 ++++ .github/workflows/scripts/qemu-2-start.sh | 196 ++++++++++++++++++ .github/workflows/scripts/qemu-3-deps.sh | 196 ++++++++++++++++++ .github/workflows/scripts/qemu-4-build.sh | 138 ++++++++++++ .github/workflows/scripts/qemu-5-setup.sh | 127 ++++++++++++ .github/workflows/scripts/qemu-6-tests.sh | 80 +++++++ .github/workflows/scripts/qemu-7-reports.sh | 80 +++++++ .github/workflows/scripts/qemu-8-summary.sh | 171 +++++++++++++++ ...fs-linux-tests.yml => zfs-linux-tests.bak} | 0 .../{zfs-linux.yml => zfs-linux.bak} | 0 .github/workflows/zfs-qemu.yml | 148 +++++++++++++ scripts/zfs-tests.sh | 65 +++++- 16 files changed, 1364 insertions(+), 1 deletion(-) rename .github/workflows/{checkstyle.yaml => checkstyle.bak} (100%) rename .github/workflows/{codeql.yml => codeql.bak} (100%) create mode 100644 .github/workflows/scripts/README.md create mode 100755 .github/workflows/scripts/merge_summary.awk create mode 100755 .github/workflows/scripts/qemu-1-setup.sh create mode 100755 .github/workflows/scripts/qemu-2-start.sh create mode 100755 .github/workflows/scripts/qemu-3-deps.sh create mode 100755 .github/workflows/scripts/qemu-4-build.sh create mode 100755 .github/workflows/scripts/qemu-5-setup.sh create mode 100755 .github/workflows/scripts/qemu-6-tests.sh create mode 100755 .github/workflows/scripts/qemu-7-reports.sh create mode 100755 .github/workflows/scripts/qemu-8-summary.sh rename .github/workflows/{zfs-linux-tests.yml => zfs-linux-tests.bak} (100%) rename .github/workflows/{zfs-linux.yml => zfs-linux.bak} (100%) create mode 100644 .github/workflows/zfs-qemu.yml diff --git a/.github/workflows/checkstyle.yaml b/.github/workflows/checkstyle.bak similarity index 100% rename from .github/workflows/checkstyle.yaml rename to .github/workflows/checkstyle.bak diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.bak similarity index 100% rename from .github/workflows/codeql.yml rename to .github/workflows/codeql.bak diff --git a/.github/workflows/scripts/README.md b/.github/workflows/scripts/README.md new file mode 100644 index 00000000000..5b2ba703e40 --- /dev/null +++ b/.github/workflows/scripts/README.md @@ -0,0 +1,9 @@ + +Workflow for each operating system: +- install qemu on the github runner +- download current cloud image of operating system +- start and init that image via cloud-init +- install dependencies and poweroff system +- start system and build openzfs and then poweroff again +- clone build system and start 3 instances of it +- the functional testings complete within times < 3h diff --git a/.github/workflows/scripts/merge_summary.awk b/.github/workflows/scripts/merge_summary.awk new file mode 100755 index 00000000000..2b00d00226c --- /dev/null +++ b/.github/workflows/scripts/merge_summary.awk @@ -0,0 +1,109 @@ +#!/bin/awk -f +# +# Merge multiple ZTS tests results summaries into a single summary. This is +# needed when you're running different parts of ZTS on different tests +# runners or VMs. +# +# Usage: +# +# ./merge_summary.awk summary1.txt [summary2.txt] [summary3.txt] ... +# +# or: +# +# cat summary*.txt | ./merge_summary.awk +# +BEGIN { + i=-1 + pass=0 + fail=0 + skip=0 + state="" + cl=0 + el=0 + upl=0 + ul=0 + + # Total seconds of tests runtime + total=0; +} + +# Skip empty lines +/^\s*$/{next} + +# Skip Configuration and Test lines +/^Test:/{state=""; next} +/Configuration/{state="";next} + +# When we see "test-runner.py" stop saving config lines, and +# save test runner lines +/test-runner.py/{state="testrunner"; runner=runner$0"\n"; next} + +# We need to differentiate the PASS counts from test result lines that start +# with PASS, like: +# +# PASS mv_files/setup +# +# Use state="pass_count" to differentiate +# +/Results Summary/{state="pass_count"; next} +/PASS/{ if (state=="pass_count") {pass += $2}} +/FAIL/{ if (state=="pass_count") {fail += $2}} +/SKIP/{ if (state=="pass_count") {skip += $2}} +/Running Time/{ + state=""; + running[i]=$3; + split($3, arr, ":") + total += arr[1] * 60 * 60; + total += arr[2] * 60; + total += arr[3] + next; +} + +/Tests with results other than PASS that are expected/{state="expected_lines"; next} +/Tests with result of PASS that are unexpected/{state="unexpected_pass_lines"; next} +/Tests with results other than PASS that are unexpected/{state="unexpected_lines"; next} +{ + if (state == "expected_lines") { + expected_lines[el] = $0 + el++ + } + + if (state == "unexpected_pass_lines") { + unexpected_pass_lines[upl] = $0 + upl++ + } + if (state == "unexpected_lines") { + unexpected_lines[ul] = $0 + ul++ + } +} + +# Reproduce summary +END { + print runner; + print "\nResults Summary" + print "PASS\t"pass + print "FAIL\t"fail + print "SKIP\t"skip + print "" + print "Running Time:\t"strftime("%T", total, 1) + if (pass+fail+skip > 0) { + percent_passed=(pass/(pass+fail+skip) * 100) + } + printf "Percent passed:\t%3.2f%", percent_passed + + print "\n\nTests with results other than PASS that are expected:" + asort(expected_lines, sorted) + for (j in sorted) + print sorted[j] + + print "\n\nTests with result of PASS that are unexpected:" + asort(unexpected_pass_lines, sorted) + for (j in sorted) + print sorted[j] + + print "\n\nTests with results other than PASS that are unexpected:" + asort(unexpected_lines, sorted) + for (j in sorted) + print sorted[j] +} diff --git a/.github/workflows/scripts/qemu-1-setup.sh b/.github/workflows/scripts/qemu-1-setup.sh new file mode 100755 index 00000000000..c371b71f55d --- /dev/null +++ b/.github/workflows/scripts/qemu-1-setup.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +###################################################################### +# 1) setup qemu instance on action runner +###################################################################### + +set -eu + +# install needed packages +sudo apt-get update +sudo apt-get install axel cloud-image-utils daemonize guestfs-tools \ + ksmtuned virt-manager linux-modules-extra-`uname -r` + +# generate ssh keys +rm -f ~/.ssh/id_ed25519 +ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -q -N "" + +# no need for some scheduler +for i in /sys/block/s*/queue/scheduler; do + echo "none" | sudo tee $i > /dev/null +done + +# this one is fast and mostly free +sudo mount -o remount,rw,noatime,barrier=0 /mnt + +# we expect RAM shortage +cat << EOF | sudo tee /etc/ksmtuned.conf > /dev/null +KSM_MONITOR_INTERVAL=60 + +# Millisecond sleep between ksm scans for 16Gb server. +# Smaller servers sleep more, bigger sleep less. +KSM_SLEEP_MSEC=10 +KSM_NPAGES_BOOST=300 +KSM_NPAGES_DECAY=-50 +KSM_NPAGES_MIN=64 +KSM_NPAGES_MAX=2048 + +KSM_THRES_COEF=20 +KSM_THRES_CONST=2048 + +LOGFILE=/var/log/ksmtuned.log +DEBUG=1 +EOF + +sudo systemctl restart ksm +sudo systemctl restart ksmtuned diff --git a/.github/workflows/scripts/qemu-2-start.sh b/.github/workflows/scripts/qemu-2-start.sh new file mode 100755 index 00000000000..870432edbb6 --- /dev/null +++ b/.github/workflows/scripts/qemu-2-start.sh @@ -0,0 +1,196 @@ +#!/usr/bin/env bash + +###################################################################### +# 2) start qemu with some operating system, init via cloud-init +###################################################################### + +set -eu + +# short name used in zfs-qemu.yml +OS="$1" + +# OS variant (virt-install --os-variant list) +OSv=$OS + +# compressed with .zst extension +FREEBSD="https://github.com/mcmilk/openzfs-freebsd-images/releases/download/v2024-07-24" +URLzs="" + +# Ubuntu mirrors +#UBMIRROR="https://cloud-images.ubuntu.com" +#UBMIRROR="https://mirrors.cloud.tencent.com/ubuntu-cloud-images" +UBMIRROR="https://mirror.citrahost.com/ubuntu-cloud-images" + +case "$OS" in + almalinux8) + OSNAME="AlmaLinux 8" + URL="https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2" + ;; + almalinux9) + OSNAME="AlmaLinux 9" + URL="https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2" + ;; + archlinux) + OSNAME="Archlinux" + URL="https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2" + ;; + centos-stream9) + OSNAME="CentOS Stream 9" + URL="https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2" + ;; + debian11) + OSNAME="Debian 11" + URL="https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2" + ;; + debian12) + OSNAME="Debian 12" + URL="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2" + ;; + fedora39) + OSNAME="Fedora 39" + OSv="fedora39" + URL="https://download.fedoraproject.org/pub/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-39-1.5.x86_64.qcow2" + ;; + fedora40) + OSNAME="Fedora 40" + OSv="fedora39" + URL="https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2" + ;; + freebsd13) + OSNAME="FreeBSD 13 (Stable)" + OSv="freebsd13.0" + URLzs="$FREEBSD/amd64-freebsd-13.3-STABLE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd13r) + OSNAME="FreeBSD 13 (Release)" + OSv="freebsd13.0" + URLzs="$FREEBSD/amd64-freebsd-13.3-RELEASE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd14) + OSNAME="FreeBSD 14 (Stable)" + OSv="freebsd14.0" + URLzs="$FREEBSD/amd64-freebsd-14.1-STABLE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd14r) + OSNAME="FreeBSD 14 (Release)" + OSv="freebsd14.0" + URLzs="$FREEBSD/amd64-freebsd-14.1-RELEASE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd15) + OSNAME="FreeBSD 15 (Current)" + OSv="freebsd14.0" + URLzs="$FREEBSD/amd64-freebsd-15.0-CURRENT.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + tumbleweed) + OSNAME="openSUSE Tumbleweed" + OSv="opensusetumbleweed" + MIRROR="http://opensuse-mirror-gce-us.susecloud.net" + URL="$MIRROR/tumbleweed/appliances/openSUSE-MicroOS.x86_64-OpenStack-Cloud.qcow2" + ;; + ubuntu20) + OSNAME="Ubuntu 20.04" + OSv="ubuntu20.04" + URL="$UBMIRROR/focal/current/focal-server-cloudimg-amd64.img" + ;; + ubuntu22) + OSNAME="Ubuntu 22.04" + OSv="ubuntu22.04" + URL="$UBMIRROR/jammy/current/jammy-server-cloudimg-amd64.img" + ;; + ubuntu24) + OSNAME="Ubuntu 24.04" + OSv="ubuntu24.04" + URL="$UBMIRROR/noble/current/noble-server-cloudimg-amd64.img" + ;; + *) + echo "Wrong value for variable OS!" + exit 111 + ;; +esac + +# freebsd15 -> used in zfs-qemu.yml +echo "$OS" > /var/tmp/os.txt + +# freebsd14.0 -> used for virt-install +echo "$OSv" > /var/tmp/osvariant.txt + +# FreeBSD 15 (Current) -> used for summary +echo "$OSNAME" > /var/tmp/osname.txt + +IMG="/mnt/tests/cloudimg.qcow2" +DISK="/mnt/tests/openzfs.qcow2" +sudo mkdir -p "/mnt/tests" +sudo chown $(whoami) /mnt/tests + +if [ ! -z "$URLzs" ]; then + echo "Loading image $URLzs ..." + time axel -q -o "$IMG.zst" "$URLzs" + zstd -q -d --rm "$IMG.zst" +else + echo "Loading image $URL ..." + time axel -q -o "$IMG" "$URL" +fi + +qemu-img convert -q -f qcow2 -O qcow2 -c \ + -o compression_type=zstd,cluster_size=256k $IMG $DISK +rm -f $IMG + +echo "Resizing image to 60GiB ..." +qemu-img resize -q $DISK 60G + +PUBKEY=`cat ~/.ssh/id_ed25519.pub` +cat < /tmp/user-data +#cloud-config + +fqdn: $OS + +# user:zfs password:1 +users: +- name: root + shell: $BASH +- name: zfs + sudo: ALL=(ALL) NOPASSWD:ALL + shell: $BASH + lock-passwd: false + passwd: \$1\$EjKAQetN\$O7Tw/rZOHaeBP1AiCliUg/ + ssh_authorized_keys: + - $PUBKEY + +growpart: + mode: auto + devices: ['/'] + ignore_growroot_disabled: false +EOF + +sudo virsh net-update default add ip-dhcp-host \ + "" --live --config + +sudo virt-install \ + --os-variant $OSv \ + --name "openzfs" \ + --cpu host-passthrough \ + --virt-type=kvm --hvm \ + --vcpus=4,sockets=1 \ + --memory $((1024*12)) \ + --memballoon model=virtio \ + --graphics none \ + --network bridge=virbr0,model=e1000,mac='52:54:00:83:79:00' \ + --cloud-init user-data=/tmp/user-data \ + --disk $DISK,bus=virtio,cache=none,format=qcow2,driver.discard=unmap \ + --import --noautoconsole >/dev/null + +# in case the directory isn't there already +mkdir -p $HOME/.ssh + +cat <> $HOME/.ssh/config +# no questions please +StrictHostKeyChecking no + +# small timeout, used in while loops +ConnectTimeout 1 +EOF diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh new file mode 100755 index 00000000000..d30823b0498 --- /dev/null +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -0,0 +1,196 @@ +#!/usr/bin/env bash + +###################################################################### +# 3) install dependencies for compiling and loading +###################################################################### + +set -eu + +function archlinux() { + echo "##[group]Running pacman -Syu" + sudo pacman -Syu --noconfirm + echo "##[endgroup]" + + echo "##[group]Install Development Tools" + sudo pacman -Sy --noconfirm base-devel bc cpio dhclient dkms fakeroot \ + fio gdb inetutils less linux linux-headers lsscsi nfs-utils parted pax \ + perf python-packaging python-setuptools qemu-guest-agent ksh samba \ + sysstat rng-tools rsync wget + echo "##[endgroup]" +} + +function debian() { + export DEBIAN_FRONTEND="noninteractive" + + echo "##[group]Running apt-get update+upgrade" + sudo apt-get update -y + sudo apt-get upgrade -y + echo "##[endgroup]" + + echo "##[group]Install Development Tools" + sudo apt-get install -y \ + acl alien attr autoconf bc cpio curl dbench dh-python \ + dkms fakeroot fio gdb gdebi git ksh lcov \ + isc-dhcp-client libacl1-dev libaio-dev libattr1-dev libblkid-dev \ + libcurl4-openssl-dev libdevmapper-dev libelf-dev libffi-dev \ + libmount-dev libpam0g-dev libselinux-dev libssl-dev libtool \ + libtool-bin libudev-dev linux-headers-$(uname -r) lsscsi \ + nfs-kernel-server pamtester parted python3 python3-all-dev \ + python3-cffi python3-dev python3-distlib python3-packaging \ + python3-setuptools python3-sphinx qemu-guest-agent rng-tools \ + rpm2cpio rsync samba sysstat uuid-dev watchdog wget xfslibs-dev \ + zlib1g-dev + echo "##[endgroup]" +} + +function freebsd() { + export ASSUME_ALWAYS_YES="YES" + + echo "##[group]Install Development Tools" + sudo pkg install -y autoconf automake autotools base64 checkbashisms fio \ + gdb gettext gettext-runtime git gmake gsed ksh93 lcov libtool lscpu \ + pkgconf python python3 pamtester pamtester qemu-guest-agent rsync + sudo pkg install -xy \ + '^samba4[[:digit:]]+$' \ + '^py3[[:digit:]]+-cffi$' \ + '^py3[[:digit:]]+-sysctl$' \ + '^py3[[:digit:]]+-packaging$' + echo "##[endgroup]" +} + +# common packages for: almalinux, centos, redhat +function rhel() { + echo "##[group]Running dnf update" + echo "max_parallel_downloads=10" | sudo -E tee -a /etc/dnf/dnf.conf + sudo dnf clean all + sudo dnf update -y --setopt=fastestmirror=1 --refresh + echo "##[endgroup]" + + echo "##[group]Install Development Tools" + sudo dnf group install -y "Development Tools" + sudo dnf install -y \ + acl attr bc bzip2 curl dbench dkms elfutils-libelf-devel fio gdb git \ + kernel-rpm-macros ksh libacl-devel libaio-devel libargon2-devel \ + libattr-devel libblkid-devel libcurl-devel libffi-devel ncompress \ + libselinux-devel libtirpc-devel libtool libudev-devel libuuid-devel \ + lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester parted perf \ + python3 python3-cffi python3-devel python3-packaging kernel-devel \ + python3-setuptools qemu-guest-agent rng-tools rpcgen rpm-build rsync \ + samba sysstat systemd watchdog wget xfsprogs-devel zlib-devel + echo "##[endgroup]" +} + +function tumbleweed() { + echo "##[group]Running zypper is TODO!" + sleep 23456 + echo "##[endgroup]" +} + +# Install dependencies +case "$1" in + almalinux8) + echo "##[group]Enable epel and powertools repositories" + sudo dnf config-manager -y --set-enabled powertools + sudo dnf install -y epel-release + echo "##[endgroup]" + rhel + echo "##[group]Install kernel-abi-whitelists" + sudo dnf install -y kernel-abi-whitelists + echo "##[endgroup]" + ;; + almalinux9|centos-stream9) + echo "##[group]Enable epel and crb repositories" + sudo dnf config-manager -y --set-enabled crb + sudo dnf install -y epel-release + echo "##[endgroup]" + rhel + echo "##[group]Install kernel-abi-stablelists" + sudo dnf install -y kernel-abi-stablelists + echo "##[endgroup]" + ;; + archlinux) + archlinux + ;; + debian*) + debian + echo "##[group]Install Debian specific" + sudo apt-get install -yq linux-perf dh-sequence-dkms + echo "##[endgroup]" + ;; + fedora*) + rhel + ;; + freebsd*) + freebsd + ;; + tumbleweed) + tumbleweed + ;; + ubuntu*) + debian + echo "##[group]Install Ubuntu specific" + sudo apt-get install -yq linux-tools-common libtirpc-dev \ + linux-modules-extra-$(uname -r) + if [ "$1" != "ubuntu20" ]; then + sudo apt-get install -yq dh-sequence-dkms + fi + echo "##[endgroup]" + echo "##[group]Delete Ubuntu OpenZFS modules" + for i in `find /lib/modules -name zfs -type d`; do sudo rm -rvf $i; done + echo "##[endgroup]" + ;; +esac + +# Start services +echo "##[group]Enable services" +case "$1" in + freebsd*) + # add virtio things + #echo 'virtio_load="YES"' | sudo -E tee -a /boot/loader.conf + #for i in balloon blk console random scsi; do + # echo "virtio_${i}_load=\"YES\"" | sudo -E tee -a /boot/loader.conf + #done + echo "fdescfs /dev/fd fdescfs rw 0 0" | sudo -E tee -a /etc/fstab + sudo -E mount /dev/fd + sudo -E touch /etc/zfs/exports + sudo -E sysrc mountd_flags="/etc/zfs/exports" + echo '[global]' | sudo -E tee /usr/local/etc/smb4.conf >/dev/null + sudo -E service nfsd enable + sudo -E service qemu-guest-agent enable + sudo -E service samba_server enable + ;; + debian*|ubuntu*) + sudo -E systemctl enable nfs-kernel-server + sudo -E systemctl enable qemu-guest-agent + sudo -E systemctl enable smbd + ;; + *) + # All other linux distros + sudo -E systemctl enable nfs-server + sudo -E systemctl enable qemu-guest-agent + sudo -E systemctl enable smb + ;; +esac +echo "##[endgroup]" + +# Enable serial console and remove 'quiet' from linux kernel cmdline +case "$1" in + freebsd*) + true + ;; + *) + echo "##[group]Enable serial output" + sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,115200n8 random.trust_cpu=on/g; s/quiet //g' /etc/default/grub || true + for i in /boot/grub/grub.cfg /etc/grub2.cfg /etc/grub2-efi.cfg /boot/grub2/grub.cfg ; do + test -e $i || continue + echo sudo grub-mkconfig -o $i + sudo grub-mkconfig -o $i + done + echo "##[endgroup]" + ;; +esac + +# reset cloud-init configuration and poweroff +sudo cloud-init clean --logs +sleep 2 && sudo poweroff & +exit 0 diff --git a/.github/workflows/scripts/qemu-4-build.sh b/.github/workflows/scripts/qemu-4-build.sh new file mode 100755 index 00000000000..0d3f9017e44 --- /dev/null +++ b/.github/workflows/scripts/qemu-4-build.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash + +###################################################################### +# 4) configure and build openzfs modules +###################################################################### + +set -eu + +function run() { + LOG="/var/tmp/build-stderr.txt" + echo "**************************************************" + echo "`date` ($*)" + echo "**************************************************" + $@ 2>>$LOG +} + +function freebsd() { + export MAKE="gmake" + echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure \ + --prefix=/usr/local \ + --with-libintl-prefix=/usr/local \ + --enable-pyzfs \ + --enable-debug \ + --enable-debuginfo + echo "##[endgroup]" + + echo "##[group]Build" + run gmake -j`sysctl -n hw.ncpu` + echo "##[endgroup]" + + echo "##[group]Install" + run sudo gmake install + echo "##[endgroup]" +} + +function linux() { + echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure \ + --prefix=/usr \ + --enable-pyzfs \ + --enable-debug \ + --enable-debuginfo + echo "##[endgroup]" + + echo "##[group]Build" + run make -j$(nproc) + echo "##[endgroup]" + + echo "##[group]Install" + run sudo make install + echo "##[endgroup]" +} + +function rpm_build_and_install() { + EXTRA_CONFIG="${1:-}" + echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure --enable-debug --enable-debuginfo $EXTRA_CONFIG + echo "##[endgroup]" + + echo "##[group]Build" + run make pkg-kmod pkg-utils + echo "##[endgroup]" + + echo "##[group]Install" + run sudo yum -y --skip-broken localinstall $(ls *.rpm | grep -v src.rpm) + echo "##[endgroup]" + +} + +function deb_build_and_install() { +echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure \ + --prefix=/usr \ + --enable-pyzfs \ + --enable-debug \ + --enable-debuginfo + echo "##[endgroup]" + + echo "##[group]Build" + run make native-deb-kmod native-deb-utils + echo "##[endgroup]" + + echo "##[group]Install" + # Do kmod install. Note that when you build the native debs, the + # packages themselves are placed in parent directory '../' rather than + # in the source directory like the rpms are. + run sudo apt-get -y install `find ../ | grep -E '\.deb$' | grep -Ev 'dkms|dracut'` + echo "##[endgroup]" +} + +# Debug: show kernel cmdline +if [ -e /proc/cmdline ] ; then + cat /proc/cmdline || true +fi + +cd $HOME/zfs +export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin" + +# build +case "$1" in + freebsd*) + freebsd + ;; + alma*|centos*) + rpm_build_and_install "--with-spec=redhat" + ;; + fedora*) + rpm_build_and_install + ;; + debian*|ubuntu*) + deb_build_and_install + ;; + *) + linux + ;; +esac + +# reset cloud-init configuration and poweroff +sudo cloud-init clean --logs +sleep 2 && sudo poweroff & +exit 0 diff --git a/.github/workflows/scripts/qemu-5-setup.sh b/.github/workflows/scripts/qemu-5-setup.sh new file mode 100755 index 00000000000..47a04cfd29d --- /dev/null +++ b/.github/workflows/scripts/qemu-5-setup.sh @@ -0,0 +1,127 @@ +#!/usr/bin/env bash + +###################################################################### +# 5) start test machines and load openzfs module +###################################################################### + +set -eu + +# wait for poweroff to succeed +PID=`pidof /usr/bin/qemu-system-x86_64` +tail --pid=$PID -f /dev/null +sudo virsh undefine openzfs + +PUBKEY=`cat ~/.ssh/id_ed25519.pub` +OSv=`cat /var/tmp/osvariant.txt` +OS=`cat /var/tmp/os.txt` + +# NOT OKAY: +# 2x CPU=4 RAM=7 -> AlmaLinux 9 (3h) - fault/auto_replace_002_pos +# 2x CPU=4 RAM=7 -> CentOS 9 (3h 2m) - io/io_uring + cli_root/zpool_status/zpool_status_008_pos +# 2x CPU=4 RAM=7 -> Fedora 39 (3h 28m) - fault/auto_spare_001_pos +# 2x CPU=4 RAM=7 -> Ubuntu 20 (2h 49m) - cli_root/zfs_copies/zfs_copies_006_pos !!?? +# 2x CPU=4 RAM=7 -> Ubuntu 24 (3h 10m) - history/history_007_pos (always!) + +# re-definition of cpu and ram per operating system +case "$OS" in + freebsd*) + # 2x CPU=4 RAM=6 -> FreeBSD 13 (2h 10m) + # 2x CPU=4 RAM=6 -> FreeBSD 13r (2h 10m) + # 2x CPU=4 RAM=6 -> FreeBSD 14 (2h 10m) + # 2x CPU=4 RAM=6 -> FreeBSD 14r (2h 10m) + VMs=2 + CPU=4 + RAM=6 + ;; + *) + # 2x CPU=4 RAM=7 -> Almalinux 8 (3h 12m) + # 2x CPU=4 RAM=7 -> Debian 11 (3h 11m) + # 2x CPU=4 RAM=7 -> Ubuntu 22 (3h 26m) + # 2x CPU=4 RAM=7 -> Fedora40 (3h 33m) + VMs=2 + CPU=4 + RAM=7 + ;; +esac + +echo $VMs > /var/tmp/vms.txt + +for i in `seq 1 $VMs`; do + echo "Generating disk for vm$i..." + sudo qemu-img create -q -f qcow2 -F qcow2 \ + -o compression_type=zstd,cluster_size=256k \ + -b /mnt/tests/openzfs.qcow2 "/mnt/tests/vm$i.qcow2" + + cat < /tmp/user-data +#cloud-config + +fqdn: vm$i + +# user:zfs password:1 +users: +- name: root + shell: $BASH +- name: zfs + sudo: ALL=(ALL) NOPASSWD:ALL + shell: $BASH + lock-passwd: false + passwd: \$1\$EjKAQetN\$O7Tw/rZOHaeBP1AiCliUg/ + ssh_authorized_keys: + - $PUBKEY + +growpart: + mode: auto + devices: ['/'] + ignore_growroot_disabled: false +EOF + + sudo virsh net-update default add ip-dhcp-host \ + "" --live --config + + sudo virt-install \ + --os-variant $OSv \ + --name "vm$i" \ + --cpu host-passthrough \ + --virt-type=kvm --hvm \ + --vcpus=$CPU,sockets=1 \ + --memory $((1024*RAM)) \ + --memballoon model=virtio \ + --graphics none \ + --cloud-init user-data=/tmp/user-data \ + --network bridge=virbr0,model=e1000,mac="52:54:00:83:79:0$i" \ + --disk /mnt/tests/vm$i.qcow2,bus=virtio,cache=none,format=qcow2,driver.discard=unmap \ + --import --noautoconsole >/dev/null +done + +# trim the qcow2 files +echo "exec 1>/dev/null 2>/dev/null" > cronjob.sh +for i in `seq 1 $VMs`; do + echo "virsh domfstrim vm$i" >> cronjob.sh +done +echo "fstrim /mnt" >> cronjob.sh +sudo chmod +x cronjob.sh +sudo mv -f cronjob.sh /root/cronjob.sh +echo '*/30 * * * * /root/cronjob.sh' > crontab.txt +sudo crontab crontab.txt +rm crontab.txt + +# check if the machines are okay +echo "Waiting for vm's to come up... (${VMs}x CPU=$CPU RAM=$RAM)" +for i in `seq 1 $VMs`; do + while true; do + ssh 2>/dev/null zfs@192.168.122.1$i "uname -a" && break + done +done +echo "All $VMs VMs are up now." + +# Save the VM's serial output (ttyS0) to /var/tmp/console.txt +# - ttyS0 on the VM corresponds to a local /dev/pty/N entry +# - use 'virsh ttyconsole' to lookup the /dev/pty/N entry +RESPATH="/var/tmp/test_results" +for i in `seq 1 $VMs`; do + mkdir -p $RESPATH/vm$i + read "pty" <<< $(sudo virsh ttyconsole vm$i) + sudo nohup bash -c "cat $pty > $RESPATH/vm$i/console.txt" & +done +OS=`cat /var/tmp/osname.txt` +echo "Console logging for $OS started." diff --git a/.github/workflows/scripts/qemu-6-tests.sh b/.github/workflows/scripts/qemu-6-tests.sh new file mode 100755 index 00000000000..488dee801d8 --- /dev/null +++ b/.github/workflows/scripts/qemu-6-tests.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +###################################################################### +# 6) load openzfs module and run the tests +# +# called via runner: +# - qemu-6-tests.sh $OS $VMs +# +# called on qemu machine: +# - qemu-6-tests.sh $OS $VMcur $VMmax +###################################################################### + +set -o pipefail + +# called directly on the runner +if [ -f /var/tmp/vms.txt ]; then + OS=`cat /var/tmp/os.txt` + VMs=`cat /var/tmp/vms.txt` + + P="/var/tmp" + SSH=`which ssh` + BASE="$HOME/work/zfs/zfs" + TESTS='$HOME/zfs/.github/workflows/scripts/qemu-6-tests.sh' + COLOR="$BASE/scripts/zfs-tests-color.sh" + + cd $P + df -h /mnt/tests > df-prerun.txt + for i in `seq 1 $VMs`; do + IP="192.168.122.1$i" + daemonize -c $P -p vm${i}.pid -o vm${i}log.txt -- \ + $SSH zfs@$IP $TESTS $OS $i $VMs + # give us the output of stdout + stderr - with prefix ;) + tail -fq vm${i}log.txt | $COLOR | sed -e "s/^/vm${i}: /g" & + echo $! > vm${i}log.pid + done + + # wait for all vm's to finish + for i in `seq 1 $VMs`; do + tail --pid=`cat vm${i}.pid` -f /dev/null + pid=`cat vm${i}log.pid` + rm -f vm${i}log.pid + kill $pid + done + + # df statistics - keep an eye on disk usage + du -sh /mnt/tests >> df-postrun.txt + df -h /mnt/tests >> df-postrun.txt + + exit 0 +fi + +# called within vm +export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin" + +case "$1" in + freebsd*) + # when freebsd's zfs is loaded, unload this one + sudo kldstat -n zfs 2>/dev/null && sudo kldunload zfs + sudo -E ./zfs/scripts/zfs.sh + sudo dmesg -c > /var/tmp/dmesg-prerun.txt + TDIR="/usr/local/share/zfs" + ;; + *) + sudo -E modprobe zfs + sudo dmesg -c > /var/tmp/dmesg-prerun.txt + TDIR="/usr/share/zfs" + ;; +esac + +# this part runs inside qemu, finally: run tests +cd /var/tmp +uname -a > uname.txt + +# run functional testings +$TDIR/zfs-tests.sh -vK -s 3G -T $2/$3 +RV=$? + +# we wont fail here, this will be done later +echo $RV > exitcode.txt +exit 0 diff --git a/.github/workflows/scripts/qemu-7-reports.sh b/.github/workflows/scripts/qemu-7-reports.sh new file mode 100755 index 00000000000..3338f491166 --- /dev/null +++ b/.github/workflows/scripts/qemu-7-reports.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +###################################################################### +# 7) output the results of the previous stage in an ordered way +###################################################################### + +set -o pipefail + +cd /var/tmp +OS=`cat os.txt` + +# build failed +if [ ! -s vms.txt ]; then + scp -r 2>/dev/null zfs@192.168.122.10:/var/tmp . + tar cf /tmp/qemu-$OS.tar -C /var/tmp -h . || true + exit 0 +fi + +VMs=`cat vms.txt` + +# build was okay +echo "********************************************************************" +echo "Disk usage before:" +cat df-prerun.txt + +echo "Disk usage afterwards:" +cat df-postrun.txt +echo "********************************************************************" + +FAIL="FAIL" +PASS="PASS" + +BASE="$HOME/work/zfs/zfs" + +# exit code of testing, default is "all good 0" +RV=0 + +for i in `seq 1 $VMs`; do + f="exitcode.vm$i" + scp 2>/dev/null zfs@192.168.122.1$i:/var/tmp/exitcode.txt $f + test -f $f || echo 2 > $f + rv=`cat $f` + if [ $rv != 0 ]; then + msg=$FAIL + RV=$rv + else + msg=$PASS + fi + + echo "##[group]Results vm$i [$msg]" + cat "vm${i}log.txt" | $BASE/scripts/zfs-tests-color.sh + echo "##[endgroup]" +done + +# all tests without grouping: +MERGE="$BASE/.github/workflows/scripts/merge_summary.awk" +$MERGE vm*log.txt | $BASE/scripts/zfs-tests-color.sh + +RESPATH="/var/tmp/test_results" +for i in `seq 1 $VMs`; do + rsync -arL zfs@192.168.122.1$i:$RESPATH/current $RESPATH/vm$i || true + scp zfs@192.168.122.1$i:"/var/tmp/*.txt" $RESPATH/vm$i || true +done +cp -f /var/tmp/*.txt $RESPATH || true +tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true + +echo "********************************************************************" + +echo "TODO: debug messages ..." +echo "TODO: serial messages ..." +echo "TODO: dmesg messages ..." + +# FreeBSD findings: +# lock order reversal: -> FreeBSD problem +# +# Linux findings: +# "] PANIC at " .. "] " -> Linux Ops + +echo "********************************************************************" +exit $RV diff --git a/.github/workflows/scripts/qemu-8-summary.sh b/.github/workflows/scripts/qemu-8-summary.sh new file mode 100755 index 00000000000..f5007c654ab --- /dev/null +++ b/.github/workflows/scripts/qemu-8-summary.sh @@ -0,0 +1,171 @@ +#!/usr/bin/env bash + +###################################################################### +# generate github summary page of all the testings +###################################################################### + +# max size in KiB of debug output +DEBUG_MAX="100" + +function output() { + echo -e $* >> "out-$logfile.md" +} + +function outfile() { + CUR=`stat --printf="%s" "out-$logfile.md"` + ADD=`stat --printf="%s" "$1"` + X=$((CUR+ADD)) + if [ $X -gt $((1024*1023)) ]; then + logfile=$((logfile+1)) + fi + cat "$1" >> "out-$logfile.md" +} + +function showfile() { + cont=`cat $1` + hl="$2" +cat < tmp +
+ +$hl + +
$cont
+ +
+EOF + outfile tmp + rm -f tmp +} + +function send2github() { + test -f "$1" || exit 0 + dd if="$1" bs=1023k count=1 >> $GITHUB_STEP_SUMMARY +} + +function check_copy() { + test -s "$1" || return 0 + cat $1 > $2 +} + +# generate summary of one test +function generate() { + #################################################################### + # osname.txt -> used for headline + # vm${N}log.txt -> output of ssh/tail - used for merged summary + # vm${N}/build-stderr.txt -> used once + #################################################################### + # vm${N}/console.txt -> all 3 used + # vm${N}/dmesg-prerun.txt -> used once + # vm${N}/uname.txt -> all 3 used + # vm${N}/current/log -> if not there, kernel panic loading + # vm${N}/current/results -> if not there, kernel panic testings + # vm${N}/exitcode.txt -> exitcode of testings partN + #################################################################### + + # headline of this summary + logfile=$((logfile+1)) + osname=`cat osname.txt` + VMs=`cat vms.txt` + + output "\n# Functional Tests: $osname\n" + for i in `seq 1 $VMs`; do + for f in build-stderr.txt dmesg-prerun.txt; do + check_copy vm$i/$f $f + touch $f + done + for f in uname.txt; do + test -s vm$i/$f && cat vm$i/$f >> $f + touch $f + done + done + + output "
"
+  outfile uname.txt
+  output "
" + + showfile "build-stderr.txt" "Module build (stderr output)" + showfile "dmesg-prerun.txt" "Dmesg output (vm start and module load)" + + for i in `seq 1 $VMs`; do + log="vm$i/current/log" + + FAIL=0 + if [ ! -s "$log" ]; then + output ":exclamation: Logfile of vm$i is missing :exclamation:" + FAIL=1 + fi + + if [ ! -s "vm$i/current/results" ]; then + output ":exclamation: Results file of vm$i is missing :exclamation:" + FAIL=1 + fi + + console="vm$i/console.txt" + dprerun="vm$i/dmesg-prerun.txt" + test -s "$console" && showfile "$console" "vm$i: serial console output" + test -s "$dprerun" && showfile "$dprerun" "vm$i: dmesg kernel output" + + # no log or resultfile, skip presenting them + test $FAIL != 0 && continue + + awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; } \ + /\[SKIP\]|\[PASS\]/{ show=0; } show' $log > debug.txt + S=`stat --printf="%s" "debug.txt"` + if [ $S -gt $((1024*DEBUG_MAX)) ]; then + dd if=debug.txt of=debug-vm$i.txt count=$DEBUG_MAX bs=1024 2>/dev/null + echo "..." >> debug-vm$i.txt + echo "!!! THIS FILE IS BIGGER !!!" >> debug-vm$i.txt + echo "Please download the zip archiv for full content!" >> debug-vm$i.txt + else + mv -f debug.txt debug-vm$i.txt + fi + done + + # /home/runner/work/zfs/zfs/.github/workflows/scripts/merge_summary.awk + BASE="$HOME/work/zfs/zfs" + MERGE="$BASE/.github/workflows/scripts/merge_summary.awk" + $MERGE vm*log.txt > merge.txt + test -s "merge.txt" && showfile "merge.txt" "Test Summary" + + for f in debug-vm*.txt; do + test -s $f || continue + S=`stat --printf="%s" "$f"` + KB=`echo "$S/1024"|bc` + showfile "$f" "Debug file $f: $KB KiB" + done +} + +# functional tests via qemu +function summarize() { + for tarfile in Logs-functional-*/qemu-*.tar; do + if [ ! -s "$tarfile" ]; then + output "\n# Functional Tests: unknown\n" + output ":exclamation: Tarfile $tarfile is empty :exclamation:" + continue + fi + rm -rf vm* *.txt + tar xf "$tarfile" + generate + done +} + +# https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits +# Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB. +# [ ] can not show all error findings here +# [x] split files into smaller ones and create additional steps + +# first call, generate all summaries +if [ ! -f out-1.md ]; then + # create ./zts-report.py for generate() + TEMPLATE="tests/test-runner/bin/zts-report.py.in" + cat $TEMPLATE| sed -e 's|@PYTHON_SHEBANG@|python3|' > ./zts-report.py + chmod +x ./zts-report.py + + logfile="0" + summarize + send2github out-1.md +else + send2github out-$1.md +fi + +exit 0 diff --git a/.github/workflows/zfs-linux-tests.yml b/.github/workflows/zfs-linux-tests.bak similarity index 100% rename from .github/workflows/zfs-linux-tests.yml rename to .github/workflows/zfs-linux-tests.bak diff --git a/.github/workflows/zfs-linux.yml b/.github/workflows/zfs-linux.bak similarity index 100% rename from .github/workflows/zfs-linux.yml rename to .github/workflows/zfs-linux.bak diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml new file mode 100644 index 00000000000..bfcbb468f59 --- /dev/null +++ b/.github/workflows/zfs-qemu.yml @@ -0,0 +1,148 @@ +name: zfs-qemu + +on: + push: + pull_request: + +jobs: + + qemu-vm: + name: qemu-vm + strategy: + fail-fast: false + matrix: + # all: + # os: [almalinux8, almalinux9, archlinux, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] + os: [almalinux8, almalinux9, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] + # openzfs: + # os: [almalinux8, almalinux9, centos-stream9, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] + # freebsd: + # os: [freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup SSH + run: | + mkdir -p $HOME/.ssh + echo "ConnectTimeout 1" >> $HOME/.ssh/config + echo "StrictHostKeyChecking no" >> $HOME/.ssh/config + echo "${{ secrets.AUTHORIZED_KEYS }}" >> $HOME/.ssh/authorized_keys + echo "${{ secrets.SSH_KEY }}" > $HOME/.ssh/id_ed25519 + echo "${{ secrets.KNOWN_HOSTS }}" >> $HOME/.ssh/known_hosts + chmod 600 $HOME/.ssh/id_ed25519 + R=`shuf -n 1 -i 10000-60000` + echo "Port $R" + ssh -x -N -C -f -R $R:127.0.0.1:22 mcmilk@${{ secrets.SOME_HOST }} + + - name: Setup QEMU + timeout-minutes: 10 + run: .github/workflows/scripts/qemu-1-setup.sh + + - name: Start build machine + timeout-minutes: 10 + run: .github/workflows/scripts/qemu-2-start.sh ${{ matrix.os }} + + - name: Install dependencies + timeout-minutes: 20 + run: | + echo "Install dependencies in QEMU machine" + IP=192.168.122.10 + while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do + ssh 2>/dev/null zfs@$IP "uname -a" && break + done + scp .github/workflows/scripts/qemu-3-deps.sh zfs@$IP:qemu-3-deps.sh + PID=`pidof /usr/bin/qemu-system-x86_64` + ssh zfs@$IP '$HOME/qemu-3-deps.sh' ${{ matrix.os }} + # wait for poweroff to succeed + tail --pid=$PID -f /dev/null + sleep 5 # avoid this: "error: Domain is already active" + + - name: Build modules + timeout-minutes: 30 + run: | + echo "Build modules in QEMU machine" + sudo virsh start openzfs + rm -f $HOME/.ssh/known_hosts + IP=192.168.122.10 + while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do + ssh 2>/dev/null zfs@$IP "uname -a" && break + done + rsync -ar $HOME/work/zfs/zfs zfs@$IP:./ + ssh zfs@$IP '$HOME/zfs/.github/workflows/scripts/qemu-4-build.sh' ${{ matrix.os }} + + - name: Setup testing machines + timeout-minutes: 5 + run: .github/workflows/scripts/qemu-5-setup.sh + + - name: Run tests + timeout-minutes: 270 + run: .github/workflows/scripts/qemu-6-tests.sh ${{ matrix.os }} + + - name: Create test reports + if: always() + timeout-minutes: 10 + run: .github/workflows/scripts/qemu-7-reports.sh + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: Logs-functional-${{ matrix.os }} + path: /tmp/qemu-${{ matrix.os }}.tar + if-no-files-found: ignore + + cleanup: + if: always() + name: Cleanup + runs-on: ubuntu-latest + needs: [ qemu-vm ] + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/download-artifact@v4 + - name: Generating summary + run: .github/workflows/scripts/qemu-8-summary.sh + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 2 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 3 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 4 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 5 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 6 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 7 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 8 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 9 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 10 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 11 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 12 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 13 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 14 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 15 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 16 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 17 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 18 + - name: Generating summary... + run: .github/workflows/scripts/qemu-8-summary.sh 19 + - uses: actions/upload-artifact@v4 + with: + name: Summary Files + path: out-* diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index c25903ea1be..957e674be2f 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # shellcheck disable=SC2154 # # CDDL HEADER START @@ -208,6 +208,46 @@ find_runfile() { fi } +# Given a TAGS with a format like "1/3" or "2/3" then divide up the test list +# into portions and print that portion. So "1/3" for "the first third of the +# test tags". +# +# +split_tags() { + # Get numerator and denominator + NUM=$(echo $TAGS | cut -d/ -f1) + DEN=$(echo $TAGS | cut -d/ -f2) + # At the point this is called, RUNFILES will contain a comma separated + # list of full paths to the runfiles, like: + # + # "/home/hutter/qemu/tests/runfiles/common.run,/home/hutter/qemu/tests/runfiles/linux.run" + # + # So to get tags for our selected tests we do: + # + # 1. Remove unneeded chars: [],\ + # 2. Print out the last field of each tag line. This will be the tag + # for the test (like 'zpool_add'). + # 3. Remove duplicates between the runfiles. If the same tag is defined + # in multiple runfiles, then when you do '-T ' ZTS is smart + # enough to know to run the tag in each runfile. So '-T zpool_add' + # will run the zpool_add from common.run and linux.run. + # 4. Ignore the 'functional' tag since we only want individual tests + # 5. Print out the tests in our faction of all tests. This uses modulus + # so "1/3" will run tests 1,3,6,9 etc. That way the tests are + # interleaved so, say, "3/4" isn't running all the zpool_* tests that + # appear alphabetically at the end. + # 6. Remove trailing comma from list + # + # TAGS will then look like: + # + # "append,atime,bootfs,cachefile,checksum,cp_files,deadman,dos_attributes, ..." + + cat ${RUNFILES/,/ } | tr -d [],\' | awk '/tags = /{print $NF}' | sort | \ + uniq | grep -v functional | \ + awk -v num=$NUM -v den=$DEN '{ if(NR % den == (num - 1)) {printf "%s,",$0}}' | \ + sed -E 's/,$//' +} + # # Symlink file if it appears under any of the given paths. # @@ -331,6 +371,10 @@ OPTIONS: -t PATH|NAME Run single test at PATH relative to test suite, or search for test by NAME -T TAGS Comma separated list of tags (default: 'functional') + Alternately, specify a fraction like "1/3" or "2/3" to + run the first third of tests or 2nd third of the tests. This + is useful for splitting up the test amongst different + runners. -u USER Run single test as USER (default: root) EXAMPLES: @@ -489,6 +533,8 @@ fi # TAGS=${TAGS:='functional'} + + # # Attempt to locate the runfiles describing the test workload. # @@ -509,6 +555,23 @@ done unset IFS RUNFILES=${R#,} +# The tag can be a fraction to indicate which portion of ZTS to run, Like +# +# "1/3": Run first one third of all tests in runfiles +# "2/3": Run second one third of all test in runfiles +# "6/10": Run 6th tenth of all tests in runfiles +# +# This is useful for splitting up the test across multiple runners. +# +# After this code block, TAGS will be transformed from something like +# "1/3" to a comma separate taglist, like: +# +# "append,atime,bootfs,cachefile,checksum,cp_files,deadman,dos_attributes, ..." +# +if echo $TAGS | grep -Eq '^[0-9]+/[0-9]+$' ; then + TAGS=$(split_tags) +fi + # # This script should not be run as root. Instead the test user, which may # be a normal user account, needs to be configured such that it can From b4a5b64407c58bcb730b11039c7fb260b15a67c5 Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 2 Aug 2024 11:23:35 -0700 Subject: [PATCH 8/8] Testing raidz_expand_001_pos failure --- .github/workflows/scripts/qemu-6-tests.sh | 8 ++- .github/workflows/scripts/qemu-7-reports.sh | 14 ++++- .github/workflows/zfs-qemu.yml | 58 ++++++++++++++----- .../cli_root/zfs_copies/zfs_copies.kshlib | 11 ++++ .../zpool_status/zpool_status_008_pos.ksh | 7 ++- .../functional/crtime/crtime_001_pos.ksh | 5 +- .../functional/raidz/raidz_expand_001_pos.ksh | 21 ++++++- .../functional/raidz/raidz_expand_002_pos.ksh | 4 ++ 8 files changed, 104 insertions(+), 24 deletions(-) diff --git a/.github/workflows/scripts/qemu-6-tests.sh b/.github/workflows/scripts/qemu-6-tests.sh index 488dee801d8..7bbcc8e680a 100755 --- a/.github/workflows/scripts/qemu-6-tests.sh +++ b/.github/workflows/scripts/qemu-6-tests.sh @@ -71,8 +71,14 @@ esac cd /var/tmp uname -a > uname.txt +# ONLY FOR TESTING DO NOT COMMIT +# +TAGS=$2/$3 + +# TAGS=raidz + # run functional testings -$TDIR/zfs-tests.sh -vK -s 3G -T $2/$3 +$TDIR/zfs-tests.sh -vK -s 3G -T $TAGS RV=$? # we wont fail here, this will be done later diff --git a/.github/workflows/scripts/qemu-7-reports.sh b/.github/workflows/scripts/qemu-7-reports.sh index 3338f491166..108774a79e9 100755 --- a/.github/workflows/scripts/qemu-7-reports.sh +++ b/.github/workflows/scripts/qemu-7-reports.sh @@ -52,16 +52,26 @@ for i in `seq 1 $VMs`; do echo "##[endgroup]" done +RESPATH="/var/tmp/test_results" + # all tests without grouping: MERGE="$BASE/.github/workflows/scripts/merge_summary.awk" -$MERGE vm*log.txt | $BASE/scripts/zfs-tests-color.sh +$MERGE vm*log.txt | $BASE/scripts/zfs-tests-color.sh | tee $RESPATH/summary.txt -RESPATH="/var/tmp/test_results" for i in `seq 1 $VMs`; do rsync -arL zfs@192.168.122.1$i:$RESPATH/current $RESPATH/vm$i || true scp zfs@192.168.122.1$i:"/var/tmp/*.txt" $RESPATH/vm$i || true done cp -f /var/tmp/*.txt $RESPATH || true + + +# Save a list of all failed test logs for easy access +awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }; /\[SKIP\]|\[PASS\]/{ show=0; } show' \ + $RESPATH/vm*/current/log >> $RESPATH/summary-failure-logs.txt + +cp $RESPATH/summary.txt $RESPATH/summary-with-logs.txt +cat $RESPATH/summary-failure-logs.txt >> $RESPATH/summary-with-logs.txt + tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true echo "********************************************************************" diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml index bfcbb468f59..a69cd493135 100644 --- a/.github/workflows/zfs-qemu.yml +++ b/.github/workflows/zfs-qemu.yml @@ -2,7 +2,7 @@ name: zfs-qemu on: push: - pull_request: +# pull_request: jobs: @@ -13,10 +13,11 @@ jobs: matrix: # all: # os: [almalinux8, almalinux9, archlinux, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] - os: [almalinux8, almalinux9, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] + # os: [almalinux8, almalinux9, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] # openzfs: # os: [almalinux8, almalinux9, centos-stream9, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] # freebsd: + os: [almalinux8, almalinux9, fedora39, fedora40, freebsd13, freebsd14, ubuntu20, ubuntu22, ubuntu24] # os: [freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15] runs-on: ubuntu-24.04 steps: @@ -24,18 +25,18 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - - name: Setup SSH - run: | - mkdir -p $HOME/.ssh - echo "ConnectTimeout 1" >> $HOME/.ssh/config - echo "StrictHostKeyChecking no" >> $HOME/.ssh/config - echo "${{ secrets.AUTHORIZED_KEYS }}" >> $HOME/.ssh/authorized_keys - echo "${{ secrets.SSH_KEY }}" > $HOME/.ssh/id_ed25519 - echo "${{ secrets.KNOWN_HOSTS }}" >> $HOME/.ssh/known_hosts - chmod 600 $HOME/.ssh/id_ed25519 - R=`shuf -n 1 -i 10000-60000` - echo "Port $R" - ssh -x -N -C -f -R $R:127.0.0.1:22 mcmilk@${{ secrets.SOME_HOST }} +# - name: Setup SSH +# run: | +# mkdir -p $HOME/.ssh +# echo "ConnectTimeout 1" >> $HOME/.ssh/config +# echo "StrictHostKeyChecking no" >> $HOME/.ssh/config +# echo "${{ secrets.AUTHORIZED_KEYS }}" >> $HOME/.ssh/authorized_keys +# echo "${{ secrets.SSH_KEY }}" > $HOME/.ssh/id_ed25519 +# echo "${{ secrets.KNOWN_HOSTS }}" >> $HOME/.ssh/known_hosts +# chmod 600 $HOME/.ssh/id_ed25519 +# R=`shuf -n 1 -i 10000-60000` +# echo "Port $R" +# ssh -x -N -C -f -R $R:127.0.0.1:22 mcmilk@${{ secrets.SOME_HOST }} - name: Setup QEMU timeout-minutes: 10 @@ -87,12 +88,41 @@ jobs: run: .github/workflows/scripts/qemu-7-reports.sh - uses: actions/upload-artifact@v4 + id: artifact-upload-step if: always() with: name: Logs-functional-${{ matrix.os }} path: /tmp/qemu-${{ matrix.os }}.tar if-no-files-found: ignore + - name: Test Summary + if: success() || failure() + run: | + cat /var/tmp/test_results/summary.txt + echo "" + echo "Full logs for download:" + echo '${{ steps.artifact-upload-step.outputs.artifact-url }}' + echo "File listing:" + ls -l /var/tmp/test_results/ + + # Did we have a test failure? + if grep -vq 0 /var/tmp/test_results/vm*/exitcode.txt ; then + echo "One or more tests failed" + cat /var/tmp/test_results/summary-failure-logs.txt + # On test failures, the github test results page will autoscroll to the + # bottom of summary-with-logs.txt. The first thing we want to see + # is the summary page of failures so print another copy of it at + # the bottom of the "page" for easy access. + echo "" + cat /var/tmp/test_results/summary.txt + echo "" + echo "Full logs for download:" + echo '${{ steps.artifact-upload-step.outputs.artifact-url }}' + false + else + true + fi + cleanup: if: always() name: Cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib index a7a93a3046d..2456fbabc20 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib @@ -155,5 +155,16 @@ function do_vol_test # Ubuntu 20.04 wants a sync here log_must sync + + # Not sure if this 'udevadm settle' is needed, but we once saw this + # failure and want to attempt to mitigate it: + # + # ERROR: zfs destroy testpool/testvol1 exited 1 + # cannot destroy 'testpool/testvol1': dataset is busy + # + if is_linux; then + udevadm settle + fi + log_must zfs destroy $vol } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh index 6be2ad5a741..8a35f1ae51c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh @@ -69,12 +69,12 @@ for raid_type in "draid2:3d:6c:1s" "raidz2"; do log_mustnot eval "zpool status -e $TESTPOOL2 | grep ONLINE" # Check no ONLINE slow vdevs are show. Then mark IOs greater than - # 10ms slow, delay IOs 20ms to vdev6, check slow IOs. + # 160ms slow, delay IOs 160ms to vdev6, check slow IOs. log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev6 "ONLINE" log_mustnot eval "zpool status -es $TESTPOOL2 | grep ONLINE" - log_must set_tunable64 ZIO_SLOW_IO_MS 10 - log_must zinject -d $TESTDIR/vdev6 -D20:100 $TESTPOOL2 + log_must set_tunable64 ZIO_SLOW_IO_MS 160 + log_must zinject -d $TESTDIR/vdev6 -D320:100 $TESTPOOL2 log_must mkfile 1048576 /$TESTPOOL2/testfile sync_pool $TESTPOOL2 log_must set_tunable64 ZIO_SLOW_IO_MS $OLD_SLOW_IO @@ -91,6 +91,7 @@ for raid_type in "draid2:3d:6c:1s" "raidz2"; do log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev1 "ONLINE" log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev2 "ONLINE" log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev3 "ONLINE" + log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev1 | grep ONLINE" log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev2 | grep ONLINE" log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev3 | grep ONLINE" diff --git a/tests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh b/tests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh index b2d0e737865..1d16a8f8386 100755 --- a/tests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh @@ -63,7 +63,10 @@ for arg in ${args[*]}; do fi log_must touch $TESTFILE typeset -i crtime1=$(stat_crtime $TESTFILE) - if (( crtime1 != crtime )); then + + # On slow test machines, there's a slight chance crtime1 rolls over + # to the next second. If that happens count it as ok. + if ! within_tolerance $crtime1 $crtime 1 ; then log_fail "touch modified crtime ($crtime1 != $crtime)" fi done diff --git a/tests/zfs-tests/tests/functional/raidz/raidz_expand_001_pos.ksh b/tests/zfs-tests/tests/functional/raidz/raidz_expand_001_pos.ksh index 063d7fa735d..1ff39036640 100755 --- a/tests/zfs-tests/tests/functional/raidz/raidz_expand_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/raidz/raidz_expand_001_pos.ksh @@ -137,7 +137,7 @@ function test_scrub # typeset nparity=$2 typeset dir=$3 typeset combrec=$4 - + log_note "Begin: $1, $2, $3, $4" reflow_size=$(get_pool_prop allocated $pool) randbyte=$(( ((RANDOM<<15) + RANDOM) % $reflow_size )) log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $randbyte @@ -151,10 +151,18 @@ function test_scrub # dd conv=notrunc if=/dev/zero of=$dir/dev-$i \ bs=1M seek=4 count=$(($dev_size_mb-4)) done + log_must sync log_must zpool import -o cachefile=none -d $dir $pool - + if is_pool_scrubbing $pool ; then + wait_scrubbed $pool + fi + log_note "=== About to scrub1 ===" + log_note "$(zpool status -vs)" log_must zpool scrub -w $pool + log_note "=== After scrub1 ===" + log_note "$(zpool status -vs)" + log_must zpool clear $pool log_must zpool export $pool @@ -163,10 +171,17 @@ function test_scrub # dd conv=notrunc if=/dev/zero of=$dir/dev-$i \ bs=1M seek=4 count=$(($dev_size_mb-4)) done + log_must sync log_must zpool import -o cachefile=none -d $dir $pool - + if is_pool_scrubbing $pool ; then + wait_scrubbed $pool + fi + log_note "=== About to scrub2 ===" + log_note "$(zpool status -vs)" log_must zpool scrub -w $pool + log_note "=== After scrub2 ===" + log_note "$(zpool status -vs)" log_must check_pool_status $pool "errors" "No known data errors" diff --git a/tests/zfs-tests/tests/functional/raidz/raidz_expand_002_pos.ksh b/tests/zfs-tests/tests/functional/raidz/raidz_expand_002_pos.ksh index 004f3d1f925..e416926d1a0 100755 --- a/tests/zfs-tests/tests/functional/raidz/raidz_expand_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/raidz/raidz_expand_002_pos.ksh @@ -105,6 +105,10 @@ for disk in ${disks[$(($nparity+2))..$devs]}; do log_fail "pool $pool not expanded" fi + # It's possible the pool could be auto scrubbing here. If so, wait. + if is_pool_scrubbing $pool ; then + wait_scrubbed $pool + fi verify_pool $pool pool_size=$expand_size