dragonfly.git
4 years agoFix building release on master. v5.4.3
Sascha Wildner [Fri, 17 May 2019 15:39:20 +0000 (17:39 +0200)]
Fix building release on master.

* <histedit.h> was moved to /usr/include/priv on master, so add that
  to the include search path when building sh(1) as a bootstrap tool.

* Fix the apropos(1) database generation (used for 'make distribution').
  If the system doesn't have the makewhatis(8) for a compatible
  database, just build no database.

4 years agolibc: Implement properly pthread_equal() stub.
zrj [Thu, 18 Apr 2019 20:01:47 +0000 (23:01 +0300)]
libc: Implement properly pthread_equal() stub.

Functional stub is needed to avoid forcing thread library on librecrypto.

4 years agokernel - Restore kern.cam.da.X.trim_enabled sysctl
Matthew Dillon [Sat, 11 May 2019 16:06:43 +0000 (09:06 -0700)]
kernel - Restore kern.cam.da.X.trim_enabled sysctl

* This sysctl was not always being properly installed due to an
  ordering and timing issue.

* The code was not setting the trim flag in the correct structure.

4 years agokernel - MFC portions of the MAP_STACK fix
Matthew Dillon [Fri, 3 May 2019 22:19:43 +0000 (15:19 -0700)]
kernel - MFC portions of the MAP_STACK fix

* MFC portions of d6924570fb and 4837705ef8 from master.  This changes
  MAP_STACK semantics to better-align with application expectations.

  In particular, we finish the transition to requiring MAP_TRYFIXED
  in order to allow a mapping to use the ungrown area of a MAP_STACK
  mapping, and we basically kill userland's ability to create auto-grow
  mappings by converting MAP_STACK to a normal anonymous mmap.

* The original auto-grow feature for the primary user stack as created
  by the kernel's exec() code remains intact in order to remain compatible
  with the pthreads library in -release.

4 years agokernel - Permanently fix FP bug (mfc)
Matthew Dillon [Fri, 3 May 2019 22:01:24 +0000 (15:01 -0700)]
kernel - Permanently fix FP bug (mfc)

* Bring in 007800820 from master, but just just by setting the heuristic
  mode to 1 to force a FPU restore on every thread switch. Do not allow
  the heuristic to be changed.

  The heuristic has been completely removed from master.

4 years ago<execinfo.h>: Include <sys/cdefs.h> explicitly for __{BEGIN,END}_DECLS.
Sascha Wildner [Mon, 29 Apr 2019 10:44:01 +0000 (12:44 +0200)]
<execinfo.h>: Include <sys/cdefs.h> explicitly for __{BEGIN,END}_DECLS.

Normally this should come in via our <stddef.h>, but ports compilers
might include the compiler's own <stddef.h> that doesn't seem to
include it.

Reported-by: profmax
4 years agopf - Fix SMP race in max-src-nodes, max-src-conn tracking
Matthew Dillon [Sun, 28 Apr 2019 03:02:39 +0000 (20:02 -0700)]
pf - Fix SMP race in max-src-nodes, max-src-conn tracking

* Fix a SMP race in max-src-nodes tracking where an atomic op was
  not being used.

* Fix a possible SMP race in max-src-conn tracking where atomic ops
  were not being used.

Reported-by: zach
4 years agonrelease: Install security/ca_root_nss explicitly (non-automatic).
Sascha Wildner [Thu, 25 Apr 2019 13:06:35 +0000 (15:06 +0200)]
nrelease: Install security/ca_root_nss explicitly (non-automatic).

This is to prevent it accidentally being removed by an autoremove
after deleting the package that brought it in as a dependency.

Reported-by: Frank Rehwinkel <frankrehwinkel@gmail.com>
5 years agokernel/tty: Use GID_TTY for non root users by default.
zrj [Fri, 19 Apr 2019 10:32:55 +0000 (13:32 +0300)]
kernel/tty: Use GID_TTY for non root users by default.

Previous behaviour defaulting to GID_WHEEL was confusing OpenSSH tests.

5 years agoFix a couple of NULL dereferences in error paths. v5.4.2
Sascha Wildner [Thu, 18 Apr 2019 14:53:24 +0000 (16:53 +0200)]
Fix a couple of NULL dereferences in error paths.

5 years agokernel - Add /dev/part-by-label
Matthew Dillon [Thu, 28 Feb 2019 06:36:27 +0000 (22:36 -0800)]
kernel - Add /dev/part-by-label

* The DragonFly disklabel has a 'label' field which accepts up to
  a 63 byte ascii label.

* When this field is not empty, the kernel will now create a
  "/dev/part-by-label/<label>.<part>" alias.

  For example, if the label is FUBAR and you create a label with
  partitions 'a', 'b', and 'd', then you will get:

  # ls /dev/part-by-label
  FUBAR.a      FUBAR.b      FUBAR.d

* WARNING!  Duplicate labels will replace each other, so the
  label that shows up will be non-deterministic.

Suggested-by: Aaron LI
5 years agohammer2 - Correct allocator race and related corruption
Matthew Dillon [Fri, 12 Apr 2019 02:04:56 +0000 (19:04 -0700)]
hammer2 - Correct allocator race and related corruption

* When allocating fragments (below 16KB), for example 1K directory
  entries, 1K inodes, compressed file blocks that happen to be
  fragments, or end-of-file fragments, the allocator must ensure
  that any partially freed block is set back to fully allocated.

* In this specific case the allocator was not setting the
  correct bits in the freemap.  The situation never occurs
  on a block boundary (different code is executed which does
  the correct calculation), so the related block will always
  be in a minimally allocated state (either partially allocated
  or fully allocated).

  This means that the corruption can only happen under the specific
  circumstance where a fragment is allocated out of a block that
  the bulkfree code is simultaneously trying to free (marking it
  partially-allocated).  Because the wrong bits are set, the NEXT
  bulkfree pass can also miss the fact that the fragment is
  allocated and finish transitioning the block from partially-
  allocated to fully-free.

  A later allocation then corrupts the block, resulting in CHECK
  errors on the console.

* Because the bulkfree code always comes in and in ALL SITUATIONS OTHER
  THAN THIS SPECIFIC RACE will re-mark the blocks fully-allocated,
  the corruption can ONLY occur during heavy write activity during
  a bulkfree operation, typically when heavy manipulation of directory
  entries or inodes occurs.

