Commit Graph

616 Commits

Author SHA1 Message Date
riastradh 3c01401a94 Omit unused definition with broken cpp conditional. 2018-11-15 04:55:26 +00:00
riastradh ec4edf7a44 Omit conflicting definition that breaks build on aarch64. 2018-11-15 04:55:17 +00:00
riastradh 30279c00db "PRIu64", not llu, to print uint64_t. 2018-11-15 04:55:06 +00:00
riastradh 44773f2a69 Define _LP64 or _ILP32 for all architectures.
Rather than write out a table for each architecture, rely on the C
compiler to define _LP64 for 64-bit ones, on the assumption that
anything not LP64 is ILP32, and on CTASSERTs to verify this
assumption so that if it's wrong it'll fail safely with a noisy build
failure.

Gives zfs half a chance of building on, e.g., powerpc.
2018-11-14 17:09:08 +00:00
christos 550eae4327 Avoid conflicts with "our" (the FreeBSD) nvpair/nvlist implementation by
prefixing all symbols with "opensolaris_".
2018-10-23 22:26:14 +00:00
christos b87aa2b0b0 prefix all nv* symbols with opensolaris_ 2018-10-23 22:25:21 +00:00
martin b30151731a Do not initialize .vfs_fhtovp twice 2018-09-16 06:09:01 +00:00
christos be58bd6f37 The macros kidmap_getsidby{u,g}id always return 1 from sid.h on NetBSD,
and clang is complaining about the impossible... So initialize rid and
be done with it, it is the least intrusive fix.
2018-09-14 19:06:53 +00:00
christos 3085e9459c handle clang stupidity 2018-09-07 02:25:40 +00:00
christos 7c0e6d1ccc remove duplicate typedef (it is in sunddi.h) 2018-09-06 00:44:43 +00:00
riastradh d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
christos 49c18b3098 Avoid uninitialized warning. 2018-08-20 06:47:16 +00:00
christos 54ddcf50a8 use the right variables (fix cut-n-pastos) 2018-08-18 12:00:11 +00:00
christos 3d1aec003a make sure rid and idx are initialized. 2018-08-18 11:59:25 +00:00
christos 4122fc0e66 vdev_inuse might not be called and spare_guid contains random stuff. 2018-08-18 11:58:59 +00:00
christos 2df913e657 get rid of kernelbase 2018-08-16 14:14:51 +00:00
christos bb6b99b5bf handle variable kernel vm min address 2018-08-12 16:07:27 +00:00
hannken 1471f8ff92 Initialize z_lockf for new znodes.
Ok: Chuck Silvers
2018-07-31 09:33:50 +00:00
maxv 753a273974 Replace KERN_BASE by VM_MIN_KERNEL_ADDRESS. Also add XXX on INKERNEL. 2018-07-27 07:32:59 +00:00
kamil cd35dc3d84 Rework the changes to DTRACE/ZFS files that were fixing Clang/LLVM build
Rever changes to upstream files and replace them with additional -Wno-
compiler argument flags.

Tested with base LLVM.

Requested by <chuq>
2018-06-29 11:33:46 +00:00
gson 7c2276b8da Use space between words 2018-06-16 15:18:33 +00:00
maya 93c55cb558 Avoid declaring ulonglong_t.
Comment here already says it isn't necessary and will be removed.
Hasten the process for us and avoid the problematic typedef.

This is useful because u_longlong_t would otherwise need to be
provided by compat headers.
2018-06-13 04:21:21 +00:00
kamil d2d2a14700 Replace HAVE_GCC with ACTIVE_CC == gcc checks
Kernel modules build with GCC and Clang/LLVM.

