2 years agoMerge branch 'vendor/DHCPCD'
Roy Marples [Sun, 6 Sep 2020 16:17:50 +0000 (17:17 +0100)]
Merge branch 'vendor/DHCPCD'

2 years agoUpdate to dhcpcd-9.2.0 with the following changes:
Roy Marples [Sun, 6 Sep 2020 16:15:23 +0000 (17:15 +0100)]
Update to dhcpcd-9.2.0 with the following changes:

 * route: ensure IPv4LL routes come last in priority
 * DHCP: fix many issues with extending the last lease
 * privsep: don't read control group from config in privsep
 * privsep: only the master process responds to signals
 * privsep: use a socketpair for stderr/stdin rather than dupping /dev/null
 * privsep: right limit stdin/stderr/stdout
 * privsep: dumping a lease is now run in a sandbox
 * options: check if kernel supports INET or INET6 before enabling default
 * options: let clientid override a prior duid
 * options: allow -1 to represent infinity for requested lease time
 * dhcpcd: fix a crash initing a new interface after route overflow

2 years agosys/vfs/hammer2: Remove #if0'd function hammer2_allocsize()
Tomohiro Kusumi [Sat, 5 Sep 2020 18:14:17 +0000 (03:14 +0900)]
sys/vfs/hammer2: Remove #if0'd function hammer2_allocsize()

This is obsolete version of hammer2_getradix() which won't be used again.

2 years agosys/vfs/hammer2: Ignore HAMMER2_BREF_TYPE_EMPTY in hammer2_adjreadcounter()
Tomohiro Kusumi [Sat, 5 Sep 2020 18:02:24 +0000 (03:02 +0900)]
sys/vfs/hammer2: Ignore HAMMER2_BREF_TYPE_EMPTY in hammer2_adjreadcounter()

2 years agolibm: Mark some functions hidden (syncs math_private.h with OpenBSD).
Sascha Wildner [Sun, 6 Sep 2020 11:12:08 +0000 (13:12 +0200)]
libm: Mark some functions hidden (syncs math_private.h with OpenBSD).

2 years ago<sys/cdefs.h>: Add __{BEGIN,END}_HIDDEN_DECLS definitions and use them.
Sascha Wildner [Sun, 6 Sep 2020 11:06:37 +0000 (13:06 +0200)]
<sys/cdefs.h>: Add __{BEGIN,END}_HIDDEN_DECLS definitions and use them.

Remove local empty definitions of these macros in some Makefiles.

Thanks to zrj for testing with a full bulk build.

Taken-from: OpenBSD

2 years ago<sys/cdefs.h>: Move __dso_{public,hidden} to the other visibility defs.
Sascha Wildner [Sun, 6 Sep 2020 11:01:17 +0000 (13:01 +0200)]
<sys/cdefs.h>: Move __dso_{public,hidden} to the other visibility defs.

2 years ago<sys/cdefs.h>: Untangle the __{BEGIN,END}_DECLS definitions a bit.
Sascha Wildner [Sun, 6 Sep 2020 10:58:30 +0000 (12:58 +0200)]
<sys/cdefs.h>: Untangle the __{BEGIN,END}_DECLS definitions a bit.

Mainly separate the defined(__cplusplus) and the __GNU_PREREQ__(4, 0)

2 years agosys/vfs/hammer2: Fix function names in kprintf
Tomohiro Kusumi [Sat, 5 Sep 2020 12:34:07 +0000 (21:34 +0900)]
sys/vfs/hammer2: Fix function names in kprintf

2 years agoworld - Add /usr/projects maintenance to /usr/Makefile.
Matthew Dillon [Fri, 4 Sep 2020 18:18:04 +0000 (11:18 -0700)]
world - Add /usr/projects maintenance to /usr/Makefile.

* Add /usr/projects maintenance to /usr/Makefile.  This allows the
  dragonfly projects repo to be pulled and maintained, if desired.

2 years agocalendar(1): Rewrite to support Chinese & Julian calendars
Aaron LI [Sun, 2 Aug 2020 14:17:59 +0000 (22:17 +0800)]
calendar(1): Rewrite to support Chinese & Julian calendars

I wanted to use Chinese calendar in the calendar(1) utility, so I started
working on it.  The Chinese calendar is a lunisolar calendar and requires
calculations of Sun and Moon positions.  Along the way of implementing the
Chinese calendar support, more and more parts of the old code has been
replaced.  Now, the new calendar(1) code base has been mostly rewritten to
be more extensible to support multiple calendars.  Although only the
Gregorian (the default), Chinese and Julian calendars are currently
supported, more calendars now becomes much easier to add.

* Support Chinese calendar
* Support Julian calendar
* More accurate Sun and Moon calculations
* More extensible
* More calendar files/entries and more accurate information
* Better code base

Major Changes:
* If no user's calendar file, default to '/etc/calendar/default'
* Search calendar files in '/etc/calendar', which allows to override the
  calendar file in '/usr/share/calendar' in a system-wide way
* Add '-s' option to show information of Chinese/Julian calendar or
* Add '-H' option to specify the calendar home directory
* Add '-L' option to specify the location, which should be set to get
  accurate Sun/Moon information