* Correct the fragmentary bitmap calculation to set the proper
  bits.

5 years agokernel - Add AC256 (sound) quirk
Matthew Dillon [Tue, 2 Apr 2019 23:00:06 +0000 (16:00 -0700)]
kernel - Add AC256 (sound) quirk

* Add quirk for AC256 sound devices.

Taken-from: FreeBSD
Tested-by: drill-use@irc
5 years agoSync zoneinfo database with tzdata2019a from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Tue, 2 Apr 2019 16:11:55 +0000 (18:11 +0200)]
Sync zoneinfo database with tzdata2019a from ftp://ftp.iana.org/tz/releases

* Palestine will not start DST until 2019-03-30, instead of 2019-03-23 as
  previously predicted.

* Metlakatla rejoined Alaska Time (from previously Pacific Standard Time)
  on 2019-01-20.

* Affecting older timestamps only: Israel observed DST in 1980 and 1984.

For a detailed list of changes, see share/zoneinfo/NEWS.

5 years agodumpfs(8): Fix conversion of 32 bit ufs_time_t's with ctime().
Sascha Wildner [Mon, 25 Mar 2019 09:16:53 +0000 (10:16 +0100)]
dumpfs(8): Fix conversion of 32 bit ufs_time_t's with ctime().

Data from neighboring fields was leaking in, leading to odd dates.

5 years agosysctl(8): Add support for char and short sized values.
Sascha Wildner [Sat, 23 Mar 2019 21:47:26 +0000 (22:47 +0100)]
sysctl(8): Add support for char and short sized values.

This was missing from 347aefc6a85af5bf5b7a1a6918f706878a8232ef.

Reported-by: zrj
5 years agosmbfs - Bring in some string safety and type-o corrections
Matthew Dillon [Wed, 20 Mar 2019 05:40:30 +0000 (22:40 -0700)]
smbfs - Bring in some string safety and type-o corrections

* Bring in some string safety fixes and type-o corrections from
  FreeBSD.

Submitted-by: Varun C H
Taken-from: FreeBSD

5 years agopthreads - sleep() needs strong reference
Matthew Dillon [Wed, 20 Mar 2019 05:34:47 +0000 (22:34 -0700)]
pthreads - sleep() needs strong reference

* Fix problem with sleep() not canceling due to missing strong
  reference.

Reported-by: godfrey
5 years agohammer2 - Fix panic on corrupt root inode on mount
Matthew Dillon [Wed, 20 Mar 2019 04:40:24 +0000 (21:40 -0700)]
hammer2 - Fix panic on corrupt root inode on mount

* If the root inode is corrupt at mount time H2 was panicing
  instead of cleanly aborting.  Fixed by adding missing initialization.

* This case can occur when the device is partially overwritten by
  a dd or another filesystem.  Redundant volume headers may still alow
  H2 to find one, but the iroot might reside at a lower block number and
  already have been blown away.

Reported-by: BJoe / Bug #3181
5 years agokernel - Fix info->si_code for waitid() (2)
Matthew Dillon [Mon, 18 Mar 2019 20:43:41 +0000 (13:43 -0700)]
kernel - Fix info->si_code for waitid() (2)

* Our si_status was W*() encoded, but linux does not W*() encode
  theirs.

  Do not W*() encode ours either.  Also properly decode the exit signal
  and exit code.

5 years agokernel - Fix info->si_code for waitid()
Matthew Dillon [Mon, 18 Mar 2019 20:05:18 +0000 (13:05 -0700)]
kernel - Fix info->si_code for waitid()

* info->si_code was improperly setting CLD_KILLED for normal exit()s
  with non-zero exit codes.

Reported-by: tuxillo
5 years agopsm - Fix panic in ps/2 mouse driver
Matthew Dillon [Tue, 12 Mar 2019 04:10:12 +0000 (21:10 -0700)]
psm - Fix panic in ps/2 mouse driver

* Fix a race in the ps/2 driver where a callout could be interrupted
  by psmintr() and corrupt the ps/2 packet buffer, causing a panic.

* Use a lockmgr lock instead of (archaic) critical sections for interrupt
  protection.  Also use the locked callout API.  This will hopefully
  prevent any further corruption.

Reported-by: drill-use@irc
5 years agortld-elf - Allow dynamic (late) relocations to relro section (2)
Matthew Dillon [Tue, 12 Feb 2019 20:28:11 +0000 (12:28 -0800)]
rtld-elf - Allow dynamic (late) relocations to relro section (2)

* Add missing header file adjustment

5 years agortld-elf - Allow dynamic (late) relocations to relro section
Matthew Dillon [Mon, 11 Feb 2019 21:47:22 +0000 (13:47 -0800)]
rtld-elf - Allow dynamic (late) relocations to relro section

* Normally the relro section is mprotect()ed to read-only after normal
  load relocations.

* It appears that some programs can issue dynamic relocations at
  run-time to such sections.

* If the relro mprotect has been done on an object, temporarily mprotect
  the object back to RW to execute the relocation, then mprotect it back
  to RO.

Reported-by: marino
5 years agokernel/ena: Fix another error path.
Sascha Wildner [Fri, 1 Mar 2019 13:30:07 +0000 (14:30 +0100)]
kernel/ena: Fix another error path.

Release the MSI-X vector if we fail after it's been allocated but
before we can use the goto.

5 years agokernel/ena: Fix an uninitialized variable issue in an error path.
Sascha Wildner [Fri, 1 Mar 2019 13:24:13 +0000 (14:24 +0100)]
kernel/ena: Fix an uninitialized variable issue in an error path.

At this point in initialization, we just return ENXIO on failure.

Reported-by: zrj
5 years agolibc: Remove old MLINKS for fpclassify.3.
Sascha Wildner [Thu, 28 Feb 2019 16:10:48 +0000 (17:10 +0100)]
libc: Remove old MLINKS for fpclassify.3.

I forgot to remove them in b6b35a1b4c682b25f983fc039f153dcd04094189.

Reported-by: zrj
5 years agoinstall(1): Fix usage(), we don't have -T.
Sascha Wildner [Wed, 6 Feb 2019 18:05:26 +0000 (19:05 +0100)]
install(1): Fix usage(), we don't have -T.