Requested by <joerg>
2018-06-07 13:21:44 +00:00
kamil 60490a027e Correct compilation of osnet/dev/systrace/systrace.c under Clang
Mark arguments to dtrace_probe_lookup() with __UNCONST().
The proper fix constifying it causes pollution of const in too many files.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 17:47:10 +00:00
kamil 3982d87926 Correct compilation of osnet/dev/profile/profile.c under Clang
Constify char* types when initialized with liternals.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 17:19:49 +00:00
kamil afef2ab3de Correct compilation of osnet/dev/dtrace/x86/dis_tables.c under Clang
Constify dgr_suffix.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 17:16:56 +00:00
kamil 9a546da821 Correct compilation of osnet/dev/dtrace/dtrace_hacks.c under Clang
Use __UNCONST() to remove const from an argument.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 15:54:03 +00:00
kamil 03c04814f0 Correct compilation of osnet/dist/uts/common/dtrace/dtrace.c under Clang
Add missing const keywords in dtrace_strncmp().

Initialize lim1 and lim2 to zero always. This prevents a false positive
about potentially unset but used variable.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 15:24:57 +00:00
kamil ec5a3bbdb8 Swap conditions HAVE_LLVM -> HAVE_GCC 2018-06-06 15:01:13 +00:00
kamil 76b9fb4568 Make cddl/osnet/Makefile.zfs compatible with MKLLVM=yes
Clang/LLVM does not recognize:
 - -Wno-discarded-qualifiers

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 14:47:54 +00:00
kamil 8627ada168 Correct compilation of osnet/dist/cmd/dtrace/dtrace.c under Clang
Add missing const keywords.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 14:46:58 +00:00
kamil 54f848644c Make cddl/osnet/usr.sbin/dtrace -W compatible with MKLLVM=yes
Clang/LLVM does not recognize:
 - -Wno-discarded-qualifiers
 - -Wno-unused-but-set-variable

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 14:31:45 +00:00
kamil 38533b841d Make cddl/osnet/lib/libdtrace buildable with MKLLVM=yes
Clang/LLVM does not recognize:
 - -Wno-maybe-uninitialized
 - -Wno-unused-but-set-variable

MKGCC=yes still builds the distribution.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by <The NetBSD Foundation>
2018-06-06 14:18:39 +00:00
christos cc268b724c remove <sys/proc.h> done in the dtrace header now. 2018-06-05 12:04:19 +00:00
christos 61c2ab4099 add <sys/proc.h> because the header needs proc_t kthread_t etc. 2018-06-04 21:36:03 +00:00
christos fbc4edde8d better to put this (<sys/proc.h>) in the dtrace header where the definitions
are needed.
2018-06-04 21:35:29 +00:00
kre fea21eb07e The (dtrace version of) <sys/proc.h> is needed for kthread_t
(same as the amd64 version).   This should fix (one of) the
current i386 build breakages.
2018-06-04 20:12:45 +00:00
christos 8f1adcbb03 Add a blurb of a general approach how to maintain these files. 2018-06-03 20:59:49 +00:00
christos 68837537fe The native mutex.h has a userland visible portion. make it so and fix the
build.
2018-06-03 14:56:52 +00:00
chs bbfe9dbd31 tweak the osnet compat headers to allow building on MacOS and Linux hosts. 2018-06-03 05:55:08 +00:00
chs 01d6e97218 avoid calling kpause() with a delay of 0. 2018-06-03 03:05:56 +00:00
christos 5a38769f09 - Remove more extraneous includes to avoid circular dependencies with the
real header files.
- Add <sys/errno.h> to <sys/systm.h> to avoid changing the source, but
  it should really belong to the source.
2018-06-02 18:46:34 +00:00
christos 50f0215b97 don't include <sys/proc.h> 2018-06-02 15:47:22 +00:00
christos a4bb88f1bb Use a constant to prevent dynamic array allocation which messes up SSP. 2018-06-02 01:19:46 +00:00
kre c0824e2dbe Avoid duplicate typedefs so these headers can be used
as part of tools build, when the base system compiler does
not allow duplicate type definitions.

