OpenZFS/src a3073e5.github/workflows/scripts qemu-4-build-vm.sh

CI: Have zfs-build-packages workflow build tarballs on Alma (#18662)

Previously, zfs-build-packages would only build source tarballs
on Fedora due to problems with building them on RHEL 7.  That's
a relic of the past now, as we haven't supported RHEL 7 since
it went EOL in 2024.  With this change, we now build the tarballs
on both Alma and Fedora.

Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
Reviewed-by: Olaf Faaland <faaland1 at llnl.gov>
Reviewed-by: Chris Longros <chris.longros at gmail.com>
DeltaFile
+3-4.github/workflows/scripts/qemu-4-build-vm.sh
+3-41 files

OpenZFS/src 7fe05a5module/zfs abd.c

abd: Fix stats asymmetry in case of Direct I/O

abd_alloc_from_pages() does not call abd_update_scatter_stats(),
since memory is not really allocated there.  But abd_free_scatter()
called by abd_free() does.  It causes negative overflow of some
ABD and possibly ARC counters.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <rob.norris at truenas.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18390
DeltaFile
+2-1module/zfs/abd.c
+2-11 files

OpenZFS/src ec88debmodule/zfs zil.c vdev_removal.c, tests/runfiles common.run

Fix log vdev removal issues

When we clear the log, we should clear all the fields, not only
zh_log.  Otherwise remaining ZIL_REPLAY_NEEDED will prevent the
vdev removal.  Handle it also from the other side, when zh_log
is already cleared, while zh_flags is not.

spa_vdev_remove_log() asserts that allocated space on removed log
device is zero.  While it should be so in perfect world, it might
be not if space leaked at any point.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18277
DeltaFile
+95-0tests/zfs-tests/tests/functional/removal/removal_with_missing_log.ksh
+16-4module/zfs/zil.c
+1-1tests/runfiles/common.run
+0-1module/zfs/vdev_removal.c
+1-0tests/zfs-tests/tests/Makefile.am
+113-65 files

OpenZFS/src e6a856fmodule/zfs dbuf.c

Simplify dnode_level_is_l2cacheable()

We should not dereference through dn_handle->dnh_dnode once we
already have a dnode pointer.  The result will be the same.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18212
DeltaFile
+1-2module/zfs/dbuf.c
+1-21 files

OpenZFS/src b4842ae. META

Tag zfs-2.3.8

META file and changelog updated.

Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
DeltaFile
+1-1META
+1-11 files

OpenZFS/src e2705f6module/zfs zvol.c

ZVOL: Add encryption key check for block cloning

Somehow during block cloning porting from file systems was missed
the check for identical encryption keys.  As result, blocks cloned
between unrelated ZVOLs produced authentication errors on later
reads.  Having same or different encryption root does not matter.

This patch copies dmu_objset_crypto_key_equal() call from FS side.

Reviewed-by: Ameer Hamza <ahamza at ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18315
DeltaFile
+16-0module/zfs/zvol.c
+16-01 files

OpenZFS/src 7ab1633module/zfs dbuf.c

Remove parent ZIO from dbuf_prefetch()

I am not sure why it was added there 10 years ago, but it seems not
needed now.  According to my tests removing it improves sequential
read performance with recordsize=4K by 5-10% by reducing the CPU
overhead in prefetcher.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Reviewed-by: Ameer Hamza <ahamza at ixsystems.com>
Reviewed-by: Akash B <akash-b at hpe.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18214
DeltaFile
+3-14module/zfs/dbuf.c
+3-141 files

OpenZFS/src 6d336famodule/zfs abd.c

abd: Fix stats asymmetry in case of Direct I/O

abd_alloc_from_pages() does not call abd_update_scatter_stats(),
since memory is not really allocated there.  But abd_free_scatter()
called by abd_free() does.  It causes negative overflow of some
ABD and possibly ARC counters.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <rob.norris at truenas.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18390
DeltaFile
+2-1module/zfs/abd.c
+2-11 files

OpenZFS/src b72c843module/zfs dbuf.c

Simplify dnode_level_is_l2cacheable()

We should not dereference through dn_handle->dnh_dnode once we
already have a dnode pointer.  The result will be the same.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18212
DeltaFile
+1-2module/zfs/dbuf.c
+1-21 files

OpenZFS/src 83020cf. META

Tag zfs-2.4.3

META file and changelog updated.

Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
DeltaFile
+1-1META
+1-11 files

OpenZFS/src 1821ca2module/zfs zvol.c

ZVOL: Add encryption key check for block cloning

Somehow during block cloning porting from file systems was missed
the check for identical encryption keys.  As result, blocks cloned
between unrelated ZVOLs produced authentication errors on later
reads.  Having same or different encryption root does not matter.

This patch copies dmu_objset_crypto_key_equal() call from FS side.

Reviewed-by: Ameer Hamza <ahamza at ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18315
DeltaFile
+16-0module/zfs/zvol.c
+16-01 files

OpenZFS/src 50697dcmodule/zfs zil.c vdev_removal.c, tests/runfiles common.run

Fix log vdev removal issues

When we clear the log, we should clear all the fields, not only
zh_log.  Otherwise remaining ZIL_REPLAY_NEEDED will prevent the
vdev removal.  Handle it also from the other side, when zh_log
is already cleared, while zh_flags is not.

spa_vdev_remove_log() asserts that allocated space on removed log
device is zero.  While it should be so in perfect world, it might
be not if space leaked at any point.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18277
DeltaFile
+95-0tests/zfs-tests/tests/functional/removal/removal_with_missing_log.ksh
+16-4module/zfs/zil.c
+1-1tests/runfiles/common.run
+0-1module/zfs/vdev_removal.c
+1-0tests/zfs-tests/tests/Makefile.am
+113-65 files

OpenZFS/src 9711768module/zfs dbuf.c

Remove parent ZIO from dbuf_prefetch()

I am not sure why it was added there 10 years ago, but it seems not
needed now.  According to my tests removing it improves sequential
read performance with recordsize=4K by 5-10% by reducing the CPU
overhead in prefetcher.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Reviewed-by: Ameer Hamza <ahamza at ixsystems.com>
Reviewed-by: Akash B <akash-b at hpe.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18214
DeltaFile
+3-14module/zfs/dbuf.c
+3-141 files

OpenZFS/src 8489d70include/os/freebsd/spl/sys cmn_err.h kmem.h, include/sys spa.h vdev.h

Rename several printf attributes declarations to __printf__

For kernel builds on FreeBSD, we redefine `__printf__` to
`__freebsd_kprintf__`, to support FreeBSD kernel printf(9) extensions
with clang.

In OpenZFS various printf related functions are declared with
`__attribute__((format(printf, X, Y)))`, so these won't work with the
above redefinition. With clang 21 and higher, this leads to errors
similar to:

    sys/contrib/openzfs/module/zfs/spa_misc.c:414:38: error: passing
    'printf' format string where 'freebsd_kprintf' format string is
    expected [-Werror,-Wformat]
      414 |         (void) vsnprintf(buf, sizeof (buf), fmt, adx);
          |                                             ^

Since attribute names can always be spelled with leading and trailing
double underscores, rename these instances.

    [7 lines not shown]
DeltaFile
+8-8include/os/freebsd/spl/sys/cmn_err.h
+2-2include/os/freebsd/spl/sys/kmem.h
+2-2include/sys/spa.h
+1-1include/sys/vdev.h
+1-1include/sys/zfs_debug.h
+14-145 files

OpenZFS/src 07c1e2e. META

Tag zfs-2.2.10

META file and changelog updated.

Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
DeltaFile
+1-1META
+1-11 files

OpenZFS/src 3d39a57include/os/freebsd/spl/sys cmn_err.h kmem.h, include/sys spa.h vdev.h

Rename several printf attributes declarations to __printf__

For kernel builds on FreeBSD, we redefine `__printf__` to
`__freebsd_kprintf__`, to support FreeBSD kernel printf(9) extensions
with clang.

In OpenZFS various printf related functions are declared with
`__attribute__((format(printf, X, Y)))`, so these won't work with the
above redefinition. With clang 21 and higher, this leads to errors
similar to:

    sys/contrib/openzfs/module/zfs/spa_misc.c:414:38: error: passing
    'printf' format string where 'freebsd_kprintf' format string is
    expected [-Werror,-Wformat]
      414 |         (void) vsnprintf(buf, sizeof (buf), fmt, adx);
          |                                             ^

Since attribute names can always be spelled with leading and trailing
double underscores, rename these instances.

    [7 lines not shown]
DeltaFile
+8-8include/os/freebsd/spl/sys/cmn_err.h
+2-2include/os/freebsd/spl/sys/kmem.h
+2-2include/sys/spa.h
+1-1include/sys/vdev.h
+1-1include/sys/zfs_debug.h
+14-145 files

OpenZFS/src 7e054b2tests/unit test_namecheck.c Makefile.am

unit/namecheck: test name validation

Add a test_namecheck unit suite covering zfs_namecheck name check
functions, including: pool, dataset, snapshot, bookmark, component,
permset and mountpoint, plus get_dataset_depth and dataset_nestcheck.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <rob.norris at truenas.com>
Signed-off-by: Christos Longros <chris.longros at gmail.com>
Closes #18643

* unit/namecheck: simplify name generation and helpers

1) introduce check_longname_invalid() and simplify the long-name helper
2) document that zfs_max_dataset_nesting is a tunable and drop the
   unnecessary restore