5 years agokernel - Sync usb3.0 pci ids w/FreeBSD
Matthew Dillon [Thu, 31 Jan 2019 19:35:40 +0000 (11:35 -0800)]
kernel - Sync usb3.0 pci ids w/FreeBSD

* Add missing PCI ids for Sunrise Point, Lewisburg, Union Point,
  and Cavium ThunderX.

Reported-by: dualcyclo
5 years agoAdd work-around for bug #3167
Michael Neumann [Wed, 9 Jan 2019 20:41:47 +0000 (21:41 +0100)]
Add work-around for bug #3167

"UEFI boot hangs right after initializing UEFI framebuffer."
It actually boots but the system console is not shown.

I had this issue on a TUXEDO InfinityBook Pro 14v4.
This commits allows me to boot by setting loader tunable
machdep.hack_efifb_probe_early=1.

This commit is not intended to be there forever.
It's there for people who experience the same issue and want
a quick and easy way to test if this fixes their booting issue.

Discussed-with: dillon

5 years agotmpfs - Fix periodic syncer cpu-bound stalls w/tmpfs on big-mem boxes
Matthew Dillon [Tue, 15 Jan 2019 22:17:26 +0000 (14:17 -0800)]
tmpfs - Fix periodic syncer cpu-bound stalls w/tmpfs on big-mem boxes

* A bug in tmpfs leaves dirty tmpfs vnodes (which is basically all
  of them) on the syncer list, causing the syncer to scan the entire
  list every few seconds.  When a large number of vnodes are involved,
  this can lead to noticable cpu-bound stalls on the cpu the syncer is
  running on.

* Generally speaking this should significantly improve applications
  which use tmpfs a lot, such as synth runs, but was probably not noticed
  on machines with less than 32GB of ram due to the lower kern.maxvnodes
  default.

* Solved by unconditionally removing the vnode from the syncer list
  in tmpfs_fsync(), but otherwise leaving the vnode marked VISDIRTY and
  usually also VOBJDIRTY.  Tmpfs's reclaim code properly handles the
  disconnect regardless of the syncer state of the vnode.

  Removing the vnode ensures that only one syncer pass is performed on
  it, instead of repeated passes every few seconds.

5 years agokernel: Hide the sysctl.debug sysctl in the SYSCTL_DEBUG kernel option.
Sascha Wildner [Mon, 14 Jan 2019 17:59:58 +0000 (18:59 +0100)]
kernel: Hide the sysctl.debug sysctl in the SYSCTL_DEBUG kernel option.

The output is quite excessive and was previously too easily triggered,
like with "sysctl name=value" (instead of just "name=value") in
/etc/sysctl.conf.

Taken-from: FreeBSD

5 years agorc.subr: Fix breakage in the rcrun(8) scripts.
Sascha Wildner [Thu, 10 Jan 2019 18:55:49 +0000 (19:55 +0100)]
rc.subr: Fix breakage in the rcrun(8) scripts.

0e7badd402459228d38ddfb0e06224b5a3d9fdf8 added an early exit to
rc.subr to avoid sourcing it again. However, some DragonFly bits
in rc.conf are specific to the rc.d script that rc.subr is sourced
from, specifically the contents of the $provide_list variable. The
result was that the varsym variables that rcstart(8) et al. use to
track dependency states were not get set.

Put the setup of $provide_list before the early exit.

5 years agoRevert "Remove some dead code."
Sascha Wildner [Sun, 6 Jan 2019 18:18:47 +0000 (19:18 +0100)]
Revert "Remove some dead code."

This reverts commit cbd427ca6efda3055e8e1a189941b6a84fc67aaf.

Oops, didn't mean to MFC this.

5 years agoRemove some dead code.
Sascha Wildner [Sun, 6 Jan 2019 18:16:25 +0000 (19:16 +0100)]
Remove some dead code.

5 years agoSync zoneinfo database with tzdata2018i from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Mon, 31 Dec 2018 19:24:33 +0000 (20:24 +0100)]
Sync zoneinfo database with tzdata2018i from ftp://ftp.iana.org/tz/releases

* Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.

* New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.

* Metlakatla, Alaska observes PST this winter only.

* Guess Morocco will continue to adjust clocks around Ramadan.

* Add predictions for Iran from 2038 through 2090.

* São Tomé and Príncipe switches from +01 to +00 on 2019-01-01.

For a detailed list of changes, see share/zoneinfo/NEWS.

5 years agokernel/acpi: Bring in FreeBSD's r341632.
Sascha Wildner [Thu, 27 Dec 2018 23:23:14 +0000 (00:23 +0100)]
kernel/acpi: Bring in FreeBSD's r341632.

On specific machines (a Lenovo Ideapad 100-15IBD in this case) would fail
detecting the battery properly after 7bcb6caf98d72e1e5fd653428e604ea1.

See https://lists.freebsd.org/pipermail/svn-src-all/2018-December/173505.html
for further info.

Reported-by: mazocomp on #dragonflybsd.
Taken-from: FreeBSD

5 years agortadvctl(8): Add __printflike and fix warnings. v5.4.1
Sascha Wildner [Fri, 21 Dec 2018 20:21:29 +0000 (21:21 +0100)]
rtadvctl(8): Add __printflike and fix warnings.

5 years agolibc/sysvipc: Mark two functions as printf-like and fix resulting errors.
Sascha Wildner [Fri, 21 Dec 2018 14:14:14 +0000 (15:14 +0100)]
libc/sysvipc: Mark two functions as printf-like and fix resulting errors.

5 years agoFixed broken links.
Justin C. Sherrill [Thu, 20 Dec 2018 04:38:29 +0000 (23:38 -0500)]
Fixed broken links.

http://bugs.dragonflybsd.org/issues/3161

5 years agorc.d/varsym: Rewrite following rc.d/sysctl
Aaron LI [Thu, 13 Dec 2018 05:53:54 +0000 (13:53 +0800)]
rc.d/varsym: Rewrite following rc.d/sysctl

* Rewrite this script following the same logic and style of rc.d/sysctl.
  The basic syntax is checked before setting it.

* Clarify the /etc/varsym.conf syntax in the man page.

