Commit Graph

869 Commits

Author SHA1 Message Date
kardel a0487d0c30 provide pathconf for .zfs control directory. avoids errors on
ls -l ../.zfs.
2023-02-17 21:50:13 +00:00
chs 8d48e2b9a3 dtrace: remove unnecessary fflush()
Apply this commit from FreeBSD:

  commit f339a3ef6369b368f3a2455792a7a3a4c28f92c4
  Author: Chuck Silvers <chs@FreeBSD.org>
  Date:   Wed Feb 9 17:09:26 2022 -0800

      dtrace: remove unnecessary fflush()

      This call was added back in the early days of dtrace porting and
      no one knows why anymore.  The extra flushing causes lots of
      unnecessary CPU overhead when a script produces lots of output,
      as well as easily losing output because the command can't keep up.

      Sponsored by:	Netflix
      Reviewed by:	imp, markj
      Differential Revision:	https://reviews.freebsd.org/D34216
2023-02-07 22:54:02 +00:00
chs 10ec3626c6 dtrace: re-fix aggregations to report from all online CPUs
Reapply the fix to dt_status() from rev 1.10
("Don't return success when the target CPU is offline")
which was lost in rev 1.12 ("sync with FreeBSD").
The FreeBSD version that we have been using since then does run on NetBSD
but always reports that CPU 0 is online and all other CPUs are offline,
because the sysctl that it uses does not exist on NetBSD.
2023-02-06 22:22:12 +00:00
christos dabd0d314f Don't bail out if the input file does not have a symbol table. This happens
with crtn.o which used to have an empty symbol table with binutils 2.34,
with binutils 2.39 has no symbol table.
2022-12-25 20:23:42 +00:00
hannken cfe3f2c399 Add a helper to set or clear lower mount and use it.
Always add a reference to the lower mount.