* Add '-T' option to specify the current time for Sun/Moon calculations
* Much Improved calendar file parser
* More clean man page
* More helpful error messages
* Some bug fixes and various cleanups

The new calendar algorithms are implemented by referring to this great
Calendrical Calculations: The Ultimate Edition (4th Edition)
by Edward M. Reingold and Nachum Dershowitz.
Cambridge University Press, 2018.
ISBN: 9781107057623

More information about the development history of this calendar(1) utility
can be found in my GitHub repository:

2 years agoMakefile.usr: Always use pkg-static
Antonio Huete Jimenez [Thu, 3 Sep 2020 23:32:53 +0000 (01:32 +0200)]
Makefile.usr: Always use pkg-static

  - Should help in between LibreSSL upgrades.

2 years agosbin/newfs_hammer2: Fail if no free space left
Tomohiro Kusumi [Thu, 3 Sep 2020 15:17:02 +0000 (00:17 +0900)]
sbin/newfs_hammer2: Fail if no free space left

stat[v]fs shows negative free space if newfs/mount'd with <0 free_space.

2 years agosys/vfs/hammer2: Remove obsolete comments for hammer2_install_volume_header()
Tomohiro Kusumi [Thu, 3 Sep 2020 15:10:06 +0000 (00:10 +0900)]
sys/vfs/hammer2: Remove obsolete comments for hammer2_install_volume_header()

