1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-25 07:49:18 +00:00
Commit Graph

2354 Commits

Author SHA1 Message Date
Dimitry Andric
3ceba58a75 Fix gcc uninitialized warning in FreeBSD zio_crypt.c
With gcc we are seeing the following -Werror warning:

    In file included from /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h:28,
                     from /workspace/src/sys/contrib/openzfs/include/sys/zfs_context.h:69:
    In function 'zfs_uio_init',
        inlined from 'zio_do_crypt_data' at /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1690:2:
    /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h:102:45: error: 'puio_s.uio_offset' is used uninitialized [-Werror=uninitialized]
      102 |                 zfs_uio_soffset(uio) = uio_s->uio_offset;
          |                                        ~~~~~^~~~~~~~~~~~
    /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c: In function 'zio_do_crypt_data':
    /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1683:20: note: 'puio_s' declared here
     1683 |         struct uio puio_s, cuio_s;
          |                    ^~~~~~
    In function 'zfs_uio_init',
        inlined from 'zio_do_crypt_data' at /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1691:2:
    /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h:102:45: error: 'cuio_s.uio_offset' is used uninitialized [-Werror=uninitialized]
      102 |                 zfs_uio_soffset(uio) = uio_s->uio_offset;
          |                                        ~~~~~^~~~~~~~~~~~
    /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c: In function 'zio_do_crypt_data':
    /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1683:28: note: 'cuio_s' declared here
     1683 |         struct uio puio_s, cuio_s;
          |                            ^~~~~~

Indeed, `zfs_uio_init()` does:

    static __inline void
    zfs_uio_init(zfs_uio_t *uio, struct uio *uio_s)
    {
            memset(uio, 0, sizeof (zfs_uio_t));
            if (uio_s != NULL) {
                    GET_UIO_STRUCT(uio) = uio_s;
                    zfs_uio_soffset(uio) = uio_s->uio_offset;
            }
    }

