Commit Graph

1373 Commits

Author SHA1 Message Date
Martin Matuska
b9c2c366db zfs: merge openzfs/zfs@fb6d53206 (zfs-2.1-release) into stable/13
Notable upstream pull request merges:
 #13976 3ad882658 Avoid calling rw_destroy() on uninitialized rwlock
 #15243 11574a793 Add zfs_prepare_disk script for disk firmware install
 #15331 e1bc32f71 Report ashift of L2ARC devices in zdb
 #15675 12a031a3f spa: make read/write queues configurable
 #15719 b4481996b spa: Fix FreeBSD sysctl handlers
 #15719 8e5298f0a spa: Let spa_taskq_param_get()'s addition of a newline
                       be optional
 #15769 dfece78a4 Add 'zpool status -e' flag to see unhealthy vdevs
 #15847 d1ee3d611 LUA: Backport CVE-2020-24370's patch

Obtained from:	OpenZFS
OpenZFS commit:	fb6d532066
OpenZFS tag:	zfs-2.1.15
2024-03-01 15:16:06 +01:00
Alan Somers
e2ce586899 zfsd: fault disks that generate too many I/O delay events
If ZFS reports that a disk had at least 8 I/O operations over 60s that
were each delayed by at least 30s (implying a queue depth > 4 or I/O
aggregation, obviously), fault that disk.  Disks that respond this
slowly can degrade the entire system's performance.

Sponsored by:	Axcient
Reviewed by:	delphij
Differential Revision: https://reviews.freebsd.org/D42825

(cherry picked from commit d565784a7e)
2024-01-19 13:16:48 -07:00
Michael Tuexen
dc2408133b dtrace: fix constants used by the siftr probe
The constants used in the C code were changed in
https://svnweb.freebsd.org/changeset/base/343646
but changing them also in the dtrace translator was missed.

Reviewed by:		cc, rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D40805

(cherry picked from commit f5541b85a5)
2024-01-11 10:00:33 +01:00
Mark Johnston
693dbc0070 ctfconvert: Handle DW_AT_data_bit_offset
This attribute is new in DWARF 4 and supersedes DW_AT_bit_offset.

PR:		276059
Reported by:	rscheff
Tested by:	rscheff
MFC after:	1 week

(cherry picked from commit 78cd75393e)
2024-01-08 20:00:31 -05:00
Mark Johnston
cc8af47b6d libdtrace: Fix TCP data offset handling in the tcpinfo_t translator
The header gives an offset in 32-bit words, and the translator is
supposed to convert that to a byte count.  But, the conversion was
incorrect.

Reviewed by:	tuexen, rscheff
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43264

(cherry picked from commit c3268c23de)
2024-01-08 20:00:30 -05:00
Mark Johnston
6418d08ae4 libdtrace: Fix line number reporting in error messages
MFC after:	1 week

(cherry picked from commit ad3174ecea)
2024-01-07 11:56:42 -05:00
John Baldwin
37ba303aa0 Trim various $FreeBSD$
Approved by:	markj (cddl/contrib changes)
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41961

(cherry picked from commit f53355131f)
2023-10-24 11:23:57 -07:00
Alan Somers
3676929d3c Fix zfsd with the device_removal pool feature.
Previously zfsd would crash in the presence of a pool with a
top-level-vdev that had previously been removed.  The crash happened
because the configuration nvlist of such a TLV contains an empty
ZPOOL_CONFIG_CHILDREN array, which led to a pop_front from an empty
list, which has undefined behavior.

The crash only happened in stable/14 and later, probably do to
differences in libcxx, but the change should be MFCed anyway.

PR:		273663
Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
Sponsored by:	Axcient
Reviewed by:	mav
Differential Revision: https://reviews.freebsd.org/D41818

(cherry picked from commit 0b294a386d)
2023-09-21 16:20:43 -06:00
Alan Somers
b969a40cdf zfsd: listen for sysevent.fs.zfs instead of misc.fs.zfs
At some point the names of these devd events changed.  Probably it
happened when importing OpenZFS.  Before that, FreeBSD's sysevent_alloc
method didn't create a "class" nvpair in the event, which led to
log_sysevent using the event's ev_subclass field as its type.

Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D39437

