path: root/sys/cddl/contrib/opensolaris
Commit message (Collapse)AuthorAgeFilesLines
* dtrace: Fix a kernel panic in printm()Domagoj Stolfa2023-09-061-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | When using printm(), one should always pass a scratch pointer to it. This is achieved by calling printm with memref BEGIN { printm(fixed_len, memref(ptr, var_len)); } which will return a pointer to the DTrace scratch space of size sizeof(uintptr_t) * 2. However, one can easily call printm() as follows BEGIN { printm(10, (void *)NULL); } and panic the kernel as a result. This commit does two things: (1) adds a new macro DTRACE_INSCRATCHPTR(mstate, ptr, howmany) which checks if a certain pointer is in the DTrace scratch space; (2) uses DTRACE_INSCRATCHPTR() to implement a check on printm()'s DIFO return value in order to avoid the panic and sets CPU_DTRACE_BADADDR if the address is not in the scratch space. Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D41722
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-164-8/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* inline_fls: remove redundant INLINE_FLS testDoug Moore2023-07-061-2/+2
| | | | | | | HAS_INLINE_FLS and similar macros are defined always. Removes the redundant tests for these always-true conditions. Reviewed by: mhorne Differential Revision: https://reviews.freebsd.org/D40707
* dtrace: deduplicate arm64 breakpoint definitionChristos Margiolis2023-06-031-0/+6
| | | | | | | Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40363
* dtrace: deduplicate some RISC-V functionsChristos Margiolis2023-05-301-0/+8
| | | | | | | | | | match_opcode() is defined in FBT, kinst, and dtrace_subr.c. The function prologue-checking functions are defined in FBT and kinst. Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40335
* dtrace: remove ifdef around dtrace_instr_size()Christos Margiolis2023-05-231-2/+0
| | | | | | | | | | | | Architectures that are not included in the #ifdef won't be able to compile libdtrace. This was tested on an ARM64 build. If the ifdef is removed, libdtrace can be compiled with no problems, otherwise it fails at libdtrace. Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39948
* dtrace: export dtrace_dis_get_byte()Christos Margiolis2023-05-221-0/+4
| | | | | | | | | | | | kinst uses this function as well, but because it is not exported, it implements its own copy of it. The patch also exposes the function to userland, so programs that need to use dtrace_disx86() can use this function instead of rolling their own copies. Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39871
* dtrace: expose dtrace_instr_size() to userland and implement it for riscvChristos Margiolis2023-04-201-1/+4
| | | | | | | | | | 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
* dtrace: get rid of uchar_t typesChristos Margiolis2023-04-201-2/+2
| | | | | | | | | | Callers are specifying uint8_t anyway and this slightly reduces dependencies on compatibility typedefs. No functional change intended. Reviewed by: markj, mhorne MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39490
* dtrace: Improve a verifier error messageDomagoj Stolfa2023-01-241-10/+10
| | | | | | | | | | | Using '%r0' in efunc causes it to parse %r as a 'r' specifier. This diff just adds a '%' in front of '%r0' in order to create the correct output. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38176
* powerpc/dtrace: Guard fuword64 usage for powerpc64 onlyJustin Hibbits2022-11-211-0/+4
| | | | | | | | | | | 32-bit powerpc doesn't have a fuword64, so only use it on powerpc64. This could also be done elsewhere that splits 32-bit and 64-bit accesses, but adding ifdefs everywhere would just clutter up the source for little benefit. This is the only usage of fuword64 directly; other archs have a dtrace_fuword64_nocheck(), but powerpc does not, and I don't see a need to add it currently. MFC after: 1 week
* dtrace: Make pid provider work on trivial testsJustin Hibbits2022-10-301-0/+4
| | | | | | | | | | | 'newpc' needs set in the "common" case. With this, the trivial test $ dtrace -n 'pid$target:libc:strlen:entry { trace(timestamp); }' -p <pid> now works. MFC after: 3 weeks
* dtrace: Add a "regs" variableMark Johnston2022-10-041-19/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D36799
* dtrace/amd64: Implement emulation of call instructionsMark Johnston2022-08-091-0/+4
| | | | | | | | | | | | | | | | | | | Here, the provider is responsible for updating the trapframe to redirect control flow and for computing the return address. Once software-saved registers are restored, the emulation shifts the remaining context down on the stack to make space for the return address, then copies the address provided by the invop handler. dtrace_invop() is modified to allocate temporary storage space on the stack for use by the provider to return the return address. This is to support a new provider for amd64 which can instrument arbitrary instructions, not just function entry and exit instructions as FBT does. In collaboration with: christos Sponsored by: Google, Inc. (GSoC 2022) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Adjust dtrace_getf_barrier() definition to avoid clang 15 warningDimitry Andric2022-07-191-1/+1
| | | | | | | | | | | | | | | With clang 15, the following -Werror warnings is produced: sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c:17019:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] dtrace_getf_barrier() ^ void This is because dtrace_getf_barrier() is declared with a (void) argument list, but defined with an empty argument list. Make the definition match the declaration. MFC after: 3 days
* Use KERNEL_PANICKED() in more placesMitchell Horne2022-06-021-2/+2
| | | | | | | | | | This is slightly more optimized than checking panicstr directly. For most of these instances performance doesn't matter, but let's make KERNEL_PANICKED() the common idiom. Reviewed by: mjg MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D35373
* zfs: merge openzfs/zfs@a86e08941 (master) into mainMartin Matuska2022-03-081-2/+2
| | | | | | | | | | | | | | | | | | | | Notable upstream pull request merges: #9078: log xattr=sa create/remove/update to ZIL #11919: Cross-platform xattr user namespace compatibility #13014: Report dnodes with faulty bonuslen #13016: FreeBSD: Fix zvol_cdev_open locking #13019: spl: Don't check FreeBSD rwlocks for double initialization #13027: Fix clearing set-uid and set-gid bits on a file when replying a write #13031: Add enumerated vdev names to 'zpool iostat -v' and 'zpool list -v' #13074: Enable encrypted raw sending to pools with greater ashift #13076: Receive checks should allow unencrypted child datasets #13098: Avoid dirtying the final TXGs when exporting a pool #13172: Fix ENOSPC when unlinking multiple files from full pool Obtained from: OpenZFS OpenZFS commit: a86e089415679cf1b98eb424a159bb36aa2c19e3
* ctf: Import ctf.h from OpenBSDMark Johnston2022-03-071-360/+0
| | | | | | | | | | | | | | | | | 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 MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34358
* fasttrap: Avoid creating WX mappingsMark Johnston2022-03-012-3/+4
| | | | | | | | | | | | | | | | | fasttrap instruments certain instructions by overwriting them and copying the original instruction to some per-thread scratch space which is executed after the probe fires. This trampoline jumps back to the tracepoint after executing the original instruction. The created mapping has both write and execute permissions, and so this mechanism doesn't work when allow_wx is disabled. Work around the restriction by using proc_rwmem() to write to the trampoline. Reviewed by: vangyzen Tested by: Amit <akamit91@hotmail.com> MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34304
* fasttrap: Assert that fasttrap_fork() successfully unmaps scratch spaceMark Johnston2022-03-011-2/+3
| | | | | | | No functional change intended. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* fd: rename fget*_locked to fget*_norefMateusz Guzik2022-02-221-1/+4
| | | | | | | | This gets rid of the error prone naming where fget_unlocked returns with a ref held, while fget_locked requires a lock but provides nothing in terms of making sure the file lives past unlock. No functional changes.
* Teach DTrace about BTI on arm64Andrew Turner2022-01-191-0/+3
| | | | | | | | | | | | | The Branch Target Identification (BTI) Armv8-A extension adds new instructions that can be placed where we may indirrectly branch to, e.g. at the start of a function called via a function pointer. We can't emulate these in DTrace as the kernel will have raised a different exception before the DTrace handler has run. Skip over the BTI instruction if it's used as the first instruction in a function. Sponsored by: The FreeBSD Foundation
* dtrace: add a knob to control maximum size of principal buffersAndriy Gapon2022-01-111-1/+3
| | | | | | | | | | | | | | | | | | We had a hardcoded limit of 1/128-th of physical memory that was further subdivided between all CPUs as principal buffers are allocated on the per-CPU basis. Actually, the buffers could use up 1/64-th of the memmory because with the default switch policy there are two buffers per CPU. This commit allows to change that limit. Note that the discussed limit is per dtrace command invocation. The idea is to limit the size of a single malloc(9) call, not the total memory size used by DTrace buffers. Reviewed by: markj MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D33648
* dtrace: Disable getf() as it is broken on FreeBSDDomagoj Stolfa2021-12-171-0/+4
| | | | | | | | | | | | | | | | | | getf() on FreeBSD calls _sx_slock(), _sx_sunlock() and fget_locked(). Furthermore, it does not set the per-core fault flag, meaning it usually ends up in a double fault panic once getf() does get called, especially from fbt. Reviewing the DTrace Toolkit + a number of other scripts scattered around FreeBSD, I have not been able to find one use of getf(). Given how broken the implementation currently is, we disable it until it can be implemented properly. Also comment out a test in aggs/tst.subr.d for getf(). Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33378
* Create sys/reg.h for the common code previously in machine/reg.hAndrew Turner2021-08-301-1/+1
| | | | | | | | | | Move the common kernel function signatures from machine/reg.h to a new sys/reg.h. This is in preperation for adding PT_GETREGSET to ptrace(2). Reviewed by: imp, markj Sponsored by: DARPA, AFRL (original work) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19830
* sys/cddl: remove extraneous semicolonsEd Maste2021-08-161-1/+1
| | | | | | | Fixes: 5a1b490d502e ("FreeBSD changes to vendor source.") Fixes: 91eaf3e1831d ("Custom DTrace kernel module...") MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace: use %zu format specifier for data of size_t typeKonstantin Belousov2021-08-081-1/+1
| | | | Sponsored by: The FreeBSD Foundation
* Teach DTrace that unaligned accesses are OK on aarch64, not just x86.Robert Watson2021-03-221-1/+1
| | | | | | MFC after: 3 days Reviewed: andrew Differential Revision: https://reviews.freebsd.org/D29369
* Handle functions that use a nop in the arm64 fbtAndrew Turner2021-03-031-0/+2
| | | | | | | | | To trace leaf asm functions we can insert a single nop instruction as the first instruction in a function and trigger off this. Reviewed by: gnn Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D28132
* Handle using a sub instruction in the arm64 fbtAndrew Turner2021-01-121-0/+9
| | | | | | | | Some stack frames are too large for a store pair instruction we already detect in the arm64 fbt code. Add support for handling subtracting the stack pointer directly. Sponsored by: Innovate UK
* Only allow a store through sp in the arm64 fbtAndrew Turner2021-01-121-1/+3
| | | | | | | | | | | | | | | | When searching for an instruction to patch out in the arm64 function boundary trace we search for a store pair with a write back. This instruction is commonly used to store two registers to the stack and update the stack pointer to hold space for more. This works in many cases, however not all functions use this, e.g. when the stack frame is too large. In these cases we may find another instruction of the same type that doesn't store through the stack pointer. Filter these instructions out and assume if we see one we are past the function prologue. Reported by: rwatson Sponsored by: Innovate UK
* dtrace: Fix /"string" == NULL/ comparisons using an uninitialized value.Bryan Drewery2021-01-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A test of this is funcs/tst.strtok.d which has this filter: BEGIN /(this->field = strtok(this->str, ",")) == NULL/ { exit(1); } The test will randomly fail with exit status of 1 indicating that this->field was NULL even though printing it out shows it is not. This is compiled to the DTrace instruction set: // Pushed arguments not shown here // call strtok() and set result into %r1 07: 2f001f01 call DIF_SUBR(31), %r1 ! strtok // set thread local scalar this->field from %r1 08: 39050101 stls %r1, DT_VAR(1281) ! DT_VAR(1281) = "field" // Prepare for the == comparison // Set right side of %r2 to NULL 09: 25000102 setx DT_INTEGER[1], %r2 ! 0x0 // string compare %r1 (strtok result) to %r2 10: 27010200 scmp %r1, %r2 In this case only %r1 is loaded with a string limit set to lim1. %r2 being NULL does not get loaded and does not set lim2. Then we call dtrace_strncmp() with MIN(lim1, lim2) resulting in passing 0 and comparing neither side. dtrace_strncmp() handles this case fine and it already has been while being lucky with what lim2 was [un]initialized as. Reviewed by: markj, Don Morris <dgmorris AT earthlink.net> Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27671
* Install dtrace.h and dependenciesAlex Richardson2021-01-071-2/+12
| | | | | | | | | | | | | This makes the minimum amount of changes to allow inclusion of dtrace.h without all the solaris compatibility headers. Installing dtrace.h allows compiling consumers of libdtrace (e.g. https://github.com/tmetsch/python-dtrace) without requiring a copy of the source tree. For python-dtrace I worked around this in https://github.com/tmetsch/python-dtrace/commit/58019c9a12022203a9ffda286dd8b41f1a5ace42 but being able to build the library without installed sources would be extremely useful. Reviewed By: gnn Differential Revision: https://reviews.freebsd.org/D27884
* [cddl] Fix lz4 function definitions to not tri pup compile.Adrian Chadd2020-11-172-2/+7
| | | | | | | | | | | This tripped up in llvm compilation on amd64 noting that lz4_init/lz4_fini were lacking in being previously defined. Reviewed by: emaste, freqlabs, brooks Differential Revision: https://reviews.freebsd.org/D27240 Notes: svn path=/head/; revision=367770
* Update OpenZFS to 2.0.0-rc3-gfc5966Matt Macy2020-10-171-2130/+0
| | | | | | | | | | | - fix panic due to tqid overflow - Improve libzfs_error_init messages - Expose zfetch_max_idistance tunable - Make dbufstat work on FreeBSD - Fix EIO after resuming receive of new dataset over an existing one Notes: svn path=/head/; revision=366780
* Add zstd support to the boot loader.Warner Losh2020-10-121-243/+0
| | | | | | | | | | | | | | | Add support to the _STANDALONE environment enough bits of the kernel that we can compile it. We still have a small zstd_shim.c since there were 3 items that were a bit hard to nail down and may be cleaned up in the future. These go hand in hand with a number of commits to sys/sys in the past weeks, should this need be MFCd. Discussed with: mmacy (in review and on IRC/Slack) Reviewed by: freqlabs (on openzfs repo) Differential Revision: https://reviews.freebsd.org/D26218 Notes: svn path=/head/; revision=366657
* ZFS: band-aid for -DNO_CLEANMatt Macy2020-08-251-1/+3
| | | | | | | | | Submitted by: Neal Chauhan Approved by: imp@ Differential Revision: https://reviews.freebsd.org/D26183 Notes: svn path=/head/; revision=364788
* Merge OpenZFS support in to HEAD.Matt Macy2020-08-25298-196927/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The primary benefit is maintaining a completely shared code base with the community allowing FreeBSD to receive new features sooner and with less effort. I would advise against doing 'zpool upgrade' or creating indispensable pools using new features until this change has had a month+ to soak. Work on merging FreeBSD support in to what was at the time "ZFS on Linux" began in August 2018. I first publicly proposed transitioning FreeBSD to (new) OpenZFS on December 18th, 2018. FreeBSD support in OpenZFS was finally completed in December 2019. A CFT for downstreaming OpenZFS support in to FreeBSD was first issued on July 8th. All issues that were reported have been addressed or, for a couple of less critical matters there are pull requests in progress with OpenZFS. iXsystems has tested and dogfooded extensively internally. The TrueNAS 12 release is based on OpenZFS with some additional features that have not yet made it upstream. Improvements include: project quotas, encrypted datasets, allocation classes, vectorized raidz, vectorized checksums, various command line improvements, zstd compression. Thanks to those who have helped along the way: Ryan Moeller, Allan Jude, Zack Welch, and many others. Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25872 Notes: svn path=/head/; revision=364746
* zfs: add an option to the bootloader to rewind the ZFS checkpointMariusz Zaborski2020-08-183-3/+20
| | | | | | | | | | | | | | | | | | The checkpoints are another way of keeping the state of ZFS. During the rewind, the pool has to be exported. This makes checkpoints unusable when using ZFS as root. Add the option to rewind the ZFS checkpoint at the boot time. If checkpoint exists, a new option for rewinding a checkpoint will appear in the bootloader menu. We fully support boot environments. If the rewind option is selected, the boot loader will show a list of boot environments that existed before the checkpoint. Reviewed by: tsoome, allanjude, kevans (ok with high-level overview) Differential Revision: https://reviews.freebsd.org/D24920 Notes: svn path=/head/; revision=364355
* Fix linker error in libuutil with recent LLVMAlex Richardson2020-08-072-8/+1
| | | | | | | | | | | | | | | | Not marking the function as static can result in a linker error: undefined reference to __assfail [--no-allow-shlib-undefined] I noticed this error after updating our CHERI LLVM to the latest upstream LLVM HEAD revision. This change effectively reverts r329984 and marks dmu_buf_init_user as static (which keeps the GCC build happy). Reviewed By: #zfs, asomers, freqlabs, mav Differential Revision: https://reviews.freebsd.org/D25663 Notes: svn path=/head/; revision=364027
* Fix cddl tools bootstrapping on macOS and LinuxAlex Richardson2020-08-071-1/+8
| | | | | | | | Reviewed By: brooks Differential Revision: https://reviews.freebsd.org/D25979 Notes: svn path=/head/; revision=364022
* MFOpenZFS: Add support for boot environment data to be stored in the labelToomas Soome2020-08-056-14/+242
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We are building new bootonce mechanism (previously zfs bootnext) and it is based on this OpenZFS change. Since this patch is nicely self contained, I am commiting it as is, and we can stack our changes. Original patch description follows: Modern bootloaders leverage data stored in the root filesystem to enable some of their powerful features. GRUB specifically has a grubenv file which can store large amounts of configuration data that can be read and written at boot time and during normal operation. This allows sysadmins to configure useful features like automated failover after failed boot attempts. Unfortunately, due to the Copy-on-Write nature of ZFS, the standard behavior of these tools cannot handle writing to ZFS files safely at boot time. We need an alternative way to store data that allows the bootloader to make changes to the data. This work is very similar to work that was done on Illumos to enable similar functionality in the FreeBSD bootloader. This patch is different in that the data being stored is a raw grubenv file; this file can store arbitrary variables and values, and the scripting provided by grub is powerful enough that special structures are not required to implement advanced behavior. We repurpose the second padding area in each label to store the grubenv file, protected by an embedded checksum. We add two ioctls to get and set this data, and libzfs_core and libzfs functions to access them more easily. There are no direct command line interfaces to these functions; these will be added directly to the bootloader utilities. Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Paul Dagnelie <pcd@delphix.com> Closes #10009 Obtained from: OpenZFS Sponsored by: Netflix, Klara Inc. Notes: svn path=/head/; revision=363911
* zfs_keys_nextboot array is missing ZPOOL_CONFIG_POOL_GUID and ZPOOL_CONFIG_GUIDToomas Soome2020-08-051-1/+3
| | | | | | | | | | | | As we do check the incomint nvlist, we either need to list all possible keys or use wildcard. PR: 248462 Reported by: larafercue@gmail.com Sponsored by: Netflix, Klara Inc. Notes: svn path=/head/; revision=363910
* vfs: remove the obsolete privused argument from vaccessMateusz Guzik2020-08-051-1/+1
| | | | | | | | This brings argument count down to 6, which is passable without the stack on amd64. Notes: svn path=/head/; revision=363893
* zfs: add support for lockless lookupMateusz Guzik2020-07-255-10/+147
| | | | | | | | Tested by: pho (in a patchset, previous version) Differential Revision: https://reviews.freebsd.org/D25581 Notes: svn path=/head/; revision=363522
* Fix a memory leak in dsl_scan_visitbp().Mark Johnston2020-07-201-1/+1
| | | | | | | | | | | | This should be triggered only if arc_read() fails, i.e., quite rarely. The same logic is already present in OpenZFS. PR: 247445 Submitted by: jdolecek@NetBSD.org MFC after: 1 week Notes: svn path=/head/; revision=363373
* Fix page fault in zfsctl_snapdir_getattrAlan Somers2020-07-021-1/+2
| | | | | | | | | | | | | | | Must acquire the z_teardown_lock before accessing the zfsvfs_t object. I can't reproduce this panic on demand, but this looks like the correct solution. PR: 247668 Reviewed by: avg MFC after: 2 weeks Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D25543 Notes: svn path=/head/; revision=362891
* Fix "current" variable name conflict with openzfsMatt Macy2020-06-271-39/+39
| | | | | | | | | The variable "current" is an alias for curthread in openzfs. Rename all variable uses of current in dtrace.c to curstate. Notes: svn path=/head/; revision=362667
* MFOpenZFS: Add basic zfs ioc input nvpair validationToomas Soome2020-06-232-79/+376
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We want newer versions of libzfs_core to run against an existing zfs kernel module (i.e. a deferred reboot or module reload after an update). Programmatically document, via a zfs_ioc_key_t, the valid arguments for the ioc commands that rely on nvpair input arguments (i.e. non legacy commands from libzfs_core). Automatically verify the expected pairs before dispatching a command. This initial phase focuses on the non-legacy ioctls. A follow-on change can address the legacy ioctl input from the zfs_cmd_t. The zfs_ioc_key_t for zfs_keys_channel_program looks like: static const zfs_ioc_key_t zfs_keys_channel_program[] = { {"program", DATA_TYPE_STRING, 0}, {"arg", DATA_TYPE_UNKNOWN, 0}, {"sync", DATA_TYPE_BOOLEAN_VALUE, ZK_OPTIONAL}, {"instrlimit", DATA_TYPE_UINT64, ZK_OPTIONAL}, {"memlimit", DATA_TYPE_UINT64, ZK_OPTIONAL}, }; Introduce four input errors to identify specific input failures (in addition to generic argument value errors like EINVAL, ERANGE, EBADF, and E2BIG). ZFS_ERR_IOC_CMD_UNAVAIL the ioctl number is not supported by kernel ZFS_ERR_IOC_ARG_UNAVAIL an input argument is not supported by kernel ZFS_ERR_IOC_ARG_REQUIRED a required input argument is missing ZFS_ERR_IOC_ARG_BADTYPE an input argument has an invalid type Reviewed by: allanjude Obtained from: OpenZFS Sponsored by: Netflix, Klara Inc. Differential Revision: https://reviews.freebsd.org/D25393 Notes: svn path=/head/; revision=362531
* MFOpenZFS: Add zio_ddt_free()+ddt_phys_decref() error handlingAllan Jude2020-06-222-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | The assumption in zio_ddt_free() is that ddt_phys_select() must always find a match. However, if that fails due to a damaged DDT or some other reason the code will NULL dereference in ddt_phys_decref(). While this should never happen it has been observed on various platforms. The result is that unless your willing to patch the ZFS code the pool is inaccessible. Therefore, we're choosing to more gracefully handle this case rather than leave it fatal. http://mail.opensolaris.org/pipermail/zfs-discuss/2012-February/050972.html https://github.com/openzfs/zfs/commit/5dc6af0eec29b119b731c793037fd77214fc9438 Reported by: Pierre Beyssac Obtained from: OpenZFS MFC after: 2 weeks Sponsored by: Klara Inc. Notes: svn path=/head/; revision=362505