Someone please fix this some better way than this!
2018-06-01 00:56:19 +00:00
kre 12c661f52d Build fix attempt, use TOOL_AWK (with fallback to "awk") rather than "nawk". 2018-05-29 01:09:49 +00:00
chs 710a39faba add some new files missed by my script:
merge a new version of the CDDL dtrace and ZFS code.
this changes the upstream vendor from OpenSolaris to FreeBSD,
and this version is based on FreeBSD svn r315983.

in addition to the 10 years of improvements from upstream,
this version also has these NetBSD-specific enhancements:
 - dtrace FBT probes can now be placed in kernel modules.
 - ZFS now supports mmap().
2018-05-28 23:47:39 +00:00
chs ba2539a980 merge a new version of the CDDL dtrace and ZFS code.
this changes the upstream vendor from OpenSolaris to FreeBSD,
and this version is based on FreeBSD svn r315983.

in addition to the 10 years of improvements from upstream,
this version also has these NetBSD-specific enhancements:
 - dtrace FBT probes can now be placed in kernel modules.
 - ZFS now supports mmap().
2018-05-28 21:04:59 +00:00
chs 3227e6cf66 import new CDDL dtrace and ZFS code from FreeBSD svn r315983. 2018-05-28 20:52:50 +00:00
christos bacfdb6969 add casts 2018-01-07 20:02:52 +00:00
christos 7eaaf56ed8 add trivial handling for DW_ATE_UTF, does not work. 2017-12-31 03:08:49 +00:00
kre 4464b377cc Let's define symbols before using them. 2017-11-18 18:52:59 +00:00
christos 3be9d673a3 use symbolic constant for 0 2017-11-18 13:51:56 +00:00
christos 114ddb80d3 our pool code needs either PR_SLEEP or PR_NOWAIT; arrange for that explaining
the current choice :-)
2017-11-17 18:18:01 +00:00
christos 7de85f86e1 kill another wrong ELFSIZE setting. 2017-11-06 04:43:50 +00:00
christos eed7a256a0 need to undef KERN_ELFSIZE too here... 2017-11-06 03:51:37 +00:00
abhinav 062266a272 Undo the previous
While it fixed the problem of trailing spaces, but if the probe specifier
contained leading spaces, it would brake dtrace. The proper fix would be
to skip the leading spaces in the string as well.

However, it would result in a bigger diff for a very small benefit. While
a new import of dtrace is impending, it's better not to have this change.

Discussed with christos.
2017-06-05 21:19:32 +00:00
abhinav 143b096d8f Fix the trailing space in the probe specifier's name in dtrace(1)'s output.
When using dtrace using one of the tracing options, such as -n, -P, -i, -f etc.,
the first line of output from dtrace one is something like this:

sudo dtrace -n 'syscall:::entry /pid == 100/ {@num[probefunc] = count();}'
dtrace: description 'syscall:::entry ' matched 482 probes

There is a trailing space at the end of the probe specifier name ('syscall:::entry ').
This happens beucase dtrace tries to separate the probe name from the predicate and actions
using `{' and `/' as the separators but doesn't consider space also as a possible separator.

Output after this change:
sudo dtrace -n 'syscall:::entry /pid == 100/ {@num[probefunc] = count();}'
dtrace: description 'syscall:::entry' matched 482 probes

ok christos@
2017-06-05 17:11:10 +00:00
joerg 47fb074ea2 Fix argument order. 2017-05-26 22:50:35 +00:00
riastradh 7f7aad09bd Make VOP_RECLAIM do the last unlock of the vnode.
VOP_RECLAIM naturally has exclusive access to the vnode, so having it
locked on entry is not strictly necessary -- but it means if there
are any final operations that must be done on the vnode, such as
ffs_update, requiring exclusive access to it, we can now kassert that
the vnode is locked in those operations.

We can't just have the caller release the last lock because some file
systems don't use genfs_lock, and require the vnode to remain valid
for VOP_UNLOCK to work, notably unionfs.
2017-05-26 14:20:59 +00:00
abhinav 9f1571e578 Fix a typo: s/intepretation/interpretation 2017-05-12 21:01:36 +00:00
abhinav 8a253e32f4 Change section number from 1M to 1
The man page gets installed in section 1 anyway.