(cherry picked from commit 92642bba4d)

Fix zfsd unittests after 92642bba4d

At the time we ensured that the more important functional tests were
working, but neglected to update the unit tests.

Sponsored by:	Axcient

(cherry picked from commit 2a0c0aea42)
2023-09-06 15:48:55 -06:00
Warner Losh
b144e70a33 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit fa9896e082)
2023-08-23 11:43:31 -06:00
Warner Losh
023fc80ee3 Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit d0b2dbfa0e)
2023-08-23 11:43:30 -06:00
Warner Losh
3d497e17eb Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in main:
(cherry picked from commit 1d386b48a5)
2023-08-23 11:43:26 -06:00
Warner Losh
8ad303d68c Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/

Similar commit in main:
(cherry picked from commit 2a63c3be15)
2023-08-23 11:43:23 -06:00
Warner Losh
34041aac83 Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit 42b388439b)
2023-08-23 11:43:22 -06:00
Warner Losh
17da660ad5 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit b3e7694832)
2023-08-23 11:43:21 -06:00
Mark Johnston
44ee4e90a3 ctfconvert: Integer encoding types are unsigned
Before this change, encodings in the user-defined range were being
sign-extended.

MFC after:	1 week
Sponsored by:	Innovate UK

(cherry picked from commit 258a0d760a)
2023-07-05 09:07:06 -04:00
Christos Margiolis
de55271894 dtrace: add register bindings for RISC-V
Reviewed by:	mhorne, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39611

(cherry picked from commit 1fef7abdc7)
2023-05-07 13:54:08 -04:00
Christos Margiolis
4d9000cb22 dtrace: expose dtrace_instr_size() to userland and implement it for riscv
dtrace_instr_size() is needed by the forthcoming RISC-V port of kinst,
as well as by libdtrace in D38825 for both amd64 and RISC-V.

Reviewed by:	markj, mhorne
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39489

(cherry picked from commit 080e56a6c9)
2023-05-07 13:54:08 -04:00
Mark Johnston
f22bd73428 libdtrace: Do not set SHF_ALLOC on SUNW_dof relocation sections
The section will contain static relocations which do not need to be
preserved after linking, and moreover these relocations may reference
symbols that end up getting removed.

Do not set SHF_ALLOC and instead let the linker decide what needs to be
done.

PR:		258872
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 27f35b7dd4)
2023-04-11 10:10:24 -04:00
Christos Margiolis
3813808b1f libdtrace: fix indendation in dt_printd()
No functional change.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39145

(cherry picked from commit 3afba490c1)
2023-03-27 08:49:30 -04:00
Ed Maste
2dd014ca0c dwatch: install hard links with same mode as target
Previoulsy when using NO_ROOT we recorded METALOG entries for dwatch
hard links with different file modes than their link targets, which is
not permitted.

Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37477

(cherry picked from commit 7543a9c028)
2023-03-23 10:33:01 -04:00
John Baldwin
6611fe011f libicp: Link with -z noexecstack for ld.bfd.
The assembly source files do not contain GNU-stack annotations, so
ld.bfd defaults to using an executable stack.