while the code in `zio_crypt.c` has:

    /*
     * Primary encryption / decryption entrypoint for zio data.
     */
    int
    zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key,
        dmu_object_type_t ot, boolean_t byteswap, uint8_t *salt, uint8_t *iv,
        uint8_t *mac, uint_t datalen, uint8_t *plainbuf, uint8_t *cipherbuf,
        boolean_t *no_crypt)
    {
            int ret;
            boolean_t locked = B_FALSE;
            uint64_t crypt = key->zk_crypt;
            uint_t keydata_len = zio_crypt_table[crypt].ci_keylen;
            uint_t enc_len, auth_len;
            zfs_uio_t puio, cuio;
            struct uio puio_s, cuio_s;
            uint8_t enc_keydata[MASTER_KEY_MAX_LEN];
            crypto_key_t tmp_ckey, *ckey = NULL;
            freebsd_crypt_session_t *tmpl = NULL;
            uint8_t *authbuf = NULL;

            zfs_uio_init(&puio, &puio_s);
            zfs_uio_init(&cuio, &cuio_s);
            memset(GET_UIO_STRUCT(&puio), 0, sizeof (struct uio));
            memset(GET_UIO_STRUCT(&cuio), 0, sizeof (struct uio));

So between the declaration of `puio_s` and `cuio_s`, there is no
initialization of these variables before `zfs_uio_init()` gets called.

Similar to the Linux variant of zio_crypt.c, I think it would be better
to memset the structs `puio_s` and `cuis_s` _before_ calling
`zfs_uio_init()`.

Reviewed by:    tsoome
MFC after:      3 days
Differential Revision: https://reviews.freebsd.org/D47281
2024-10-25 18:19:25 +02:00
Martin Matuska
87bf66d4a7 zfs: merge openzfs/zfs@b2f6de7b5
Notable upstream pull request merges:
 #16598 b4e4cbeb2 Always validate checksums for Direct I/O reads
 #16603 cefef28e9 vdev_id: multi-lun disks & slot num zero pad
 #16613 ab777f436 Return boolean_t in inline functions of
                  lib/libspl/include/sys/uio.h
 #16616 efeb60b86 FreeBSD: ignore some includes when not building kernel
 #16617 ca0141f32 zpool/zfs: restore -V & --version options
 #16632 7bf525530 zpool/zfs: allow --json wherever -j is allowed
 #16635 7e4be9275 zdb: fix printf format in dump_zap()
 #16640 48dfe3974 Fallback to strerror() when strerror_l() isn't available
 #16650 38a04f0a7 freebsd: Use compiler.h from FreeBSD's base's linuxkpi
 #16664 fba6a9069 zfs_debug: Restore log size limit for userspace
 #16665 fba6a9069 Fix compile-time warnings caused by duplicate struct
                  typedefs
 #16667 b2f6de7b5 zdb: show bp in uberblock dump

Obtained from:	OpenZFS
OpenZFS commit:	b2f6de7b58
2024-10-20 21:26:56 +02:00
Bjoern A. Zeeb
96190b4fef LinuxKPI based WiFi drivers: scripts to extract fwget(8) and port details
Add a "zzz_fw_ports_fwget.sh" script to each LinuxKPI based wireless
driver which in essential are all the same and in detail all different.
The scripts have been referenced in fwget(8) sources since d33f5a0afa
but were never committed.

The scripts do the full job compared to `single-line-scripts` I tried to
use before to ease maintainance life.  Some use hacks like calling cpp
and extracting bits from the output to piece them together over multiple
files.  It will be left as an exercise for the future to see if what was
done (a longer while ago) for iwlwifi(4) would be a good idea for some
other drivers too, to have a FreeBSD-specific sysctl to export some of
the accumulated data in an easily processable way.
The scripts are written in the "perl spirit" -- "to get the job done" --
and not to be nice or neat or efficient.  For that we do not need them
often enough or in any critical path.  People are welcome to improve
them if they feel like.
I've used them for two version updates now and even if ports enforce
some other (manual) editing to keep support for multiple branches for
now they worked extremly well.

For the most the scripts extract 2 parts: PCI IDs and firmware name;
then they add "flavor"s to both and put the information together.

That output is then separated into:
- fwget(8) lines of PCI ID to port/package
  wifi-firmware-${name}-kmod-${flavor} mappings and
- distfiles per flavor for the ports.
- For iwlwififw(4) we also generate the tables for the man page
  (and the wiki) and hopefully the .Sh HARDWARE section for iwlwifi.4
  soon too.

Depending on driver various other checks are done, e.g.,
- does the PCI ID have one or more firmware files/flavors associated,
- does the referenced firmware exist in the linux-firmware.git repo,
- are there duplicates,
- find the latest version of the firmware API.

Sponsored by:	The FreeBSD Foundation
Suggested by:	imp (to have automation in D44918)
MFC after:	3 days
2024-10-17 17:26:28 +00:00
Bjoern A. Zeeb
b4c8f251d6 iwlwifi: FreeBSD specific sysctl export update
Update the sysctl export (also adding a mapping function) to also
print (1) for all lines the "flavor" (device_family) name and (2)
also print lines where we only have the trans cfg and not iwl cfg
as with the flavor we can match PCI IDs to firmware package and so
we can have an increased number of matches.
A side effect is that we can also have fwget(8) PCI ID matches for
firmware (flavors) not yet (publicly) existing.  That will allow
us to add them at a later point while a previous release already
supports the chipsets and knows how to get the firmware for them.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-10-17 17:26:24 +00:00
Warner Losh
b487b1f502 openzfs/freebsd: Use compiler.h from FreeBSD's base's linuxkpi
The FreeBSD linux/compiler.h in OpenZFS was copied from a very old
version of FreeBSD's linuxkpi's linux/compiler.h. There's no need for
this duplication. Use FreeBSD's linuxkpi version instead, and provide
zfs_fallthrough to augment it (it's all that's needed). Use #pragma once
to avoid naming issues for guard variables. Since this is a complete
rewrite, use my copyright here (the original code in FreeBSD still
credits everybody).

Remove extra copies of macros that were defined elsewhere, but are now
properly defined in LinuxKPI so are redundant.

This is currently pull request #16650 upstream. Committing now to get
wider testing (make universe works, but historically doesn't catch all
errors).

Sponsored by:		Netflix
Reviewed by:		brooks
Differential Revision:	https://reviews.freebsd.org/D47131
2024-10-15 15:05:49 -06:00
Osama Abboud
f5f8d7c9cd ena: Upgrade ena-com to freebsd v2.8.0
Merge commit '0fd934a2fd12fa74ae409d3de1313e449be5d97e'

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
2024-10-15 17:02:26 +00:00
Sia Jee Heng
8056c66557 acpica: Update the SPCR table to version 4
cherry pick 1eeff52124a45d5cd887ba5687bbad0116e4d211 from acpica:

SPCR: Update the SPCR table to version 4

The Microsoft Serial Port Console Redirection (SPCR) specification
revision 1.09 comprises additional fields [1]. The newly added fields
are:
- RISC-V SBI
- Precise Baud Rate
- NamespaceStringLength
- NamespaceStringOffset
- NamespaceString

Additionaly, this code will support up to SPCR revision 1.10, as it
includes only minor wording changes.

[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table

Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com>
2024-10-11 12:06:33 -06:00
Bjoern A. Zeeb
ce15215bef rtw89: add missing bsddriver.name assignments for two chipsets
On FreeBSDs we locally set bsddriver.name in struct pci_driver to have
the same name for all chipsets.  This helps with, e.g., device
enumeration.  For two chipsets the manual entry was missing.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-10-11 13:40:15 +00:00
Martin Matuska
7a7741af18 zfs: merge openzfs/zfs@b10992582
Notable upstream pull request merges:
 #9416  -multiple zio_compress: introduce max size threshold
 #10018 a10e552b9 Adding Direct IO Support
 #15147 e419a63bf xattr dataset prop: change defaults to sa
 #15454 7e957fde7 send/recv: open up additional stream feature flags
 #15810 0d77e738e Defer resilver only when progress is above a threshold
 #15921 3cf2bfa57 Allocate zap_attribute_t from kmem instead of stack
 #16483 -multiple dmu_objset: replace dnode_hash impl with cityhash4
 #16485 8be2f4c3d zio_resume: log when unsuspending the pool
 #16491 88433e640 sys/types32.h: Remove struct timeval32 from libspl header
 #16496 f245541e2 zfs_file: implement zfs_file_deallocate for FreeBSD 14
 #16511 308f7c2f1 Fix an uninitialized data access
 #16529 29c9e6c32 Fix handling of DNS names with '-' in them for sharenfs
 #16531 ddf5f34f0 Avoid fault diagnosis if multiple vdevs have errors
 #16539 6f50f8e16 zfs_log: add flex array fields to log record structs
 #16546 d40d40913 Evicting too many bytes from MFU metadata
 #16551 3014dcb76 Reduce and handle EAGAIN errors on AIO label reads
 #16554 80645d658 FreeBSD: restore zfs_znode_update_vfs()
 #16565 832f66b21 FreeBSD: Sync taskq_cancel_id() returns with Linux
 #16567 48d1be254 Properly release key in spa_keystore_dsl_key_hold_dd()
 #16569 141368a4b Restrict raidz faulted vdev count
 #16583 c84a37ae9 lua: add flex array field to TString type
 #16584 86737c592 Avoid computing strlen() inside loops
 #16587 d34d4f97a snapdir: add 'disabled' value to make .zfs inaccessible
 #16593 224393a32 feature: large_microzap
 #16597 412105977 Temporarily disable Direct IO by default
 #16605 4ebe674d9 ARC: Cache arc_c value during arc_evict()

Backported pull request merges:
 #16613 ab777f436 Return boolean_t in inline functions of
                  lib/libspl/include/sys/uio.h
 #16616 efeb60b86 FreeBSD: ignore some includes when not building kernel
 #16635 ---TBD--- zdb: fix printf format in dump_zap()

Obtained from:	OpenZFS
OpenZFS commit:	b109925820
OpenZFS tag:	2.3.0-rc1
2024-10-11 08:43:49 +02:00
John Baldwin
59f5f100b7 openzfs: Reduce local diffs
These are all local diffs that have no functional change.

Reviewed by:	mav, emaste
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D46530
2024-10-03 12:07:43 -04:00
Jamie Gritton
ae1a0648b0 jail: unbreak the zfs.mount_snapshot option
The change of its description from integer to boolean didn't actually
change it to a boolean, but only made it impossible to set as either
a boolean or an integer.

Rather than make it work as a boolean parameter should, just revert
to the old (working) integer parameter, and change the documentation
to match.

PR:		274263
Reported by:	andrew.hotlab at hotmail
2024-09-19 12:49:01 -07:00
Bjoern A. Zeeb
7728586800 mt76: add mt7615 to the pile of buildable drivers
Ignoring page_pools with the few needed adjustments and ignoring 7622
mt7615 seems to build as well.  Add it so once we can connect it to
the build people can start testing and debugging.
(The actual work was done on a newer version of the mt76 drivers but
it seems the to-build-changes equally apply here already).

Requested by:	Radu-Cristian Fotescu (freebsd-wireless, 2024-07-31)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-09-13 00:18:02 +00:00
Jessica Clarke
796c6031cd Merge commit 88433e640d from upstream OpenZFS (by Jessica Clarke)
sys/types32.h: Remove struct timeval32 from libspl's header (#16491)

  macOS Sequoia's sys/sockio.h, as included by various bootstrap tools
  whilst building FreeBSD, has started to include net/if.h, which then
  includes sys/_types/_timeval32.h and provide a conflicting definition
  for struct timeval32. Since this type is entirely unused within OpenZFS,
  simply delete the type rather than adding in some kind of OS detection.

  This fixes building FreeBSD on macOS Sequoia (Beta).

  Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
  Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
  Reviewed-by: Alexander Motin <mav@FreeBSD.org>
  Reviewed-by: Tony Hutter <hutter2@llnl.gov>

MFC after:	1 week
2024-09-11 18:01:06 +01:00
Mariusz Zaborski
7f4731ab67 libnv: correct the calculation of the structure's size
Reported by:	Milosz Kaniewski <milosz.kaniewski@gmail.com>
2024-09-11 16:43:43 +02:00
Baptiste Daroussin
001ca4955e zdb: fix build on 32bits 2024-09-10 15:41:26 +02:00
Martin Matuska
e2df9bb441 zfs: merge openzfs/zfs@b10992582
Notable upstream pull request merges:
 #15892 -multiple Fast Dedup: Introduce the FDT on-disk format and feature flag
 #15893 -multiple Fast Dedup: “flat” DDT entry format
 #15895 -multiple Fast Dedup: FDT-log feature
 #16239 6be8bf555 zpool: Provide GUID to zpool-reguid(8) with -g
 #16277 -multiple Fast Dedup: prune unique entries
 #16316 5807de90a Fix null ptr deref when renaming a zvol with snaps and snapdev=visible
 #16343 77a797a38 Enable L2 cache of all (MRU+MFU) metadata but MFU data only
 #16446 83f359245 FreeBSD: fix build without kernel option MAC
 #16449 963e6c9f3 Fix incorrect error report on vdev attach/replace
 #16505 b10992582 spa_prop_get: require caller to supply output nvlist

Obtained from:	OpenZFS
OpenZFS commit:	b109925820
2024-09-09 18:13:02 +02:00
Rob Norris
d59a761834 spa_prop_get: require caller to supply output nvlist
All callers to spa_prop_get() and spa_prop_get_nvlist() supplied their
own preallocated nvlist (except ztest), so we can remove the option to
have them allocate one if none is supplied.

This sidesteps a bug in spa_prop_get(), where the error var wasn't
initialised, which could lead to the provided nvlist being freed at the
end.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
(cherry picked from commit 366d6fecf6bb3c59668b0f3b89f2a610595f3d2f)
2024-09-05 10:27:35 -07:00
Mariusz Zaborski
241a7ddd71 libnv: add tests to verify potential overflow issues
Differential Revision:  https://reviews.freebsd.org/D46131
2024-09-04 13:43:16 +02:00
Mariusz Zaborski
3aaaca1b51 libnv: verify that string is null terminated
During unpacking, we ensure that we do not read beyond the
declared size. However, unpack uses a function that copies
null-terminated strings. Prior to this commit, if the last string
was not null-terminated, it could result in copying data into a
buffer smaller than the allocated size.

Security:       FreeBSD-24:09.libnv
Security:       CVE-2024-45288
Security:       CAP-03
Reported by:    Synacktiv
Sponsored by:   The Alpha-Omega Project
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46138
2024-09-04 13:42:55 +02:00
Mariusz Zaborski
36fa90dbde libnv: allocate buffer in a safe way
Ensure that the calculation of size of array doesn't
overflow.

Security:	FreeBSD-24:09.libnv
Security:	CVE-2024-45287
Security:	CAP-02
Reported by:	Synacktiv
Reported by:	Taylor R Campbell (NetBSD)
Sponsored by:	The Alpha-Omega Project
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D46131
2024-09-04 13:42:49 +02:00
Zhenlei Huang
778ea7ed5a vchiq(4): Stop checking for failures from malloc(M_WAITOK)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45852
2024-09-03 18:25:34 +08:00
Zhenlei Huang
66c35a6675 krping: Stop checking for failures from malloc(M_WAITOK)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45852
2024-09-03 18:25:21 +08:00
Warner Losh
ce7fac64ba Revert "nvme: Separate total failures from I/O failures"
All kinds of crazy stuff was mixed into this commit. Revert
it and do it again.

This reverts commit d5507f9e43.

Sponsored by:		Netflix
2024-08-15 21:29:53 -06:00
Warner Losh
d5507f9e43 nvme: Separate total failures from I/O failures
When it's a I/O failure, we can still send admin commands. Separate out
the admin failures and flag them as such so that we can still send admin
commands on half-failed drives.

Fixes: 9229b3105d (nvme: Fail passthrough commands right away in failed state)
Sponsored by: Netflix
2024-08-15 20:22:18 -06:00
Martin Matuska
29dc934914 zfs: merge openzfs/zfs@d2ccc2155
Notable upstream pull request merges:
 #16431 244ea5c48 Add missing kstats to dataset kstats

Obtained from:	OpenZFS
OpenZFS commit: d2ccc21552
2024-08-15 13:30:31 +02:00
Paul Dagnelie
bd4f2023bb Add missing kstats to dataset kstats
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #16431
(cherry picked from commit 244ea5c488)
2024-08-14 15:42:00 -07:00
Gleb Smirnoff
b458ddf27f zfs: fix build without MAC 2024-08-14 09:06:31 -07:00
Martin Matuska
ce4dcb97ca zfs: merge openzfs/zfs@9c56b8ec7
Notable upstream pull request merges:
 #15817 5536c0dee Sync AUX label during pool import
 #15889 c7ada64bb ddt: dedup table quota enforcement
 #15890 62e7d3c89 ddt: add support for prefetching tables into the ARC
 #15894 e26b3771e spa_preferred_class: pass the entire zio
 #15894 d54d0fff3 dnode: allow storage class to be overridden by object type
 #16197 55427add3 Several improvements to ARC shrinking
 #16217 -multiple JSON output for various zfs and zpool subcommands
 #16248 24e6585e7 libzfs.h: Set ZFS_MAXPROPLEN and ZPOOL_MAXPROPLEN
                  to ZAP_MAXVALUELEN
 #16264 9dfc5c4a0 Fix long_free_dirty accounting for small files
 #16268 ed0db1cc8 Make txg_wait_synced conditional in zfsvfs_teardown,
                  for FreeBSD
 #16288 d60debbf5 Fix sa_add_projid to lookup and update SA_ZPL_DXATTR
 #16308 ec580bc52 zfs: add bounds checking to zil_parse
 #16310 c21dc56ea Fix zdb_dump_block for little endian
 #16315 7ddc1f737 zil: add stats for commit failure/fallback
 #16326 b0bf14cdb abd: lift ABD zero scan from zio_compress_data()
                  to abd_cmp_zero()
 #16337 c8184d714 Block cloning conditionally destroy ARC buffer
 #16338 dbe07928b Add support for multiple lines to the sharenfs property
                  for FreeBSD
 #16374 1a3e32e6a Cleanup DB_DNODE() macros usage
 #16374 ed87d456e Skip dnode handles use when not needed
 #16346 fb6d8cf22 Add some missing vdev properties
 #16364 670147be5 zvol: ensure device minors are properly cleaned up
 #16382 dea8fabf7 FreeBSD: Fix RLIMIT_FSIZE handling for block cloning
 #16387 aef452f10 Improve zfs_blkptr_verify()
 #16395 cbcb52243 Fix the names of some FreeBSD sysctls in
                  include/tunables.cfg
 #16401 5b9f3b766 Soften pruning threshold on not evictable metadata
 #16404 cdd53fea1 FreeBSD: Add missing memory reclamation accounting
 #16404 1fdcb653b Once more refactor arc_summary output
 #16419 1f5bf91a8 Fix memory corruption during parallel zpool import
                  with -o cachefile
 #16426 cf6e8b218 zstream: remove duplicate highbit64 definition

Obtained from:	OpenZFS
OpenZFS commit:	9c56b8ec78
2024-08-10 11:43:43 +02:00
Dimitry Andric
82246ac5d8 Fix enum warnings in ath_hal's ar9300
This fixes a number of clang 19 warnings:

    sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:709:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
      709 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
      148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
          |       ~~~ ^  ~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:745:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
      745 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
      148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
          |       ~~~ ^  ~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:781:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
      781 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
      148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
          |       ~~~ ^  ~~~~~~~~~~~~~~~~~~

The `FBIN2FREQ()` and `FREQ2FBIN()` macros in `ar9300eep.h` are invoked
in most places around the `ath_hal` code with a (effectively) boolean
second argument, corresponding to "is this 2GHz?". But in the code that
is warned about, the value `HAL_FREQ_BAND_2GHZ` is of a different
non-boolean type, `HAL_FREQ_BAND`.

Update the `FBIN2FREQ()` and `FREQ2FBIN()` macros to interpret the
second argument as boolean value, and rename the macro parameter names
to better describe their meaning.

Reviewed by:	adrian, bz
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D46201
2024-08-04 14:31:06 +02:00
Mark Johnston
f029f62779 zdb: Fix printf formatting of a uint64_t
This fixes the build on 32-bit platforms.

Fixes:	dc91e74524 ("zdb: dump ZAP_FLAG_UINT64_KEY ZAPs properly (#16334)")
2024-07-18 10:52:52 -04:00
Martin Matuska
75e1fea68a zfs: merge openzfs/zfs@1147a2797
Notable upstream pull request merges:
 #16209 --multi-- icp: rip out everything we don't use
 #16230 20c8bdd85 FreeBSD: Update use of UMA-related symbols in
                  arc_available_memory
 #16242 121a2d335 FreeBSD: unregister mountroot eventhandler on unload
 #16258 5de3ac223 vdev_open: clear async fault flag after reopen
 #16270 436731276 zvol: Fix suspend lock leaks
 #16273 c87cb22ba head_errlog: fix use-after-free
 #16284 f72e081fb FreeBSD: Use a statement expression to implement
                  SET_ERROR()
 #16300 a10faf5ce FreeBSD: Use the new freeuio() helper to free dynamically
                  allocated UIOs
 #16302 a7fc4c85e zstd: don't call zstd_mempool_reap if there are no buffers
 #16334 dc91e7452 zdb: dump ZAP_FLAG_UINT64_KEY ZAPs properly

Obtained from:	OpenZFS
OpenZFS commit: 1147a27978
2024-07-18 10:02:12 +02:00
Warner Losh
e9ac41698b Remove residual blank line at start of Makefile
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Jamie Gritton
9cbf1de7e3 Mark the zfs.mount_snapshot jail parameter as boolean.
PR:		274263
Differential Revision:	https://reviews.freebsd.org/D45647
2024-06-24 13:00:49 -07:00
Mark Johnston
e5a7890dc0 zfs: Use a statement expression to implement SET_ERROR()
This way we can avoid making assumptions about the SDT probe
implementation.  No functional change intended.

This was submitted upstream as https://github.com/openzfs/zfs/pull/16284

MFC after:	1 week
2024-06-19 16:57:30 -04:00
Jessica Clarke
fe2b60f87e openzfs: Fix mismerge breaking macOS bootstrap
Upstream added the libspl_gettid implementation for macOS and when
merging back to FreeBSD this resulted in two copies of the same code.
Delete this second copy, restoring the file to be the same as upstream.

Fixes:	aca928a50a ("zfs: merge openzfs/zfs@e2357561b")
2024-05-31 22:12:18 +01:00
Warner Losh
d0a9cc17ba sys/contrib: Mop up $FreeBSD$ tags
Mop up left-over $FreeBSD$ tags that aren't in upstream and were added
for the previous $FreeBSD$ checker.

Sponsored by:		Netflix
2024-05-31 13:45:26 -06:00
Martin Matuska
aca928a50a zfs: merge openzfs/zfs@e2357561b
Notable upstream pull request merges:
 #15940 41ae864b6 Replace P2ALIGN with P2ALIGN_TYPED and delete P2ALIGN
 #16128 5137c132a zpool import output is not formated properly
 #16138 efbef9e6c FreeBSD: Add zfs_link_create() error handling
 #16146 04bae5ec9 Disable high priority ZIO threads on FreeBSD and Linux
 #16151 cc3869153 zfs_ioc_send: use a dedicated taskq thread for send
 #16151 adda768e3 spa: remove spa_taskq_dispatch_sync()
 #16151 515c4dd21 spa: flatten spa_taskq_dispatch_ent()
 #16151 0a543db37 spa_taskq_dispatch_ent: simplify arguments
 #16153 975a13259 Add support for parallel pool exports
 #16153 89acef992 Simplified the scope of the namespace lock
 #16159 136c05321 ZAP: Fix leaf references on zap_expand_leaf() errors
 #16162 af5dbed31 Fix scn_queue races on very old pools
 #16165 3400127a7 Fix ZIL clone records for legacy holes
 #16167 414acbd37 Unbreak FreeBSD cross-build on MacOS broken in 051460b8b
 #16172 eced2e2f1 libzfs: Fix mounting datasets under thread limit pressure
 #16178 b64afa41d Better control the thread pool size when mounting datasets
 #16181 fa99d9cd9 zfs_dbgmsg_print: make FreeBSD and Linux consistent
 #16191 e675852bc dbuf: separate refcount calls for dbuf and dbuf_user
 #16198 a043b60f1 Correct level handling in zstream recompress
 #16204 34906f8bb zap: reuse zap_leaf_t on dbuf reuse after shrink
 #16206 d0aa9dbcc Use memset to zero stack allocations containing unions
 #16207 8865dfbca Fix assertion in Persistent L2ARC
 #16208 08648cf0d Allow block cloning to be interrupted by a signal
 #16210 e2357561b FreeBSD: Add const qualifier to members of struct
        opensolaris_utsname
 #16214 800d59d57 Some improvements to metaslabs eviction
 #16216 02c5aa9b0 Destroy ARC buffer in case of fill error
 #16225 01c8efdd5 Simplify issig()

Obtained from:	OpenZFS
OpenZFS commit:	e2357561b9
2024-05-31 11:26:50 +02:00
Bojan Novković
4c053c17f2 zfs: Update use of UMA-related symbols in arc_available_memory
da76d34 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. This change was submitted to upstream
as well.

Approved by:	markj (mentor)
Fixes:	da76d34
2024-05-27 15:47:17 +02:00
Alexander Motin
49086aa35d Fix scn_queue races on very old pools
Code for pools before version 11 uses dmu_objset_find_dp() to scan
for children datasets/clones.  It calls enqueue_clones_cb() and
enqueue_cb() callbacks in parallel from multiple taskq threads.
It ends up bad for scan_ds_queue_insert(), corrupting scn_queue
AVL-tree.  Fix it by introducing a mutex to protect those two
scan_ds_queue_insert() calls.  All other calls are done from the
sync thread and so serialized.

Reviewed-by:	Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by:	Brian Atkinson <batkinson@lanl.gov>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes	#16162
PR:	278414
2024-05-23 12:20:37 -04:00
Brooks Davis
d316de24fa zfs: 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.

Fix i386 gcc builds while we wait for this to be merged to OpenZFS.

Sponsored by:	DARPA, AFRL
Pull Request:	https://github.com/openzfs/zfs/pull/16203
2024-05-17 17:01:19 +01:00
Emmanuel Vadot
8d13bc63c0 Import device-tree files from Linux 6.8
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-05-06 10:46:36 +02:00
Emmanuel Vadot
84943d6f38 Import device-tree files from Linux 6.7
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-05-06 10:45:28 +02:00
Emmanuel Vadot
aa1a8ff2d6 Import device-tree files from Linux 6.6
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-05-06 10:43:59 +02:00
Martin Matuska
3c1be0b261 zfs: unbreak macOS bootstrap
Temporary patch until vendor implements a fix.
2024-05-04 01:58:25 +02:00
Martin Matuska
b985c9cafd zfs: merge openzfs/zfs@8f1b7a6fa
Notable upstream pull request merges:
 #15839 c3f2f1aa2 vdev probe to slow disk can stall mmp write checker
 #15888 5044c4e3f Fast Dedup: ZAP Shrinking
 #15996 db499e68f Overflowing refreservation is bad
 #16118 67d13998b Make more taskq parameters writable
 #16128 21bc066ec Fix updating the zvol_htable when renaming a zvol
 #16130 645b83307 Improve write issue taskqs utilization
 #16131 8fd3a5d02 Slightly improve dnode hash
 #16134 a6edc0adb zio: try to execute TYPE_NULL ZIOs on the current task
 #16141 b28461b7c Fix arcstats for FreeBSD after zfetch support

Obtained from:	OpenZFS
OpenZFS commit:	8f1b7a6fa6
2024-05-03 18:05:08 +02:00
Martin Matuska
0d4ad64077 zfs: merge openzfs/zfs@1f940de07
Notable upstream pull request merges:
 #16038 1f940de07 L2ARC: Cleanup buffer re-compression
 #16093 c183d164a Parallel pool import
 #16094 cd3e6b4f4 Add zfetch stats in arcstats
 #16103 35bf25848 Fix: FreeBSD Arm64 does not build currently
 #16104 4036b8d02 Refactor dbuf_read() for safer decryption
 #16110 9f83eec03 Handle FLUSH errors as "expected"
 #16117 c346068e5 zfs get: add '-t fs' and '-t vol' options

Obtained from:  OpenZFS
OpenZFS commit: 1f940de072
2024-04-23 23:59:18 +02:00
Brooks Davis
04e0313a71 ztest: use ASSERT3P to compare pointers
Fixes i386-gcc13 build.  Direct commit while waiting for upstream.

Pull Request: https://github.com/openzfs/zfs/pull/16115
2024-04-19 22:31:53 +01:00
Martin Matuska
b9dee1dca2 zfs: unbreak aarch64 build with non-gcc compilers
Workaround until a permanent fix comes from vendor
2024-04-17 06:44:12 +02:00
Martin Matuska
1719886f6d zfs: merge openzfs/zfs@90ba19eb7
Notable upstream pull request merges:
 #15784 90ba19eb7b Do no use .cfi_negate_ra_state within the assembly
                   on Arm64
 #15942 b6bbaa8372 Give a better message from 'zpool get' with invalid
                   pool name
 #15943 ca678bc0bc Makefile.bsd: sort and cleanup source file list
 #15953 fa480fe5ba zinject: show more device fault fields
 #15983 30c4eba4ea Fix panics when truncating/deleting files
 #15992 99741bde59 zvol: use multiple taskq
 #16015 a100a195fa Add support for zfs mount -R <filesystem>
 #16022 5e5fd0a178 Speculative prefetch for reordered requests
 #16040 997f85b4d3 L2ARC: Relax locking during write
 #16042 b12738182c Improve dbuf_read() error reporting
 #16051 a9a4290173 xdr: header cleanup
 #16052 eeca9a91d6 Fix read errors race after block cloning
 #16057 aa5445c28b Remove db_state DB_NOFILL checks from syncing context
 #16061 76d1dde94c zinject: inject device errors into ioctls
 #16072 9e63631dea Small fix to prefetch ranges aggregation
 #16077 44f337be30 Illumos#16463 zfs_ioc_recv leaks nvlist
 #16085 4725e543be zinject: "no-op" error injection
 #16086 c6da985e28 Add the BTI elf note to the AArch64 SHA2 assembly

Obtained from:	OpenZFS
OpenZFS commit:	90ba19eb7b
2024-04-16 22:54:07 +02:00
Martin Matuska
783d3ff6d7 zfs: merge openzfs/zfs@39be46f43
Notable upstream pull request merges:
 #15509 b1e46f869 Add ashift validation when adding devices to a pool
 #15927 45e23abed Update resume token at object receive
 #15941 bf8f72359 BRT: Skip duplicate BRT prefetches
 #15950 8cd8ccca5 BRT: Skip getting length in brt_entry_lookup()
 #15951 80cc51629 ZAP: Massively switch to _by_dnode() interfaces
 #15954 2c01cae8b BRT: Change brt_pending_tree sorting order
 #15955 4616b96a6 BRT: Relax brt_pending_apply() locking
 #15959 5c4a4f82c zio: update ZIO type x stage documentation
 #15962 493fcce9b Provide macros for setting and getting blkptr birth times
 #15963 90ff73235 freebsd: fix missing headers in distribution tarball
 #15967 f68bde723 BRT: Make BRT block sizes configurable
 #15976 c28f94f32 ZAP: Some cleanups/micro-optimizations
 #15995 cfb96c772 vdev_disk: clean up spa/bdev mode conversion
 #16006 c0aab8b8f zvols: prevent overflow of minor device numbers
 #16007 a89d209bb BRT: Fix holes cloning
 #16008 c9d8f6c59 Fix option string, adding -e and fixing order

Obtained from:	OpenZFS
OpenZFS commit:	39be46f43f
2024-03-30 23:54:24 +01:00