dragonfly.git
7 years agokernel - Rename desiredvnodes to maxvnodes, fix deadlock
Matthew Dillon [Sun, 16 Oct 2016 21:13:39 +0000 (14:13 -0700)]
kernel - Rename desiredvnodes to maxvnodes, fix deadlock

* Rename the kernel variable 'desiredvnodes' to 'maxvnodes' to match
  the sysctl name (which has always been 'maxvnodes'), and to make the
  code more readable.

* Probable fix to a rare mount/umount deadlock which can occur in two
  situations (1) When a large number of mounts and unmounts are running
  concurrently, and (2) During a umount -a, shutdown, or reboot.

* Considered minor, normal use cases will not reproduce this bug.  Only
  synth or poudriere can generate the mount/umount traffic necessary to
  reproduce this bug.

* Also fixes a minor kernel memory leak of the mount structure which can
  occur when a 'df' or filesystem sync races a umount.  Also minor.

Reported-by: marino (mount race)
7 years agoif_iwm - Partly sync if_iwm_binding.c to Linux iwlwifi code.
Imre Vadász [Sun, 16 Oct 2016 18:55:13 +0000 (20:55 +0200)]
if_iwm - Partly sync if_iwm_binding.c to Linux iwlwifi code.

* Store macid and color values in struct iwm_vap, to avoid hardcoded
  constants a bit.

* Add iwm_mvm_binding_remove_vif() function (will be used in disconnecting
  from an access point without resetting the whole device).

* Not adding code from Linux iwlwifi yet, to handle one PHY context to
  be bound to several VAPs/virtual-interfaces, it's definitely not needed
  in the near future.

Taken-From: Linux iwlwifi

7 years agoif_iwm - Move in_phyctxt from struct iwm_node to phy_ctxt in struct iwm_vap.
Imre Vadász [Sun, 16 Oct 2016 10:23:44 +0000 (12:23 +0200)]
if_iwm - Move in_phyctxt from struct iwm_node to phy_ctxt in struct iwm_vap.

* This better matches how things are organized in Linux's iwlwifi.

7 years agosbin/mount_hammer: Add missing switch case from bab16452
Tomohiro Kusumi [Sun, 16 Oct 2016 04:01:54 +0000 (13:01 +0900)]
sbin/mount_hammer: Add missing switch case from bab16452

The previous commit bab16452 needed 1..15 case for expected values,
so as not to show an irrelevant message via default case.

7 years agosbin/mount_hammer: Fix warning messages
Tomohiro Kusumi [Sun, 16 Oct 2016 03:07:51 +0000 (12:07 +0900)]
sbin/mount_hammer: Fix warning messages

Add warning messages for -1 and non-0-15 for master_id.

-1 and 0-15 inclusive are the only supoprted values,
so remove probably from the existing warning message.

7 years agosbin/hammer: Mention bug in hammer recover command
Tomohiro Kusumi [Sat, 15 Oct 2016 14:46:57 +0000 (23:46 +0900)]
sbin/hammer: Mention bug in hammer recover command

newfs_hammer overwrites layer1/2, but doesn't overwrite data in
blockmap beyond layer1/2, so old data is still there if the volume
has been re-formatted until the new fs overwrites old fs by using
more disk space than the old fs.

This is usually not a problem because the new fs doesn't have a
pointer to data in old fs, but hammer recover just iterates zone-2
offset till it hits end of the disk space which may include data
from the old fs. As mentioned in the comment, it's likely to hit
assertion if the old data located near the end of the volume is
B-Tree nodes depending on situation of the old fs.

7 years agosbin/hammer: Add volume signature check on loading a volume
Tomohiro Kusumi [Sat, 15 Oct 2016 14:16:14 +0000 (23:16 +0900)]
sbin/hammer: Add volume signature check on loading a volume

7 years agosbin/hammer: Cleanup arguments of init_volume()
Tomohiro Kusumi [Sat, 15 Oct 2016 01:15:02 +0000 (10:15 +0900)]
sbin/hammer: Cleanup arguments of init_volume()

Change the order of arguments to make the i/f similar to open(2)
as well as load_volume().

This is only for newfs (and volume-add), nothing else gets affected.

7 years agosbin/hammer: Make hammer recover use hammer_parsedevs_noverify()
Tomohiro Kusumi [Fri, 14 Oct 2016 12:33:59 +0000 (21:33 +0900)]
sbin/hammer: Make hammer recover use hammer_parsedevs_noverify()

hammer recover command should be able to run the recovery code
even if volume header is broken (not just broken blockmap part)
to certain extent, since the purpose of this is to recover contents
of a broken filesystem.

By using 0 for verify argument of load_volume(), hammer recover
skips sanity checks for ondisk volume header.

Also see 173bd31c.

7 years agosbin/hammer: Add verify argument to load_volume()
Tomohiro Kusumi [Fri, 14 Oct 2016 12:27:09 +0000 (21:27 +0900)]
sbin/hammer: Add verify argument to load_volume()

Add an argument to select whether to verify volume header or not.
This is for the next commit.

7 years agokernel - Fix improper user-space access in sys___semctl()
Matthew Dillon [Fri, 14 Oct 2016 16:32:12 +0000 (09:32 -0700)]
kernel - Fix improper user-space access in sys___semctl()

* Fix an improper user-space access in sys__semctl()

* Fix an improper kernel-space access that was using
  a user-supplied pointer.

Reported-by: Mateusz Kocielski - LogicalTrust
7 years agodrm/linux: Add kmap_to_page()
François Tigeot [Fri, 14 Oct 2016 06:59:09 +0000 (08:59 +0200)]
drm/linux: Add kmap_to_page()

7 years agodrm/linux: Add get_nr_swap_pages()
François Tigeot [Thu, 13 Oct 2016 10:07:00 +0000 (12:07 +0200)]
drm/linux: Add get_nr_swap_pages()

7 years agoif_iwm - Allow listening on both chains/atennas to get diversity.
Imre Vadász [Wed, 12 Oct 2016 20:19:31 +0000 (22:19 +0200)]
if_iwm - Allow listening on both chains/atennas to get diversity.