(cherry picked from commit 7e3e70ce21)
2023-03-22 08:22:06 -07:00
Mark Johnston
1a0e3257ca lockstat: Use gelf.h instead of playing games with the preprocessor
This reverts a portion of 1477dd823e ("Merge OpenZFS support in to
HEAD.").  No functional change intended.

MFC after:	1 week

(cherry picked from commit 49e3972afc)
2023-03-05 12:24:26 -05:00
Mark Johnston
04e14db224 lockstat: Use the correct type for a symbol size
No functional change intended.

MFC after:	1 week

(cherry picked from commit f4f5e69c84)
2023-03-05 12:24:17 -05:00
Zhenlei Huang
95f418fe2a Delete obsolete Solaris compat header file stdlib.h
This drops function `getexecname()` redirection.

Historically `getexecname()` is a compatibility definition. Since
openzfs has its own implementation of function `getexecname()` in libspl
and has been merged into base, the compat header file stdlib.h is
no longer needed and should not be used.

Also without this fix libspl will end up an incompatible version of
`getprogname()` with libc. In particular, if zfs is enabled, programs
such as pgrep in /rescue can be wrongly statically linked with libspl
and will not function properly.

PR:		269738
Reviewed by:	markj
Fixes:		9e5787d228 Merge OpenZFS support in to HEAD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38733

(cherry picked from commit 7f0ebf0876)
2023-03-02 10:56:05 +08:00
Zhenlei Huang
eba26d0ba3 ctf: Remove unused function prototype for getpname()
This function prototype should have been removed along with the
implementation.

Fixes:		3dd5524264 ctfdump: Use getprogname()
MFC after:	1 day

(cherry picked from commit f8e1aa85fe)
2023-02-27 11:12:48 +08:00
Zhenlei Huang
994eb2fb8a ctfdump: Use getprogname()
Also remove no longer used function `getpname()`.

Reviewed by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38740

(cherry picked from commit 3dd5524264)
2023-02-26 09:53:15 +08:00
Emmanuel Vadot
40b8a8f253 pkgbase: Put zfs utilities and lib in their own package
It is useful to have zfs utilities and lib in a separate package as
it allow users to create image that can support ZFS (i.e. not with
WITHOUT_ZFS in src.conf set) without bloating the default image with
all zfs tools (for example for jails).

Differential Revision:	https://reviews.freebsd.org/D36225

(cherry picked from commit a71ea7bea0)
2023-02-02 10:32:55 +01:00
Mark Johnston
98492960c3 libdtrace: Change the binding of USDT probe symbols to STB_WEAK
Otherwise, if multiple object files contain references to the same
probe, newish lld will refuse to link them by default, raising a
duplicate global symbol definition error.  Previously, duplicate global
symbols with identical absolute st_values were permitted by both lld and
GNU ld.

Since dtrace has no use for probe function symbols after the relocation
performed by dtrace -G, make the symbols weak as well, following a
suggestion from MaskRay.

Reported by:	dim
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit be39466a10)
2022-12-19 09:56:38 -05:00
Gordon Bergling
81fc4f36f0 zfsd(8): Fix a typo in an error message
- s/faild/failed/

(cherry picked from commit 4bd5e6221e)
2022-11-01 07:02:22 +01:00
Mark Johnston
d289333e80 libdtrace: Fix some CPU register number definitions to match the kernel
(cherry picked from commit 53a31c87df)
2022-10-19 10:15:59 -04:00
Mark Johnston
247ea4381b dtrace: Add a "regs" variable
This allows invop-based providers (i.e., fbt and kinst) to expose the
register file of the CPU at the point where the probe fired.  It does
not work for SDT providers because their probes are implemented as plain
function calls and so don't save registers.  It's not clear what
semantics "regs" should have for them anyway.

This is akin to "uregs", which nominally provides access to the
userspace registers.  In fact, DIF already had a DIF_VAR_REGS variable
defined, it was simply unimplemented.

Usage example: print the contents of %rdi upon each call to
amd64_syscall():

    fbt::amd64_syscall:entry {printf("%x", regs[R_RDI]);}

Note that the R_* constants are defined in /usr/lib/dtrace/regs_x86.d.
Currently there are no similar definitions for non-x86 platforms.

Reviewed by:	christos

(cherry picked from commit bdd101c4d4)
2022-10-18 09:58:11 -04:00
Martin Matuska
f193a24ec5 zfs: merge openzfs/zfs@6a6bd4939 (zfs-2.1-release) into stable/13
OpenZFS release 2.1.6