Reviewed-by: swildner
5 years agorc.d/sysctl: Rewrite to be more robust and clean
Aaron LI [Thu, 13 Dec 2018 05:58:27 +0000 (13:58 +0800)]
rc.d/sysctl: Rewrite to be more robust and clean

* Check the validity of the sysctl config and warn about the invalid
  syntax.

  A common mistake is that users set 'sysctl <mib>=<val>' in
  /etc/sysctl.conf, which generate huge amount of junk/mysterious
  messages on the console.  Now this will be warned.

* Reorganize the logic to be much cleaner.

* Do not bother to check whether the new value is different from the old
  one.

* Rename the function for consistency.

5 years agorc.d/mountcritlocal: Clean up
Aaron LI [Fri, 14 Dec 2018 14:57:51 +0000 (22:57 +0800)]
rc.d/mountcritlocal: Clean up

Clean the code a bit and fix the style.

5 years agohammer2 - Cleanup 'info' command
Matthew Dillon [Tue, 18 Dec 2018 16:31:56 +0000 (08:31 -0800)]
hammer2 - Cleanup 'info' command

* hammer2 info validates the partition info, but assumed that
  the filesystem would be a disklabel.  Add code to validate
  against GPT slices too by checking the filesystem uuid.

Reported-by: ftigeot
5 years agorc: Let dhcpcd(8) go to background immediately by default
Aaron LI [Fri, 14 Dec 2018 14:08:26 +0000 (22:08 +0800)]
rc: Let dhcpcd(8) go to background immediately by default

Set the default value of "dhcpcd_flags" to be "-b", thus don't let
dhcpcd(8) block the boot, especially when there is no wireless
connection, with the default settings.

5 years agonetwork.subr: Workaround race between wpa_supplicant and dhcpcd
Aaron LI [Wed, 12 Dec 2018 04:06:17 +0000 (12:06 +0800)]
network.subr: Workaround race between wpa_supplicant and dhcpcd

Insert a 1-second delay after starting wpa_supplicant(8) to workaround
the race between it and dhcpcd(8), which can modify the interface's
state and break wpa_supplicant's ongoing SSID scan.

dhclient(8) doesn't have such an issue with wpa_supplicant.

Tested-by: me, Daniel Bilik <ddb@neosystem.org>
5 years agoAllow optional "inet6" keyword in ipv6_ifconfig_<ifname>
Aaron LI [Wed, 12 Dec 2018 14:53:00 +0000 (22:53 +0800)]
Allow optional "inet6" keyword in ipv6_ifconfig_<ifname>

5 years agorc.d/netif: Rework wlan interface configuration
Aaron LI [Wed, 12 Dec 2018 03:52:24 +0000 (11:52 +0800)]
rc.d/netif: Rework wlan interface configuration

* wlan interfaces are more similar to clonable interfaces rather than
  vlan interfaces, so move the relevant code from childif_create() to
  network.subr as wlan_up(), which will be called to create the wlan
  interfaces before setting up them.

  Now, list_net_interfaces() shouldn't list "net.wlan.devices".

* Add the wlan_down() function in network.subr to destroy the wlan
  devices.

* Meanwhile, fix childif_destroy() to properly destroy the vlan
  interfaces created by childif_create().  Also tweak the order of this
  function in netif_stop().

* The 2-second delay in netif_start() doesn't apply anymore, since the
  DHCP and WPA configurations are now handled in ifconfig_up() called by
  ifn_start().

This patch is loosely based on FreeBSD's code.  Thanks to them.

5 years agonetwork.subr: Properly bring up/down interfaces
Aaron LI [Wed, 12 Dec 2018 03:29:10 +0000 (11:29 +0800)]
network.subr: Properly bring up/down interfaces

Now that the interface will be properly brought up in ifconfig_up(),
clean up the rc.d/wpa_supplicant script.

5 years agonetwork.subr: Add IPv6 support to ifalias_{up,down}()
Aaron LI [Wed, 12 Dec 2018 03:16:05 +0000 (11:16 +0800)]
network.subr: Add IPv6 support to ifalias_{up,down}()

* Factor out the common parts of ifalias_{up,down}() to be
  ifalias_common().
* Add IPv6 support to ifalias_common().
* Use ifalias_up() in network6_interface_setup().

5 years agorc.d/netif: Rename network_* to netif_* for consistency
Aaron LI [Tue, 11 Dec 2018 13:27:43 +0000 (21:27 +0800)]
rc.d/netif: Rename network_* to netif_* for consistency

Rename network_* subroutines to netif_* for better consistency.  Also
set the rcvar and add netif_enable=YES to rc.conf.

Taken-from: FreeBSD (r272959, r278506)

5 years agonetwork.subr: Clean up list_net_interfaces()
Aaron LI [Tue, 11 Dec 2018 13:16:25 +0000 (21:16 +0800)]
network.subr: Clean up list_net_interfaces()

The rc.d/netif takes care of DHCP/non-DHCP interfaces appropriately, and
thus the interface type filter feature in list_net_interfaces() is no
longer needed since long ago.

5 years agonetwork.subr: Cleanups and minor improvements
Aaron LI [Tue, 11 Dec 2018 06:05:20 +0000 (14:05 +0800)]
network.subr: Cleanups and minor improvements

* Localize variables in all functions.
* Better name several variables (e.g., $i -> $_if).
* Simplify several test and case usages.
* Use the newly added "-n" option for ifconfig(8) in ifexists().
* Improve comments, debug messages, and styles.
* Print a message when calling rtsol(8) to auto configure an interface,
  since it may take several seconds.

5 years agorc: Use SYSCTL{,_N,_W} variables
Aaron LI [Sun, 9 Dec 2018 02:55:55 +0000 (10:55 +0800)]
rc: Use SYSCTL{,_N,_W} variables

With minor cleanups to IO redirections.

5 years agohammer2 - stabilization, fix delete-on-reclaim (2)
Matthew Dillon [Tue, 11 Dec 2018 17:26:19 +0000 (09:26 -0800)]
hammer2 - stabilization, fix delete-on-reclaim (2)

* Fix double-delete.  When an inode is finally deleted, the
  HAMMER2_INODE_ISUNLINKED flag must be cleared to avoid a
  double delete later in reclaim.