* This might improve throughput slightly when far from the accesspoint,
  apparently by allowing the firmware to listen on either of the two
  antennas (if there are two, i.e. on 7260/7265/8260), whichever has
  a better reception.

Taken-From: Linux iwlwifi

7 years agosys/vfs/hammer: Use HAMMER_MAX_KEY for initial trunc_off values
Tomohiro Kusumi [Wed, 12 Oct 2016 12:57:37 +0000 (21:57 +0900)]
sys/vfs/hammer: Use HAMMER_MAX_KEY for initial trunc_off values

ip->trunc_off variants are to be compared with node elm's base.key,
so it should use HAMMER_MAX_KEY on initialization instead of
0x7FFFFFFFFFFFFFFFLL.

7 years agosys/vfs/hammer: Add HAMMER_MIN|MAX_ONDISK_LOCALIZATION
Tomohiro Kusumi [Tue, 11 Oct 2016 15:05:19 +0000 (00:05 +0900)]
sys/vfs/hammer: Add HAMMER_MIN|MAX_ONDISK_LOCALIZATION

Use | for HAMMER_MAX_ONDISK_LOCALIZATION, but not +.
Also see 7e52af60.

7 years agosys/vfs/hammer: Use MIN/MAX macros for B-Tree node's elm base
Tomohiro Kusumi [Tue, 11 Oct 2016 14:40:45 +0000 (23:40 +0900)]
sys/vfs/hammer: Use MIN/MAX macros for B-Tree node's elm base

Leave obj_type with 0 instead of using HAMMER_OBJTYPE_UNKNOWN,
since it's not intended to be unknown, but literally intended
to be a value of 0.

7 years agodrm/linux: Add sign_extend64()
François Tigeot [Tue, 11 Oct 2016 07:26:14 +0000 (09:26 +0200)]
drm/linux: Add sign_extend64()

7 years agodrm/linux: Add kasprintf and kvasprintf()
François Tigeot [Tue, 11 Oct 2016 07:04:25 +0000 (09:04 +0200)]
drm/linux: Add kasprintf and kvasprintf()

7 years agodrm/linux: Add kstrtouint()
François Tigeot [Tue, 11 Oct 2016 06:41:04 +0000 (08:41 +0200)]
drm/linux: Add kstrtouint()

Inspired from: FreeBSD

7 years agovkernel - Fix FP corruption in VMX/EPT mode
Matthew Dillon [Mon, 10 Oct 2016 17:22:12 +0000 (10:22 -0700)]
vkernel - Fix FP corruption in VMX/EPT mode

* Properly invalidating the EPT TLB cache when it potentially becomes
  stale.

* When destroying a VMX context, make sure the EPT TLB cache has been
  invalidated for that context as a safety.

* Fix a bug in vmx_vminit() where it was losing track of the currently
  loaded VMX.

* Setup the VMX to clear the host CR0_TS, and the host makes sure the FP
  state is correct prior to vmlaunch.

* Make sure the GUEST_CR0's CR0_TS reflects the vkernel says it should
  reflect.

* The vkernel has a choice of asking the guest user context to #NM fault
  on FP use or not.  Both mechanics work, but its probably better for it
  to ensure that the FP state is valid and tell the user context to not
  fault.  However, this commit makes sure that both mechanics work.

* Document why we shouldn't vmclear the old current context when loading
  a different context.

* Cleanup some of the vkernel's pmap handling.  This isn't perfect and
  probably needs to be rewritten (we need a more powerful guest pmap
  adjustment system call to properly synchronize changes).  For now
  we try to avoid races against detecting the (M)odified flag by clearing
  the RW flag first.

7 years agovkernel - Add COW image capability
Matthew Dillon [Sun, 9 Oct 2016 23:41:17 +0000 (16:41 -0700)]
vkernel - Add COW image capability

* Add a copy-on-write disk image feature.  This allows a vkernel
  to mount a disk image RO or R+W but does not try to write changes
  back to the image file.

  This allows multiple vkernel instances to use the same image
  file.

* Note that when the vkernel operates on an image in this mode,
  modifications will eat up system memory and swap, so the user
  should be cognizant of the use-case.  Still, the flexiblity of
  being able to mount the image R+W should not be underestimated.

7 years agoiwm.4: Mention iwm7265Dfw firmware. Update DIAGNOSTICS section a bit.
Imre Vadász [Sun, 9 Oct 2016 19:45:16 +0000 (21:45 +0200)]
iwm.4: Mention iwm7265Dfw firmware. Update DIAGNOSTICS section a bit.

7 years agoif_iwm - Add basic powermanagement support via ifconfig wlan0 powersave.
Imre Vadász [Sat, 23 Jul 2016 13:54:50 +0000 (15:54 +0200)]
if_iwm - Add basic powermanagement support via ifconfig wlan0 powersave.

* The DEVICE_POWER_FLAGS_CAM_MSK flag was removed in the upstream iwlwifi
  in Linux commit ceef91c89480dd18bb3ac51e91280a233d0ca41f.

* Add sc_ps_disabled flag to struct iwm_softc, which corresponds to
  mvm->ps_disabled in struct iwl_mvm in Linux iwlwifi.

* Adds a hw.iwm.power_scheme tunable which corresponds to the power_scheme
  module parameter in Linux iwlwifi. Set this to 1 for completely
  disabling power management, 2 (default) for balanced powermanagement,
  and 3 for lowerpower mode (which does dtim period skipping).

* Imports the constants.h file from iwlwifi as if_iwm_constants.h.

* This doesn't allow changing the powermanagement setting while connected,
  also one can only choose between enabled and disabled powersaving with
  ifconfig (so switching between balanced and low-power mode requires
  rebooting to change the tunable).

* After any changes to powermanagement (i.e. "ifconfig wlan0 powersave" to
  enable powermanagement, or "ifconfig wlan0 -powersave" for disabling
  powermanagement), one has to disconnect and reconnect to the accespoint
  for the change to take effect.

Taken-From: Linux iwlwifi

7 years agosys/dev/disk/dm: Make dmdebug() print __func__
Tomohiro Kusumi [Sun, 9 Oct 2016 09:22:18 +0000 (18:22 +0900)]
sys/dev/disk/dm: Make dmdebug() print __func__

