Commit Graph

869 Commits

Author SHA1 Message Date
sevan 86e1b08aff Fix column layout 2020-06-25 09:39:19 +00:00
mlelstv bf2615aa1b Don't assume everything is a wedge and has a parent device. On non-wedges
this crashes.

Instead, just talk to the referenced device and rely on the dk driver
to pass requests correctly.
2020-06-25 09:39:15 +00:00
sevan 5c85b20eb8 No truss here 2020-06-24 18:49:01 +00:00
sevan 115e612e0f mdocify 2020-06-24 18:43:38 +00:00
sevan 7226fd0ff8 mdocify 2020-06-24 18:06:01 +00:00
jdolecek ce67beced2 reduce stack usage in dsl_scan_recurse() - allocate memory for
temporary zbookmark_phys_t using kmem_alloc() rather than stack;
this recuses several times usually, and this saves 2x
sizeof(zbookmark_phys_t) == 64 bytes per recursion

part of fix for PR kern/55402 by Frank Kardel
2020-06-24 16:29:34 +00:00
jdolecek 41a612de4f change dsl_scan_visitbp() to allocate blkptr_t dynamically rather than
on-stack - this function is called recursively, and the 120 bytes per call
add up; also remove unused variable

part of fix for PR kern/55402 by Frank Kardel
2020-06-24 16:23:16 +00:00
jdolecek 5964fe3b97 reduce stack usage in vdev_queue_io_to_issue() - zio_t is about 1KB, and
the function potentially recurses into itself

part of fix for PR kern/55402 by Frank Kardel
2020-06-24 16:16:01 +00:00
jmcneill 62a169693c If calling d_minphys on the parent disk device, make sure we use the
parent disk device's dev_t. Fixes zfs on wedges on ld(4).

XXX pullup-9
2020-06-21 21:29:11 +00:00
jdolecek 99379c717f use pool_cache for (meta)data buffers also on NetBSD
this should generally slightly improve performance on MP systems, and
specifically for xbd(4) storage avoids slow unaligned I/O buffer handling

this change requires updated kernel, to allow up to SPA_MAXBLOCKSHIFT item
size for pools

fixes PR kern/55397 by Frank Kardel
2020-06-19 14:13:23 +00:00
ad 4b8a875ae2 uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched.  It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
2020-06-11 19:20:42 +00:00
fox 1644357e99 external/cddl/osnet: Suppress -Werror=stringop-truncation error
This logic correctly uses strncpy(3) to fully initialize a fixed-width field, and also ensures
NUL-termination on the next line as other users of the field expect.

Add -Werror=stringop-truncation to prevent build failure, when run with MKSANITIZER=yes.

Error was reported when build.sh was run with MKSANITIZER=yes flag.