3) drop snprintf and use fixed intervals for the delimiters in a
   random string


    [4 lines not shown]
DeltaFile
+314-0tests/unit/test_namecheck.c
+15-1tests/unit/Makefile.am
+1-0tests/unit/.gitignore
+330-13 files

OpenZFS/src 77e64d8include/sys vdev.h, module/zfs vdev.c zfs_ioctl.c

Fix self-deadlock when setting the "allocating"/"path" vdev property

zfs_ioc_vdev_set_props() acquires the SCL_CONFIG lock as a reader and
holds it across the call to vdev_prop_set(). For the "allocating"
property, vdev_prop_set() calls spa_vdev_noalloc()/spa_vdev_alloc(),
which descend through spa_vdev_enter() into spa_config_enter(spa,
SCL_ALL, RW_WRITER); the "path" property does the same via
spa_vdev_setpath().

Acquiring SCL_CONFIG as a writer while the same thread already holds it
as a reader is a self-deadlock: the writer waits for scl_count to drain
to zero, but scl_count is the thread's own reader, which is not released
until vdev_prop_set() returns. As a result "zpool set allocating=off|on
<vdev>" hangs the calling thread, and txg_sync, which also needs
SCL_CONFIG as a reader, stalls behind it and freezes the pool.

The SCL_CONFIG reader was added by commit d65015938e19 ("Vdev allocation
bias/class change", #18493) to keep the vdev tree stable across the guid
lookup and the property handling.

    [28 lines not shown]
DeltaFile
+90-0tests/zfs-tests/tests/functional/cli_root/zpool_set/vdev_set_path.ksh
+67-15module/zfs/vdev.c
+80-0tests/zfs-tests/tests/functional/cli_root/zpool_set/vdev_set_allocating.ksh
+2-32module/zfs/zfs_ioctl.c
+2-2include/sys/vdev.h
+2-1tests/runfiles/common.run
+243-501 files not shown
+245-507 files

OpenZFS/src cc4f4a4module/zfs dsl_scan.c

dsl_scan: close errorscrub cursor on pause

If the cursor were ever to actively hold resources, not finalising it
would mean leaking those resources whenever the scrub is paused.

The cursor is already reinitialized from the stored serialized form
if/when it is resumed, so there's nothing we need from the old one, just
to release it.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18603
DeltaFile
+1-0module/zfs/dsl_scan.c
+1-01 files

OpenZFS/src b8e4787module Makefile.bsd

FreeBSD: Make it possible to build openzfs.ko with sanitizers

Add make options which let one respectively compile the kernel modules
with the address sanitizer, memory sanitizer, and undefined behaviour
sanitizer enabled.  This makes it much easier to run the ZTS with those
sanitizers enabled.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Chris Longros <chris.longros at gmail.com>
Signed-off-by: Mark Johnston <markj at FreeBSD.org>
Closes #18596
DeltaFile
+6-0module/Makefile.bsd
+6-01 files

OpenZFS/src b4415e6cmd/zdb zdb.c

When reading a vdev label skip libzfs_core_init()

There's no need to call libzfs_core_init() when `zdb -l` is used to
read a vdev label.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: tiehexue <tiehexue at hotmail.com>
Closes #18606
DeltaFile
+1-1cmd/zdb/zdb.c
+1-11 files

OpenZFS/src 7ac1293include/sys zap_impl.h

zap_impl: use flex array field for mzap_phys_t.mz_chunks

mz_phys_t is always a full-block allocation, with mz_chunks[] as an
array over the rest of the block past the header.

Recent Linux compiled with CONFIG_UBSAN will complain about this:

    UBSAN: array-index-out-of-bounds in module/zfs/zap.c:1236:28
    index 2 is out of range for type 'mzap_ent_phys_t [1]'

The fix is straightforward; simply convert this field to a flex member.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18550
DeltaFile
+2-1include/sys/zap_impl.h
+2-11 files

OpenZFS/src 54e6dbdmodule/zfs arc.c

arc: export additional required symbols

External consumers of arc_read() need to be able to destroy the
returned arc_buf_t.  Add the arc_buf_destroy() interface as an
exported symbol.

Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18533
DeltaFile
+1-0module/zfs/arc.c
+1-01 files

OpenZFS/src 2bbb5a1include/sys zio_impl.h, man/man8 zpool-events.8

Fix double free for blocks cloned after DDT prune

Before this change, for blocks marked with D flag but absent in DDT
(pruned from it), zio_ddt_free() fell back to ZIO_STAGE_DVA_FREE
without trying ZIO_STAGE_BRT_FREE first.  Same time such blocks
might be present in BRT, and not handling that would result in
double/multiple free.

This change makes ZIO_DDT_FREE_PIPELINE include ZIO_FREE_PIPELINE,
just adding required ZIO_STAGE_ISSUE_ASYNC and ZIO_STAGE_DDT_FREE,
and moves DDT stages before BRT.  This way, if the block is found
in DDT by zio_ddt_free(), the pipeline is short-circuited to
ZIO_INTERLOCK_PIPELINE, similar to what zio_brt_free() does.  If
not, then BRT is checked, and if also no match, the block is freed.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <rob.norris at truenas.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18520
DeltaFile
+152-0tests/zfs-tests/tests/functional/dedup/dedup_bclone_pruned.ksh
+15-8module/zfs/zio.c
+6-7include/sys/zio_impl.h
+5-5man/man8/zpool-events.8
+4-3tests/runfiles/common.run
+1-1module/zcommon/zfs_valstr.c
+183-241 files not shown
+184-247 files

OpenZFS/src 5b0f44bcmd arcstat.in arc_summary, include/sys arc_impl.h

zarcstat: detect attached L2ARC device with no data

zarcstat and zarcsummary detected L2ARC presence using the l2_size
kstat, which is data held in L2ARC, not whether a cache device is
attached. When a cache device was attached but empty (freshly added,
or fully evicted):

  - zarcstat rejected "-f l2*" with "Incompatible field specified!"
  - zarcsummary printed "L2ARC not detected, skipping section",
    hiding cumulative I/O history and health counters

Expose the existing l2arc_ndev counter as a new kstat l2_dev_count.
It is maintained by l2arc_add_vdev() and l2arc_remove_vdev(), so it
tracks attachment in real time. Use it in both tools, falling back to
l2_size for compatibility with older kernel modules.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Ameer Hamza <ahamza at ixsystems.com>
Closes #18499
DeltaFile
+3-3cmd/arcstat.in
+4-1cmd/arc_summary
+2-0include/sys/arc_impl.h
+2-0module/zfs/arc.c
+11-44 files

OpenZFS/src 534ec43module/zfs lz4_zfs.c gzip.c, module/zstd zfs_zstd.c

enforce exact decompressed length for lz4, gzip, and zstd

Decompressors must expand a ZFS block to exactly the expected number
of bytes. Treat decompression to an unexpected length as failure, so
truncated or short output is not accepted as valid decompression. This
makes our handling of decompress return values consistent with the
decompression functions' APIs.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Alek Pinchuk <Alek.Pinchuk at connectwise.com>
Closes #18599
DeltaFile
+11-4module/zfs/lz4_zfs.c
+9-0module/zstd/zfs_zstd.c
+6-2module/zfs/gzip.c
+26-63 files

OpenZFS/src cbfccbcmodule/os/linux/spl spl-kmem.c

spl_kvmalloc: remove __GFP_COMP before calling vmalloc()

In cb1833023 we stopped using it for KM_VMEM allocations, since its not
a valid flag for vmalloc(). However, there's a fallback path for
non-KM_VMEM allocations to use vmalloc(), and we need to remove
__GFP_COMP there too to avoid a warning.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18558
DeltaFile
+6-0module/os/linux/spl/spl-kmem.c
+6-01 files

OpenZFS/src dac211fcmd/zdb zdb.c, tests/zfs-tests/tests/functional/bclone bclone_samefs_data.ksh

zdb: detect BRT and DDT leaks during block traversal

During -b traversal, track BRT and DDT reference counts and report
blocks claimed more times than their reference tables account for
if it causes claim errors, instead of just asserting it.  Also
report entries with references not fully consumed by the traversal.

Add zdb leaks checks to cloning and dedup tests. This should make
sure the pools are in a sane state after completing the functional
tests.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18494
DeltaFile
+114-51cmd/zdb/zdb.c
+4-0tests/zfs-tests/tests/functional/block_cloning/block_cloning_after_device_removal.ksh
+3-0tests/zfs-tests/tests/functional/bclone/bclone_samefs_data.ksh
+3-0tests/zfs-tests/tests/functional/block_cloning/block_cloning_lwb_buffer_overflow.ksh
+3-0tests/zfs-tests/tests/functional/block_cloning/block_cloning_replay.ksh
+3-0tests/zfs-tests/tests/functional/block_cloning/block_cloning_replay_encrypted.ksh
+130-5112 files not shown
+156-5118 files

OpenZFS/src 084cd70module/os/freebsd/zfs zfs_vnops_os.c

Fix "panic: cache_vop_rename: lingering negative entry"

A FreeBSD ZFS filesystem with properties "utf8only=on" and
"normalization=formD" consistently produces this panic when
building the lang/perl-5.42.0 port.

A ZFS file system with "utf8only=off" and "normalization=none"
works fine.

The cause of the panic seems to be incorrectly using the FreeBSD
namecache when normalisation is present. This commit adds a
predicate to prevent that.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Jan Martin Mikkelsen <janm-github at transactionware.com>
Closes #18430
DeltaFile
+1-1module/os/freebsd/zfs/zfs_vnops_os.c
+1-11 files

OpenZFS/src c0a6529module/zfs dmu_send.c, tests/runfiles common.run

Fix off-by-one in PREVIOUSLY_REDACTED handler that drops last block

In send_reader_thread(), the PREVIOUSLY_REDACTED handler computed
file_max as MIN(dn->dn_maxblkid, range->end_blkid).  dn_maxblkid is
an inclusive maximum block ID while range->end_blkid is exclusive (one
past the last block).  The resulting file_max was then used as an
exclusive loop bound, causing the last block of any file (at index
dn_maxblkid) to be silently skipped when a PREVIOUSLY_REDACTED range
covered the end of the file.

The block was never written to the send stream so the receiver kept
zeros there.  ZFS reported no error because the stream itself was
valid; the data was simply absent.

Fix: use dn_maxblkid + 1 so file_max is consistently exclusive.

Add a regression test (redacted_max_blkid.ksh) that modifies only the
last block of a file in one clone, creates a redaction bookmark from
it, then sends an unmodified clone incrementally from that bookmark.

    [7 lines not shown]
DeltaFile
+118-0tests/zfs-tests/tests/functional/redacted_send/redacted_max_blkid.ksh
+2-1tests/runfiles/common.run
+1-1module/zfs/dmu_send.c
+1-0tests/zfs-tests/tests/Makefile.am
+122-24 files