and fix/remove dmdebug calls that could be cleaned up or simplified.

7 years agosys/vfs/hammer: Mention ondisk fields are in little endian
Tomohiro Kusumi [Sun, 9 Oct 2016 07:18:59 +0000 (16:18 +0900)]
sys/vfs/hammer: Mention ondisk fields are in little endian

Explicitly mention HAMMER1 uses little endian for ondisk structures,
but not host endian (which is little on currently supported arch).

This is easier because adding big endian support doesn't break
anything at least on DragonFly/x86_64.

This doesn't affect anything/anyone in reality because HAMMER1 on
DragonFly is the only HAMMER1 implementation (that I know of other
than the read only FUSE port).

7 years agosbin/hammer: Remove getdir()
Tomohiro Kusumi [Sat, 8 Oct 2016 07:22:34 +0000 (16:22 +0900)]
sbin/hammer: Remove getdir()

Using dirname(3) with a santiy check for trailing / on creating PFS
does the same as getdir(), so use a library rather than its own.

No one uses getdir() anymore, so it can be removed.

7 years agosbin/hammer: Cleanup getpfs()/scanpfsid()
Tomohiro Kusumi [Sat, 8 Oct 2016 07:12:17 +0000 (16:12 +0900)]
sbin/hammer: Cleanup getpfs()/scanpfsid()

No functional difference.

7 years agosbin/hammer: Partly revert 8b640662 in 2014
Tomohiro Kusumi [Wed, 21 Sep 2016 22:04:18 +0000 (07:04 +0900)]
sbin/hammer: Partly revert 8b640662 in 2014

I guess it makes sense that 8b640662 silently ignores trailing / and
do destructive operations to a filesystem, since there isn't really
anything one can do by specifying a root inode (directory) of a PFS,
but it shouldn't silently modify (not ignore) the user input.

A command like pfs-status uses that input after calling getpfs(),
so the program should not silently modify the string and print it
as if that was the user input, because it's not. It should also avoid
modifying argv[i] even if it's technically possible (make it shorter).

It's also better to do it based on lstat(2) result than unconditionally
checking a trailing / based on assumption that a symlink that ends
with / is a directory (which is right if it actually exists).

The only case behaves differently from 8b640662 is when there is a
slave PFS that hasn't been synced with a master PFS yet after created.
In this case it fails to run commands using path arg with trailing /,
because lstat(2) mentioned above in scanpfsid() fails due to lack of
the root inode. This occurs by design of HAMMER, but not a tool issue.

Above won't be a problem either because the scenario mentioned in
8b640662 is mostly about auto completion by a shell, while in this
case the shell just recognizes it as a broken link. The tool doesn't
need to assist everything that users would potentially do based on
assumption that may be right or wrong.
Also see http://lists.dragonflybsd.org/pipermail/users/2015-April/228012.html

-----
Actually I even suspect reports by users and 8b640662 were wrong
in the first place, because one would still get the same PFS id from
both "symlink" and "symlink/" when "symlink" is a symlink to PFS.
"symlink" can extract the PFS id directly from "@@.." format, but
"symlink/" eventually results the same via hammer_pfs_autodetect().
In fact I could pfs-upgrade/pfs-downgrade by reverting whole 8b640662.

Having said that, it still needs to strip trailing / on pfs-destroy
otherwise it won't be able to remove a symlink to PFS after it gets
destroyed.

7 years agosbin/hammer: Use dirname(3) instead of getdir() in scanpfsid()
Tomohiro Kusumi [Sat, 8 Oct 2016 07:31:53 +0000 (16:31 +0900)]
sbin/hammer: Use dirname(3) instead of getdir() in scanpfsid()

scanpfsid() can use dirname(3) for fd instead of getdir().
It's actually better to use dirname(3) which strips trailing /
first and then return a pointer to directory path, instead of
getdir() which only strips trailing / if any, because that's
what scanpfsid() is trying to do with fd.

If path is
    path/to/pfs -> @@...
scanpfsid() wants to open("path/to"), and if path is
    path/to/pfs/
which is @@.. itself if the PFS is not destroyed,
scanpfsid() still wants to open("path/to").

The second one doesn't occur since 8b640662 changed getpfs()
to strip trailing / before calling scanpfsid().
However the next commit is going to partly revert 8b640662,
and this change makes the next 2 commits easier to implement,
while being logically separated topic.

7 years agokernel - Refactor VMX code
Matthew Dillon [Sat, 8 Oct 2016 23:57:16 +0000 (16:57 -0700)]
kernel - Refactor VMX code