Ride 9.99.105
2022-11-04 11:20:39 +00:00
simonb 6abe31b74d Provide an empty ASSERT macro ifdef _STANDALONE. 2022-10-31 10:44:29 +00:00
simonb 424b4ac256 Whitespace nit. 2022-10-31 10:32:28 +00:00
simonb b132f31296 Only need TIMESPEC_OVERFLOW() to check against INT32_{MIN,MAX} on FreeBSD. 2022-10-31 04:50:12 +00:00
nia 06871316e9 Remove references to GEOM from zpool(8). 2022-10-24 14:22:53 +00:00
kardel 2b1d295dd5 Revert. Spotted by hannken@ - fix needs to be in zfs_ctldir.c it is missing
VOP_PATHCONF.
2022-10-03 16:04:19 +00:00
kardel 4c598b636f for unsupported names return EINVAL as per TOG
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
discussed with christos@
2022-09-27 10:33:21 +00:00
mlelstv 75ded7d598 Reference kernel-wide hz constant instead of using a private but possibly
different value.
2022-09-19 22:30:19 +00:00
riastradh 37d4d19175 dtrace_fbt: Allow tracing names that start with `__'.
This was never relevant on FreeBSD and I don't think it is relevant on
NetBSD either.  The FreeBSD change to lift this restriction had the
following comment:

    r306570 | markj | 2016-10-02 00:35:00 +0000 (Sun, 02 Oct 2016) | 7 lines

    Allow tracing of functions prefixed by "__".

    This restriction was inherited from upstream but is not relevant on FreeBSD.
    Furthermore, it hindered the tracing of locking primitive subroutines.
2022-09-02 11:03:50 +00:00
riastradh c5301d0824 dtrace_sdt: Fix bug in builtin module reference counting.
Don't module_hold(NULL)!  This mistake was introduced in my attempt
to get dtrace working for sdt probes defined in non-builtin modules
like zfs.
2022-08-31 12:34:04 +00:00
riastradh 72797797ee dtrace/i386: Need machine/cpufunc.h for x86_read_flags and rcr2. 2022-08-21 18:58:45 +00:00
riastradh dead83d64a bsd.kmodule.mk: Build modules with KDTRACE_HOOKS if MKDTRACE=yes. 2022-08-07 23:42:09 +00:00
riastradh 81efaf9e90 dtrace_sdt: Register sdt providers and probes in loaded modules too. 2022-08-07 20:47:05 +00:00
chs 02f91ef077 change the ARC reclaim code to use the pagedaemon's free page target
rather than having a separate target.
2022-08-03 01:53:06 +00:00
riastradh e3c82a0cc6 solaris: Give threads less bad names. 2022-07-30 13:09:19 +00:00
riastradh d3d72cee9c osnet: Stop disabling dtrace probes. 2022-07-30 13:03:05 +00:00
riastradh c24f208cc5 zfs: Give condvars more meaningful names.
These will be truncated to 16 characters, but hey, better'n `zfscv'.
2022-07-30 12:59:31 +00:00
chs 28cd7476b4 fix ARC checks for available memory:
there's an extra check that we inherited from FreeBSD that tries to
detect KVA exhaustion on platforms with limited KVA, but the condition
that decided whether to use the extra check was using a FreeBSDism
that doesn't exist on NetBSD, resulting in this check being used on
all platforms.  on amd64 systems with lots of memory, this extra check
would result in the ARC thinking that it constantly needed to reclaim memory,
resulting in all the xcall threads running all the time but not doing
anything useful.  change this condition so that this extra check for
KVA exhaustion is only used on 32-bit platforms.  fixes PR 55707.
2022-05-04 15:49:55 +00:00
jkoshy fde05ead87 Minor: fix a typo. 2022-05-03 12:09:19 +00:00
jkoshy 9df6d2eefa Follow FreeBSD revision <0e15d9fbeba4> and simplify #ifdef'ed code.
This change avoids redefining 'SHN_SUNW_IGNORE' if the symbol is already
present.
2022-05-02 20:09:48 +00:00
hannken 89ddb8af18 Unlock vnode for VOP_IOCTL(). 2022-04-16 07:56:45 +00:00
christos 41fac1e5ad Add link our policy. 2022-03-30 16:34:27 +00:00
riastradh e7bed28911 driver(9): devsw_detach never fails. Make it return void.
Prune a whole lotta dead branches as a result of this.  (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back.  To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
2022-03-28 12:33:20 +00:00
christos 884c22fa28 add a kauth vnode check for adding links 2022-03-27 16:26:26 +00:00
riastradh 4e7bd1dfb2 osnet: Delete dead #if 0 code using hardclock_ticks. 2022-03-18 23:32:14 +00:00
riastradh e468962b6a lockstat(4): KNF. No functional change intended. 2022-02-27 14:16:32 +00:00
riastradh d3ab1269bf lockstat(4): Membar audit.
- Serialize updates to lockstat_enabled, lockstat_dev_enabled, and
  lockstat_dtrace_enabled with a new __cpu_simple_lock.

- Use xc_barrier to obviate any need for additional membars in
  lockstat_event.

- Use atomic_load/store_* for access that might not be serialized by
  lockstat_lock or lockstat_enabled_lock.
2022-02-27 14:16:12 +00:00
riastradh 11ba2468a1 zfs: Expose hostid to zfs, as in gethostid/sethostid(3).
If set to nonzero, the hostid is recorded in the metadata of a zpool,
and checked by `zpool import' when the pool has not been explicitly
exported.  After reboot, zpool import will not need `-f' to reimport
the pool.

Setting the hostid must be done explicitly through sysctl (or the
sethostid(3) library call) on all ports except acorn32, amiga,
mvme68k, newsmips, sparc, sparc64, sun2, and sun3.  So for most users
this change will have no immediate effect.  But you can obviate the
need for `zpool import -f' by adding `kern.hostid=123456789' to
/etc/sysctl.conf and importing the pool one last time with `-f'.
2021-12-28 17:51:23 +00:00
simonb 8ac21e5a89 In zfs_setattr() don't recheck the auth policy for a "nodump" flags
change. zfs_netbsd_setattr() has already checked if this request is
authorised, and our secpolicy_xvattr() doesn't check kauth chflags.

XXX: Fix this propery when we migrate to openzfs.

riastradh@: Seems reasonable.
2021-12-22 14:04:10 +00:00
hauke 5ab0766754 Default files to BSD group ownership in line with ffs, after the lead
of FreeBSD <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=139076>
(patch by hannken@)
2021-12-21 15:08:14 +00:00
simonb 674cec8ef5 In vattr_init_mask() check for va_flags and if set add to the mask of
to the things that setattr is interested in.
Fixes chflags(2) on ZFS.

Thanks riastradh@ for fix.
2021-12-17 08:07:12 +00:00
simonb 45fbb8e465 In zfs_statvfs(), set f_bresvd and f_fresvd to 0. Fixes random kernel
accounting suspend/resumes with erroneous values leaking out.

Note: no userland leakage as statvfs(2) handler memset 0's the buffer.

XXX: Should be fixed with a memset in VFS_STATVFS().
2021-11-30 12:37:38 +00:00
simonb 2dab5a2679 Hacks to get zdb working on NetBSD:
- Force accessing raw device but we're passed the block device.
 - Deal with wedges not returning their size on a stat(2) and use
   the DIOCGMEDIASIZE ioctl instead.

Ok chs@.
2021-10-27 11:35:23 +00:00
thorpej 982ae832c3 Overhaul of the EVFILT_VNODE kevent(2) filter:
- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
  forcing each individual file system to deal with it (except VOP_RENAME(),
  because VOP_RENAME() is a mess and we currently have 2 different ways
  of handling it; at least it's reasonably well-centralized in the "new"
  way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
  compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
  to avoid doing work for events no one cares about (avoiding, e.g.
  taking locks and traversing the klist to send a NOTE_WRITE when
  someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
  to be invoked before and after vop_pre() and vop_post(), respectively.
  Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
  vop_*_args structures.  These context fields are used to convey information
  between the file system VOP function and the VOP wrapper, but do not
  occupy an argument slot in the VOP_*() call itself.  These context fields
  are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
  back the resulting link count of the target vnode.  Return this in tmpfs,
  udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.
2021-10-20 03:08:16 +00:00
simonb 9642c2c8a1 Clamp zfs nlinks at UINT32_MAX (nlink_t max) instead of (much) smaller
16-bit LINK_MAX until we bump LINK_MAX.  Fixes fts(3) problems with
"rm -rf" on zfs directories with > 32766 subdirectories.

Thanks mlelstv@ and mrg@ for helping debug this.
2021-09-06 08:37:43 +00:00
mlelstv 5746ce6090 Don't use __FBSDID, similar to kern/kobj.c, kern/misc.c, kern/sysevent.c 2021-09-05 11:43:22 +00:00
rillig 825116fea2 osnet: fix lint warning about empty declaration
proc_bkpt.c(32): warning: empty declaration [0]

Use the same definition as in libarchive.
2021-09-05 10:18:31 +00:00
christos 07a5a803ce Include <time.h> for all GNU systems (hurd). From Damien Zammit 2021-08-29 08:43:12 +00:00
riastradh 549613bcf6 libzfs: Zero DIOCLWEDGES input before ioctl.
Otherwise we ask the kernel to write over whatever random pointer was
in the stack garbage here, when all we wanted was to learn whether
dkwl_nwedges is zero or nonzero.

XXX pullup-9
2021-08-28 10:47:45 +00:00
riastradh 45ada0c008 PR/56355: Exclude the symbol trap, not all symbols other than trap. 2021-08-18 11:26:17 +00:00
christos cb485a28ce PR/56355: Taylor Campbell: restore strcmp() over strncmp() 2021-08-15 16:33:57 +00:00
christos fd6562d6eb PR/56355: Brad Harder: dtrace triggers double-fault in supervisor mode 2021-08-11 11:16:49 +00:00
skrll 7f8c58afc7 KNF 2021-07-25 06:07:42 +00:00
dholland 4171507047 Abolish all the silly indirection macros for initializing vnode ops tables.
These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
2021-07-18 23:57:13 +00:00
dholland d819c3614f Use macros for the canned parts of device and fifo vnode op tables.
Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
2021-07-18 23:56:12 +00:00
kardel b5f331ca20 PR kern/56316: vn_open doesn't follow symlinks
remove setting of O_NOFOLLOW. restores ZFS being able
to open devices via symlinks again.
2021-07-18 07:22:22 +00:00