First two are implemented.
bread will fail for a small device with <4 volume headers (4 isn't mandatory).

2 years agokernel: avoid possible use-after-free in ipv6
Daniel Fojt [Thu, 3 Sep 2020 06:59:12 +0000 (08:59 +0200)]
kernel: avoid possible use-after-free in ipv6

Fix improper mbuf handling when processing IPv6 Hop-by-Hop options.

Taken from: FreeBSD (FreeBSD-SA-20:24.ipv6)

2 years agofdisk - Add storage expansion option
Matthew Dillon [Wed, 2 Sep 2020 20:00:56 +0000 (13:00 -0700)]
fdisk - Add storage expansion option

* Add the -x option to fdisk.  This will expand the last valid
  slice for an existing dos label to fit the storage.

  fdisk will refuse to expand an EFI GPT label, use 'gpt expand ...'

2 years agogpt, disklabel64 - Add storage expansion options (2)
Matthew Dillon [Wed, 2 Sep 2020 18:51:15 +0000 (11:51 -0700)]
gpt, disklabel64 - Add storage expansion options (2)

* Cleanup debugging printfs and improve messages.

2 years agogpt, disklabel64 - Add storage expansion options
Matthew Dillon [Wed, 2 Sep 2020 18:24:47 +0000 (11:24 -0700)]
gpt, disklabel64 - Add storage expansion options

* Add gpt expand directive.  For example 'gpt expand /dev/da0' will
  expand the gpt to fill /dev/da0.  This allows the gpt to be enlarged
  to fit a new, larger storage device or expanded storage and can be issued
  on a live gpt if desired.

* Add disklabel64 -x and -xx features.  This expands the disklabel to
  fit the new enlarged slice that it resides in.  If -xx is specified,
  the last partition configured in the disklabel will also be enlarged.

* And we already have 'hammer2 growfs <mountpt>' to grow a live hammer2
  filesystem to fit an enlarged partition.

2 years agosys/vfs/hammer2: Remove unused HAMMER2_INODE_RENAME_INPROG
Tomohiro Kusumi [Wed, 2 Sep 2020 16:10:07 +0000 (01:10 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_INODE_RENAME_INPROG

Appeared in 51bf8e9b90e371ed867e5fd82f8ad6fb74867b22 in 2013,
but never used.

Also fix obsolete comments for inode flags.

2 years agosys/vfs/hammer2: Fix wrong comment for hammer2_inode_modify()
Tomohiro Kusumi [Wed, 2 Sep 2020 16:03:54 +0000 (01:03 +0900)]
sys/vfs/hammer2: Fix wrong comment for hammer2_inode_modify()

Sync with changes after 815e1c13cd185a8d3507c7d200b6f53a78b6a364 in 2015.

2 years agosys/vfs/ext2fs: Cleanup empty lines (sync with FreeBSD)
Tomohiro Kusumi [Wed, 2 Sep 2020 15:50:17 +0000 (00:50 +0900)]
sys/vfs/ext2fs: Cleanup empty lines (sync with FreeBSD)

from freebsd/freebsd@db86a2fd1ccdf6fcdfe452f21d38a7f038b368a7

2 years agosys/vfs/msdosfs: Cleanup empty lines (sync with FreeBSD)
Tomohiro Kusumi [Wed, 2 Sep 2020 15:37:18 +0000 (00:37 +0900)]
sys/vfs/msdosfs: Cleanup empty lines (sync with FreeBSD)

from freebsd/freebsd@db86a2fd1ccdf6fcdfe452f21d38a7f038b368a7

2 years agosys/vfs/autofs: Cleanup empty lines (sync with FreeBSD)
Tomohiro Kusumi [Wed, 2 Sep 2020 15:36:36 +0000 (00:36 +0900)]
sys/vfs/autofs: Cleanup empty lines (sync with FreeBSD)

from freebsd/freebsd@db86a2fd1ccdf6fcdfe452f21d38a7f038b368a7

2 years agokernel: Fix LINT64 build after Linux RCU changes
Fran├žois Tigeot [Wed, 2 Sep 2020 08:10:08 +0000 (10:10 +0200)]
kernel: Fix LINT64 build after Linux RCU changes

2 years agohammer2 - Add HAMMER2IOC_GROWFS ioctl (2)
Matthew Dillon [Tue, 1 Sep 2020 21:29:36 +0000 (14:29 -0700)]
hammer2 - Add HAMMER2IOC_GROWFS ioctl (2)

* Fix minor bug to not try to write volume headers beyond the new size.
  Only applicable to H2 filesystems less than 8GB in size.

2 years agohammer2 - Implement 'growfs' directive
Matthew Dillon [Tue, 1 Sep 2020 21:25:19 +0000 (14:25 -0700)]
hammer2 - Implement 'growfs' directive

* Implement the 'growfs' directive, as in:

  hammer2 growfs /mnt

* If you resize the partition a hammer2 filesystem resides on, you
  can grow the filesystem into the partition via this command.

  The hammer2 filesystem must be mounted to issue this command.

* Note that disklabel partitions can be made larger in-place, even
  with the filesystem using the partition already mounted, as long
  as the drive actually has room to spare.

2 years agohammer2 - Add HAMMER2IOC_GROWFS ioctl
Matthew Dillon [Tue, 1 Sep 2020 21:24:28 +0000 (14:24 -0700)]
hammer2 - Add HAMMER2IOC_GROWFS ioctl

* This ioctl allows a live filesystem to be resized into a partition
  that has increased in size.

2 years agodrm - Implement poor-man's RCU
Matthew Dillon [Tue, 1 Sep 2020 18:13:25 +0000 (11:13 -0700)]
drm - Implement poor-man's RCU

* Implement a really poor-man's RCU.  Not even remotely perfect, this
  is just a brute-force tie-in for now.

  RCU operations are queued and then executed on the calling cpu
  1 second later.

2 years agokernel - Revamp ifsq_watchdog*() a bit
Matthew Dillon [Tue, 1 Sep 2020 18:06:23 +0000 (11:06 -0700)]
kernel - Revamp ifsq_watchdog*() a bit

* Add a flags argument to ifsq_watchdog_init() and implement two

  IF_WDOG_ALLTICKS Watchdog callback occurs each second
prior to terminal count, and on terminal

  IF_WDOG_LASTTICK Watchdog callback occurs one second prior
to terminal count, and on terminal count.

  0 Watchdog callback only occurs on terminal

  Note that the ifnet lock is fully serialized when a watchdog
  callback is made, so generally speaking to avoid hicups you
  only want to use IF_WDOG_LASTTICK.

* This feature allows the watchdog code to flush any tx buffers
  (call *_txeof()) that have completed transmission.  Many NICs
  and virtual NICs don't bother to generate interrupts to clean-up
  such buffers when the rings are only lightly loaded.

* Fix spurious vtnet watchdog events on lightly loaded vtnet
  interfaces, loosly using the same code that FreeBSD uses
  (just txeof from the second-prior watchdog callback and then
  check on terminal count).

2 years agosys/vfs/hammer2: Remove Debugger() call for debugging in normal paths
Tomohiro Kusumi [Tue, 1 Sep 2020 15:03:12 +0000 (00:03 +0900)]
sys/vfs/hammer2: Remove Debugger() call for debugging in normal paths

2 years agosys/vfs/hammer2: Remove obsolete comments on indirect block
Tomohiro Kusumi [Mon, 31 Aug 2020 17:18:21 +0000 (02:18 +0900)]
sys/vfs/hammer2: Remove obsolete comments on indirect block

These comments from 9061bde5ad5e46bcaee746ed03d598a75b38691f in 2013
aren't really true today. Depends on blockref type, but indirect
blocks are usually 4, 16, or 32 KB, and blockref is 128 bytes.

2 years agosys/vfs/hammer2: Use hammer2_spin_t
Tomohiro Kusumi [Mon, 31 Aug 2020 15:21:00 +0000 (00:21 +0900)]
sys/vfs/hammer2: Use hammer2_spin_t

Use hammer2_spin_t instead of DragonFly specific lock primitive
structure "struct spinlock" for spinlock.

2 years agoPartially revert commit bdaacb9f+.
Daniel Fojt [Mon, 31 Aug 2020 10:09:13 +0000 (12:09 +0200)]
Partially revert commit bdaacb9f+.

Make *_RB_SCAN() back inlined. Possible inlining failures should be
treated gracefully with particular WORLD_CCOPTLEVEL.

Pointed out by: Sascha Wildner

2 years agofsck_hammer2(8): de-inline couple of functions
Daniel Fojt [Sun, 30 Aug 2020 11:30:30 +0000 (13:30 +0200)]
fsck_hammer2(8): de-inline couple of functions

Fix -Werror=inline ("call is unlikely and code size would grow") exposed
when building world with -Os.

2 years agolibefivar: use correct types in conversion macros
Daniel Fojt [Mon, 31 Aug 2020 06:46:28 +0000 (08:46 +0200)]
libefivar: use correct types in conversion macros

Adjust Strtoi() and Strtoi64() to return unsigned results, to match
upstream implementation.

Discussed with: Sascha Wildner

2 years agolibefivar: avoid accessing type-punned pointer
Daniel Fojt [Sat, 29 Aug 2020 10:23:53 +0000 (12:23 +0200)]
libefivar: avoid accessing type-punned pointer

Fix -Werror=strict-aliasing in Strtoi64() macro exposed when building
world with -O2.

2 years agolibfetch: avoid dereferencing possibly uninitialized pointer
Daniel Fojt [Sat, 29 Aug 2020 08:58:35 +0000 (10:58 +0200)]
libfetch: avoid dereferencing possibly uninitialized pointer

Fix -Werror=maybe-uninitialized exposed when building world with -Os.

2 years agosys/vfs/hammer2: Minor cleanup from cecb915381c4268602e4dfb4725d792e633b326d
Tomohiro Kusumi [Sun, 30 Aug 2020 16:40:03 +0000 (01:40 +0900)]
sys/vfs/hammer2: Minor cleanup from cecb915381c4268602e4dfb4725d792e633b326d

2 years agosys/vfs/hammer2: Remove nonexistent function prototypes
Tomohiro Kusumi [Sun, 30 Aug 2020 15:00:12 +0000 (00:00 +0900)]
sys/vfs/hammer2: Remove nonexistent function prototypes

2 years agolibc & libkvm: Fix wrong calculations in getloadavg() functions.
Sascha Wildner [Sun, 30 Aug 2020 07:52:34 +0000 (09:52 +0200)]
libc & libkvm: Fix wrong calculations in getloadavg() functions.

41ca9afb26bd2f0654acb8462f6abe441e329f80 changed the ldavg field of
struct loadavg to an array of __uint64_t from previously fixpt_t
which is __uint32_t.

Adjust two associated nelem calculations to use __uint64_t as well.

2 years ago<sys/if_media.h>: Fix typo.
Sascha Wildner [Sat, 29 Aug 2020 18:10:48 +0000 (20:10 +0200)]
<sys/if_media.h>: Fix typo.

2 years agosys/vfs/hammer2: Remove unused HAMMER2_MODIFY_{NO_MODIFY_TID,UNUSED0008}
Tomohiro Kusumi [Sat, 29 Aug 2020 15:37:28 +0000 (00:37 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_MODIFY_{NO_MODIFY_TID,UNUSED0008}

No longer used since 504565062f34ec55037ac0cf308fe3562f091460 in 2014.

2 years agosys/vfs/hammer2: Remove unused HAMMER2_BMAP_*
Tomohiro Kusumi [Sat, 29 Aug 2020 15:27:42 +0000 (00:27 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_BMAP_*

No longer used since d7bfb2cbc2b575acb989d4aad0d2477b2f2fe693 in 2013.
These were used in vop_bmap.

2 years agosys/vfs/hammer2: Remove unused HAMMER2_FREECACHE_*
Tomohiro Kusumi [Sat, 29 Aug 2020 15:19:13 +0000 (00:19 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_FREECACHE_*

No longer used since 91abd41080e36691a2b192d816cd4bd90bcd7d12 in 2013.

The freemap layout when these were added is no longer compatible
with the current one, so these won't be used again either.

2 years agosys/vfs/hammer2: Remove unused HAMMER2_DELDUP_RECORE
Tomohiro Kusumi [Sat, 29 Aug 2020 15:15:11 +0000 (00:15 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_DELDUP_RECORE

No longer used since da6f36f44bb9c76612e31b56cdfe4d787e53d61f in 2014.
hammer2_chain_delete_duplicate() was also removed.

2 years agovkernel: Adjust vke(4) for the if_media.h changes (fixes vkernel build).
Sascha Wildner [Sat, 29 Aug 2020 12:40:18 +0000 (14:40 +0200)]
vkernel: Adjust vke(4) for the if_media.h changes (fixes vkernel build).

2 years ago<net/if_media.h>: Adjust ethernet media types some more.
Sascha Wildner [Sat, 29 Aug 2020 10:13:58 +0000 (12:13 +0200)]
<net/if_media.h>: Adjust ethernet media types some more.

* IFM_1000_FX was cleaned up long ago in FreeBSD (see r95702) and

* Add a useful comment from FreeBSD.

* Adjust some whitespace and indentation.

While here, clean up the ifmedia.4 manual page a bit and add a
IFM_10G_TWINAX description (from NetBSD).

2 years agox86_64/machdep.c: Fix two minor typos and indentation
Aaron LI [Sat, 29 Aug 2020 08:00:38 +0000 (16:00 +0800)]
x86_64/machdep.c: Fix two minor typos and indentation

2 years agokernel - Fix KVM implosion by enabling the IOAPIC
Matthew Dillon [Sat, 29 Aug 2020 01:32:43 +0000 (18:32 -0700)]
kernel - Fix KVM implosion by enabling the IOAPIC

* We were disabling the IOAPIC universally when running under a VM,
  because older VMs sometimes broke when it was enabled.

  However, this can actually implode the virtual machine by causing
  interrupt routing to go haywire.

  Add a case statement and always enable the IOAPIC on bare hardware
  and KVM guests.

* Change the default to also enable the IOAPIC on all other VMs.
  Cases can be added for specific disablement if necessary.

* Fixes Google Cloud Environment booting.

2 years agokernel - Be more verbose about disabling the IOAPIC
Matthew Dillon [Sat, 29 Aug 2020 01:27:46 +0000 (18:27 -0700)]
kernel - Be more verbose about disabling the IOAPIC

* Be more verbose when disabling the IOAPIC.

* We current disable auto-EOI on the lapic.  Add some code in
  case we enable in the future to ensure that it remains disabled
  for KVM guests.

2 years agokernel - Fix atomicy issue in APIC EOI and enable_icus
Matthew Dillon [Sat, 29 Aug 2020 01:23:50 +0000 (18:23 -0700)]
kernel - Fix atomicy issue in APIC EOI and enable_icus

* Change ICU_INTREN() and ICU_INTRDIS() to only modify the ICU
  whos bit is being changed, rather than always setting the mask
  for both ICUs.

* If masking a level IRQ on the APIC, make sure the EOI
  to the APIC is atomic with the masking operation.

* Make sure that ICU enablement is atomic with ICU masking

* Does not fix any known bugs

2 years agosbin/hammer2: Introduce HAMMER2_SHOW_DEPTH to limit "show" depth
Tomohiro Kusumi [Fri, 28 Aug 2020 15:24:28 +0000 (00:24 +0900)]
sbin/hammer2: Introduce HAMMER2_SHOW_DEPTH to limit "show" depth

Useful to check HAMMER2 radix tree nodes not so deep in the tree.

2 years agosbin/hammer2: Drop extra indentation in "show" when -q
Tomohiro Kusumi [Fri, 28 Aug 2020 15:23:46 +0000 (00:23 +0900)]
sbin/hammer2: Drop extra indentation in "show" when -q

2 years agosbin/hammer2: Fix "show" and "volhdr" output format
Tomohiro Kusumi [Fri, 28 Aug 2020 15:39:59 +0000 (00:39 +0900)]
sbin/hammer2: Fix "show" and "volhdr" output format

2 years agolibc/getdate: Add getdate_err to the Symbol.map too.
Sascha Wildner [Fri, 28 Aug 2020 11:29:32 +0000 (13:29 +0200)]
libc/getdate: Add getdate_err to the Symbol.map too.

Seems lang/clisp picks up getdate().

Reported-by: zrj
2 years agokernel: Adjust wmesg.
Sascha Wildner [Fri, 28 Aug 2020 04:38:08 +0000 (06:38 +0200)]
kernel: Adjust wmesg.

Just like in vfs_rootmountalloc().

Pointed-out-by: aly
2 years ago<net/if_media.h>: IFM_HPNA_1 != IFM_10G_LR, renumber as needed.
Sascha Wildner [Thu, 27 Aug 2020 15:41:04 +0000 (17:41 +0200)]
<net/if_media.h>: IFM_HPNA_1 != IFM_10G_LR, renumber as needed.

Reported-by: zrj
2 years agosys/vfs/hammer2: Remove HAMMER2_MINIO* macros
Tomohiro Kusumi [Thu, 27 Aug 2020 15:08:07 +0000 (00:08 +0900)]
sys/vfs/hammer2: Remove HAMMER2_MINIO* macros

HAMMER2_MINIO* were added in 1a7cfe5ae3c897f704a358fd3e556a55e430dcb1
in 2013 to switch HAMMER2_MINIO* values with ifdefs when ondisk format
wasn't stable.

This is no longer needed, and using both HAMMER2_MINIO* and HAMMER2_LBUF*
should be avoided. Users of HAMMER2_MINIO* exist in several userspace
programs which walk through blockrefs from top to bottom.

2 years agoefibootmgr(8): Sync with FreeBSD.
Sascha Wildner [Thu, 27 Aug 2020 15:17:52 +0000 (17:17 +0200)]
efibootmgr(8): Sync with FreeBSD.

Adds the -f (--fw-ui) and -F (--no-fw-ui) options to enter (or not) the
firmware's user interface upon next boot.

Taken-from: FreeBSD

2 years agotmpfs - Improve assertions
Matthew Dillon [Thu, 27 Aug 2020 05:55:54 +0000 (22:55 -0700)]
tmpfs - Improve assertions

* Improve assertions to detect failed RB_INSERT() operations.

2 years agokernel - Deal with VOP_NRENAME races
Matthew Dillon [Thu, 27 Aug 2020 05:41:05 +0000 (22:41 -0700)]
kernel - Deal with VOP_NRENAME races

* VOP_NRENAME() as implemented by the kernel can race any number of
  ways, including deadlocking, allowing duplicate entries, and panicing
  tmpfs.  It typically requires a heavy test load to replicate this but
  a dsynth build triggered the issue at least once.

  Other recently reported tmpfs issues with log file handling might also
  be effected.

* A per-mount (semi-global) lock is now obtained whenever a directory
  is renamed.  This helps deal with numerous MP races that can cause
  lock order reversals.

  Loosely taken from netbsd and linux (mjg brought me up to speed on
  this).  Renaming directories is fraught with issues and this fix,
  while somewhat brutish, is fine.  Directories are very rarely renamed
  at a high rate.

* kern_rename() now proactively locks all four elements of a rename
  operation (source_dir, source_file, dest_dir, dest_file) instead of
  only two.

* The new locking function, cache_lock4_tondlocked(), takes no chances
  on lock order reversals and will use a (currently brute-force)
  non-blocking and lock cycling algorithm.  Probably needs some work.

* Fix a bug in cache_nlookup() related to reusing DESTROYED entries
  in the hash table.  This algorithm tried to reuse the entries while
  maintaining shared locks, since only the entries need to be manipulate
  to reuse them.  However, this resulted in lookup races which could
  cause duplicate entries.  The duplicate entries then triggered
  assertions in TMPFS.

* nlookup now tries a little harder and will retry if the parent of an
  element is flagged DESTROYED after its lock was released.  DESTROYED
  elements are not necessarily temporary events as an operation can wind
  up running in a deleted directory and must properly fail under those

* Use krateprintf() to reduce debug output related to rename race

* Revamp nfsrv_rename() as well (requires more testing).

* Allow nfs_namei() to be called in a loop for retry purposes if
  desired.  It now detects that the nd structure is initialized
  from a prior run and won't try to re-parse the mbuf (needs testing).

Reported-by: zrj, mjg
2 years agokernel - Document confusing physmap[1] initialization
Matthew Dillon [Wed, 26 Aug 2020 18:56:52 +0000 (11:56 -0700)]
kernel - Document confusing physmap[1] initialization

* Document confusing physmap[1] initialization

2 years agotmpfs - Enhance assertion (not a bug fix)
Matthew Dillon [Wed, 26 Aug 2020 17:47:50 +0000 (10:47 -0700)]
tmpfs - Enhance assertion (not a bug fix)

* Enhance a reported assertion to provide more information.

Reported-by: zrj
2 years agokernel - Remove tty-related debug message
Matthew Dillon [Wed, 26 Aug 2020 17:44:42 +0000 (10:44 -0700)]
kernel - Remove tty-related debug message

* Remove a debugging message that is no longer needed.  The kprintf was
  added to determine if a particular handled race could actually happen.
  Answer is: yes it can.

2 years agosys/vfs/hammer2: Remove comment on nonexistent MINALLOCSIZE
Tomohiro Kusumi [Wed, 26 Aug 2020 15:15:40 +0000 (00:15 +0900)]
sys/vfs/hammer2: Remove comment on nonexistent MINALLOCSIZE

Removed in 1a7cfe5ae3c897f704a358fd3e556a55e430dcb1 in 2013.

2 years agosbin/newfs_hammer2: Use ~HAMMER2_PBUFMASK64 to obtain pbuf offset
Tomohiro Kusumi [Wed, 26 Aug 2020 15:15:18 +0000 (00:15 +0900)]
sbin/newfs_hammer2: Use ~HAMMER2_PBUFMASK64 to obtain pbuf offset

HAMMER2 in practice uses ~HAMMER2_PBUFMASK64 for this purpose
rather than HAMMER2_OFF_MASK_HI which is only used here.
Also more readable considering use of PBUF macros in HAMMER2.

2 years agokernel/{a,b}list: Use __func__ in panic messages.
Sascha Wildner [Wed, 26 Aug 2020 09:54:37 +0000 (11:54 +0200)]
kernel/{a,b}list: Use __func__ in panic messages.

This fixes some mistakes too (*_radix_free -> *_leaf_free).

2 years agosys/vfs/hammer2: Fix whitespace to align indentation
Tomohiro Kusumi [Tue, 25 Aug 2020 17:16:15 +0000 (02:16 +0900)]
sys/vfs/hammer2: Fix whitespace to align indentation

2 years agosys/vfs/hammer2: Remove unused HAMMER2_AV* macros
Tomohiro Kusumi [Tue, 25 Aug 2020 17:10:19 +0000 (02:10 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_AV* macros

Appeared in 9061bde5ad5e46bcaee746ed03d598a75b38691f in 2013,
but never used.

The freemap layout when these were added is no longer compatible
with the current one, so these won't be used again either.

2 years agokernel/nata: Fix operator precedence issue.
Sascha Wildner [Tue, 25 Aug 2020 04:43:26 +0000 (06:43 +0200)]
kernel/nata: Fix operator precedence issue.

2 years agozoneinfo: Update /etc/localtime when upgrading timezones.
Sascha Wildner [Mon, 24 Aug 2020 19:04:04 +0000 (21:04 +0200)]
zoneinfo: Update /etc/localtime when upgrading timezones.

* Add tzsetup(8) to the bootstrap-tools.

* Install the backward file to retain obsolete timezones as links
  for backward compatibility. Remove all these timezones from
  Makefile_upgrade.inc again. Also extend mtree/BSD.usr.dist for
  this and remove the old 'dragonfly' file (which was only for UTC).

* After installing new timezones, run tzsetup -r to upgrade the user's
  chosen timezone. Allow this to fail for quickworlders. It will start
  working after the next full buildworld.

Taken-from: FreeBSD (with modifications)

2 years agosys/vfs/hammer2: Remove unused HAMMER2_OFF_NOPREF
Tomohiro Kusumi [Mon, 24 Aug 2020 16:20:11 +0000 (01:20 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_OFF_NOPREF

Appeared in 1a7cfe5ae3c897f704a358fd3e556a55e430dcb1 in 2013,
but never used.

2 years agosys/vfs/hammer2: Remove unused HAMMER2_OFF_BAD and HAMMER2_MAX_COPIES
Tomohiro Kusumi [Mon, 24 Aug 2020 16:14:36 +0000 (01:14 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_OFF_BAD and HAMMER2_MAX_COPIES

Appeared in 703720e4d599857d052f0a65f2840224ce36ec5a in 2012,
but never used.

2 years agosys/vfs/hammer2: Remove unused HAMMER2_SPECTHREADS
Tomohiro Kusumi [Sun, 23 Aug 2020 15:44:38 +0000 (00:44 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_SPECTHREADS

No longer used since 2085215738c03d949e60de63843cb91e84836eb9 in 2016.

2 years ago<sys/systm.h>: Fix muldivu64() comment.
Sascha Wildner [Sun, 23 Aug 2020 09:50:00 +0000 (11:50 +0200)]
<sys/systm.h>: Fix muldivu64() comment.

2 years agokernel/pmap: Remove code under !defined(PMAP_ADVANCED).
Sascha Wildner [Sat, 22 Aug 2020 18:03:16 +0000 (20:03 +0200)]
kernel/pmap: Remove code under !defined(PMAP_ADVANCED).

We've been running with PMAP_ADVANCED by default since February 27.
Remove the old, inactive code.

Approved-by: dillon
2 years agokernel - Remove global cwd statistics counters
Matthew Dillon [Fri, 21 Aug 2020 18:17:05 +0000 (11:17 -0700)]
kernel - Remove global cwd statistics counters

* These were only used for debugging purposes and interfere with
  MP operation.  Just remove them.

2 years agomake(1): Fix default search path back to just /usr/share/mk.
Sascha Wildner [Fri, 21 Aug 2020 17:36:48 +0000 (19:36 +0200)]
make(1): Fix default search path back to just /usr/share/mk.

This '...' hack was intended to fix pkgsrc problems at the time but
didn't work (see 2b01fcf91a45a96b and 3db89b525e9bf920). And it was
then left in in the hopes it might be useful for something.

However, in practice it can only lead to confusion when you're
building in another BSD's tree for testing purposes and make starts
looking for and using .mk files we don't have in the upper levels
of the foreign tree instead of properly reporting that it could not
find the file.

2 years agodhclient: teach the script about resolvconf(8)
Roy Marples [Thu, 20 Aug 2020 19:53:00 +0000 (20:53 +0100)]
dhclient: teach the script about resolvconf(8)

2 years agokate.4: Sort SEE ALSO.
Sascha Wildner [Thu, 20 Aug 2020 09:55:58 +0000 (11:55 +0200)]
kate.4: Sort SEE ALSO.

2 years agogames/sail: adjust to updated ncurses
Daniel Fojt [Wed, 19 Aug 2020 18:14:00 +0000 (20:14 +0200)]
games/sail: adjust to updated ncurses

Reported by: Rimvydas Jasinskas

2 years agogames/mille: adjust to updated ncurses
Daniel Fojt [Wed, 19 Aug 2020 18:12:11 +0000 (20:12 +0200)]
games/mille: adjust to updated ncurses

Reported by: Rimvydas Jasinskas

2 years agosys/vfs/hammer2: Remove unused tailq structs
Tomohiro Kusumi [Wed, 19 Aug 2020 15:12:33 +0000 (00:12 +0900)]
sys/vfs/hammer2: Remove unused tailq structs

No longer used since
da6f36f44bb9c76612e31b56cdfe4d787e53d61f in 2014 and
ecfe89b8868b30c9ddfa9c86cb4b0a20365a248d in 2018.

2 years agokernel - Remove machdep.hack_efifb_probe_early hack
Michael Neumann [Wed, 19 Aug 2020 14:11:34 +0000 (16:11 +0200)]
kernel - Remove machdep.hack_efifb_probe_early hack

* This hack was introduced as a temporary fix for bug #3167 (see commit c2a57f42).

* Since commit faeb2db "kernel - Hack the DMAP size" the temporary hack is no longer required.

* Tested on TUXEDO InfinityBook Pro 14v4 laptop where this bug initially occured.

2 years agokernel: recognize newer Intel I219 ethernet controllers
David Shao [Tue, 18 Aug 2020 11:18:36 +0000 (04:18 -0700)]
kernel: recognize newer Intel I219 ethernet controllers

Define additional Intel I219-LM and I219-V Ethernet PCI device numbers.

Taken from NetBSD current sys/dev/pci/pcidevs.h, verified on physical
hardware for I219-V11 0x0D4D.

Submitted via: https://bugs.dragonflybsd.org/issues/3244

2 years agoUpgrade ncurses. 2/2
Daniel Fojt [Fri, 14 Aug 2020 19:28:41 +0000 (21:28 +0200)]
Upgrade ncurses. 2/2

- adapt Makefiles
- regenerate header files
- import new generated include/comp_userdefs.c
- adjust Symbol.map

2 years agoUpgrade ncurses. 1/2
Daniel Fojt [Thu, 13 Aug 2020 16:27:16 +0000 (18:27 +0200)]
Upgrade ncurses. 1/2

Merge branch 'vendor/NCURSES' into master.

2 years agovendor/ncurses: upgrade from 6.0-20160305 to 6.2-20200212 vendor/NCURSES
Daniel Fojt [Wed, 12 Aug 2020 07:35:19 +0000 (09:35 +0200)]
vendor/ncurses: upgrade from 6.0-20160305 to 6.2-20200212

The TERMINAL structure in <term.h> is now opaque. Doing that allowed
making the structure larger, to hold the extended numeric data.
When configured for wide-characters (i.e. ncursesw), the TERMINAL
structure is extended and is named TERMTYPE2. When configured for
8-bit (narrow) characters, the TERMTYPE2 structure is not used.

For detailed description of all other changes, enhancements, bugfixes
and performance improvements, see:


2 years agoopenpam: Add back includes removed in 7196b98de8a8d.
Sascha Wildner [Tue, 18 Aug 2020 21:13:52 +0000 (23:13 +0200)]
openpam: Add back includes removed in 7196b98de8a8d.

I should have just added <security/openpam.h>.

2 years agoyacc(1): Add config.h and use it.
Sascha Wildner [Tue, 18 Aug 2020 19:07:17 +0000 (21:07 +0200)]
yacc(1): Add config.h and use it.

2 years ago__realpath.2: Fix typo.
Sascha Wildner [Tue, 18 Aug 2020 18:28:00 +0000 (20:28 +0200)]
__realpath.2: Fix typo.

2 years agokdump(8): fix indentation in mkioctls
Daniel Fojt [Tue, 18 Aug 2020 17:15:38 +0000 (19:15 +0200)]
kdump(8): fix indentation in mkioctls

2 years agosys/vfs/ext2fs: Don't do endian conversion twice
Tomohiro Kusumi [Tue, 18 Aug 2020 15:54:40 +0000 (00:54 +0900)]
sys/vfs/ext2fs: Don't do endian conversion twice

Doesn't affect anything on DragonFly.

from freebsd/freebsd@86fbc13431233b277bc8739539a18019ae53e88f

2 years agopthread - Respect RLIMIT_STACK for main thread's stack size
Michael Neumann [Mon, 17 Aug 2020 21:19:51 +0000 (23:19 +0200)]
pthread - Respect RLIMIT_STACK for main thread's stack size

Prior to this commit, the stack size of the main thread was fixed
at 4 MB which was too low for certain applications.

This commit fixes bootstrapping the lang/crystal compiler (see [1]).

Reviewed-by: dillon
Fixes-issue: #3234

[1]: https://github.com/crystal-lang/crystal/pull/9178

2 years agoFix the synopses of some libarchive and openpam manual pages.
Sascha Wildner [Mon, 17 Aug 2020 16:33:09 +0000 (18:33 +0200)]
Fix the synopses of some libarchive and openpam manual pages.

2 years ago<sys/elf_common.h>: Add GNU note types and NT_GNU_PROPERTY_TYPE_0 bits.
Sascha Wildner [Sat, 15 Aug 2020 15:06:15 +0000 (17:06 +0200)]
<sys/elf_common.h>: Add GNU note types and NT_GNU_PROPERTY_TYPE_0 bits.

Apparently some ports need those.

Reported-by: zrj
Taken-from:  FreeBSD (r348628)

2 years agobyacc: Add our local READMEs on master.
Sascha Wildner [Sat, 15 Aug 2020 06:22:03 +0000 (08:22 +0200)]
byacc: Add our local READMEs on master.

2 years agoMerge branch 'vendor/BYACC'
Sascha Wildner [Sat, 15 Aug 2020 06:21:09 +0000 (08:21 +0200)]
Merge branch 'vendor/BYACC'

2 years agovendor/BYACC: Remove our local READMEs from the vendor branch.
Sascha Wildner [Sat, 15 Aug 2020 06:20:45 +0000 (08:20 +0200)]
vendor/BYACC: Remove our local READMEs from the vendor branch.

2 years agolocaledef(1): Set yydebug only when YYDEBUG is set.
Sascha Wildner [Sat, 15 Aug 2020 06:10:52 +0000 (08:10 +0200)]
localedef(1): Set yydebug only when YYDEBUG is set.