5 years agohammer2 - stabilization, fix delete-on-reclaim
Matthew Dillon [Mon, 10 Dec 2018 23:35:31 +0000 (15:35 -0800)]
hammer2 - stabilization, fix delete-on-reclaim

* Fix the delete-on-reclaim code which had been commented out
  temporarily during the prior work.  Restore and cleanup the
  code.

  This code handles deleting inodes for files which were unlinked
  (nlinks count -> 0) but still had open descriptors.

* Fixes inode leak in df output and on the media.

5 years agoHAMMER2 - Update DESIGN document
Matthew Dillon [Sun, 9 Dec 2018 04:58:18 +0000 (20:58 -0800)]
HAMMER2 - Update DESIGN document

* Bring the design document up-to-snuff.

5 years agokernel - Fix rare vref() assertion
Matthew Dillon [Sat, 8 Dec 2018 22:34:51 +0000 (14:34 -0800)]
kernel - Fix rare vref() assertion

* The VREF_TERMINATE flag gets cleared when a vnode is reactivated.
  However, concurrent LK_SHARED locks on vnodes can race the v_state
  test.  Thus the code cannot assume that VREF_TERMINATE has been cleared
  when v_state is VS_ACTIVE.

  To avoid the race, we simply unconditionally clear VREF_TERMINATE on
  a successful vget().

* Could be reproduced by running blogbench and synth together, both of
  which generate extreme filesystem-intensive loads.

5 years agohammer2 - stabilization, fix hammer2_inode_get()
Matthew Dillon [Sat, 8 Dec 2018 04:26:15 +0000 (20:26 -0800)]
hammer2 - stabilization, fix hammer2_inode_get()

* Fix a lock order reversal in hammer2_inode_get() which can be
  triggered under heavy loads.

5 years agohammer2 - Cleanup
Matthew Dillon [Sat, 8 Dec 2018 02:06:36 +0000 (18:06 -0800)]
hammer2 - Cleanup

* Cleanup a few wrappers, remove struct buf related temporary
  debug code.

* Add some lock assertions.

* Unlimit M_HAMMER2 (for use with HAMMER2_IO_DEBUG)

5 years agohammer2 - Add HAMMER2_IO_DEBUG
Matthew Dillon [Sat, 8 Dec 2018 02:05:16 +0000 (18:05 -0800)]
hammer2 - Add HAMMER2_IO_DEBUG

* Add HAMMER2_IO_DEBUG (default disabled).  This tracks callers
  that use hammer2_io's.  This eats a huge amount of (up to ~20GB)
  of kernel memory.

5 years agokernel - Improve umount operation
Matthew Dillon [Fri, 7 Dec 2018 02:50:07 +0000 (18:50 -0800)]
kernel - Improve umount operation

* Move the cache_inval(), and both cache_unmounting() and
  cache_clearmntcache() into the retry loop.  This ensures that
  the nc_refs test actually has a chance to update during the retry.

  This should significantly improve umount operation, reducing umount
  races against exiting processes still using the filesystem.

* Only issue the allproc scan which matches and clears proc->p_textnch
  on a forced umount.  Otherwise disallow the umount attempt.  We
  may have to reallow this later, but the shutdown code now properly
  clears p_textnch so it should take care of the case for us (which
  is why this code was originally present).

* Properly dispose of p->p_textnch during shutdown/halt/reboot for
  the calling process, proc0, and init.  This is an attempt to allow
  the system to cleanly unmount root.

* Cleanup the warning and error messages to clarify umount failures.

* Only reinstasll the syncer vp on error if umount deinstalled it.

* Add some debugging sysctls (default disabled).

Reported-by: marino
5 years agohammer2 - stabilization
Matthew Dillon [Thu, 6 Dec 2018 06:42:31 +0000 (22:42 -0800)]
hammer2 - stabilization

* Adjust the chain lock a bit to bump lockcnt prior to acquiring
  a non-blocking shared lock, instead of afterwords, which cleans
  up a live-loop case in the chain unlock code.

* Cleanup misc debugging.  Add some inode debugging code (default
  disabled).

* Add some crash-dump (or live) debug utilities for tracking down
  chains, dio's, and inodes.  kgdb's macros are too slow for iterating
  a million chains.

5 years agohammer2 - refactor filesystem sync 7/N
Matthew Dillon [Wed, 5 Dec 2018 18:19:31 +0000 (10:19 -0800)]
hammer2 - refactor filesystem sync 7/N

* Increase default caps for dirty chain and dirty inode counts.  The
  new SYNCQ semantics allow this number to be arbitrarily large, but
  it is still a good idea not to allow it to get out of control.

  NOTE: One advantage of higher caps is that it gives the frontend more
  time to delete temporary files.

* Get rid of the old syncer speedup / write moderation mechanisms.
  Replace with a new VFS_MODIFYING() hook that allows the filesystem
  to implement moderation prior to any vnode locks being held.

  Remove hammer2_pfs_memory_wait() calls from VOP bodies, implement
  the hammer2_pfs_memory_wait() call via VFS_MODIFYING() instead.

* Move the moderation wakeup for the inode count to the syncer, and
  change the parameter to use pmp->sideq_count.

5 years agokernel - Add trigger_syncer(), VFS_MODIFYING()
Matthew Dillon [Wed, 5 Dec 2018 05:49:35 +0000 (21:49 -0800)]
kernel - Add trigger_syncer(), VFS_MODIFYING()

* Add trigger_syncer().  This function asynchronously triggers the
  syncer vnode in the syncer thread for the mount.  It is a NOP if
  there is no syncer thread or syncer vnode.

  Will be used by HAMMER2 to pipeline syncs when heavy filesystem
  activity over-extends internal memory structures.

* Add VFS_MODIFYING().  This is a hook into the filesystem that
  modifying filesystem ops in the kernel will call prior to locking
  any vnodes.  It allows the filesystem to moderate the over-allocation
  of internal structures.  Waiting until after the VOP is called is too
  late, so we need kernel support for this.  Numerous attempts to hack
  moderation code into the H2 VOPs have all failed spectacularly.

  In H2, over-allocation can occur because H2 must retain disconnected
  inodes related to file creation and deletion until the next sync cycle.