Notable upstream pull requeset merges:
  #11733 ICP: Add missing stack frame info to SHA asm files
  #12274 Optimize txg_kick() process
  #12284 Add Module Parameter Regarding Log Size Limit
  #12285 Introduce a tunable to exclude special class buffers from L2ARC
  #12287 Remove refcount from spa_config_*()
  #12425 Avoid small buffer copying on write
  #12516 Fix NFS and large reads on older kernels
  #12678 spa.c: Replace VERIFY(nvlist_*(...) == 0) with fnvlist_*
  #12789 Improve log spacemap load time
  #13022 Add more control/visibility and speedup spa_load_verify()
  #13106 add physical device size to SIZE column in 'zpool list -v'
  #13388 Improve mg_aliquot math
  #13405 Revert "Reduce dbuf_find() lock contention"
  #13452 More speculative prefetcher improvements
  #13476 Refactor Log Size Limit
  #13540 AVL: Remove obsolete branching optimizations
  #13553 Reduce ZIO io_lock contention on sorted scrub
  #13555 Scrub mirror children without BPs
  #13563 FreeBSD: Improve crypto_dispatch() handling
  #13576 Several sorted scrub optimizations
  #13579 Fix and disable blocks statistics during scrub
  #13582 Several B-tree optimizations
  #13591 Avoid two 64-bit divisions per scanned block
  #13606 Avoid memory copies during mirror scrub
  #13613 Avoid memory copy when verifying raidz/draid parity
  #13643 Fix scrub resume from newly created hole
  #13756 FreeBSD: Mark ZFS_MODULE_PARAM_CALL as MPSAFE
  #13767 arcstat: fix -p option
  #13781 Importing from cachefile can trip assertion
  #13794 Apply arc_shrink_shift to ARC above arc_c_min
  #13798 Improve too large physical ashift handling
  #13811 Fix column width in 'zpool iostat -v' and 'zpool list -v'
  #13842 make DMU_OT_IS_METADATA and DMU_OT_IS_ENCRYPTED return B_TRUE
         or B_FALSE
  #13855 zfs recv hangs if max recordsize is less than received
         recordsize
  #13861 Fix use-after-free in btree code
  #13865 vdev_draid_lookup_map() should not iterate outside draid_maps
  #13878 Delay ZFS_PROP_SHARESMB property to handle it for encrypted
         raw receive
  #13882 FreeBSD: Fix integer conversion for vnlru_free{,_vfsops}()
  #13885 Fix incorrect size given to bqueue_enqueue() call in dmu_redact.c
  #13908 FreeBSD: stop passing LK_INTERLOCK to VOP_LOCK
  #13930 zpool: Don't print "repairing" on force faulted drives
  #13954 Fix bad free in skein code

Obtained from:	OpenZFS
OpenZFS tag:	zfs-2.1.6
OpenZFS commit:	6a6bd49398
Relnotes:	yes
2022-10-04 17:52:45 +02:00
Mark Johnston
a853b4c425 ctfconvert: Give bitfield types names distinct from the base type
CTF integers have an explicit width and so can be used to represent
bitfields.  Bitfield types emitted by ctfconvert(1) share the name of
the base integer type, so a struct field with type "unsigned int : 15"
will have a type named "unsigned int".

To avoid ambiguity when looking up types by name, add a suffix to names
of bitfield types to distinguish them from the base type.  Then, if
ctfmerge happens to order bitfield types before the corresponding base
type in a CTF file, a name lookup will return the base type, which is
always going to be the desired behaviour.

PR:		265403
Reported by:	cy
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1165fc9a52)
2022-08-11 10:36:11 -04:00
Mark Johnston
cf63676e08 dtrace tests: Override RLIMIT_CORE for a test which triggers a core dump
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e1700a36a9)
2022-08-11 10:36:11 -04:00
Mark Johnston
28ceed5f7a dtrace tests: Rename some test type names to avoid a conflict
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6a05f14381)
2022-08-11 10:36:11 -04:00
Kornel Dulęba
f470bff421 lockstat: Fix construction of comparision predicates
Passing "0x%p" to sprintf results in double "0x" being printed.
This causes a dtrace script compilation failure when "-d" flag
is specified.
Fix that by removing the extraneous "0x".

Reviewed by:	markj
Approved by:	mw(mentor)
Obtained from:	Semihalf
Sponsored by:	Alstom
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35690

(cherry picked from commit 9dbacce2d4)
2022-07-19 11:37:03 +02:00
Mark Johnston
5def1805d1 ctfdump: Remove definitions of warn() and vwarn()
The presence of the latter causes a link error when building a
statically linked ctfdump(1) because libc defines the same symbol.
libc's warn() is defined as a weak symbol and so does not cause the same
problem, but let's just use libc's version.