* Refactor the VMX code to use all three VMM states available to use
  instead of two.  The three states available are:

  active and current (VMPTRLD)
  active not current (replaced by some other context being VMPTRLD'd)
  inactive not current (VMCLEAR)

  In short, there is no need to VMCLEAR the current context when activating
  another via VMPTRLD, doing so greatly reduces performance.  VMCLEAR is
  only really needed when a context is being destroyed or being moved to
  another cpu.

* Also fixes a few bugs along the way.

* Live loop in vmx_vmrun() when necessary, otherwise we wind up with serious
  problems synchronizing IPIs.  The thread will still be subject to its
  process priority.

7 years agoif_iwm - Add iwm_nic_unlock() calls missing from previous commit.
Imre Vadász [Sat, 8 Oct 2016 21:56:42 +0000 (23:56 +0200)]
if_iwm - Add iwm_nic_unlock() calls missing from previous commit.

7 years agoif_iwm - iwm_{read,write}_prph() don't grab the nic lock in iwm themselves.
Imre Vadász [Sat, 8 Oct 2016 21:06:50 +0000 (23:06 +0200)]
if_iwm - iwm_{read,write}_prph() don't grab the nic lock in iwm themselves.

* Fix a couple of cases where the nic lock ended up not being grabbed
  during an iwm_read_prph() or iwm_write_prph().

7 years agokernel/iwm: Fix building into the kernel without IWM_DEBUG.
Sascha Wildner [Sat, 8 Oct 2016 06:06:42 +0000 (08:06 +0200)]
kernel/iwm: Fix building into the kernel without IWM_DEBUG.

7 years agokernel/iwm: Allow IWM_DEBUG to come in via the kernel config too.
Sascha Wildner [Sat, 8 Oct 2016 06:06:03 +0000 (08:06 +0200)]
kernel/iwm: Allow IWM_DEBUG to come in via the kernel config too.

Previously, it was only ever set for the module.

7 years agokernel/ecc: Add MODULE_VERSION()s.
Sascha Wildner [Fri, 7 Oct 2016 18:41:09 +0000 (20:41 +0200)]
kernel/ecc: Add MODULE_VERSION()s.

This prevents the loader from loading the module (and whining later about
it) if the driver is built into the kernel as is the case for ecc in our
default config.

7 years agokernel - Fix low memory process kill bug
Matthew Dillon [Sat, 8 Oct 2016 02:13:41 +0000 (19:13 -0700)]
kernel - Fix low memory process kill bug

* If a process is being killed, don't let it stay put in a low-memory
  vm_wait loop in kernel mode, it will never exit.

* Try to improve the chances that we can dump by adjusting an assertion in
  the user thread scheduler.

7 years agokernel - Fix a system lockup with vmm
Matthew Dillon [Sat, 8 Oct 2016 02:10:06 +0000 (19:10 -0700)]
kernel - Fix a system lockup with vmm

* Fix an issue where vkernel_lwp_exit() was improperly trying to kfree()
  the vklp->ve pointer for the guest-thread case.  This field holds a
  user-supplied address in that case, not a kernel structure.

* Yield the cpu more aggressively in the VMM_GUEST_RUN loop.  We were
  testing for pending interrupts but we were not calling lwkt_switch()

* Do not exit the vkernel on a call or jump to address 0.  This debugging
  code should have been removed and wasn't.  A user process running under
  the vkernel could cause the vkernel itself to exit.

* Numerous syntactical cleanups.

Reported-by: tuxillo
7 years agosbin/hammer: Change "PFS #" to "PFS#"
Tomohiro Kusumi [Sat, 8 Oct 2016 00:13:36 +0000 (09:13 +0900)]
sbin/hammer: Change "PFS #" to "PFS#"

It's mostly "PFS#", so remove extra space between "PFS" and "#".

7 years agosbin/hammer: Don't wait 5 secs on pfs-destroy if -d (for devs)
Tomohiro Kusumi [Fri, 7 Oct 2016 22:46:42 +0000 (07:46 +0900)]
sbin/hammer: Don't wait 5 secs on pfs-destroy if -d (for devs)

PFS commands still have bugs and weird behaviors, so don't force
devs to wait 5 secs everytime doing hammer pfs-destroy.

But don't mention this in manpage, because this should be forced
against regular users no matter what.

Also remove extra space between "PFS" and "#" to sync the format
with other printfs.

7 years agoif_iwm - Add the BSS's basic rates to iwm's LQ command, not all the rates.
Imre Vadász [Fri, 7 Oct 2016 18:32:52 +0000 (20:32 +0200)]
if_iwm - Add the BSS's basic rates to iwm's LQ command, not all the rates.

Makes the firmware use appropriate Tx rates for ACKs.

Taken-From: OpenBSD

7 years agosbin/hammer: Make getdir() support more than 1 trailing /
Tomohiro Kusumi [Wed, 5 Oct 2016 20:10:37 +0000 (05:10 +0900)]
sbin/hammer: Make getdir() support more than 1 trailing /

Also add a comment that tells difference from dirname(3) with
trailing /, which was true prior to this commit.

Nothing changes from the way commands use this function.

7 years agosbin/hammer: Remove meaningless sscanf for "@@PFS%d" format
Tomohiro Kusumi [Wed, 21 Sep 2016 01:48:39 +0000 (10:48 +0900)]
sbin/hammer: Remove meaningless sscanf for "@@PFS%d" format

This isn't necessary as userspace never reads "@@PFS%d" via readlink(2).
"@@%jx:%d" covers all the necessary patterns.

It also shouldn't be here because the first stat(2) call in this
function ignores the result due to possible slave PFS (before once
synced with a master PFS), so an arbitrary string that matches this
"@@PFS%d" pattern for path argument (whether it really exists or not)
makes this function return non negative fd while it should return -1.

If "@@PFS%d" is the name of an existing file or a directory, then
that's also not what this function is looking for, so it can still
be ignored.

7 years agosbin/hammer: Remove redundant ioctl(GET_PSEUDOFS) call in getpfs()
Tomohiro Kusumi [Wed, 21 Sep 2016 00:18:55 +0000 (09:18 +0900)]
sbin/hammer: Remove redundant ioctl(GET_PSEUDOFS) call in getpfs()

If scanpfsid() failed, it needs to try to open(2) the path whether
it's a symlink or a file or a directory, but it needs not to call
ioctl(GET_PSEUDOFS) which gets called right after this anyway.

The error message "Cannot access PFS" is misleading too, because
once scanpfsid() fails, the path isn't necessarily a PFS or a symlink
to a PFS.

Also note that calling this ioctl with -1 set to pfs.pfs_id is okay.
In that case, the ioctl will try to detect the PFS id based on fd.

7 years agosbin/hammer: Remove XXX in a comment
Tomohiro Kusumi [Thu, 29 Sep 2016 01:56:35 +0000 (10:56 +0900)]
sbin/hammer: Remove XXX in a comment

There isn't anything wrong with or special about this part, so remove XXX.
The code that originally came with this comment is gone.
See c3be93f2 in 2008 for details.

7 years agosbin/newfs_hammer: Check/initialize uuid after getopt
Tomohiro Kusumi [Mon, 26 Sep 2016 23:54:11 +0000 (08:54 +0900)]
sbin/newfs_hammer: Check/initialize uuid after getopt

Allow the program to go through options even with invalid uuid,
so it at least allows some basic options like -h.
This is same as what sbin/hammer does.

7 years agosbin/hammer: Partly revert 2c1d3cef in 2010
Tomohiro Kusumi [Mon, 26 Sep 2016 20:42:29 +0000 (05:42 +0900)]
sbin/hammer: Partly revert 2c1d3cef in 2010

This is the same as d6c59c72, so read d6c59c72 for details.

The code in 2c1d3cef in 2010 was later replaced by libhammer, so what
this commit actually does is revert a part of those libhammer commits,
but whatever it is, a certain directory being null mounted on somewhere
else is beyond the scope of hammer or any other filesystems.
This command originally had no such extra info, and that was better.

It's also confusing in the sense that it silently changes the output
depending on whether it's mounted or not.

7 years agosbin/hammer: Remove alloc_data_element()
Tomohiro Kusumi [Mon, 26 Sep 2016 19:53:56 +0000 (04:53 +0900)]
sbin/hammer: Remove alloc_data_element()

This function is not used by anyone, and it's normal that way.
The userspace command can't just allocate a user data alone without
other metadata getting involved.

Also note this function isn't fully functional as hammer userspace
only supports upto 16KB buffer. While this function seems to care
about large data zone, it can't handle >16KB by design (at least for now).

7 years agosys/vfs/hammer: Add HAMMER_FSTYPE_STRING
Tomohiro Kusumi [Mon, 26 Sep 2016 16:51:43 +0000 (01:51 +0900)]
sys/vfs/hammer: Add HAMMER_FSTYPE_STRING

It's better to define this in hammer's core ondisk header than
only having it as a string literal in some userspace tools.

7 years agosbin/hammer: Sync return value of test_btree_search() with hammer_btree_cmp()
Tomohiro Kusumi [Mon, 26 Sep 2016 16:26:55 +0000 (01:26 +0900)]
sbin/hammer: Sync return value of test_btree_search() with hammer_btree_cmp()

Sync with the previous commit.
Doesn't change anything as all it matters is whether it's + or - or 0.

7 years agosbin/hammer: Move hammer_btree_cmp() to cmd_show.c
Tomohiro Kusumi [Mon, 26 Sep 2016 01:39:57 +0000 (10:39 +0900)]
sbin/hammer: Move hammer_btree_cmp() to cmd_show.c

This function isn't necessary in userspace unless a command wants
to walk through the B-Tree. The only hammer command that needs to
do this is hammer show, so make it a static function of hammer show
just like other node/elm related functions are static.

This is a copy-pasted function from sys/vfs/hammer/hammer_btree.c,
but keep it copy-pasted code without having it as an static inline
function in hammer_btree.h, as it has bunch of conditionals that
make asm of a caller unreadable.

7 years agosbin/hammer: Rename alloc_btree_element() to alloc_btree_node()
Tomohiro Kusumi [Mon, 26 Sep 2016 01:22:50 +0000 (10:22 +0900)]
sbin/hammer: Rename alloc_btree_element() to alloc_btree_node()

Make it clear that it's allocating a 4KB node, but not elm part.
Also change return type to hammer_node_ondisk_t.
Don't need to cast to void* on returning.

7 years agosbin/hammer: Remove get_ondisk() after previous commits
Tomohiro Kusumi [Mon, 26 Sep 2016 00:52:20 +0000 (09:52 +0900)]
sbin/hammer: Remove get_ondisk() after previous commits

After the previous commits, a static function get_ondisk() is only
used by get_buffer_data() which is a function for arbitrary ondisk
data, so it can simply be a part of get_buffer_data().

7 years agosbin/hammer: Remove get_node()
Tomohiro Kusumi [Mon, 26 Sep 2016 00:51:45 +0000 (09:51 +0900)]
sbin/hammer: Remove get_node()

Just call get_data_buffer(offset, &buffer, 0) like other data do.

7 years agosbin/hammer: Make get_node() a wrapper over get_buffer_data()
Tomohiro Kusumi [Sun, 25 Sep 2016 22:20:44 +0000 (07:20 +0900)]
sbin/hammer: Make get_node() a wrapper over get_buffer_data()

get_node() which is only used by hammer show/blockmap commands should
be a wrapper over the existing get_buffer_data().

It needs to do rel_buffer() if the given offset is out of range when
*bufferp is non NULL. Adding this check makes this function equivalent
of get_buffer_data() with 0 for isnew. isnew must be 0 because this
function assumes and only works when the B-Tree node already exists.

This doesn't change anything because hammer show/blockmap always give
NULL for *bufferp, but it should still be changed.

7 years agolocaledef: Improve cc_list parsing
John Marino [Thu, 6 Oct 2016 15:46:50 +0000 (10:46 -0500)]
localedef: Improve cc_list parsing

I had originally suspected the parsing of ctype definition files as being
the source of the ctype flag mis-definitions, but it wasn't.  In the
process, I simplified the cc_list parsing so I'm committing the no-impact
improvement separately.  It removes some parsing redundancies and
won't parse partial range definitions anymore.

7 years agolocaledef: Fix ctype dump (fixed wide spread errors)
John Marino [Thu, 6 Oct 2016 15:37:06 +0000 (10:37 -0500)]
localedef: Fix ctype dump (fixed wide spread errors)

This was a CTYPE encoding error involving consecutive points of the same
ctype.  It was reported by myself to Illumos over a year ago but I was
unsure if it was only happening on BSD.  Given the cause, the bug is also
present on Illumos.

Basically, if consecutive points were of the exact same ctype, they would
be defined as a range regardless.  For example, all of these would be
considered equivalent:

  <A> ... <C>, <H>  (converts to <A> .. <H>)
  <A>, <B>, <H>     (converts to <A> .. <H>)
  <A>, <J> ... <H>  (converts to <A> .. <H>)

So all the points that shouldn't have been defined got "bridged" by the
extreme points.

The effects were recently reported to FreeBSD on PR 213013.  There are
countless places were the ctype flags are misdefined, so this is a major
fix that has to be MFC'd.

7 years agoif_iwm - Enable Energy Based Scan (EBS).
Imre Vadász [Wed, 5 Oct 2016 20:31:35 +0000 (22:31 +0200)]
if_iwm - Enable Energy Based Scan (EBS).

* This can significantly reduce scan duration thus saving time and power.
  EBS failure reported by FW disables EBS for current connection. It is
  re-enabled upon new connection attempt on any WLAN interface.

Taken-From: Linux iwlwifi

7 years agoif_iwm - GC unused code from if_iwm_scan.c, copyied from iwn or iwlwifi/dvm.
Imre Vadász [Wed, 5 Oct 2016 18:40:23 +0000 (20:40 +0200)]
if_iwm - GC unused code from if_iwm_scan.c, copyied from iwn or iwlwifi/dvm.

7 years agoif_iwm - Tiny cleanup in iwm_rx_addbuf().
Imre Vadász [Wed, 5 Oct 2016 11:29:12 +0000 (13:29 +0200)]
if_iwm - Tiny cleanup in iwm_rx_addbuf().

7 years agoif_iwm - Make ucode capabilities and api flags handling more like iwlwifi.
Imre Vadász [Tue, 4 Oct 2016 22:41:41 +0000 (00:41 +0200)]
if_iwm - Make ucode capabilities and api flags handling more like iwlwifi.

Taken-From: Linux iwlwifi

7 years agoif_iwm - Remove a couple of unneeded IWM_UCODE_TLV_FLAGS_* flags.
Imre Vadász [Tue, 4 Oct 2016 21:05:19 +0000 (23:05 +0200)]
if_iwm - Remove a couple of unneeded IWM_UCODE_TLV_FLAGS_* flags.

* All the supported firmwares have these flags set.

* This removes the following flags:
    IWM_UCODE_TLV_FLAGS_PM_CMD_SUPPORT,
    IWM_UCODE_TLV_FLAGS_NEWBT_COEX,
    IWM_UCODE_TLV_FLAGS_BF_UPDATED,
    IWM_UCODE_TLV_FLAGS_D3_CONTINUITY_API,
    IWM_UCODE_TLV_FLAGS_STA_KEY_CMD,
    IWM_UCODE_TLV_FLAGS_DEVICE_PS_CMD,
    IWM_UCODE_TLV_FLAGS_SCHED_SCAN,
    IWM_UCODE_TLV_FLAGS_RX_ENERGY_API,
    IWM_UCODE_TLV_FLAGS_TIME_EVENT_API_V2

* Also remove definitions and code for dealing with the v1 time-event api.

* Remove unneeded calc_rssi() function.

Taken-From: Linux iwlwifi

7 years agoSync ACPICA with Intel's version 20160930.
Sascha Wildner [Tue, 4 Oct 2016 19:25:31 +0000 (21:25 +0200)]
Sync ACPICA with Intel's version 20160930.

* Increase maximum loop count before AE_AML_INFINITE_LOOP exception to
  1048575.

* iasl: Correctly handle unresolved symbols in the hardware map file.

* iasl: Support for control method invocation as an operand of DeRefOf().

* Various improvements and some issues fixed.

For a more detailed list, please see sys/contrib/dev/acpica/changes.txt.

7 years agoLibreSSL: complete update v2.4.2 => v2.4.3
John Marino [Mon, 3 Oct 2016 19:31:45 +0000 (14:31 -0500)]
LibreSSL: complete update v2.4.2 => v2.4.3

7 years agoMerge branch 'vendor/LIBRESSL'
John Marino [Mon, 3 Oct 2016 19:58:14 +0000 (14:58 -0500)]
Merge branch 'vendor/LIBRESSL'

7 years agoUpdate LibreSSL from version 2.4.2 => 2.4.3
John Marino [Mon, 3 Oct 2016 19:23:51 +0000 (14:23 -0500)]
Update LibreSSL from version 2.4.2 => 2.4.3

7 years agomtree(8): Fix wrong extern.
Sascha Wildner [Mon, 3 Oct 2016 17:56:42 +0000 (19:56 +0200)]
mtree(8): Fix wrong extern.

Done wrong by me in b4b8669d4991221d7aafe58b020346a1746d1ead.

Reported-by: zrj
7 years agoRelocate private panel library to intended location
John Marino [Mon, 3 Oct 2016 16:19:47 +0000 (11:19 -0500)]
Relocate private panel library to intended location

The only consumer of libpanel is the DF installer.  It wasn't installed in
the correct private area, but the linker found it anyway on the standard
search path.  Fix the installation location and task "make upgrade" to
remove the publically installed private libraries.

7 years agopc64: Fix typo in wrmsr_safe.
Imre Vadász [Mon, 3 Oct 2016 12:41:29 +0000 (14:41 +0200)]
pc64: Fix typo in wrmsr_safe.

7 years agoUse <termios.h> instead of the deprecated <sys/termios.h>.
Sascha Wildner [Mon, 3 Oct 2016 12:09:18 +0000 (14:09 +0200)]
Use <termios.h> instead of the deprecated <sys/termios.h>.

7 years agoSplit out <sys/_termios.h> for struct termios and the flags.
Sascha Wildner [Mon, 3 Oct 2016 12:08:15 +0000 (14:08 +0200)]
Split out <sys/_termios.h> for struct termios and the flags.

termios.h includes it and has the C library interface.

Similar to what FreeBSD did. No functional change.

7 years agoif_iwm - Move mbuf hacks after sanity checks in iwm_mvm_rx_rx_mpdu().
Imre Vadász [Mon, 3 Oct 2016 10:21:53 +0000 (12:21 +0200)]
if_iwm - Move mbuf hacks after sanity checks in iwm_mvm_rx_rx_mpdu().

* This avoids leaving the mbuf in a weird state, when dropping a packet.

7 years agoRemove old timezone via 'make upgrade'.
Sascha Wildner [Sun, 2 Oct 2016 00:28:09 +0000 (02:28 +0200)]
Remove old timezone via 'make upgrade'.

7 years agobsd-family-tree: Sync with FreeBSD (various NetBSD versions).
Sascha Wildner [Sun, 2 Oct 2016 00:29:17 +0000 (02:29 +0200)]
bsd-family-tree: Sync with FreeBSD (various NetBSD versions).

7 years agosys/dev/disk/dm: Remove default:break for switch enums on kldload
Tomohiro Kusumi [Sat, 1 Oct 2016 21:20:55 +0000 (06:20 +0900)]
sys/dev/disk/dm: Remove default:break for switch enums on kldload

This could be reverted as compilers may warn if not all enum elements
are covered, but some dm targets don't have default case on loading,
and it's been working. Compiles with LINT64.

7 years agosys/dev/disk/dm: Remove #if0'd dmminphys() from NetBSD
Tomohiro Kusumi [Wed, 21 Sep 2016 02:36:51 +0000 (11:36 +0900)]
sys/dev/disk/dm: Remove #if0'd dmminphys() from NetBSD

This is specific to NetBSD, so we can remove this.

7 years agosys/dev/disk/dm: Cleanup
Tomohiro Kusumi [Wed, 21 Sep 2016 02:29:49 +0000 (11:29 +0900)]
sys/dev/disk/dm: Cleanup

7 years agoif_iwm - Get rid of struct iwm_rx_data argument for iwm_mvm_rx_rx_mpdu.
Imre Vadász [Sat, 1 Oct 2016 15:18:45 +0000 (17:18 +0200)]
if_iwm - Get rid of struct iwm_rx_data argument for iwm_mvm_rx_rx_mpdu.

7 years agoExpose ld.bfd and ld.gold
John Marino [Sat, 1 Oct 2016 00:26:59 +0000 (19:26 -0500)]
Expose ld.bfd and ld.gold

It's now expected that ld, ld.bfd, and ld.gold are all installed by
modern binutils.  The -fuse-gold option on GCC depends on it (both from
base and ports) and possibly clang as well.  This work is 6 months old,
but it was never committed as collect2 utility was only recently
built and installed.

Discussed with: dillon (6 months ago).

7 years agoSync zoneinfo database with tzdata2016g from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Thu, 29 Sep 2016 17:39:30 +0000 (19:39 +0200)]
Sync zoneinfo database with tzdata2016g from ftp://ftp.iana.org/tz/releases