Ok christos, mrg
2017-05-12 20:58:35 +00:00
riastradh 6fa7b15833 Change VOP_REMOVE and VOP_RMDIR to preserve lock/ref on dvp.
No change to vp -- the plan is to replace the node by the
componentname in the vop parameters, and let all directory vops do
lookups internally.

Proposed on tech-kern with no objections:
https://mail-index.netbsd.org/tech-kern/2017/04/17/msg021825.html
2017-04-26 03:02:47 +00:00
riastradh 87fb32292e Make VOP_INACTIVE preserve vnode lock on return.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2017/04/01/msg021751.html

Ride 7.99.68, a bumpy bus of incremental vfs improvements!
2017-04-11 14:24:59 +00:00
chs 44b9f41144 apply changes equivalent to freebsd r256822, r267759 and r298171:
fix the dtrace "args" variable to return correct values.
simplify the invop handlers a bit by changing the second argument
from a pointer into the stack to a pointer to the trapframe.
2017-02-27 06:46:59 +00:00
hannken 326db3aaf6 Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
2017-02-17 08:31:23 +00:00
chs e2632a59f3 put back the include of dtrace_bsd.h, it actually is needed. 2017-02-01 21:59:09 +00:00
chs 82ba364bfa fix this module to depend on the solaris module rather than the dtrace module.
remove an unneeded header.
2017-02-01 20:06:21 +00:00
chs 769e07db09 add some missing bits from freebsd r211554:
remove the DOODAD from prochandler().
we are now DOODAD-compatible with current freebsd.
2017-02-01 20:02:22 +00:00
christos 398615dda3 Rearrange headers 2017-01-12 23:12:59 +00:00
christos 3391c5f1a7 fix a few warnings. 2017-01-10 19:20:34 +00:00
christos 67442b909a PR/51118: Jared McNeill: Fix build on FreeBSD by removing osnet assert.h
and sys/limits.h and use sys/syslimits.h directly.
2017-01-07 21:39:52 +00:00
christos 05cc892852 arrange for .in files to be rebuilt. 2016-12-19 01:26:31 +00:00
christos e3e83e546b PR/51539: Henning Petersen: replace , with ; 2016-10-09 14:05:12 +00:00
pgoyette 06402e0a42 Move kern_ctf.c into the dtrace_fbt module (the only place it is used)
rather than including in kernels with KDTRACE_HOOKS defined.  Update
the dtrace_fbt module to depend on the zlib module.

Bump kernel version to avoid module mismatch.

Welcome to 7.99.38 !
2016-09-16 03:10:45 +00:00
hannken 7139aab724 Remove now obsolete operation vcache_remove().
Welcome to 7.99.36
2016-08-20 12:37:06 +00:00
christos c4b5e49df8 include bsd.init.mnk for consistency and set NOLINT since this overrides
MKLINT which can be re-set from /etc/mk.conf.
2016-08-04 17:07:23 +00:00
christos bf745eac2e machdep.booted_kernel is not an absolute path, make it so. Now u_int is
found but its parent is not :-)
2016-08-03 16:37:02 +00:00
pgoyette 29ec3266f4 Use C99 initializers for the cdevsw
No functional change intended or expected.
2016-07-17 02:09:10 +00:00
pgoyette 2f144b973e Add missing dp_proc_unlock() in error path.
From PR kern/51285 (Henning Petersen)

XXX Pullup to 7 and 7-0
2016-06-30 00:23:36 +00:00
pgoyette b8fd0470b4 One more removal of a redefined symbol while loading dtrace module.
Should finish the issues with PR kern/51265
2016-06-23 06:44:52 +00:00
pgoyette df0e13d590 On NetBSD we already have strpbrk() in libkern, so we don't need to
provide another copy in the module.  Removes another 'redefined symbol'
error when loading the module.