5 years agohammer2 - refactor filesystem sync 6/N
Matthew Dillon [Sun, 2 Dec 2018 20:39:48 +0000 (12:39 -0800)]
hammer2 - refactor filesystem sync 6/N

* Dependency tracking.  Add modest cross-dependency grouping.  This code
  does not track dependencies in a graph.  Instead, it simply groups
  dependent inodes together.  This means that dependency groups can get
  rather large when, for example, lots of files are being created or
  deleted in the same directory.

* We retain the excellent dynamic inode reordering code for the syncq.
  When the frontend blocks on an inode that is in the syncq, the inode
  will be reordered to the front of the queue to reduce the frontend
  stall time as much as possible.

* Remove the COPYQ transaction flag and related sequencing.

* Fix flush sequencing for pmp->iroot.  We must flush iroot's chains with
  HAMMER2_XOP_FSSYNC last.  When iroot is dirty, the out-of-order flush
  of iroot that occurs before the final stage must be run without FSSYNC
  set, otherwise iroot's pmp->pfs_iroot_blocksets[] will not be consistent
  because the remaining inodes in the syncq haven't been flushed yet.

* Fix a broken syncer speedup conditional.

5 years agohammer2 - refactor filesystem sync 5/N
Matthew Dillon [Sat, 1 Dec 2018 21:57:35 +0000 (13:57 -0800)]
hammer2 - refactor filesystem sync 5/N

* Dependency ops need one atomic wrapper.  Adjust the use of
  pmp->list_spin for the atomic wrapper.

* Reorder hammer2_inode_depend() call from after hammer2_igetv()
  to before it.  This is because hammer2_igetv() can temporarily
  release the inode lock and the dependency code assumes that does
  not happen.

* Cleanup

* This code is still not 100% because earlier dependency pairs
  that wind up on the sideq can be split if an overlapping dependency
  occurs later that flags PASS2.

5 years agohammer2 - Add 'snapshot-debug' directive
Matthew Dillon [Fri, 16 Nov 2018 06:32:56 +0000 (22:32 -0800)]
hammer2 - Add 'snapshot-debug' directive

* Add the 'snapshot-debug' directive which takes a snapshot without
  first sync'ing the filesystem.  The idea is that the snapshot will
  be taken relative to the most recent filesystem sync (automatic or
  manual), and should still represent a fully consistent filesystem.

5 years agohammer2 - refactor filesystem sync 4/N
Matthew Dillon [Tue, 13 Nov 2018 21:32:33 +0000 (13:32 -0800)]
hammer2 - refactor filesystem sync 4/N

* Save synchronized iroot blockmaps for snapshot code, and use them
  in the snapshot code.

* Improve dependency handling and syncq/sideq flagging for
  dependencies.  Also improve the hammer2_inode_t reordering
  code that allows the frontend to continue operating on dirty
  inodes simultaneous with a filesystem sync.

* Move inode deletion into the filesystem sync code (in addition to
  creation), for the same reason.

* Fix lost ref counts in the snapshot code which were causing umount
  panics.

* Stabilization pass on volume flush code.  Since flushes stop at
  inode boundaries, we must properly flush the superroot before
  flushing the volume header.  That is, the flush sequence is:

  - flush inodes for PFS  (flushes inode content)
  - flush PFS root inode  (flushes through to inodes)
  - flush superroot inode (flushes through to PFS root)
  - flush volume header   (flushes voulume header to superroot)

  Theoretically this allows the filesystem asynchronously write data
  and inodes flushed by the kernel's buffer cache and vnode code
  concurrent with a filesystem flush without messing up filesystem
  consistency, because these asynchronously flushed inodes are not
  included (or have already been flushed) in the filesystem flush that
  is already underway.

* Filesystem consistency still not perfect (using snapshot-debug
  directive to test during heavy filesystem modification loads,
  directory entries are sometimes desynchronized from their inodes).

5 years agohammer2 - refactor filesystem sync 3/N
Matthew Dillon [Sat, 10 Nov 2018 02:05:14 +0000 (18:05 -0800)]
hammer2 - refactor filesystem sync 3/N

* Attempt to guarantee filesystem consistency at all sync points.

* Pretty severely hacked, and at the moment this can result in
  syncs which never end if the filesystem is busy.

5 years agohammer2 - refactor filesystem sync 2/N
Matthew Dillon [Fri, 9 Nov 2018 01:10:07 +0000 (17:10 -0800)]
hammer2 - refactor filesystem sync 2/N

* Flesh out the flush partitioning code, fixing a number of issues.

* Refactor hammer2_inode_lock() and add hammer2_inode_lock4() to
  interlock against flushes.  This is handled by blocking inode locks
  against SYNCQ, and reordering the inode to the front of the SYNCQ list
  in order to unblock as quickly as possible as the filesystem sync
  progresses.  The result should be relatively few frontend stalls
  during a filesystem sync.

* Disable resource caps for the moment, because synchronous
  operations to prevent resource limits from blowing out break
  the current inode_lock*() code and allow vnode deadlocks to
  occur.

* To avoid deadlocks, the filesystem sync currently must clear SYNCQ
  before locking the inode & vnode, and if it cannot lock a vnode it
  must continue on with the next inode and then restart.  Retried
  vnodes introduce a short delay to give the frontend time to work
  the blocking operation.

  This is necessary because the kernel locks vnodes before entering the
  H2 frontend, and we cannot safely unlock/relock them to work around
  this.  Nor do we necessarily even have full knowledge on which vnodes
  the current thread has locked.

* Does not yet guarantee complete filesystem consistency on-crash.

5 years agohammer2 - refactor filesystem sync 1/N
Matthew Dillon [Mon, 5 Nov 2018 01:31:07 +0000 (17:31 -0800)]
hammer2 - refactor filesystem sync 1/N

* Change H2 to allow concurrent filesystem sync and modifying
  frontend operations.

* FLUSH transactions no longer block modifying frontend
  transactions.

* Change filesystem sync operation to put all modified
  inodes on the pmp->syncq (which is also combined with
  any inodes on pmp->sideq), and then iterating the
  syncq to flush each inode.

  After this is done, stage 2 will flush the meta-data tree
  leading to each inode.

  This code will also handle delayed inode creation and
  destruction ops, which require modifications to the meta-data
  tree governing the inodes themselves (so we don't want the
  frontend to do it and interfere with the flush).