* Turkey switched from EET/EEST (+02/+03) to permanent +03,
    effective 2016-09-07.  (Thanks to Burak AYDIN.)  Use "+03" rather
    than an invented abbreviation for the new time.

* New leap second 2016-12-31 23:59:60 UTC as per IERS Bulletin C 52.
    (Thanks to Tim Parenti.)

* For America/Los_Angeles, spring-forward transition times have been
    corrected from 02:00 to 02:01 in 1948, and from 02:00 to 01:00 in
    1950-1966.

* For zones using Soviet time on 1919-07-01, transitions to UT-based
    time were at 00:00 UT, not at 02:00 local time.  The affected
    zones are Europe/Kirov, Europe/Moscow, Europe/Samara, and
    Europe/Ulyanovsk.  (Thanks to Alexander Belopolsky.)

* The Factory zone now uses the time zone abbreviation -00 instead
    of a long English-language string, as -00 is now the normal way to
    represent an undefined time zone.

* Several zones in Antarctica and the former Soviet Union, along
    with zones intended for ships at sea that cannot use POSIX TZ
    strings, now use numeric time zone abbreviations instead of
    invented or obsolete alphanumeric abbreviations.  The affected
    zones are Antarctica/Casey, Antarctica/Davis,
    Antarctica/DumontDUrville, Antarctica/Mawson, Antarctica/Rothera,
    Antarctica/Syowa, Antarctica/Troll, Antarctica/Vostok,
    Asia/Anadyr, Asia/Ashgabat, Asia/Baku, Asia/Bishkek, Asia/Chita,
    Asia/Dushanbe, Asia/Irkutsk, Asia/Kamchatka, Asia/Khandyga,
    Asia/Krasnoyarsk, Asia/Magadan, Asia/Omsk, Asia/Sakhalin,
    Asia/Samarkand, Asia/Srednekolymsk, Asia/Tashkent, Asia/Tbilisi,
    Asia/Ust-Nera, Asia/Vladivostok, Asia/Yakutsk, Asia/Yekaterinburg,
    Asia/Yerevan, Etc/GMT-14, Etc/GMT-13, Etc/GMT-12, Etc/GMT-11,
    Etc/GMT-10, Etc/GMT-9, Etc/GMT-8, Etc/GMT-7, Etc/GMT-6, Etc/GMT-5,
    Etc/GMT-4, Etc/GMT-3, Etc/GMT-2, Etc/GMT-1, Etc/GMT+1, Etc/GMT+2,
    Etc/GMT+3, Etc/GMT+4, Etc/GMT+5, Etc/GMT+6, Etc/GMT+7, Etc/GMT+8,
    Etc/GMT+9, Etc/GMT+10, Etc/GMT+11, Etc/GMT+12, Europe/Kaliningrad,
    Europe/Minsk, Europe/Samara, Europe/Volgograd, and
    Indian/Kerguelen.  For Europe/Moscow the invented abbreviation MSM
    was replaced by +05, whereas MSK and MSD were kept as they are not
    our invention and are widely used.