Reviewed by: kamil@
2020-06-07 23:26:54 +00:00
hannken 24c6f44f9c Replace vp->v_count with vrefcnt(vp) and
remove now unneeded "#define v_count ...".
2020-05-26 08:39:27 +00:00
ad 0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
ad 154ae82447 Fix bugs in previous. 2020-05-21 20:43:23 +00:00
ad e9af4fa226 zfs_netbsd_getpages:
- implement the PGO_LOCKED case
- handle npages > 1 for PGO_SYNCIO
2020-05-20 20:47:18 +00:00
christos 9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
ad 4c6ec8e8eb Bump PROF_ARTIFICIAL_FRAMES to 4 now that cyclics are run from statclock(). 2020-05-15 23:57:17 +00:00
chs cc0d11d270 fix the handling in putpage of the page containing EOF. 2020-05-13 05:52:54 +00:00
ad 8122ec364a Run Solaris cyclics from statclock() so dtrace isn't locked out by IPL_SCHED
(assuming the machine has a separate statclock() which almost all don't).
2020-05-08 22:10:08 +00:00
hannken f106ce5415 Operation zfs_zget_cleaner() cannot fail, comment and add assertions. 2020-05-07 09:13:06 +00:00
hannken 1243122ba6 Revert Rev. 1.31 as it is no longer possible for the handle to be NULL. 2020-05-07 09:12:31 +00:00
hannken 5e7dc406e9 Revert Rev. 1.63 and add a comment why we have to zil_commit() here:
Operation zfs_znode.c::zfs_zget_cleaner() depends on this
zil_commit() as a barrier to guarantee the znode cannot
get freed before its log entries are resolved.
2020-05-07 09:12:03 +00:00
maxv daaf22542e Modify the hotpatch mechanism, in order to make it much less ROP-friendly.
Currently x86_patch_window_open is a big problem, because it is a perfect
function to inject/modify executable code with ROP.

 - Remove x86_patch_window_open(), along with its x86_patch_window_close()
   counterpart.
 - Introduce a read-only link-set of hotpatch descriptor structures,
   which reference a maximum of two read-only hotpatch sources.
 - Modify x86_hotpatch() to open a window and call the new
   x86_hotpatch_apply() function in a hard-coded manner.
 - Modify x86_hotpatch() to take a name and a selector, and have
   x86_hotpatch_apply() resolve the descriptor from the name and the
   source from the selector, before hotpatching.
 - Move the error handling in a separate x86_hotpatch_cleanup() function,
   that gets called after we closed the window.

The resulting implementation is a bit complex and non-obvious. But it
gains the following properties: the code executed in the hotpatch window
is strictly hard-coded (no callback and no possibility to execute your own
code in the window) and the pointers this code accesses are strictly
read-only (no possibility to forge pointers to hotpatch an area that was
not designated as hotpatchable at compile-time, and no possibility to
choose what bytes to write other than the maximum of two read-only
templates that were designated as valid for the given destination at
compile-time).

With current CPUs this slightly improves a situation that is already
pretty bad by definition on x86. Assuming CET however, this change closes
a big hole and is kinda great.

The only ~problem there is, is that dtrace-fbt tries to hotpatch random
places with random bytes, and there is just no way to make it safe.
However dtrace is only in a module, that is rarely used and never compiled
into the kernel, so it's not a big problem; add a shitty & vulnerable
independent hotpatch window in it, and leave big XXXs. It looks like fbt
is going to collapse soon anyway.
2020-05-02 11:37:17 +00:00
riastradh 499bfa80cb Fix crgetgroups shim.
- Don't use a static buffer for the result.

- kauth_cred_getgroups refuses to return more than the actual number
  of groups, so passing NGROUPS_MAX generally doesn't work.

To avoid patching zfs, just expose struct kauth_cred::cr_groups
directly, with __KAUTH_PRIVATE.  Unclear why the official API only
exposes it via memcpy or copyout anyway.

This makes unprivileged zfs operations work, by anyone with access to
/dev/zfs (which is conventionally mode 777, and which we should maybe
set it to by default; zfs has its own ACL system, zfs allow).
2020-04-29 05:54:37 +00:00
riastradh e6079aec7f Set up more of a fake struct buf, for ldminphys.
Fixes:

arm64# zpool create rpool ld4
[ 198.4376097] panic: Trap: Data Abort (EL1): Translation Fault L1 with read access for 0000000000000178: pc ffffc0000017acf4: opcode f940bc00: ldr x0, [x0,#376]
[ 198.4694793] fp ffffc00073026660 ldminphys() at ffffc0000017acf4 netbsd:ldminphys+0x34
[ 198.4792624] fp ffffc00073026680 vdev_disk_open.part.4() at ffffc000013d4c4c zfs:vdev_disk_open.part.4+0x37c
[ 198.4792624] fp ffffc000730268d0 vdev_open() at ffffc000013d2530 zfs:vdev_open+0x68
[ 198.4792624] fp ffffc00073026920 vdev_open_children() at ffffc000013d2958 zfs:vdev_open_children+0x40
[ 198.4792624] fp ffffc00073026950 vdev_root_open() at ffffc000013dad48 zfs:vdev_root_open+0x30

XXX pullup-9
2020-04-29 04:30:40 +00:00
ad 23bf88000c Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed().  Signature matches
FreeBSD.
2020-04-13 19:23:17 +00:00
mlelstv 946cdc57b6 When collecting zpool devices, skip disks with wedges so that a
concurrent test of a wedge on that disk doesn't fail.
2020-04-04 13:45:22 +00:00
christos d920a30f1a Add libproc 2020-04-04 13:15:48 +00:00
hannken f829bc96b4 With zfs_netbsd_reclaim() no longer doing an unconditional
zil commit dmu_buf_get_user() may return a NULL handle when
the znode already disappeared.
2020-03-20 08:26:01 +00:00
fox ea2ed373b0 external/cddl/osnet: Do not suppress the warning output for libdtrace.
Changed -Wno-maybe-uninitialized to -Wno-error=maybe-uninitialized to allow
warnings to be printed out during build.

Suggested by: christos@
2020-03-17 01:36:29 +00:00
fox cc6a7388a1 external/cddl/osnet: Fix -Werror=maybe-uninitialized error in zfs_acl.c.
Detected by build.sh with MKLIBCSANITIZER=yes and fixed upstream, pick only the fix from the commit.

Upstream commits

100a91aa3e
100a91aa3e

Cherry-pick:
From 100a91aa3e9773f2a2a373c5cb066b52c780716c Mon Sep 17 00:00:00 2001
From: Chunwei Chen <david.chen@osnexus.com>
Date: Fri, 17 Jun 2016 17:36:01 -0700
Subject: [PATCH] Fix NFS credential

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4772
Closes #4758

Reviewed by: kamil@
2020-03-17 00:54:03 +00:00
fox 6594959c4a external/cddl/osnet: Supress -Werror=maybe-uninitialized error in libdtrace.
It looks like this is a false positive, since the section of code triggering the error

external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c:400:42:

is only accessed after "err" is initialized.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@
2020-03-17 00:50:12 +00:00
ad da3ef92bf6 Make uvm_pagemarkdirty() responsible for putting vnodes onto the syncer
work list.  Proposed on tech-kern@.
2020-03-14 20:45:23 +00:00
fox 9fab322cb1 external/cddl/osnet: Fix possible null pointer access.
Detected by UBSan and fixed upstream, pick only the fix from the commit.

Cherry-pick:
From 928e8ad47d3478a3d5d01f0dd6ae74a9371af65e Mon Sep 17 00:00:00 2001
From: Serapheim Dimitropoulos <serapheimd@gmail.com>
Date: Wed, 20 Feb 2019 09:59:57 -0800
Subject: [PATCH] Introduce auxiliary metaslab histograms

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #8358

Reviewed by: kamil@
2020-03-09 15:40:50 +00:00
fox 998369905c external/cddl/osnet: Fix possible signed integer overflow
Detected by UBSan and fixed upstream

Cherry-pick:
From 05852b3467b44cdf88541ec67624cd1f5f2ded1d Mon Sep 17 00:00:00 2001
From: luozhengzheng <luo.zhengzheng@zte.com.cn>
Date: Fri, 14 Oct 2016 05:25:05 +0800
Subject: [PATCH] Fix coverity defects: CID 147571, 147574

CID 147571: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
CID 147574: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5268

Reviewed by: kamil@
2020-03-09 15:37:46 +00:00
mgorny d783b29581 Update dtrace errno.d mapping and add a script for it
Add a new script to autogenerate errno.d from errno.h, and use it
to regenerate the list to match NetBSD errno codes.
2020-03-08 22:11:48 +00:00
riastradh 9a5bc0da50 Avoid unnecessary zil_commit on rm.
1. Issue zil_commit only if we're actually updating something --
   there's no need to commit if we're unlinking the file or if
   there's no atime update being applied.

2. Issue zil_commit only if the zfs has sync=always set -- for
   sync=standard there's no need for us to commit anything here since
   no application asked for an explicit sync.

Speeds up untarring base.tgz on top of itself by a factor of about
2x, and speeds up rm by a factor of about 10x, on my system with an
SSD SLOG over SATA.  Histogram of unlink, rmdir, and rename timing
shows dramatic reduction in latency for most samples.

(To be fair, this was not an improvement over zfs; issuing the
unnecessary zil_commit was a self-inflicted performance wound.)
2020-03-08 19:59:45 +00:00
wiz 80e58ff06c genric -> generic 2020-03-05 22:44:19 +00:00
riastradh 3a391130d2 Revert "Add fixup operation to remove private mutex types for x86."
The x86 (and arm) definitions of struct kmutex are no longer defined
differently depending on __MUTEX_PRIVATE.
2020-03-05 16:05:05 +00:00
riastradh 338179b531 Use vpanic, not vprintf and then panic. 2020-03-03 06:44:38 +00:00
riastradh ffcf681ee3 New ioctl DIOCGSECTORALIGN returns sector alignment parameters.
struct disk_sectoralign {
	/* First aligned sector number.  */
	uint32_t dsa_firstaligned;

	/* Number of sectors per aligned unit.  */
	uint32_t dsa_alignment;
};

- Teach wd(4) to get it from ATA.
- Teach cgd(4) to pass it through from the underlying disk.
- Teach dk(4) to pass it through with adjustments.
- Teach zpool (zfs) to take advantage of it.
  => XXX zpool doesn't seem to understand when the vdev's starting
     sector is misaligned.

Missing:

- ccd(4) and raidframe(4) support -- these should support _using_
  DIOCGSECTORALIGN to decide where to start putting ccd or raid
  stripes on disk, and these should perhaps _implement_
  DIOCGSECTORALIGN by reporting the stripe/interleave factor.

- sd(4) support -- I don't know any obvious way to get it from SCSI,
  but if any SCSI wizards know better than I, please feel free to
  teach sd(4) about it!

- any ld(4) attachments -- might be worth teaching the ld drivers for
  nvme and various raid controllers to get the aligned sector size

There's some duplicate logic here for now.  I'm doing it this way,
rather than gathering the logic into a new disklabel_sectoralign
function or something, so that this change is limited to adding a new
ioctl, without any new kernel symbols, in order to make it easy to
pull up to netbsd-9 without worrying about the module ABI.
2020-03-02 16:01:56 +00:00
kamil ce57424237 Fix undefined behavior in misaligned pointer usage
Detected by UBSan and already fixed upstream.

Cherry-pick:
From aa0218d6a12814fac50b287214f9f3b0b99e11b1 Mon Sep 17 00:00:00 2001
From: Brian Behlendorf <behlendorf1@llnl.gov>
Date: Tue, 7 Jan 2014 23:24:37 +0100
Subject: [PATCH] Fix nvlist 'Bus Error' for Sparc

The mis-aligned memory accesses in nvpair_native_embedded() and
nvpair_native_embedded_array() will cause a 'Bus Error' for
architectures such as Sparc which not fully byte addressible.
To avoid this issue care is taken to avoid dereferencing the
potentially mis-aligned packed nvlist_t.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: marku89 <mar42@kola.li>
Issue #1700
2020-03-02 15:45:33 +00:00
mlelstv 8b765a5da5 Use utility functions to handle disk geometry. 2020-02-29 17:15:43 +00:00
mlelstv 5568ea814a Fix disk geometry calculation. Add DIOCGPARTINFO to support
getdisksize() used by other drivers, filesystems and specfs.
2020-02-29 17:03:33 +00:00
riastradh 55a1499437 Teach zfs bdevsw to do b_psize.
This is needed, among other things, to swap on zvols.

Attempting to swap on zvols currently deadlocks but that's a separate
issue that needs to be fixed too!
2020-02-28 03:52:26 +00:00
ad d2a0ebb67a UVM locking changes, proposed on tech-kern:
- Change the lock on uvm_object, vm_amap and vm_anon to be a RW lock.
- Break v_interlock and vmobjlock apart.  v_interlock remains a mutex.
- Do partial PV list locking in the x86 pmap.  Others to follow later.
2020-02-23 15:46:38 +00:00
riastradh b58d4067a2 Teach device nodes on zfs to handle fsync by calling spec_fsync too. 2020-02-23 06:15:27 +00:00
riastradh 5b7c5828ba Teach zfs spec nodes to VOP_BWRITE too.
Fixes hang on writing to, e.g., ffs mounted on a device node that
lives on zfs.

XXX pullup
2020-02-23 05:50:25 +00:00
joerg ce578dfc2b Explicitly cast pointers to uintptr_t before casting to enums. They are
not necessarily the same size. Don't cast pointers to bool, check for
NULL instead.
2020-02-21 00:26:21 +00:00
riastradh 3c37c6c9c5 Mark previous #ifdef __NetBSD__, per request from hannken. 2020-02-19 17:05:06 +00:00
riastradh 69aded6dbf Report the OS name and release appropriately for NetBSD.
We are not OpenSolaris or uts!
2020-02-19 16:11:19 +00:00
riastradh 18954d9723 Define VOP_STRATEGY on zfs device nodes too.
Fixes eternal hangs in attempts to do I/O on device nodes on zfs.

XXX pullup
2020-02-19 05:52:52 +00:00
roy 0495ebef35 zpool: The NetBSD specific ioctl needs to include sys/ioctl.h 2020-02-16 14:06:10 +00:00
riastradh defa864ee7 Teach zfs to revoke vnodes the usual way.
XXX pullup
2020-02-15 19:03:15 +00:00
hannken 2f425cfa36 zfs_netbsd_setattr: ignore size changes on device nodes. 2020-02-13 16:53:32 +00:00
riastradh 6db8251b26 Switch from db_write_bytes to using direct-mapping.
This way there's no dependency on ddb.
2020-02-12 06:05:31 +00:00
riastradh bfcd8bcf73 Change the address ranges that aarch64 considers toxic for dtrace.
`Toxic' means dtrace forbids D scripts from even attempting to read
or write at them.

Previously we considered [0, VM_MIN_KERNEL_ADDRESS) toxic, but
VM_MIN_KERNEL_ADDRESS is only the minimum address of the kernel map;
the direct-mapped region lies below it, and with PMAP_MAP_POOLPAGE we
allocate virtual pages for pool backing directly from physical pages
through the direct-mapped region.  Also, this did not consider I/O
mappings to be toxic, which they probably should be.

Instead, treat:

[0, AARCH64_KSEG_START)
and
[VM_KERNEL_IO_ADDRESS, 0xfff...ff)

as toxic.  (The upper bound for 0xfff...ff ought to be inclusive, not
exclusive, but I think we'll need another mechanism for expressing
that to dtrace!)
2020-02-12 06:05:23 +00:00
riastradh 772dd05c6c Count the number of artificial frames in aarch64 fbt probe correctly. 2020-02-12 01:10:25 +00:00
riastradh 21c3f7e27a Teach dtrace about el1_trap_exit frames on aarch64.
Implement dtrace_getarg and dtrace_getreg while here.
2020-02-12 01:10:16 +00:00
riastradh 639e4eee75 Use /dev/ksyms, not /netbsd, for the running kernel's symbols. 2020-02-12 01:10:08 +00:00
riastradh 5fb67fa20d Tidy up a bit: don't set things we won't use; assert nonzeroness. 2020-02-12 01:09:48 +00:00
riastradh 615f7ddec3 Tidy up a bit. No functional change intended.
aarch64 fbt_invop doesn't actually use the argument, but it would
make more sense for it to be the return value and/or first argument
register.  Certainly it's not `eax'!
2020-02-12 01:09:38 +00:00
riastradh 5f49297b68 Use db_write_bytes to overwrite kernel text. 2020-02-12 01:09:27 +00:00
fox b796f1c940 external/cddl/osnet: Suppress -Werror=stringop-truncation error.
Add GCC_NO_STRINGOP_TRUNCATION dwarf.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.

Reviewed by: kamil@
2020-02-09 07:55:13 +00:00
ad f778098a59 Track page dirtyness for ZFS (yamt-pagecache). I had forgotten that it had
its own cache.  Thanks to hannken@ for the repro.
2020-01-18 15:21:32 +00:00
ad c2e9cb9413 VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode.  Matches
FreeBSD.
2020-01-17 20:08:06 +00:00
ad 05a3457e85 Merge from yamt-pagecache (after much testing):
- Reduce unnecessary page scan in putpages esp. when an object has a ton of
  pages cached but only a few of them are dirty.

- Reduce the number of pmap operations by tracking page dirtiness more
  precisely in uvm layer.
2020-01-15 17:55:43 +00:00
pgoyette 956f25580a Another rename from uvm_free() --> uvm_availmem() 2019-12-31 14:51:29 +00:00
ad 5c06357c90 Rename uvm_free() -> uvm_availmem(). 2019-12-31 13:07:09 +00:00
ad 7d06f3305f Make mntvnode_lock per-mount, and address false sharing of struct mount. 2019-12-22 19:47:34 +00:00
ad ddd3a0be1e uvmexp.free -> uvm_free() 2019-12-21 13:00:20 +00:00
ad 5978ddc663 Break the global uvm_pageqlock into a per-page identity lock and a private
lock for use of the pagedaemon policy code.  Discussed on tech-kern.

PR kern/54209: NetBSD 8 large memory performance extremely low
PR kern/54210: NetBSD-8 processes presumably not exiting
PR kern/54727: writing a large file causes unreasonable system behaviour
2019-12-13 20:10:21 +00:00
sevan 59348bc454 We currently lack a tunable to control ZFS prefetch, so skip the warning and
FreeBSD specific instructions on settings.
2019-12-09 00:15:11 +00:00
riastradh aca9a2fd6e Avoid redefining uint_t &c. if compat_defs.h already defines them. 2019-12-05 03:21:42 +00:00
jmcneill 37d677e093 dtrace: add support for aarch64 2019-12-03 22:10:56 +00:00
jmcneill e578db34f0 Need sys/atomic.h on NetBSD 2019-12-01 20:26:31 +00:00
jmcneill fa74c92e0a Provide a default ptob() implementation 2019-12-01 20:26:05 +00:00
jmcneill 87afc7bc0f Initialize b_dev before passing buf to d_minphys (ldminphys needs this) 2019-12-01 20:25:31 +00:00
maxv 29441e93f4 Use x86_patch_window_{open,close}. This also fixes a bug: the CR0/PSL
reloads were inverted.
2019-11-13 10:13:41 +00:00
hannken c4ae6d2fe2 dtrace_trap() gets called from alltraps() -> trap() with interrupts enabled
so we cannot assert for interrupts disabled here.

Should fix PR kern/54603: kernel panic when running dtruss
2019-11-08 11:06:21 +00:00
hannken e59a8eaee2 Add missing "#ifdef _KERNEL" to fix the build of userland zfs libraries. 2019-10-15 06:58:12 +00:00
hannken 239a7f3a3b Change dmu_diff() back to use a "file" instead of a "vnode".
Command "zfs diff" calls it with a pipe, not a plain file.

Fixes PR kern/54541: kernel panic using "zfs diff"
2019-10-14 13:18:00 +00:00
christos af4abd50bc make worker thread prototype match the pthread_create signature. 2019-10-13 21:32:07 +00:00
kre e61903222f This previously had -Wno-format-truncation so I am presuming it should
have been converted to GCC_NO_FORMAT_TRUNCATION rather than
GCC_NO_STRINGOP_TRUNCATION which is what happened.   This might unbreak
the build (olr at least get it further).
2019-10-13 10:07:27 +00:00
mrg de11d87641 introduce some common variables for use in GCC warning disables:
GCC_NO_FORMAT_TRUNCATION    -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION  -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW    -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE   -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints.  many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
2019-10-13 07:28:04 +00:00
kre bab7747200 Only exclude gcc-8 warnings when the gcc we're using is gcc>=8 2019-10-10 02:35:45 +00:00
christos 04c417de37 no error for string truncation 2019-10-09 21:49:50 +00:00
brad 2ab41a9a50 For ZFS on NetBSD there are a number of functions called
zfs_netbsd_{create,mknod,link,etc..} that call functions called
zfs_{create,mknod,link,etc..}.  These later functions may return a
error code along with a *vpp that is NULL.  This situation was not
handled by the zfs_netbsd_* functions and would result in a panic in a
number of cases.  The simplest to trigger it was filling up a dataset
or pool resulting in a over quota condition.  An attempt to create
another file, or directory at that point would panic.
2019-10-04 23:06:19 +00:00
brad 2e0a32871b Add USE_SHLIBDIR=yes to a number of Makefiles for the libraries used
by /sbin/{zfs,zpool,mount_zfs}.  The general effect is to move them
from /usr/lib to /lib.  Compatibility links are installed in /usr/lib
and nothing that is installed, say in /usr/pkg, appears to break.

With this, it is possible to have a /var and /usr mount using ZFS
legacy mounting early on in the boot process.

Run tested on amd64 and i386 and compile tested on evbarm.
2019-09-22 18:45:19 +00:00
sevan 69d856e495 Use Pa macro for path
new sentence, new line
2019-09-20 22:47:36 +00:00
brad 5aa9b9d41e Add a copyright to the man page and a bit of history. 2019-09-20 22:38:28 +00:00
wiz 67060edf74 Use more markup. 2019-09-16 04:57:12 +00:00
gutteridge a55674ceb3 mount_zfs.8: add xref to fstab(5) 2019-09-15 20:51:52 +00:00
brad 12ea0a140d Add support for legacy ZFS filesystems, specified by mountpoint=legacy
in the ZFS properties of the dataset and a simple man page for
mount_zfs.  With this, it is possible to put ZFS filesystems in
/etc/fstab as file system type zfs.

Add a rc.d script that kicks the module ZFS load mostly before
mountall runs simular to what LVM does.  This allows for any legacy
mounts to be specified in critical_local_filesystems and allows for
ZFS pools on top of cgd (probably among other things).  Introduce a
rc.conf variable called zfs which needs to be set to YES, in the usual
manor of things, to get zvols and ZFS dataset support rather then just
assume that 'zfs mount' does that in mountall.  Fix a problem in
mountall if ZFS is not compiled into the system.
2019-09-15 19:38:08 +00:00
hannken 65d6baaaeb Add missing dmu_zfetch_fini() when dnode_create() lost the race. 2019-08-24 12:59:34 +00:00
hannken 799f938b54 Implement kqueue support. 2019-08-24 12:59:05 +00:00
hannken ace58db59c Implement poll support. 2019-08-24 12:58:24 +00:00
hannken c72b1aea36 task_executor: prevent use after free, the task function may free
the tasq entry.
2019-08-20 08:12:50 +00:00
hannken ae0ee8779d Rearrange the evaluation of "dvd_maxphys" so it works for wedges too. 2019-08-20 08:12:14 +00:00
hannken 9075f3bd2d Always open the raw block devices as "<device><unit>" like it
comes from sysctl "hw.disknames" without attaching the raw
partition letter.  Now pools on wedges get imported too.
2019-08-20 08:11:21 +00:00
hannken 97faa474a9 Add missing "defined(__NetBSD__)" to make "zfs promote" work. 2019-08-13 08:03:25 +00:00
maya b214c01f05 validate the length of args (like other filesystems)
ok riastradh
2019-08-07 20:45:53 +00:00
hannken 706360a664 Handle automatic module loading on device open more like FreeBSD does.
Where FreeBSD uses a module "dtraceall" that depends on all dtrace
modules we now load the basic set "dtrace sdt fbt syscall" on open.
2019-07-24 16:57:45 +00:00
hannken 67361e01b4 Remove unneeded includes. 2019-07-24 16:54:37 +00:00
hannken d233d0f45b Create "dtrace_taskq" here like FreeBSD does.
PR kern/54397: Panic when loading a DTrace module whilst DTrace is running
2019-07-23 09:06:12 +00:00
hannken b83fa74ac8 Move local changes to files below "external/cddl/osnet/dist/" and
remove now unneeded files from "external/cddl/osnet/sys/sys/".

- sys/sys/bitmap.h -> dist/uts/common/sys/bitmap.h
- sys/sys/callb.h -> dist/uts/common/sys/callb.h

Stop including "cpupart.h", not needed for build.
2019-07-23 07:46:22 +00:00
hannken c7790bc1b7 Always use "netbsd" as kernel name, dt_module_update() already takes
care to load data from the booted kernel image.
2019-07-21 15:38:06 +00:00
hannken f705610493 Try to load module "dtrace" before opening "/dev/dtrace/dtrace".
Fixes PR kern/54387: DTrace Kernel module does not autoload on first use ...
2019-07-21 15:37:27 +00:00
hannken bb86f86314 XXX: A crude hack to bring down the number of types for a
GENRIC kernel below 2**15-1 (from ~34000 to ~29800).

Remove the type attributes "volatile", "const" and "restrict",
for DTRACE these attributes are of little value.
2019-07-16 07:27:35 +00:00
hannken 9112aa41cd Add fixup operation to remove private mutex types for x86.
For GENERIC the number of types goes down from 47351 to 33981.
2019-07-16 07:26:41 +00:00
hannken fcc1d7b138 Always exclude "fbt_*" from the list of FBT probes. 2019-07-16 07:26:00 +00:00
hannken 19f44db6df Change dtrace toxic range to "0 .. VM_MIN_KERNEL_ADDRESS_DEFAULT",
the direct map may be mapped below "VM_MIN_KERNEL_ADDRESS".
2019-07-05 08:29:18 +00:00
hannken 30c4137c4d Change module type to "MODULE_CLASS_MISC" to allow preloading.
Change "dtrace_nullop()" to return zero, it gets casted to "int (*)(...)".
2019-07-05 08:28:52 +00:00
sevan 168837a76f Add rcsid 2019-06-29 20:50:01 +00:00
hannken 544f1cdcc6 import new CDDL dtrace and ZFS code from FreeBSD svn r315983
Add files missing from the initial import.
2019-06-26 11:47:53 +00:00
hannken f3f87b32db Sync with upstream r315983.
Move files originating from upstream below "dist/":

  OPENSOLARIS.LICENSE -> dist/OPENSOLARIS.LICENSE
  usr.sbin/zdb/zdb.8 -> dist/cmd/zdb/zdb.8
  sbin/zfs/zfs.8 -> dist/cmd/zfs/zfs.8
  sbin/zpool/zpool-features.7 -> dist/cmd/zpool/zpool-features.7
  sbin/zpool/zpool.8 -> dist/cmd/zpool/zpool.8
  include/libintl.h -> dist/head/libintl.h
  include/stdio_ext.h -> dist/head/stdio_ext.h
  include/thread.h -> dist/head/thread.h
  sys/kern/callb.c -> dist/uts/common/os/callb.c
  sys/kern/fm.c -> dist/uts/common/os/fm.c
  sys/sys/extdirent.h -> dist/uts/common/sys/extdirent.h
  sys/sys/isa_defs.h -> dist/uts/common/sys/isa_defs.h
  sys/sys/procset.h -> dist/uts/common/sys/procset.h
  sys/sys/sysmacros.h -> dist/uts/common/sys/sysmacros.h

Adapt "usr.sbin/fstyp/Makefile".
2019-06-24 08:27:19 +00:00
hannken 1a12b22735 Sync with upstream r315983.
FreeBSD splits "zfs_context.h" into:
  "lib/libzpool/common/sys/zfs_context.h" for user space
  "uts/common/fs/zfs/sys/zfs_context.h" for kernel space

Do the same here, move and sync "sys/sys/zfs_context.h" to
"dist/lib/libzpool/common/sys/zfs_context.h" and
"dist/uts/common/fs/zfs/sys/zfs_context.h".

Change "Makefile.zfs" to search includes from "dist/lib"
before "dist/uts" so we get the right include file.

Adapt "usr.sbin/fstyp/Makefile" to get the right include file.
2019-06-22 09:48:39 +00:00
hannken 9c87a63a8c Disable assertion: illumos 7793 ztest fails assertion in dmu_tx_willuse_space 2019-06-21 10:59:50 +00:00
skrll ebc5b22cbe Toolify 2019-06-20 14:33:04 +00:00
hannken 1c4272293a Sync with upstream r315983. 2019-06-19 08:18:01 +00:00
kamil 3c0a7f49e5 Drop unused retval pointer from do_sys_mknod{,at}()
No functional change intended.
2019-06-18 22:34:25 +00:00
hannken 490062b29c Add native vfs_suspend()/vfs_resume() before and after
zfs_suspend_fs()/zfs_resume_fs() and get rid of dead "z_sa_hdl == NULL"
znodes before vfs_resume() to keep the vnode cache consistent.

Live rollback should work now.

PR port-xen/54273 ("zpool create pool xbd2" panics DOMU kernel)
2019-06-17 08:09:57 +00:00
hannken 77431910a1 Unmap pages when zfs_rezget() re-establishes a znode with its dbufs. 2019-06-17 08:08:50 +00:00
hannken 566111e6f4 Add fstrans_start()/fstrans_done() and bounds check to zfs_netbsd_getpages(). 2019-06-17 08:08:21 +00:00
hannken 3202242d92 Skip atime update on dead "z_sa_hdl == NULL" znodes. 2019-06-17 08:07:56 +00:00
kamil 2b1dd5795a Fix build with -Wgnu-designator in the ZFS code
struct buf buf = { b_bcount: MAXPHYS }; is a legacy style designator
extension and this raised a compiler error reported by a.rin@mix.
2019-06-12 04:20:18 +00:00
hannken cfba2bba58 There is no 1:1 relation between cv_signal() and cv_timedwait() as
the latter implicitly calls cv_signal() on error.

This leads to "tq_waiting > 0" with "tq_running == 0" and the
taskq stalls.

Change task_executor() to increment and decrement "tq_waiting"
and always check and run the queue after cv_timedwait().

Use mstohz(), fix timeout and sort includes.

Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel
2019-06-11 09:05:33 +00:00
hannken 94984370e5 Try to retrieve the per-disk maximum transfer size and use it instead
of MAXPHYS.  Eagerly waiting for the merge of tls-maxphys.

Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel
2019-06-11 09:04:37 +00:00
hannken ed2fdc797c Sync with upstream r315983. 2019-06-07 10:31:21 +00:00
hannken f96d3fedeb Remove "dist/cmd/stat" containing only one left over and unneeded file. 2019-06-06 15:59:23 +00:00
hannken f1690374af Handle files not present upstream:
dist/lib/libshare/common/libshare.h -> sys/libshare.h
dist/uts/common/sys/systeminfo.h    -> sys/sys/systeminfo.h
dist/uts/common/sys/taskq_impl.h    -> TRASH

No functional change intended.
2019-06-06 14:58:50 +00:00
hannken 58fcc332f4 Switch module solaris to native XDR. 2019-06-05 16:28:06 +00:00
hannken e8ace0777f Use native XDR for libnvpair in userland. 2019-06-04 08:45:17 +00:00
hannken a26bd2a865 upport wedges as vdevs, use DIOCGWEDGEINFO before DIOCGPARTINFO.
PR kern/54219 zpool create pool dk5 causes kernel panic
2019-05-26 10:22:59 +00:00
hannken 0d3564d150 Add missing part of kmem_cache cleanup. Use Solaris argument order for
kmem_cache destructors, umem_cache_alloc() and umem_cache_free() too.
2019-05-26 10:21:00 +00:00
hannken a4a3cea66e Update the kmem_cache emulation to run its callbacks with
Solaris argument order.

No functional change intended.
2019-05-23 08:32:30 +00:00
hannken c54265e62b Implement disk_rename()/iostat_rename() to rename a disk.
Use it from zvol_rename_minor() when renaming a ZVOL.
2019-05-22 08:47:02 +00:00
hannken 72cdecc56a Add missing zvol_close() to zfsdev_close().
Change zvol_size_changed() to initialize "zv->zv_volsize"
and initialize only "dg_secsize" and "dg_secperunit".
Calling disk_set_info() will initialize the remaining
parts of the geometry.

Set "doread" in zvol_strategy() to make reading from
device possible.

Reorganize/add disk_busy()/disk_unbusy() instrumentation.

Redo zvol_ioctl() to implement DIOCGWEDGEINFO and let
disk_ioctl() process the remaining ioctls.
2019-05-22 08:46:27 +00:00
hannken da01880b38 Enable the zvol minor management to create and remove device nodes. 2019-05-22 08:45:32 +00:00
hannken 146ae763fd Update ddi environment:
- Put device major numbers into "dev_info_t".
- Fix an off-by-one in zvol_create_minor().
- When creating a node handle existing nodes
  and add owner read/write permission.
- When removing nodes remove now empty directories.
2019-05-22 08:44:48 +00:00
hannken 572f68cd17 Implement the needed part of Solaris lookupname().
Remove unneeded protoype lookupnameat().
2019-05-22 08:42:57 +00:00
hannken 8c4b1be312 Cleanup modules "solaris" and "zfs":
- Defer spa_config_load() until root is mounted.
- Restore the config path to "/etc/zfs/zpool.cache".
- Module "zfs" is type MODULE_CLASS_VFS and no longer depends on "rootvnode".
- Module "solaris" no longer depends on "mp_online".
- Fix rump component registration to not detach "/dev/zfs" if
  it didn't attach it.
2019-05-07 08:51:09 +00:00
hannken db54d209c2 This implementation of Solaris taskq API is incomplete and doesn't track
Solaris upstream.  FreeBSD already replaced it with a glue to their
taskqueue API.

Replace it with a glue component that queues Solaris taskq requests to
threadpool jobs.
2019-05-07 08:49:59 +00:00
hannken d609d7d444 Add support for fifos, character and block devices. 2019-04-15 12:59:38 +00:00
hannken b75299830a Make ZFS exportable by NFS, implement zfsctl_vptofh(),
zfs_netbsd_vptofh() and zfs_netbsd_fhtovp().

Undo changes to now completely unused zfs_fhtovp().
2019-03-18 09:22:14 +00:00
hannken adb2c81d25 Implement zfsctl_lookup_objset() to look up "zfsvfs" of an mounted snapshot. 2019-03-18 09:21:31 +00:00
hannken a9b5e877b6 Set "mnt_stat.f_fsid" and "mnt_stat.f_fsidx" from the objset guid
like FreeBSD and Illumos do.

Use "f_fsid" for "va_fsid" and cheat NFSD to export snapshots under
".zfs" by setting these snaphots "f_fsidx" to the parents "f_fsidx".
2019-03-18 09:20:58 +00:00
hannken 80fc19ea39 As zfs_netbsd_getpages() ignores "a_count" and processes exactly one page
return an error if "a_count != 1".
2019-03-18 09:20:15 +00:00
hannken 94e5a2a219 Change zfs_readdir() to use malloc() instead of kmem_alloc() to
allocate cookies.  Required by protocol, caller uses free().
2019-03-18 09:19:39 +00:00