* Modifying operations against inodes already queued for a
  filesystem sync that is in progress will now reorder the
  inode to the front of the filesystem sync in progress and
  wait for the sync on that inode to complete before proceeding.

  This is handled by blocking in the exclusive inode lock code.

* hammer2_inode_get() does not need to pass 'dip' any more
  because regular inodes are inserted under the iroot (PFS root
  inode) and no longer inserted hierarchically.

* Separate out hammer2_inode_create() into hammer2_inode_create_pfs()
  and hammer2_inode_create_normal().  These two forms are now distinct
  enough that the code is a mess if we try to leave them combined.

5 years agohammer1 - Fix left-over /va/run/hammer.cleanup files
Matthew Dillon [Mon, 17 Dec 2018 21:46:11 +0000 (13:46 -0800)]
hammer1 - Fix left-over /va/run/hammer.cleanup files

* Fix an incorrect API call by hammer1 to the pidfile_*() functions
  in libutil.  This caused hammer1 to leave its lock files sitting in
  /var/run due to a use-after-free that reared its ugly head after
  the version update.

Reported-by: JustinS
5 years agodrm: Add the DRM_IOCTL_GET_PCIINFO ioctl
François Tigeot [Mon, 10 Dec 2018 22:06:11 +0000 (23:06 +0100)]
drm: Add the DRM_IOCTL_GET_PCIINFO ioctl

* It provides an easy way to get PCI device information from
  a /dev file descriptor

* The main user will be mesa/libdrm

Obtained-from: OpenBSD

5 years agoatkbdc - Change default to still attach PS2 controller even if FADT says don't
Matthew Dillon [Sun, 16 Dec 2018 21:26:06 +0000 (13:26 -0800)]
atkbdc - Change default to still attach PS2 controller even if FADT says don't

* Temporary workaround, disable commit 131acb0380e93664 by default.
  It can be enabled again with a tunable in /boot/loader.conf:

  hw.acpi.fadt_8042_nolegacy=1

* Should work around several bug reports of the keyboard not working
  in 5.4.

5 years agodrm/i915: Add Kaby Lake and Amber Lake PCI IDs
François Tigeot [Tue, 4 Dec 2018 21:54:39 +0000 (22:54 +0100)]
drm/i915: Add Kaby Lake and Amber Lake PCI IDs

Obtained-from: Linux 4.19

5 years agodrm/i915: Add Whiskey Lake PCI IDs
François Tigeot [Tue, 4 Dec 2018 21:27:20 +0000 (22:27 +0100)]
drm/i915: Add Whiskey Lake PCI IDs

Obtained-from: Linux 4.19

5 years agodrm/i915: Add more Coffeelake PCI IDs
François Tigeot [Tue, 4 Dec 2018 20:57:46 +0000 (21:57 +0100)]
drm/i915: Add more Coffeelake PCI IDs

Obtained-from: Linux 4.19

5 years agokernel/netinet6: Fix the kernel build without "options INET6".
Sascha Wildner [Sun, 9 Dec 2018 11:53:33 +0000 (12:53 +0100)]
kernel/netinet6: Fix the kernel build without "options INET6".

5 years agokernel - Cleanup blist debug code (2) v5.4.0
Matthew Dillon [Thu, 29 Nov 2018 08:17:57 +0000 (00:17 -0800)]
kernel - Cleanup blist debug code (2)

* Conditionalize debugging kprintf() for non-kernel test
  code only.

5 years agokernel - Fix nstopped SMP race during core dump
Matthew Dillon [Thu, 29 Nov 2018 06:56:24 +0000 (22:56 -0800)]
kernel - Fix nstopped SMP race during core dump

* During a process core dump, p->p_nstopped can be adjusted without
  holding p->p_token, resulting in a SMP race which can cause
  p_nstopped to become permanently desynchronized and deadlock the
  process.

* Be robust in a p_nstopped handling case in kern_exit, just in case.

5 years agokernel - Cleanup blist debug code
Matthew Dillon [Tue, 27 Nov 2018 01:39:56 +0000 (17:39 -0800)]
kernel - Cleanup blist debug code

* Allow 64-bit fields to be specified in the debug code.  Does not
  affect the kernel.

* Correct two next_skip calculations that were casting to 32 bits.
  These are block numbers and can affect operations when > 2TB of
  swap is configured.

5 years ago<sys/errno.h>: Remove EUNUSED*.
Levente Kurusa [Tue, 27 Nov 2018 10:48:45 +0000 (11:48 +0100)]
<sys/errno.h>: Remove EUNUSED*.

These values are not used (as their name suggests) and there is no
reason for an application to ever see or use them. This has recently
caused some confusion in the Rust ecosystem, and it looks like a
comment would better serve the intended purpose than making these
values available.

Signed-off-by: Levente Kurusa <lkurusa@acm.org>
5 years agoscript.1: Fix a typo, bump date.
Sascha Wildner [Sun, 25 Nov 2018 17:40:14 +0000 (18:40 +0100)]
script.1: Fix a typo, bump date.

5 years agoscript(1): Sync with FreeBSD
Antonio Huete Jimenez [Sun, 25 Nov 2018 11:05:59 +0000 (12:05 +0100)]
script(1): Sync with FreeBSD

- Add -p flag which is used to replay typescripts.
- Add -d flag to avoid sleeps in playbacks.
- Add -F flag which allows recording/playing through pipes.
- Add -r flag to optionally record all.
- A bunch of fixes, mostly.

Note: -f flag from FreeBSD is not available since DragonFly BSD does not
      have filemon(4)

5 years agokernel - Fix probable callout race
Matthew Dillon [Sun, 25 Nov 2018 07:39:15 +0000 (23:39 -0800)]
kernel - Fix probable callout race