Related to PR kern/51265
2016-06-23 05:19:42 +00:00
pgoyette 37f3aa12f4 Import fix from FreeBSD - see [1], [2] references below...
Fix DTrace's panic() action.

It would previously call into some unfinished Solaris compatibility code
and return without actually calling panic(9). The compatibility code is
unneeded, however, so just remove it and have dtrace_panic() call vpanic(9)
directly.

Fixes immediate problem in PR-51265.  However, this now reveals another
redefined symbol 'strpbrk' in the required module "solaris".


[1] https://svnweb.freebsd.org/changeset/base/281916
[2] http://lists.freebsd.org/pipermail/svn-src-head/2015-April/071019.html
2016-06-23 04:35:35 +00:00
christos 4a082de2f6 fix dup definitions in module. 2016-06-18 21:41:08 +00:00
mlelstv ccd8c06444 Make assertion of linker_file #ifdef __FreeBSD__. Fixes DIAGNOSTIC build. 2016-06-16 06:08:06 +00:00
christos 2964f15a7a Grr, gcc-5.4 creates DW_AT_typedef without DW_AT_type for HARD_REG_SET!
<1><c26b>: Abbrev Number: 4 (DW_TAG_typedef)
    <c26c>   DW_AT_name        : (indirect string, offset: 0x16e30): HARD_REG_ELT_TYPE
    <c270>   DW_AT_decl_file   : 57
    <c271>   DW_AT_decl_line   : 43
    <c272>   DW_AT_type        : <0x70>
 <1><c276>: Abbrev Number: 102 (DW_TAG_typedef)
    <c277>   DW_AT_name        : (indirect string, offset: 0x2f954): HARD_REG_SET
    <c27b>   DW_AT_decl_file   : 57
    <c27c>   DW_AT_decl_line   : 54
2016-06-08 21:32:27 +00:00
chs 760a7ed1e9 apply the ustack() parts of freebsd r211608:
r211608 | rpaulo | 2010-08-22 03:53:32 -0700 (Sun, 22 Aug 2010) | 8 lines

	Kernel DTrace support for:
	o uregs  (sson@)
	o ustack (sson@)
	o /dev/dtrace/helper device (needed for USDT probes)

	The work done by me was:
	Sponsored by:   The FreeBSD Foundation

plus a few netbsd-specific tweaks from me.
fixes PR 50790.
2016-05-14 21:19:05 +00:00
christos d7245a7577 include stdio.h for NULL 2016-04-28 11:45:02 +00:00
christos f107a05fec remove incorrect comment 2016-04-28 11:38:41 +00:00
christos 4187cd60b2 Introduce dt_bootfile() and use it to avoid hard-coded kernel values. Fixes
dtrace hang for kernels not named netbsd.
2016-04-28 00:02:40 +00:00
christos cb19fc18b8 Apply revision 274569 from FreeBSD:
Only compare visitation counters if they've both been set for the current
type graph walk.
2016-04-10 23:37:10 +00:00
christos 0aab751630 fix test. 2016-04-09 17:58:46 +00:00
christos eabf50fc2e properly check for type id overflow 2016-04-09 17:51:50 +00:00
riastradh 989878b760 Add autounload logic to dtrace module prototype. 2016-04-09 15:18:48 +00:00
riastradh 51346d2825 Disable autoload if there are any profile probes. 2016-04-09 15:17:58 +00:00
riastradh 7256e74462 Prevent autounload while cyclics are still in use. 2016-04-09 14:50:08 +00:00
riastradh 0def3bc2ac Fix module name of dtrace_profile. 2016-04-04 05:15:07 +00:00
christos ccd8517e35 write references as pointers XXX: 2016-03-18 17:11:04 +00:00
christos 8db25f0638 treat class line struct and union 2016-03-18 17:08:45 +00:00
christos dd09ff20c8 Add support for c++ classes. 2016-03-18 17:07:23 +00:00