* Rename Asia/Rangoon to Asia/Yangon, with a backward compatibility link.
    (Thanks to David Massoud.)

* Comments now cite URLs for some 1917-1921 Russian DST decrees.
    (Thanks to Alexander Belopolsky.)

7 years agoAdd HISTORY sections in most sbin/ manual pages.
Sascha Wildner [Thu, 29 Sep 2016 17:10:46 +0000 (19:10 +0200)]
Add HISTORY sections in most sbin/ manual pages.

Submitted-by: Sevan Janiyan
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/2950>

7 years agokernel: Explicitly exclude -flto cflags for genassym.c
zrj [Thu, 29 Sep 2016 14:06:52 +0000 (17:06 +0300)]
kernel: Explicitly exclude -flto cflags for genassym.c

Causes all defines to be detected as 0x0. Try to avoid that. For now
it is unclear why nm(1) output format differs on -flto objects.

7 years agousb4bsd: Fix compilation with -flto.
zrj [Thu, 29 Sep 2016 13:18:11 +0000 (16:18 +0300)]
usb4bsd: Fix compilation with -flto.

usbd_lookup_id_by_uaa() takes const so use const in declaration.
Using -flto caused lto_wrapper to complain about:
error: uftdi_devs causes a section type conflict with urio_devs (TBI).