* Fix a probable callout race in kern/kern_event.c.  It is possible
  for the callout to be requeued during teardown and for the
  structure to subsequently become corrupted.

  Manifests as 'stuck' processes (still ^C'able if PCATCH is flagged),
  and sleeps which do not expire.  Can be triggered by synth bulk runs.

* Increase maximum number of kqueue timers from 4096 to 65536.  This
  limit will have to be moved to uidinfo (but not in this commit).

5 years agoInstall input{,-event-types}.h to /usr/include/compat/linux too.
Sascha Wildner [Fri, 30 Nov 2018 20:13:02 +0000 (21:13 +0100)]
Install input{,-event-types}.h to /usr/include/compat/linux too.

It helps preventing excessive patches in ravenport's weston.

It is kind of experimental, but depending on how useful it
proves to be for 3rd party software all in all, we will
eventually remove /usr/include/dev/misc/evdev in the future.

A -I /usr/include/compat is needed to get at these headers using
"#include <linux/input.h>", etc. They were not put in the default
include path to mislead configure scripts and the likes.

We will also evaluate if it is worth exposing further linux
specific headers in this directory.

It might even be that we change the new location again in the
future.

Requested-by: Peeter Must
5 years agokernel: Move some old unused stuff out of the way.
Sascha Wildner [Fri, 30 Nov 2018 16:13:37 +0000 (17:13 +0100)]
kernel: Move some old unused stuff out of the way.

5 years agonetwork.subr: Handle DHCP in ipv6_ifconfig_<ifname>
Aaron LI [Wed, 28 Nov 2018 04:50:44 +0000 (12:50 +0800)]
network.subr: Handle DHCP in ipv6_ifconfig_<ifname>

Commit 329743def50a061489debcd9682983235c8f5b42 allows to set
'ipv6_ifconfig_<ifname>="DHCP"' to tell dhcpcd(8) to configure DHCPv6
for interface <ifname>.  However, the "DHCP" argument shouldn't be
passed to ifconfig(8).  Handle this case by using 'ifconfig_getargs()'
in 'network6_interface_setup()'.

5 years agoinitrd: Explicitly say the status when build completes
Aaron LI [Mon, 26 Nov 2018 07:29:56 +0000 (15:29 +0800)]
initrd: Explicitly say the status when build completes

Before this change, the 'all' target that builds the rescue and initrd
will end with a '--- obj ---' line, which may cause an illusion that the
build hasn't finished.  Now, explicitly say that the build has finished.

Suggested-by: swildner
5 years agoPut note about DSA OpenSSH key deprecation, from 5 versions ago, into UPDATING.
Justin C. Sherrill [Mon, 26 Nov 2018 02:45:51 +0000 (21:45 -0500)]
Put note about DSA OpenSSH key deprecation, from 5 versions ago, into UPDATING.
This probably affects nobody at this point, but now I can feel better about
removing it from release notes where it keeps getting reprinted.

5 years agoMakefile.inc1: Some minor cleanups
Aaron LI [Sat, 24 Nov 2018 11:09:00 +0000 (19:09 +0800)]
Makefile.inc1: Some minor cleanups

No functional change.

5 years agoinitrd: Rework build and install stages
Aaron LI [Sat, 24 Nov 2018 10:52:03 +0000 (18:52 +0800)]
initrd: Rework build and install stages

* Rewrite the Makefile to provide only the 'all' and 'install' targets.
  Do not separate the handling of the rescue tools and initrd image.
  Thus greatly simplify the whole logic.

  The 'all' target will build the rescue tools and initrd contents, and
  does not require root priviledge, while the 'install' target will
  install the rescue tools to the system, create the initrd image and
  install it.

* Update the top-level makefiles to call the new 'all' and 'install'.
  The 'buildworld' target now doesn't require root priviledge, same as
  before the refactoring in 9b724c0dcb2b9548a82d28d97e34375f64668669.

* Only provide the 'initrd' top-level target to keep it simple.  This
  target will install the rescue tools and initrd image built by the
  'buildworld', overwriting the existing ones.

* Clean up the nrelease/Makefile a bit, since 'installworld' will also
  install the rescue tools and initrd image in such a case.

* Update the mkinitrd.sh script a bit.

* Update the build(7) man page and clean up a bit.

Reviewed-by: swildner
5 years agorc.d/wpa_supplicant: Prefer the DPorts version for the moment
Aaron LI [Sun, 25 Nov 2018 09:39:41 +0000 (17:39 +0800)]
rc.d/wpa_supplicant: Prefer the DPorts version for the moment

We now also ship the wpa_supplicant from DPorts, which has several
important security fixes than the base one, so prefer the DPorts
wpa_supplicant if it exists for the moment.

This patch allows us to bring the base wpa_supplicant up-to-date and
switch back to it later without requiring users to modify their
'/etc/rc.conf'.

5 years agobuild - Add security/wpa_supplicant to nrelease
Matthew Dillon [Sun, 25 Nov 2018 07:44:21 +0000 (23:44 -0800)]
build - Add security/wpa_supplicant to nrelease

* Add security/wpa_supplicant to the nrelease build.  This ensures
  that the latest wpa_supplicant is available on release.  The
  wpa_supplicant in the base system exists only to help bootstrap
  systems when the port is not installed.

5 years ago<sys/param.h>: Adjust __DragonFly_version.
Sascha Wildner [Sat, 24 Nov 2018 18:03:55 +0000 (19:03 +0100)]
<sys/param.h>: Adjust __DragonFly_version.

5 years agoRevert "drm/ttm: Remove ttm_bo_unreserve_core()"
François Tigeot [Sat, 24 Nov 2018 13:12:34 +0000 (14:12 +0100)]
Revert "drm/ttm: Remove ttm_bo_unreserve_core()"

This reverts commit 5d4803440754b62fed1abd6d641d1f7a6f7b454e.

The drm/radeon driver has a tendency to lock up more frequently
without ttm_bo_unreserve_core().

Reported-by: Michael Neumann <mneumann@ntecs.de>
5 years ago5.4 changes. v5.4.0rc1
Justin C. Sherrill [Fri, 23 Nov 2018 03:37:50 +0000 (22:37 -0500)]
5.4 changes.

5 years agoinstaller: Add serial detection
Diederik de Groot [Sun, 14 Oct 2018 23:53:19 +0000 (01:53 +0200)]
installer: Add serial detection

- The installer script now asks for TERM type when in serial port console.
- Make sure dfui is not left running using trap/cleanup

5 years agotest: Attempt to fix vnodeinfo.c (2)
Antonio Huete Jimenez [Thu, 22 Nov 2018 19:15:11 +0000 (20:15 +0100)]
test: Attempt to fix vnodeinfo.c (2)