Reported by:	stephane rochoy <stephane.rochoy@stormshield.eu>
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 45dd2eaac3)
2022-04-27 20:34:39 -04:00
Mark Johnston
ccb94ba0da ctf: Link CTF toolchain man pages to ctf.5
Also expand the CTF acronym to provide a bit of context.

PR:		259790
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5727eceabc)
2022-04-27 20:34:30 -04:00
Mark Johnston
8b01c3026b libctf: Fix recursive descent into anonymous SOU fields
PR:		262412
Tested by:	dhw, gallatin
Fixes:		a6fb869173 ("libctf: Handle CTFv3 containers")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6e563a1b60)
2022-04-14 15:02:44 -04:00
Mark Johnston
fb89cf93a5 ctf: Avoid passing a caddr_t to roundup2()
For some reason I can't reproduce this locally, but Jenkins complains.

Reported by:	Jenkins
Fixes:		bdf290cd3e ("ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}")

(cherry picked from commit 3fe1f21fb3)
2022-04-06 20:30:45 -04:00
Mark Johnston
d80faf878a ctf: Fix a -Wunused-but-set-variable warning
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cb6f722562)
2022-04-06 20:30:45 -04:00
Mark Johnston
e5b54808f7 ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}
ctfdump handles v2 and v3.  ctfconvert now emits only CTFv3, whereas
ctfmerge can merge v2 and v3 containers into v3 containers.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit bdf290cd3e)
2022-04-06 20:30:45 -04:00
Mark Johnston
a49aa9da78 libctf: Handle CTFv3 containers
In general, the patch adds indirection to minimize the amount of code
that needs to know about differences between v2 and v3.  Specifically,
some new ctf_get_ctt_* functions are added, and new LCTF_* macros are
added to use the underlying container's version to do the right thing.

CTF containers can have parent/child relationships, wherein a type ID in
one container refers to a type in the parent.  It is permitted for the
parent and child to have different versions.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a6fb869173)
2022-04-06 20:30:45 -04:00
Mark Johnston
9818e5ebf3 ctf: Add definitions for CTFv3
These are based on definitions added to binutils' libctf.  Specifically:
- Type IDs are now encoded in 32 bits rather than 16, changing the
  layout of ctf_type_t, ctf_array_t, ctf_member_t and ctf_lmember_t.
- Type info is encoded in 32 bits rather than 16.  The type "kind" is
  extended from 5 bits to 6, and the type "vlen" is extended from 10
  bits to 25.

The main upside is that we remove the current limit, imposed by CTFv2,
of 2^{15} distinct types in the main kernel executable.  Other limits,
such as that on the number of elements in an enum, imposed by the vlen
limit, are also raised.

This change adds v2 and v3 flavours of macros and type definitions which
differ between the two versions.  Compatibility is preserved for now by
having generic names refer to the v2 definitions, so, e.g., ctf_type_t
is still a v2 type.

No functional change intended.

Reviewed by:	Domagoj Stolfa
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 994297b01b)
2022-04-06 20:30:44 -04:00
Mark Johnston
3681c4f065 ctf: Import ctf.h from OpenBSD
Use it instead of the existing ctf.h from OpenSolaris.  This makes it
easier to use CTF in the core kernel, and to extend the CTF format to
support wider type IDs.

The imported ctf.h is modified to depend only on _types.h, and also to
provide macros which use the "parent" bit of a type ID to refer to types
in a parent CTF container.

No functional change intended.

Reviewed by:	Domagoj Stolfa, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2d5d2a986c)
2022-04-06 20:30:44 -04:00
Li-Wen Hsu
937d08454b
dtrace tests: Fix expected outout for tst.system.d
This is follow up of d500a85e64

PR:		262415
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 16e02ae401)
2022-03-09 11:42:23 +08:00
Mark Johnston
2d30593c24 libctf: Use const ctf_file_t references in string lookup routines
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 45c23c2608)
2022-03-02 08:59:25 -05:00
Mark Johnston
78fb81dec2 libctf: Remove checks for CTFv1
Per commit 7db423d692 ("libctf: Rip out CTFv1 support") this support
is obsolete.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 565518046c)
2022-03-02 08:58:59 -05:00
Mark Johnston
afc0a40772 libdtrace: Add a missing newline to an error message
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1ef441f699)
2022-03-02 08:58:47 -05:00