7 years agocxm(4): Fix type mismatches on firmware variables.
zrj [Thu, 29 Sep 2016 12:59:31 +0000 (15:59 +0300)]
cxm(4): Fix type mismatches on firmware variables.

This one is strange, uses casts to uint32_t.
Add attributes to prototypes too.
While there, switch to __aligned(x) for attributes.

Noticed while playing with -flto on LINT64 kernel configuration.

7 years agokernel/smbfs: Fix type mismatches for smbfs_pbuf_freecnt.
zrj [Thu, 29 Sep 2016 12:35:44 +0000 (15:35 +0300)]
kernel/smbfs: Fix type mismatches for smbfs_pbuf_freecnt.

Mostly used for getpbuf_kva() that takes int*.
Noticed while playing with -flto on LINT64 kernel configuration.

7 years agokernel/adv: Fix extern type to match the real one.
zrj [Thu, 29 Sep 2016 12:00:46 +0000 (15:00 +0300)]
kernel/adv: Fix extern type to match the real one.

Noticed while playing with -flto enabled kernel compilation.

7 years agogcc50: Compile and install collect2 utility.
zrj [Thu, 29 Sep 2016 08:20:33 +0000 (11:20 +0300)]
gcc50: Compile and install collect2 utility.

Enables few extra features and only costs <20s on buildworld time.

