]> git.proxmox.com Git - mirror_zfs.git/log
mirror_zfs.git
3 months agozvol_impl: document and tidy flags
Rob Norris [Thu, 18 Jul 2024 02:37:43 +0000 (12:37 +1000)]
zvol_impl: document and tidy flags

ZVOL_DUMPIFIED is a vestigial Solaris leftover, and not used anywhere.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16364

3 months agoFreeBSD: remove support for FreeBSD < 13.0-RELEASE (#16372)
Rob Norris [Mon, 5 Aug 2024 23:56:45 +0000 (09:56 +1000)]
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 <robn@despairlabs.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
3 months agoZTS: fix zfs_copies_006_pos test on Ubuntu 20.04 (#16409)
Tino Reichardt [Mon, 5 Aug 2024 23:18:07 +0000 (01:18 +0200)]
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 <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
3 months agoZTS: fix history_007_pos test on Ubuntu 24.04 (#16410)
Tino Reichardt [Mon, 5 Aug 2024 23:17:23 +0000 (01:17 +0200)]
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 <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
3 months agocontrib: link zpool to zfs in bash-completion (#16376)
Shengqi Chen [Mon, 5 Aug 2024 16:44:10 +0000 (00:44 +0800)]
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 <harry-chen@outlook.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
3 months agoOnce more refactor arc_summary output
Alexander Motin [Thu, 1 Aug 2024 19:27:29 +0000 (15:27 -0400)]
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 <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.

Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Umer Saleem <usaleem@ixsystems.com>
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
3 months agoFreeBSD: Add missing memory reclamation accounting
Alexander Motin [Thu, 1 Aug 2024 19:25:42 +0000 (15:25 -0400)]
FreeBSD: Add missing memory reclamation accounting

Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.

Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Umer Saleem <usaleem@ixsystems.com>
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
3 months agoBlock cloning conditionally destroy ARC buffer
Brian Atkinson [Fri, 2 Aug 2024 01:22:43 +0000 (21:22 -0400)]
Block cloning conditionally destroy ARC buffer

dmu_buf_will_clone() calls arc_buf_destroy() if there is an associated
ARC buffer with the dbuf. However, this can only be done conditionally.
If the previous dirty record's dr_data is pointed at db_dbf then
destroying it can lead to NULL pointer deference when syncing out the
previous dirty record.

This updates dmu_buf_fill_clone() to only call arc_buf_destroy() if the
previous dirty records dr_data is not pointing to db_buf. The block
clone wil still set the dbuf's db_buf and db_data to NULL, but this will
not cause any issues as any previous dirty record dr_data will still be
pointing at the ARC buffer.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Closes #16337

3 months agoFix sa.c to build on FreeBSD again. (#16403)
Tino Reichardt [Thu, 1 Aug 2024 20:04:08 +0000 (22:04 +0200)]
Fix sa.c to build on FreeBSD again. (#16403)

Fix multiple build errors on FreeBSD.

The main reason is, that the variable 'dxattr_obj' is used
uninitialized within the start of the 'out label'.

Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
3 months agoFix sa_add_projid to lookup and update SA_ZPL_DXATTR (avoid DXATTR loss) (#16288)
Jitendra Patidar [Thu, 1 Aug 2024 01:41:49 +0000 (07:11 +0530)]
Fix sa_add_projid to lookup and update SA_ZPL_DXATTR (avoid DXATTR loss) (#16288)

sa_add_projid() gets called via zfs_setattr() for setting project id
on old file/dir, which were created before upgrading to project quota
feature. This function does lookup for all possible SA and update them
all together along with project ID at needed fixed offset. But its
missing lookup and update of SA_ZPL_DXATTR, effectively it losses
SA_ZPL_DXATTR.

Closes #16287
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
3 months agoFix zdb_dump_block for little endian (#16310)
Chunwei Chen [Thu, 1 Aug 2024 01:33:39 +0000 (18:33 -0700)]
Fix zdb_dump_block for little endian (#16310)

The endian macros were changed but zdb_dump_block wasn't updated
accordingly.

Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Allan Jude <allan@klarasystems.com>
3 months agozfs: add bounds checking to zil_parse (#16308)
c1ick [Thu, 1 Aug 2024 00:17:04 +0000 (08:17 +0800)]
zfs: add bounds checking to zil_parse (#16308)

Make sure log record don't stray beyond valid memory region.

There is a lack of verification of the space occupied by fixed members
of lr_t in the zil_parse.

We can create a crafted image to trigger an out of bounds read by
following these steps:
    1) Do some file operations and reboot to simulate abnormal exit
       without umount
    2) zil_chain.zc_nused: 0x1000
    3) First lr_t
       lr_t.lrc_txtype: 0x0
       lr_t.lrc_reclen: 0x1000-0xb8-0x1
       lr_t.lrc_txg: 0x0
       lr_t.lrc_seq: 0x1
    4) Update checksum in zil_chain.zc_eck

Fix:
Add some checks to make sure the remaining bytes are large enough to
hold an log record.

Signed-off-by: XDTG <click1799@163.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
3 months agoLinux: Report reclaimable memory to kernel as such (#16385)
Alexander Motin [Tue, 30 Jul 2024 18:40:47 +0000 (14:40 -0400)]
Linux: Report reclaimable memory to kernel as such (#16385)

Linux provides SLAB_RECLAIM_ACCOUNT and __GFP_RECLAIMABLE flags to
mark memory allocations that can be freed via shinker calls.  It
should allow kernel to tune and group such allocations for lower
memory fragmentation and better reclamation under pressure.

This patch marks as reclaimable most of ARC memory, directly
evictable via ZFS shrinker, plus also dnode/znode/sa memory,
indirectly evictable via kernel's superblock shrinker.

Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
3 months agodnode: allow storage class to be overridden by object type
Rob Norris [Tue, 27 Jun 2023 02:50:18 +0000 (12:50 +1000)]
dnode: allow storage class to be overridden by object type

spa_preferred_class() selects a storage class based on (among other
things) the DMU object type. This only works for old-style object types
that match only one specific kind of thing. For DMU_OTN_ types we need
another way to signal the storage class.

This commit allows the object type to be overridden in the IO policy for
the purposes of choosing a storage class. It then adds the ability to
set the storage type on a dnode hold, such that all writes generated
under that hold will get it.

This method has two shortcomings:

- it would be better if we could "name" a set of storage class
  preferences rather than it being implied by the object type.
- it would be better if this info were stored in the dnode on disk.

In the absence of those things, this seems like the smallest possible
change.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: iXsystems, Inc.
Closes #15894

3 months agospa_preferred_class: pass the entire zio
Rob Norris [Tue, 27 Jun 2023 01:03:29 +0000 (11:03 +1000)]
spa_preferred_class: pass the entire zio

Rather than picking out specific values out of the properties, just pass
the entire zio in, to make it easier in the future to use more of that
info to decide on the storage class.

I would have rathered just pass io_prop in, but having spa.h include
zio.h gets a bit tricky.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: iXsystems, Inc.
Closes #15894

3 months agoSkip dnode handles use when not needed
Alexander Motin [Mon, 22 Jul 2024 01:13:42 +0000 (21:13 -0400)]
Skip dnode handles use when not needed

Neither FreeBSD nor Linux currently implement kmem_cache_set_move(),
which means dnode_move() is never called.  In such situation use of
dnode handles with respective locking to access dnode from dbuf is
a waste of time for no benefit.

This patch implements optional simplified code for such platforms,
saving at least 3 dnode lock/dereference/unlock per dbuf life cycle.
Originally I hoped to drop the handles completely to save memory,
but they are still used in dnodes allocation code, so left for now.

Before this change in CPU profiles of some workloads I saw 4-20% of
CPU time spent in zrl_add_impl()/zrl_remove(), which are gone now.

Reviewed-by: Rob Wing <rob.wing@klarasystems.com
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by:   iXsystems, Inc.
Closes #16374

3 months agoCleanup DB_DNODE() macros usage
Alexander Motin [Mon, 22 Jul 2024 01:04:38 +0000 (21:04 -0400)]
Cleanup DB_DNODE() macros usage

 - Use the macros in few places it was missed.
 - Reduce scope of DB_DNODE_ENTER/EXIT() and inline some DB_DNODE()
uses to make it more obvious what exactly is protected there and
make unprotected accesses by mistake more difficult.
 - Make use of zrl_owner().

Reviewed-by: Rob Wing <rob.wing@klarasystems.com
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #16374

3 months agoddt: add support for prefetching tables into the ARC
Allan Jude [Fri, 26 Jul 2024 16:16:18 +0000 (12:16 -0400)]
ddt: add support for prefetching tables into the ARC

This change adds a new `zpool prefetch -t ddt $pool` command which
causes a pool's DDT to be loaded into the ARC. The primary goal is to
remove the need to "warm" a pool's cache before deduplication stops
slowing write performance. It may also provide a way to reload portions
of a DDT if they have been flushed due to inactivity.

Sponsored-by: iXsystems, Inc.
Sponsored-by: Catalogics, Inc.
Sponsored-by: Klara, Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Will Andrews <will.andrews@klarasystems.com>
Signed-off-by: Fred Weigel <fred.weigel@klarasystems.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Will Andrews <will.andrews@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Closes #15890

3 months agoFix ZDB to dump projid for projectquota enabled (#16291)
Jitendra Patidar [Fri, 26 Jul 2024 00:18:11 +0000 (05:48 +0530)]
Fix ZDB to dump projid for projectquota enabled (#16291)

ZDB is supposed to dump "projid" via dump_znode(), when projectquota
is enabled.
-----------
static void
dump_znode(objset_t *os, uint64_t object, void *data, size_t size)
{
...
    if (dmu_objset_projectquota_enabled(os) && (pflags & ZFS_PROJID)) {
uint64_t projid;

if (sa_lookup(hdl, sa_attr_table[ZPL_PROJID], &projid,
    sizeof (uint64_t)) == 0)
(void) printf("\tprojid %llu\n", (u_longlong_t)projid);
    }
...
}
----------
But its not dumping "projid", even for project quota enabled.

dmu_objset_projectquota_enabled() does following 3 checks,
----------
boolean_t
dmu_objset_projectquota_enabled(objset_t *os)
{
        return (file_cbs[os->os_phys->os_type] != NULL &&
            DMU_PROJECTUSED_DNODE(os) != NULL &&
            spa_feature_is_enabled(os->os_spa,
SPA_FEATURE_PROJECT_QUOTA));
}
----------
It fails on file_cbs[] check. file_cbs[] gets initialised via
dmu_objset_register_type(); which is not done for the ZDB, its done for
the kernel via zfs_init().

Register a dummy callback handle for the DMU_OST_ZFS type in
ZDB main() function to dump the projid for projectquota enabled.

Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #16290
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
3 months agozil: add stats for commit failure/fallback (#16315)
Rob Norris [Thu, 25 Jul 2024 23:53:59 +0000 (09:53 +1000)]
zil: add stats for commit failure/fallback (#16315)

There's no good way to tell when a ZIL commit fails and falls back to a
transaction sync, other than perhaps a throughput drop. This adds
counters so we can see when it happens and why.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
3 months agoReplace goo.gl style link (#16373)
Alexander Motin [Thu, 25 Jul 2024 18:00:32 +0000 (14:00 -0400)]
Replace goo.gl style link (#16373)

That URL shortening scheme should stop working soon [1], while we
don't really need it here.

1. https://developers.googleblog.com/en/google-url-shortener-links-will-no-longer-be-available/

Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
3 months agoSeveral improvements to ARC shrinking (#16197)
Alexander Motin [Thu, 25 Jul 2024 17:31:14 +0000 (13:31 -0400)]
Several improvements to ARC shrinking (#16197)

- When receiving memory pressure signal from OS be more strict
trying to free some memory.  Otherwise kernel may come again and
request much more.  Return as result how much arc_c was actually
reduced due to this request, that may be less than requested.
 - On Linux when receiving direct reclaim from some file system
(that may be ZFS) instead of ignoring request completely, just
shrink the ARC, but do not wait for eviction.  Waiting there may
cause deadlock.  Ignoring it as before may put extra pressure on
other caches and/or swap, and cause OOM if nothing help.  While
not waiting may result in more ARC evicted later, and may be too
late if OOM killer activate right now, but I hope it to be better
than doing nothing at all.
 - On Linux set arc_no_grow before waiting for reclaim, not after,
or it may grow back while we are waiting.
 - On Linux add new parameter zfs_arc_shrinker_seeks to balance
ARC eviction cost, relative to page cache and other subsystems.
 - Slightly update Linux arc_set_sys_free() math for new kernels.

Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
3 months agoddt: dedup table quota enforcement
Allan Jude [Thu, 25 Jul 2024 16:47:36 +0000 (12:47 -0400)]
ddt: dedup table quota enforcement

This adds two new pool properties:
- dedup_table_size, the total size of all DDTs on the pool; and
- dedup_table_quota, the maximum possible size of all DDTs in the pool

When set, quota will be enforced by checking when a new entry is about
to be created. If the pool is over its dedup quota, the entry won't be
created, and the corresponding write will be converted to a regular
non-dedup write. Note that existing entries can be updated (ie their
refcounts changed), as that reuses the space rather than requiring more.

dedup_table_quota can be set to 'auto', which will set it based on the
size of the devices backing the "dedup" allocation device. This makes it
possible to limit the DDTs to the size of a dedup vdev only, such that
when the device fills, no new blocks are deduplicated.

Sponsored-by: iXsystems, Inc.
Sponsored-By: Klara Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Rob Wing <rob.wing@klarasystems.com>
Co-authored-by: Sean Eric Fagan <sean.fagan@klarasystems.com>
Closes #15889

3 months agoZTS: Make do_vol_test() more deterministic (#16379)
Alexander Motin [Wed, 24 Jul 2024 16:33:30 +0000 (12:33 -0400)]
ZTS: Make do_vol_test() more deterministic (#16379)

- Explicitly disable compression since mkfile uses a zero buffer.
 - Explicitly sync file systems instead of waiting for timeout.

Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoLinux 6.9: Fix UBSAN errors in sa.c (#16380)
Tony Hutter [Wed, 24 Jul 2024 00:13:04 +0000 (17:13 -0700)]
Linux 6.9: Fix UBSAN errors in sa.c (#16380)

This is a follow-on to 156a64161b4f9da35f2e0484106173344cf78317
that ignores UBSAN errors in sa.c.

Thank you @thwalker3 for the fix.

Original-patch-by: @thwalker3
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #16278
Closes #16330
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
4 months agoAdd support for multiple lines to the sharenfs property for FreeBSD (#16338)
rmacklem [Tue, 23 Jul 2024 23:38:19 +0000 (16:38 -0700)]
Add support for multiple lines to the sharenfs property for FreeBSD (#16338)

There has been a bugzilla PR#147881 requesting this
for a long time (14 years!). It extends the syntax of
the ZFS shanenfs property (for FreeBSD only) to allow
multiple sets of options for different hosts/nets,
separated by ';'s.

Signed-off-by: Rick Macklem <rmacklem@FreeBSD.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoAdd some missing vdev properties (#16346)
Don Brady [Tue, 23 Jul 2024 23:34:09 +0000 (17:34 -0600)]
Add some missing vdev properties (#16346)

Sponsored-by: Klara, Inc.
Sponsored-By: Wasabi Technology, Inc.
Signed-off-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoAUTHORS: refresh with recent new contributors (#16362)
Rob Norris [Tue, 23 Jul 2024 18:47:04 +0000 (04:47 +1000)]
AUTHORS: refresh with recent new contributors (#16362)

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: George Melikov <mail@gmelikov.ru>
4 months agoFix long_free_dirty accounting for small files (#16264)
Chunwei Chen [Tue, 23 Jul 2024 18:34:19 +0000 (11:34 -0700)]
Fix long_free_dirty accounting for small files (#16264)

For files smaller than recordsize, it's most likely that they don't have
L1 blocks. However, current calculation will always return at least 1 L1
block.

In this change, we check dnode level to figure out if it has L1 blocks
or not, and return 0 if it doesn't. This will reduce the chance of
unnecessary throttling when deleting a large number of small files.

Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Co-authored-by: Chunwei Chen <david.chen@nutanix.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
4 months agoZTS: Change cp_stress to fit timings (#16369)
Tino Reichardt [Mon, 22 Jul 2024 21:03:22 +0000 (23:03 +0200)]
ZTS: Change cp_stress to fit timings (#16369)

cp_stress is getting killed on the new QEMU-based github runners
we're developing. The problem is that the Linux based runners
should do 10 RUNS, where the FreeBSD based runners only have 3
RUNS to succeed.

This patch removes this different handling of Linux and FreeBSD.
The cp_stress test is running fine in around 2 minutes now.

Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agozdb: fix BRT dump (#16335)
Rob Norris [Thu, 18 Jul 2024 17:51:27 +0000 (03:51 +1000)]
zdb: fix BRT dump (#16335)

BRT refcounts are stored as eight uint8_ts rather than a single
uint64_t. This means that za_first_integer is only the first byte, so
max 256. This fixes it by doing a lookup for the whole value.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
4 months agoFix printf typo for `zfs receive -cv` (#16295)
glibg10b [Thu, 18 Jul 2024 00:18:12 +0000 (02:18 +0200)]
Fix printf typo for `zfs receive -cv` (#16295)

Current output:
> receiving  correctivefull stream of a into b
New output:
> receiving corrective full stream of a into b

Signed-off-by: glibg10b <56197853+glibg10b@users.noreply.github.com>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoMake sure avl_tree.avl_pad is not in kernel module (#16280)
youzhongyang [Wed, 17 Jul 2024 20:54:11 +0000 (16:54 -0400)]
Make sure avl_tree.avl_pad is not in kernel module (#16280)

The commit b192a2c (Remove avl_size field from struct avl_tree) uses a
def _KERNEL to decide to include avl_pad or not, but this _KERNEL is
defined in sys/sysmacros.h. If avl.h and sysmacros.h are not included
in the right order, it can cause a headache when working on a zfs
related kernel module.

Add sysmacros.h in avl_impl.h to fix. sysmacros.h is also removed
from spa.h as it's reduntant.

Signed-off-by: Youzhong Yang <yyang@mathworks.com>
Co-authored-by: Youzhong Yang <yyang@mathworks.com>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agozdb: dump ZAP_FLAG_UINT64_KEY ZAPs properly (#16334)
Rob Norris [Wed, 17 Jul 2024 19:02:28 +0000 (05:02 +1000)]
zdb: dump ZAP_FLAG_UINT64_KEY ZAPs properly (#16334)

These are used for DDT and BRT stores. There's limited information
available to produce meaningful output, but at least we can put
something on screen rather than crashing.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agovdev_open: clear async fault flag after reopen
Rob Norris [Tue, 11 Jun 2024 10:49:10 +0000 (20:49 +1000)]
vdev_open: clear async fault flag after reopen

After c3f2f1aa2, vdev_fault_wanted is set on a vdev after a probe fails.
An end-of-txg async task is charged with actually faulting the vdev.

In a single-disk pool, the probe failure will degrade the last disk, and
then suspend the pool. However, vdev_fault_wanted is not cleared. After
the pool returns, the transaction finishes and the async task runs and
faults the vdev, which suspends the pool again.

The fix is simple: when reopening a vdev, clear the async fault flag. If
the vdev is still failed, the startup probe will quickly notice and
degrade/suspend it again. If not, all is well!

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Don Brady <don.brady@klarasystems.com>
4 months agozts: test single-disk pool resumes properly after disk pull
Rob Norris [Thu, 9 May 2024 10:22:21 +0000 (20:22 +1000)]
zts: test single-disk pool resumes properly after disk pull

A single disk pool should suspend when its disk fails and hold the IO.
When the disk is returned, the pool should return and the IO be
reissued, leaving everything in good shape.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Don Brady <don.brady@klarasystems.com>
4 months agoUse kmap_local_page instead of kmap_atomic (#16329)
Jason Lee [Wed, 17 Jul 2024 00:27:29 +0000 (18:27 -0600)]
Use kmap_local_page instead of kmap_atomic (#16329)

Changed zfs_k(un)map_atomic to zfs_k(un)map_local

Signed-off-by: Jason Lee <jasonlee@lanl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
4 months agoLinux 6.9 compat: META (#16358)
Tony Hutter [Tue, 16 Jul 2024 23:27:54 +0000 (16:27 -0700)]
Linux 6.9 compat: META (#16358)

Update the META file to reflect compatibility with the 6.9
kernel.

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
4 months agoLinux 5.16: use bdev_nr_bytes() to get device capacity
Rob Norris [Tue, 28 May 2024 20:16:28 +0000 (16:16 -0400)]
Linux 5.16: use bdev_nr_bytes() to get device capacity

This helper was introduced long ago, in 5.16. Since 6.10, bd_inode no
longer exists, but the helper has been updated, so detect it and use it
in all versions where it is available.

Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
4 months agoLinux 6.10: work harder to avoid kmem_cache_alloc reuse
Rob Norris [Tue, 28 May 2024 15:56:41 +0000 (11:56 -0400)]
Linux 6.10: work harder to avoid kmem_cache_alloc reuse

Linux 6.10 change kmem_cache_alloc to be a macro, rather than a
function, such that the old #undef for it in spl-kmem-cache.c would
remove its definition completely, breaking the build.

This inverts the model used before. Rather than always defining the
kmem_cache_* macro, then undefining then inside spl-kmem-cache.c,
instead we make a special tag to indicate we're currently inside
spl-kmem-cache.c, and not defining those in macros in the first place,
so we can use the kernel-supplied kmem_cache_* functions to implement
spl_kmem_cache_*, as we expect.

For all other callers, we create the macros as normal and remove access
to the kernel's own conflicting names.

Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
4 months agoLinux 6.10: rework queue limits setup
Rob Norris [Tue, 28 May 2024 01:32:07 +0000 (21:32 -0400)]
Linux 6.10: rework queue limits setup

Linux has started moving to a model where instead of applying block
queue limits through individual modification functions, a complete
limits structure is built up and applied atomically, either when the
block device or open, or some time afterwards. As of 6.10 this
transition appears only partly completed.

This commit matches that model within OpenZFS in a way that should work
for past and future kernels. We set up a queue limits structure with any
limits that have had their modification functions removed. For newer
kernels that can have limits applied at block device open
(HAVE_BLK_ALLOC_DISK_2ARG), we have a conversion function to turn the
OpenZFS queue limits structure into Linux's queue_limits structure,
which can then be passed in. For older kernels, we provide an
application function that just calls the old functions for each limit in
the structure.

Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
4 months agoAdd building support for Artix Linux (#16265)
Zhao Yongming [Mon, 15 Jul 2024 23:58:00 +0000 (11:58 +1200)]
Add building support for Artix Linux (#16265)

Artix Linux is systemd free distribution based on Arch Linux, with
openrc dinit runit s6 as init alternatives. This patch will make
init scripts installation work the way Gentoo Linux with openrc.

The scripts tweaking for other init will be left to packager.

Signed-off-by: Yongming Zhao <ming.zym@gmail.com>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agozstd: don't call zstd_mempool_reap if there are no buffers (#16302)
Mateusz Guzik [Mon, 15 Jul 2024 21:51:37 +0000 (23:51 +0200)]
zstd: don't call zstd_mempool_reap if there are no buffers (#16302)

zfs_zstd_cache_reap_now is issued every second.

zstd_mempool_reap checks for both pool existence and buffer count, but
that's still 2 func calls which are trivially avoidable.

With clang it even avoids pushing the stack pointer (but still suffers
the mispredict due to a forward jump, not modified in case someone is
using zstd):

<+0>:     cmpq   $0x0,0x0(%rip)        # <zfs_zstd_cache_reap_now+8>
<+8>:     je     0x217de4 <zfs_zstd_cache_reap_now+36>
<+10>:    push   %rbp
<+11>:    mov    %rsp,%rbp
<+14>:    mov    0x0(%rip),%rdi        # <zfs_zstd_cache_reap_now+21>
<+21>:    call   0x217df0 <zstd_mempool_reap>
<+26>:    mov    0x0(%rip),%rdi        # <zfs_zstd_cache_reap_now+33>
<+33>:    pop    %rbp
<+34>:    jmp    0x217df0 <zstd_mempool_reap>
<+36>:    ret

Preferably the call would not be made to begin with if zstd is not used,
but this retains all the logic confined to zstd code.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agohead_errlog: fix use-after-free
George Amanakis [Mon, 15 Jul 2024 16:05:42 +0000 (18:05 +0200)]
head_errlog: fix use-after-free

In the commit of the head_errlog feature we introduced a bug in
dsl_dataset_promote_sync(): we may dereference origin_head and hds, both
dereferencing ddpa after calling promote_sync() on ddpa.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@nutanix.com>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #16272
Closes #16273

4 months agoFix missing semicolon in trace_dbuf.h (#16281)
Daniel Berlin [Sat, 13 Jul 2024 00:44:10 +0000 (20:44 -0400)]
Fix missing semicolon in trace_dbuf.h (#16281)

On fedora 40, on the 6.9.4 kernel (in updates-testing), assign_str
expands to a "do {<stuff> } while(0)" loop.  Without this semicolon,
the while(0) is unterminated, causing a cascade of useless errors.
With this semicolon, it compiles fine.  It also compiles fine on 6.8.11
(the previous kernel).  I have not tested earlier kernels than that, but
at worst it should add a pointless semicolon.

All other instances in the source tree are already terminated with
semicolons.

Signed-off-by: Daniel Berlin <dberlin@dberlin.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoone-word manpage correction: snapshot->rollback (#16294)
a1ea321 [Fri, 12 Jul 2024 23:27:12 +0000 (01:27 +0200)]
one-word manpage correction: snapshot->rollback (#16294)

This commit fixes what is probably a copy-paste mistake. The
`dracut.zfs` manpage claims that the `bootfs.rollback` option executes
`zfs snapshot -Rf`. `zfs snapshot` does not have a `-R` option. `zfs
rollback` does.

Signed-off-by: Alphan Yılmaz <alphanyilmaz@gmail.com>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoZTS: handle FreeBSD version numbers correctly (#16340)
Rob Norris [Fri, 12 Jul 2024 17:58:03 +0000 (03:58 +1000)]
ZTS: handle FreeBSD version numbers correctly (#16340)

FreeBSD patchlevel versions are optional and, if present, in a different
location in the version string.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoFreeBSD: Use the new freeuio() helper to free dynamically allocated UIOs (#16300)
Mark Johnston [Thu, 11 Jul 2024 23:52:51 +0000 (18:52 -0500)]
FreeBSD: Use the new freeuio() helper to free dynamically allocated UIOs (#16300)

This freeuio() interface was introduced to FreeBSD recently.  For now
it simply calls free(), so this change has no effect.  However, this
may not always be true, and in CheriBSD this change is required.

Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brooks Davis <brooks.davis@sri.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoLinux 6.9: Fix UBSAN errors in zap_micro.c
Tony Hutter [Thu, 11 Jul 2024 23:41:26 +0000 (16:41 -0700)]
Linux 6.9: Fix UBSAN errors in zap_micro.c

You can use the UBSAN_SANITIZE_* Kbuild options to exclude certain
kernel objects from the UBSAN checks.  We previously excluded
zap_micro.o with:

UBSAN_SANITIZE_zap_micro.o := n

For some reason that didn't work for the 6.9 kernel, which wants us
to use:

UBSAN_SANITIZE_zfs/zap_micro.o := n

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #16278
Closes #16330

4 months agozvol: Fix suspend lock leaks (#16270)
Mark Johnston [Wed, 10 Jul 2024 21:27:44 +0000 (16:27 -0500)]
zvol: Fix suspend lock leaks (#16270)

In several functions, we use a flag variable to track whether
zv_suspend_lock is held.  This flag was not getting reset in a
particular case where we need to retry the underlying operation,
resulting in a lock leak.  Make sure to update the flag where necessary.

Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoFix the name of the zfs_prefetch_disable parameter (#16319)
Peter Doherty [Tue, 9 Jul 2024 16:59:55 +0000 (12:59 -0400)]
Fix the name of the zfs_prefetch_disable parameter (#16319)

The ZFS module parameter name is zfs_prefetch_disable, not
zfs_disable_prefetch.

Signed-off-by: Peter Doherty <peterd@acranox.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoFix zdb "Memory fault" found on FreeBSD ZTS (#16332)
Tino Reichardt [Tue, 9 Jul 2024 16:36:17 +0000 (18:36 +0200)]
Fix zdb "Memory fault" found on FreeBSD ZTS (#16332)

Reason: nvlist_free() tries to free sth. which isn't allocted
Solution: init this variable with NULL

Closes #16311
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoFreeBSD: Use a statement expression to implement SET_ERROR() (#16284)
Mark Johnston [Tue, 9 Jul 2024 00:59:08 +0000 (19:59 -0500)]
FreeBSD: Use a statement expression to implement SET_ERROR() (#16284)

This way we can avoid making assumptions about the SDT probe
implementation.  No functional change intended.

Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agozfs.4: Document the actual default for zfs_txg_history (#16305)
Mateusz Piotrowski [Fri, 28 Jun 2024 18:21:08 +0000 (20:21 +0200)]
zfs.4: Document the actual default for zfs_txg_history (#16305)

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Mateusz Piotrowski <0mp@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoFix a mis-merge in the zdb man page (#16304)
Allan Jude [Fri, 28 Jun 2024 17:38:22 +0000 (13:38 -0400)]
Fix a mis-merge in the zdb man page (#16304)

Sponsored-by: Klara, Inc.
Sponsored-By: Wasabi Technology, Inc.
Signed-off-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
4 months agoLinux 6.9: Call add_disk() from workqueue to fix zfs_allow_010_pos (#16282)
Tony Hutter [Fri, 28 Jun 2024 16:52:03 +0000 (09:52 -0700)]
Linux 6.9: Call add_disk() from workqueue to fix zfs_allow_010_pos (#16282)

The 6.9 kernel behaves differently in how it releases block devices.  In
the common case it will async release the device only after the return
to userspace.  This is different from the 6.8 and older kernels which
release the block devices synchronously.  To get around this, call
add_disk() from a workqueue so that the kernel uses a different
codepath to release our zvols in the way we expect.  This stops
zfs_allow_010_pos from hanging.

Fixes: #16089
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
5 months agodisable automatic dependency tracking for dkms builds
Martin Wagner [Fri, 14 Jun 2024 01:08:49 +0000 (03:08 +0200)]
disable automatic dependency tracking for dkms builds

Previously the dkms build left some unwanted files
in `/usr/lib/modules` which could cause package
managers to not properly clean up old kernels.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Martin Wagner <martin.wagner.dev@gmail.com>
Closes #16221
Closes #16241

5 months agoFreeBSD: unregister mountroot eventhandler on unload
Mateusz Guzik [Fri, 14 Jun 2024 00:49:50 +0000 (02:49 +0200)]
FreeBSD: unregister mountroot eventhandler on unload

Otherwise if zfs is unloaded and reroot is being used it trips over a
stale pointer.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: Rubicon Communications, LLC ("Netgate")
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #16242

5 months agoFreeBSD: Update use of UMA-related symbols in arc_available_memory
bnovkov [Fri, 7 Jun 2024 01:11:00 +0000 (03:11 +0200)]
FreeBSD: Update use of UMA-related symbols in arc_available_memory

Recent UMA changes repurposed the use of UMA_MD_SMALL_ALLOC in a way
that breaks arc_available_memory on -CURRENT. This change
ensures that arc_available_memory uses the new symbol
while maintaining compatibility with older FreeBSD releases.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Bojan Novković <bnovkov@FreeBSD.org>
Closes #16230

5 months agocontrib/bash_completion.d: squelch FreeBSD seq when first < last
Derek Schrock [Fri, 7 Jun 2024 00:37:26 +0000 (20:37 -0400)]
contrib/bash_completion.d: squelch FreeBSD seq when first < last

With seq x -1 z and x is less than z FreeBSD seq will print the error:

$ seq 1 -1 2
seq: needs positive increment

Hide this error.  Alternatively $COMP_CWORD could be checked for < 2.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Derek Schrock <dereks@lifeofadishwasher.com>
Closes #16234

5 months agozdb: fix FreeBSD build failure
Ameer Hamza [Fri, 7 Jun 2024 00:01:26 +0000 (05:01 +0500)]
zdb: fix FreeBSD build failure

This fixes FreeBSD build failure with clang-18 after 23a489a got merged.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #16252

5 months agozdb: detect cachefile automatically otherwise force import
Ameer Hamza [Mon, 3 Jun 2024 23:28:43 +0000 (04:28 +0500)]
zdb: detect cachefile automatically otherwise force import

If a pool is created with the cache file located in a non-default
path /etc/default/zpool.cache, removed, or the cachefile property
is set to none, zdb fails to show the pool unless we specify the
cache file or use the -e option. This PR automates this process.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Akash B <akash-b@hpe.com>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #16071

5 months agoicp: remove redundant FreeBSD check
Rob Norris [Sun, 19 May 2024 11:49:19 +0000 (21:49 +1000)]
icp: remove redundant FreeBSD check

We don't build illumos-crypto for FreeBSD.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: remove unused headers
Rob Norris [Sun, 19 May 2024 11:40:59 +0000 (21:40 +1000)]
icp: remove unused headers

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: remove skein module
Rob Norris [Sun, 19 May 2024 05:00:00 +0000 (15:00 +1000)]
icp: remove skein module

Nothing calls it through the KCF interface, so this is all unused.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: remove unused SHA2 HMAC mechanisms
Rob Norris [Sun, 19 May 2024 05:00:44 +0000 (15:00 +1000)]
icp: remove unused SHA2 HMAC mechanisms

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: reorganise SHA2 digest mechanisms
Rob Norris [Sun, 19 May 2024 03:18:42 +0000 (13:18 +1000)]
icp: reorganise SHA2 digest mechanisms

sha2_mech_type_t serves double-duty, as the list of MAC providers and
also the algo type for direct callers to SHA2Init. Until we disentangle
that, reorganise it to make the separation more clear. While we're
there, remove the digest mechs we don't use.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: remove digest entry points
Rob Norris [Sun, 19 May 2024 02:58:56 +0000 (12:58 +1000)]
icp: remove digest entry points

For whatever reason, we call digest mechanisms directly, not through the
KCF digest provider. So we can remove those entry points entirely.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: remove unused KCF_ macros
Rob Norris [Sun, 19 May 2024 02:24:35 +0000 (12:24 +1000)]
icp: remove unused KCF_ macros

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: remove unusued incremental cipher methods
Rob Norris [Sat, 18 May 2024 12:17:36 +0000 (22:17 +1000)]
icp: remove unusued incremental cipher methods

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: brutally remove unused AES modes
Rob Norris [Sat, 18 May 2024 11:57:36 +0000 (21:57 +1000)]
icp: brutally remove unused AES modes

Still retaining the struture, for now.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoicp: remove unused blowfish_ctx and des_ctx
Rob Norris [Sat, 18 May 2024 11:05:20 +0000 (21:05 +1000)]
icp: remove unused blowfish_ctx and des_ctx

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16209

5 months agoZTS: Fix redacted_send failures on FreeBSD
Tony Hutter [Fri, 31 May 2024 22:11:00 +0000 (15:11 -0700)]
ZTS: Fix redacted_send failures on FreeBSD

We're seeing failures for redacted_deleted and redacted_mount
on FreeBSD 13-15:

    09:58:34.74 diff: /dev/fd/3: No such file or directory
    09:58:34.74 ERROR: diff /dev/fd/3 /dev/fd/4 exited 2

The test was trying to diff the file listings between two directories to
see if they are the same.  The workaround is to do a string comparison
of the directory listings instead of using `diff`.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #16224

5 months agoFreeBSD: Add const qualifier to members of struct opensolaris_utsname
Zhenlei Huang [Thu, 30 May 2024 16:58:20 +0000 (00:58 +0800)]
FreeBSD: Add const qualifier to members of struct opensolaris_utsname

These members have directly references to the global variables
exposed by the kernel. They are not going to be changed by this
kernel module.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Zhenlei Huang <zlei@FreeBSD.org>
Closes #16210

5 months agozpool import output is not formated properly.
Pawel Jakub Dawidek [Wed, 29 May 2024 20:34:59 +0000 (13:34 -0700)]
zpool import output is not formated properly.

The 'zpool status' output assumes that the longest prefix is six
character long plus colon plus space, eg. 'status: ', 'action: '
or 'config: ' (so eight in total). This works well even when we have
messages that requires more than one line, as '\t' is exactly eight
characters, just like the longest prefix.

The 'zpool import' output is a bit different, as it may display the
comment pool property, then the longest prefix is 'comment: ', which is
nine characters long, not eight.
All the prefixes were given an extra space in front, but:
- 'status: ' did not get an extra space.
- Messages that require more than one line should use nine spaces of
  indentation, not eight.
- The extra space in front looks redundant if there is no comment
  property set on the given pool.

Fix it by adding an extra space to all prefixes, but only if the comment
property is defined. Also, when we need to continue the message in a new
line, use '\t ' for indentation.

While here, apply small corrections to a couple messages.

Before:

   pool: tank
     id: 7412636063178848859
  state: ONLINE
status: Some supported features are not enabled on the pool.
(Note that they may be intentionally disabled if the
'compatibility' property is set.)
 action: The pool can be imported using its name or numeric identif[...]
some features will not be available without an explicit 'zp[...]
comment: Example comment.
 config:

bclone      ONLINE
  ada0      ONLINE

After:

  pool: tank
    id: 10180960571062436759
 state: ONLINE
status: Some supported features are not enabled on the pool.
(Note that they may be intentionally disabled if the
'compatibility' property is set.)
action: The pool can be imported using its name or numeric identifi[...]
some features will not be available without an explicit 'zp[...]
config:

tank        ONLINE
  ada3      ONLINE

   pool: dozer
     id: 11028319538368222579
  state: ONLINE
 status: Some supported features are not enabled on the pool.
 (Note that they may be intentionally disabled if the
 'compatibility' property is set.)
 action: The pool can be imported using its name or numeric identif[...]
 some features will not be available without an explicit 'z[...]
comment: Example comment.
 config:

dozer       ONLINE
  ada1      ONLINE

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Pawel Dawidek <pawel@dawidek.net>
Closes #16128

5 months agospl: fix compilation without HAVE_BACKTRACE
Martin Matuška [Wed, 29 May 2024 17:51:01 +0000 (19:51 +0200)]
spl: fix compilation without HAVE_BACKTRACE

The __maybe_unused macro is defined in spl/sys/debug.h

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Martin Matuska <mm@FreeBSD.org>
Closes #16229

5 months agoSimplify issig().
Pawel Jakub Dawidek [Wed, 29 May 2024 17:49:11 +0000 (10:49 -0700)]
Simplify issig().

We always call it twice with JUSTLOOKING and then FORREAL.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #16225

5 months agozed: Add deadman-slot_off.sh zedlet
Brian Behlendorf [Wed, 29 May 2024 17:46:41 +0000 (10:46 -0700)]
zed: Add deadman-slot_off.sh zedlet

Optionally turn off disk's enclosure slot if an I/O is hung
triggering the deadman.

It's possible for outstanding I/O to a misbehaving SCSI disk to
neither promptly complete or return an error.  This can occur due
to retry and recovery actions taken by the SCSI layer, driver, or
disk.  When it occurs the pool will be unresponsive even though
there may be sufficient redundancy configured to proceeded without
this single disk.

When a hung I/O is detected by the kmods it will be posted as a
deadman event.  By default an I/O is considered to be hung after
5 minutes.  This value can be changed with the zfs_deadman_ziotime_ms
module parameter.  If ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN is set
the disk's enclosure slot will be powered off causing the outstanding
I/O to fail.  The ZED will then handle this like a normal disk failure.
By default ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN is not set.

As part of this change `zfs_deadman_events_per_second` is added
to control the ratelimitting of deadman events independantly of
delay events.  In practice, a single deadman event is sufficient
and more aren't particularly useful.

Alphabetize the zfs_deadman_* entries in zfs.4.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #16226

5 months agoSome improvements to metaslabs eviction
Alexander Motin [Wed, 29 May 2024 15:53:31 +0000 (11:53 -0400)]
Some improvements to metaslabs eviction

- Add old eviction for special and dedup metaslab classes. Those
vdevs may be potentially big and fragmented with large metaslabs,
while their asynchronous write pattern is not really different
from normal class. It seems an omission to not evict old metaslabs
from them.
 - If we have metaslab preload enabled, which means we are not too
low on memory, do not evict active metaslabs even if they are not
used for some time.  Eviction of active metaslabs means we won't
be able to write anything until we load them, that may take some
time, that is straight opposite to metaslab preload goals.  For
small systems the memory saving should be less important after
recent reduction in number of allocators and so open metaslabs.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #16214

5 months agoDestroy ARC buffer in case of fill error
Alexander Motin [Sat, 25 May 2024 02:11:18 +0000 (22:11 -0400)]
Destroy ARC buffer in case of fill error

In case of error dmu_buf_fill_done() returns the buffer back into
DB_UNCACHED state.  Since during transition from DB_UNCACHED into
DB_FILL state dbuf_noread() allocates an ARC buffer, we must free
it here, otherwise it will be leaked.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15665
Closes #15802
Closes #16216

5 months agoFix assertion in Persistent L2ARC
George Amanakis [Sat, 25 May 2024 02:02:58 +0000 (04:02 +0200)]
Fix assertion in Persistent L2ARC

At the end of l2arc_evict() fix an assertion in the case that l2ad_hand
+ distance == l2ad_end.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #16202
Closes #16207

5 months agoUse memset to zero stack allocations containing unions
Rob N [Sat, 25 May 2024 02:00:29 +0000 (12:00 +1000)]
Use memset to zero stack allocations containing unions

C99 6.7.8.17 says that when an undesignated initialiser is used, only
the first element of a union is initialised. If the first element is not
the largest within the union, how the remaining space is initialised is
up to the compiler.

GCC extends the initialiser to the entire union, while Clang treats the
remainder as padding, and so initialises according to whatever
automatic/implicit initialisation rules are currently active.

When Linux is compiled with CONFIG_INIT_STACK_ALL_PATTERN,
-ftrivial-auto-var-init=pattern is added to the kernel CFLAGS. This flag
sets the policy for automatic/implicit initialisation of variables on
the stack.

Taken together, this means that when compiling under
CONFIG_INIT_STACK_ALL_PATTERN on Clang, the "zero" initialiser will only
zero the first element in a union, and the rest will be filled with a
pattern. This is significant for aes_ctx_t, which in
aes_encrypt_atomic() and aes_decrypt_atomic() is initialised to zero,
but then used as a gcm_ctx_t, which is the fifth element in the union,
and thus gets pattern initialisation. Later, it's assumed to be zero,
resulting in a hang.

As confusing and undiscoverable as it is, by the spec, we are at fault
when we initialise a structure containing a union with the zero
initializer. As such, this commit replaces these uses with an explicit
memset(0).

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16135
Closes #16206

5 months agozap: reuse zap_leaf_t on dbuf reuse after shrink
Rob N [Sat, 25 May 2024 01:55:47 +0000 (11:55 +1000)]
zap: reuse zap_leaf_t on dbuf reuse after shrink

If a shrink or truncate had recently freed a portion of the ZAP, the
dbuf could still be sitting on the dbuf cache waiting for eviction. If
it is then allocated for a new leaf before it can be evicted, the
zap_leaf_t is still attached as userdata, tripping the VERIFY.

Instead, just check for the userdata, and if we find it, reuse it.

Sponsored-by: Klara, Inc.
Sponsored-by: iXsystems, Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16157.
Closes #16204

5 months agoLinux 6.7 compat: detect if kernel defines intptr_t
Rob N [Sat, 25 May 2024 01:54:24 +0000 (11:54 +1000)]
Linux 6.7 compat: detect if kernel defines intptr_t

Since Linux 6.7 the kernel has defined intptr_t. Clang has
-Wtypedef-redefinition by default, which causes the build to fail
because we also have a typedef for intptr_t.

Since its better to use the kernel's if it exists, detect it and skip
our own.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #16201

5 months agoAvoid a gcc -Wint-to-pointer-cast warning
Brooks Davis [Sat, 25 May 2024 01:45:58 +0000 (18:45 -0700)]
Avoid a gcc -Wint-to-pointer-cast warning

On 32-bit platforms long long is generally 64-bits.  Sufficiently modern
versions of gcc (13 in my testing) complains when casting a pointer to
an integer of a different width so cast to uintptr_t first to avoid the
warning.

Fixes: c183d164aa Parallel pool import
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Don Brady <don.brady@klarasystems.com>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #16203

5 months agoAllow block cloning to be interrupted by a signal.
Pawel Jakub Dawidek [Sat, 25 May 2024 01:45:09 +0000 (18:45 -0700)]
Allow block cloning to be interrupted by a signal.

Even though block cloning is much faster than regular copying,
it is not instantaneous - the file might be large and the recordsize
small. It would be nice to be able to interrupt it with a signal
(e.g., SIGINFO on FreeBSD to see the progress).

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #16208

6 months agoFreeBSD: Add zfs_link_create() error handling
Alexander Motin [Fri, 17 May 2024 00:56:55 +0000 (20:56 -0400)]
FreeBSD: Add zfs_link_create() error handling

Originally Solaris didn't expect errors there, but they may happen
if we fail to add entry into ZAP.  Linux fixed it in #7421, but it
was never fully ported to FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #13215
Closes #16138

6 months agoconfig/zfs-build.m4: add Alpine Linux bash-completion path
omni [Sat, 4 May 2024 08:47:13 +0000 (08:47 +0000)]
config/zfs-build.m4: add Alpine Linux bash-completion path

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: omni <omni+vagant@hack.org>
Closes #16164

6 months agoconfig/zfs-build.m4: sort vendors
omni [Sat, 4 May 2024 08:44:55 +0000 (08:44 +0000)]
config/zfs-build.m4: sort vendors

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: omni <omni+vagant@hack.org>
Closes #16164

6 months agoCorrect level handling in zstream recompress.
Rich Ercolani [Thu, 16 May 2024 22:37:50 +0000 (18:37 -0400)]
Correct level handling in zstream recompress.

sscanf returns number of items parsed on success and EOF on failure.

Reviewed-by: Adam Moss <c@yotes.com>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #16198

6 months agodbuf: separate refcount calls for dbuf and dbuf_user
Rob N [Wed, 15 May 2024 20:03:41 +0000 (06:03 +1000)]
dbuf: separate refcount calls for dbuf and dbuf_user

In 92dc4ad83 I updated the dbuf_cache accounting to track the size of
userdata associated with dbufs. This adds the size of the dbuf+userdata
together in a single call to zfs_refcount_add_many(), but sometime
removes them in separate calls to zfs_refcount_remove_many(), if dbuf
and userdata are evicted separately.

What I didn't realise is that when refcount tracking is on,
zfs_refcount_add_many() and zfs_refcount_remove_many() are expected to
be paired, with their second & third args (count & holder) the same on
both sides. Splitting the remove part into two calls means the counts
don't match up, tripping a panic.

This commit fixes that, by always adding and removing the dbuf and
userdata counts separately.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reported-by: Mark Johnston <markj@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16191

6 months agozdb/ztest: send dbgmsg output to stderr
Rob Norris [Fri, 10 May 2024 03:58:26 +0000 (13:58 +1000)]
zdb/ztest: send dbgmsg output to stderr

And, make the output fd an arg to zfs_dbgmsg_print(). This is a change
in behaviour, but keeps it consistent with where crash traces go, and
it's easy to argue this is what we want anyway; this is information
about the task, not the actual output of the task.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181

6 months agozfs_dbgmsg_print: make FreeBSD and Linux consistent
Rob Norris [Fri, 10 May 2024 03:54:08 +0000 (13:54 +1000)]
zfs_dbgmsg_print: make FreeBSD and Linux consistent

FreeBSD was using fprintf(), which might not be signal-safe. Meanwhile,
Linux's locking did not cover the header output. This two quirks are
unrelated, but both have the same response: be like the other one. So
with this commit, both functions are the same except for the names of
their lock and list variables.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181

6 months agobacktrace: rework for signal safety
Rob Norris [Fri, 10 May 2024 03:04:14 +0000 (13:04 +1000)]
backtrace: rework for signal safety

Mostly, try a lot harder to not allocate anything.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181

6 months agolibspl: lift backtrace into a separate file
Rob Norris [Fri, 10 May 2024 01:26:11 +0000 (11:26 +1000)]
libspl: lift backtrace into a separate file

If it's going to be used directly by zdb/ztest, then it sort of doesn't
make sense to carry it with the assert code.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181

6 months agozdb/ztest: use libspl backtrace for crashes
Rob Norris [Fri, 10 May 2024 00:19:48 +0000 (10:19 +1000)]
zdb/ztest: use libspl backtrace for crashes

We can show much nicer backtraces these days, lets use them.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181

6 months agozdb: bring crash handling over from ztest
Rob Norris [Thu, 9 May 2024 23:56:48 +0000 (09:56 +1000)]
zdb: bring crash handling over from ztest

ztest has a very nice ability to show a backtrace when there's an
unexpected crash. zdb is used often enough on corrupted data and can
blow up too, so nice output is useful there too.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181

6 months agospa_taskq_dispatch_ent: simplify arguments
Rob Norris [Thu, 2 May 2024 02:13:38 +0000 (12:13 +1000)]
spa_taskq_dispatch_ent: simplify arguments

This renames it to spa_taskq_dispatch(), and reduces and simplifies its
arguments based on these observations from its two call sites:

- arg is always the zio, so it can be typed that way, and we don't need
  to provide it twice;
- ent is always &zio->io_tqent, and zio is always provided, so we can
  use it directly;
- the only flag used is TQ_FRONT, which can just be a bool;
- zio != NULL was part of the "use allocator" test, but it never would
  have got that far, because that arg was only set to NULL in the
  reexecute path, which is forced to type CLAIM, so the condition would
  fail at t == WRITE anyway.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16151

6 months agospa: flatten spa_taskq_dispatch_ent()
Rob Norris [Thu, 2 May 2024 02:06:58 +0000 (12:06 +1000)]
spa: flatten spa_taskq_dispatch_ent()

It is the only user of spa_taskq_dispatch_select(), so might as well
just carry it directly.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16151

6 months agospa: remove spa_taskq_dispatch_sync()
Rob Norris [Thu, 2 May 2024 02:04:24 +0000 (12:04 +1000)]
spa: remove spa_taskq_dispatch_sync()

It has no callers anymore.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16151