7 years ago<sys/cdefs.h> Also add __malloclike to lint case.
zrj [Thu, 29 Sep 2016 05:27:24 +0000 (08:27 +0300)]
<sys/cdefs.h> Also add __malloclike to lint case.

Fixes: $ echo "#include <stdlib.h>" | gcc -Wall -Wextra -Dlint -c -xc -

7 years agokernel - Remove mplock from KTRACE paths
Matthew Dillon [Tue, 27 Sep 2016 21:39:03 +0000 (14:39 -0700)]
kernel - Remove mplock from KTRACE paths

* The mplock is no longer needed for KTRACE, ktrace writes are serialized
  by the vnode lock and everything else is MPSAFE.  Note that this change
  means that even fast system calls may interleave in the ktrace output on
  a multi-threaded program.

* Fix ktrace bug related to vkernels.  The syscall2() code assumes that
  no tokens are held on entry (since we are coming from usermode), but
  a system call made from the vkernel may actually be nested inside
  another syscall2().  The mplock KTRACE held caused this to assert in
  the nested syscall2().  The removal of the mplock from the ktrace path
  also fixes this bug.

* Minor comment adjustment in vm_vmspace.c.

Reported-by: tuxillo
7 years agocpuctl(4): Require write rights for CPUCTL_MSRSBIT and CPUCTL_MSRCBIT.
Imre Vadász [Mon, 26 Sep 2016 23:44:43 +0000 (01:44 +0200)]
cpuctl(4): Require write rights for CPUCTL_MSRSBIT and CPUCTL_MSRCBIT.

* Both CPUCTL_MSRSBIT and CPUCTL_MSRCBIT write MSR registers, so they
  should require write rights like CPUCTL_WRMSR.

7 years agokernel/vmx - Add a missing lwkt_reltoken()
Antonio Huete Jimenez [Mon, 26 Sep 2016 22:45:50 +0000 (00:45 +0200)]
kernel/vmx - Add a missing lwkt_reltoken()

7 years agoif_iwm - Get rid of some more superfluous bus_dmamap_sync calls in rx path.
Imre Vadász [Mon, 26 Sep 2016 20:54:02 +0000 (22:54 +0200)]
if_iwm - Get rid of some more superfluous bus_dmamap_sync calls in rx path.

7 years agokernel - Change IPI recovery watchdog
Matthew Dillon [Mon, 26 Sep 2016 18:09:49 +0000 (11:09 -0700)]
kernel - Change IPI recovery watchdog

* Change the default recovery watchdog timeout for IPIs from 1/16 second
  to 2 seconds and the repeated timeout from 1/2 second to 2 seconds.

* Add missing initialization to pmap_inval_smp_cmpset(), without it an
  improper watchdog timeout/retry could occur.

* This still may not fix issues with VMs when core threads cause extreme
  latencies on the host.

Reported-by: zach
7 years agolibc_r: Tiny adjustment, git add.
zrj [Mon, 26 Sep 2016 10:34:38 +0000 (13:34 +0300)]
libc_r: Tiny adjustment, git add.

Got lost for fdc2e97852d952eedc66a271c9ae1c12f246934b

7 years agolibpthread: Some more adjustments for pthread_attr_setschedpolicy().
Sascha Wildner [Mon, 26 Sep 2016 09:46:01 +0000 (11:46 +0200)]
libpthread: Some more adjustments for pthread_attr_setschedpolicy().

* Adjust libc_r too.

* Remove unneeded braces.

* Adjust manual page.

7 years agoif_iwm - Add support for Firmware paging, needed for newer 8000C firmware.
Imre Vadász [Sun, 25 Sep 2016 00:32:05 +0000 (02:32 +0200)]
if_iwm - Add support for Firmware paging, needed for newer 8000C firmware.

* Uses the IWM_FW_PAGING_BLOCK_CMD firmware command to tell the firmware
  what memory ranges to use for paging.

Taken-From: Linux iwlwifi

7 years agoif_iwm - Move iwm_dma_contig_alloc/_free functions to if_iwm_util.c.
Imre Vadász [Sun, 25 Sep 2016 00:25:37 +0000 (02:25 +0200)]
if_iwm - Move iwm_dma_contig_alloc/_free functions to if_iwm_util.c.

7 years agopthread: Split pthread_exit() to smaller chunks.
zrj [Mon, 19 Sep 2016 10:20:47 +0000 (13:20 +0300)]
pthread: Split pthread_exit() to smaller chunks.

To see what is needed for thread unwind support.

7 years agopthread: Split mutex_init().
zrj [Mon, 19 Sep 2016 09:33:40 +0000 (12:33 +0300)]
pthread: Split mutex_init().

Makes it easier to see what is needed for PTHREAD_PROCESS_SHARED
support, that it is plenty..

7 years agopthread: Prefer explicit return on error.
zrj [Mon, 19 Sep 2016 08:41:17 +0000 (11:41 +0300)]
pthread: Prefer explicit return on error.

Easier to follow the logic.