4 years agosys/vfs/hammer: Remove obsolete code and comments
Tomohiro Kusumi [Tue, 18 Aug 2015 11:32:28 +0000 (20:32 +0900)]
sys/vfs/hammer: Remove obsolete code and comments

from very early stage of hammer development.

4 years agosys/vfs/hammer: Fix wrong function name in kprintf
Tomohiro Kusumi [Wed, 19 Aug 2015 10:05:09 +0000 (19:05 +0900)]
sys/vfs/hammer: Fix wrong function name in kprintf

Use the right name.
Allocating tid isn't always start of transaction.

4 years agosys/vfs/hammer: Add hammer_flush_dirty()
Tomohiro Kusumi [Tue, 18 Aug 2015 13:08:05 +0000 (22:08 +0900)]
sys/vfs/hammer: Add hammer_flush_dirty()

4 years agosys/vfs/hammer: Use HAMMER_OBJID_ROOT for root inode#
Tomohiro Kusumi [Tue, 18 Aug 2015 11:25:04 +0000 (20:25 +0900)]
sys/vfs/hammer: Use HAMMER_OBJID_ROOT for root inode#

instead of hardcoded 1.

4 years agosys/vfs/ufs: Fix typo in variable name
Tomohiro Kusumi [Tue, 18 Aug 2015 11:08:21 +0000 (20:08 +0900)]
sys/vfs/ufs: Fix typo in variable name

4 years agosys/vfs/hammer: Check ronly when overwriting volume header
Tomohiro Kusumi [Tue, 18 Aug 2015 10:11:04 +0000 (19:11 +0900)]
sys/vfs/hammer: Check ronly when overwriting volume header

Check readonly mount before overwriting volume header
with non-NULL data on load/unload.

(hammer volume-add|del ioctls which are the only cases
with non-NULL data do have readonly mount check before
load/unload, so there isn't any issue without ronly==0
but the check should be done here too)

4 years agosys/vfs/hammer: Use either HAMMER: or hammer:
Tomohiro Kusumi [Tue, 18 Aug 2015 10:06:59 +0000 (19:06 +0900)]
sys/vfs/hammer: Use either HAMMER: or hammer:

Should be either of the following.
kprintf("HAMMER: ...\n");
kprintf("hammer: ...\n");

The existing code mostly uses "HAMMER:" so use "HAMMER:".
Assuming no one or no userspace triggers anything via
"hammer:" string in dmesg.

4 years agodrm/linux: Add pci_bus compat structure
zrj [Thu, 13 Aug 2015 06:37:44 +0000 (09:37 +0300)]
drm/linux: Add pci_bus compat structure

4 years agodrm/linux: Expand pdev structure
zrj [Thu, 13 Aug 2015 06:26:52 +0000 (09:26 +0300)]
drm/linux: Expand pdev structure

Will be used to reduce direct dependency on drm functions in radeon.
Also will help a lot when updating drm itself.

4 years agodrm: Really remove the old implementation of list_sort()
François Tigeot [Sat, 22 Aug 2015 15:28:46 +0000 (17:28 +0200)]
drm: Really remove the old implementation of list_sort()

4 years agodrm: Use the NetBSD implementation of list_sort()
François Tigeot [Sat, 22 Aug 2015 13:53:03 +0000 (15:53 +0200)]
drm: Use the NetBSD implementation of list_sort()

* The NetBSD import is more similar to the Linux version and doesn't
  do dynamic memory allocation

* Remove the old incomplete FreeBSD implementation

* It wasn't even using M_DRM with its kmalloc() calls, potentially
  leaking memory

4 years agodrm/linux: Add list_sort() implementation
zrj [Mon, 17 Aug 2015 12:49:08 +0000 (15:49 +0300)]
drm/linux: Add list_sort() implementation

Taken-from: NetBSD

4 years agouipc: Wrap unp test with UNP_ISATTACHED()
Sepherosa Ziehau [Sat, 22 Aug 2015 14:05:18 +0000 (22:05 +0800)]
uipc: Wrap unp test with UNP_ISATTACHED()

4 years agosocket: Allow keeping a reference on the new socket in sonewconn_faddr
Sepherosa Ziehau [Sat, 22 Aug 2015 13:19:38 +0000 (21:19 +0800)]
socket: Allow keeping a reference on the new socket in sonewconn_faddr

It will be used to fix unix socket races.

4 years agodrm: Implement gcd64.h math function
zrj [Sat, 15 Aug 2015 14:26:17 +0000 (17:26 +0300)]
drm: Implement gcd64.h math function

Adapted-from: lib/libc/stdlib/getopt_long.c

4 years agodrm/linux: Implement simple capable() priv helper
zrj [Sun, 16 Aug 2015 09:32:55 +0000 (12:32 +0300)]
drm/linux: Implement simple capable() priv helper

4 years agodrm/linux: Add define for jiffies_64 compat
zrj [Mon, 17 Aug 2015 11:35:11 +0000 (14:35 +0300)]
drm/linux: Add define for jiffies_64 compat

Likely is wrong, but better than nothing

4 years agodrm/linux: Implement atomic64_add/atomic64_sub macros
zrj [Mon, 17 Aug 2015 12:15:54 +0000 (15:15 +0300)]
drm/linux: Implement atomic64_add/atomic64_sub macros

4 years agombintowcr.3: Remove unneeded .Pp
Sascha Wildner [Sat, 22 Aug 2015 08:36:18 +0000 (10:36 +0200)]
mbintowcr.3: Remove unneeded .Pp

4 years agomkregtable: Sync script to Linux v3.14
zrj [Sun, 16 Aug 2015 14:03:48 +0000 (17:03 +0300)]
mkregtable: Sync script to Linux v3.14

This fixes sscanf handling vulnerability

Taken-from: Linux drm/radeon/mkregtable.c

4 years agodrm: const'ify ioctls table (v2)
zrj [Mon, 3 Aug 2015 08:01:17 +0000 (11:01 +0300)]
drm: const'ify ioctls table (v2)

Because, there is no reason for it not to be const.
We never modify the contents of drm_ioctls, so make it const.

4 years agokernel/nfs: Fix up the per-export address lists.
Matthew Dillon [Fri, 21 Aug 2015 21:23:15 +0000 (14:23 -0700)]
kernel/nfs: Fix up the per-export address lists.

* Use a pool token to properly protect access to both the radix
  trees and the mask tree.

* Also free the mask tree when freeing the address list trees.

* Fix a few bugs in the original work (ne_inethead and ne_inet6head
  were not assigned, *prnh not set to NULL on free, and ne_maskhead
  was being unconditionally freed even if it wasn't initialized.

Reported-by: profmakx
Lots-of-help-from: sephe, dillon
Submitted-by: Nuno Antunes <nuno.antunes@gmail.com>
4 years agokernel/acpica: Put back debugger/disassembler code disabling at file level.
Sascha Wildner [Fri, 21 Aug 2015 20:33:10 +0000 (22:33 +0200)]
kernel/acpica: Put back debugger/disassembler code disabling at file level.

Removing those in the last ACPICA upgrade led to too much code going
into the acpi.ko module which is actually only needed when ACPI_DEBUG
is in the config.

Reported-by: profmakx, jh32
4 years agoi386 removal, part 37/x: Remove more i386 related small bits and pieces.
Sascha Wildner [Fri, 21 Aug 2015 16:16:58 +0000 (18:16 +0200)]
i386 removal, part 37/x: Remove more i386 related small bits and pieces.

4 years agosocket: Reorder state setting a little bit in sonewconn_faddr()
Sepherosa Ziehau [Fri, 21 Aug 2015 15:14:10 +0000 (23:14 +0800)]
socket: Reorder state setting a little bit in sonewconn_faddr()

This prevents several possible races.

4 years agosocket: Move accept queues flush into sofree()
Sepherosa Ziehau [Fri, 21 Aug 2015 13:23:10 +0000 (21:23 +0800)]
socket: Move accept queues flush into sofree()

Prepare to fix unix socket races.

4 years agoi386 removal, part 36/x: Remove the i386 specific kgzip(8) utility.
Sascha Wildner [Fri, 21 Aug 2015 15:11:27 +0000 (17:11 +0200)]
i386 removal, part 36/x: Remove the i386 specific kgzip(8) utility.

It was used to compress kernels to be loaded without the loader.

For our standard loader it is enough to just gzip the kernel (i.e.,
create /boot/kernel/kernel.gz). This doesn't work with modules

4 years agoSync ACPICA with Intel's version 20150818.
Sascha Wildner [Fri, 21 Aug 2015 14:25:11 +0000 (16:25 +0200)]
Sync ACPICA with Intel's version 20150818.

* Disassembler and debugger are now standalone components without
  cross-component dependencies.

* Various fixes: BZ 1186, BZ 1192, BZ 1135, BZ 1015, BZ 794, BZ 1176,
  BZ 1185, BZ 1184, BZ 1188, BZ 1190, BZ 1187, BZ 1189, BZ 1191.

* More small fixes without BZ IDs.

* In the debugger, "objects" without arguments now displays a summary
  of the current namespace objects.

* In acpinames(8), the new -x option can be used to set the debug level,
  just like in acpiexec(8).

* aapits test has been removed.

4 years agokernel - Fix several low memory+swap pageout/killproc issues
Matthew Dillon [Thu, 20 Aug 2015 23:45:27 +0000 (16:45 -0700)]
kernel - Fix several low memory+swap pageout/killproc issues

* Add significant slop to the PQAVERAGE() calculation in the
  pageout daemon and increase the slop in the vm_paging_target()
  test the pageout daemon makes to determine if it can stop early.

  These adjustments fix a degenerate case when no swap is configured
  and a large number of clean pages are present in the inactive queue
  which could prevent the pageout daemon from cleaning a sufficient number
  of pages and cause it to start killing processes even when plenty of
  freeable memory exists.

* Impose a one-second delay when killing processes due to insufficient
  memory + swap.  This reduces the chance that multiple processes will
  be killed even if the first one would have been sufficient by giving
  the kernel more time to dipose of the process.

* Fix a bug in vm_page_alloc().  When v_free_count exactly matches
  v_free_reserved it successfully passes the vm_page_count_target()
  test but vm_page_alloc() will still fail.  This results in a livelock
  in vm_fault_object() and will livelock the pageout daemon vs a user
  process stuck in vm_fault(), causing the machine to lock.

  Fixed by adjusting the conditional test in vm_page_alloc().

Reported-by: luxh
4 years agolgamma.3: There is no lgammal_r() function in libm.
Sascha Wildner [Thu, 20 Aug 2015 21:19:56 +0000 (23:19 +0200)]
lgamma.3: There is no lgammal_r() function in libm.

4 years agolibc/regex: Fix up the regex upgrade.
Sascha Wildner [Thu, 20 Aug 2015 20:33:12 +0000 (22:33 +0200)]
libc/regex: Fix up the regex upgrade.

* Fix typo in 3 function names: s/regnw/regwn/.

* Add missing overriding #defines for 4 further functions to <regex.h>.

4 years ago<math.h>: Fix visibility of scalb(), which was removed from Issue 7.
Sascha Wildner [Thu, 20 Aug 2015 16:59:20 +0000 (18:59 +0200)]
<math.h>: Fix visibility of scalb(), which was removed from Issue 7.

4 years agologb.3: There is no scalbl() function in libm.
Sascha Wildner [Thu, 20 Aug 2015 16:47:32 +0000 (18:47 +0200)]
logb.3: There is no scalbl() function in libm.

4 years agovkernel.7: Sort -d alphabetically.
Sascha Wildner [Thu, 20 Aug 2015 11:45:08 +0000 (13:45 +0200)]
vkernel.7: Sort -d alphabetically.

4 years agombintowcr.3: Add missing types.
Sascha Wildner [Thu, 20 Aug 2015 11:43:56 +0000 (13:43 +0200)]
mbintowcr.3: Add missing types.

4 years agoprocctl.2: Clean up a bit.
Sascha Wildner [Thu, 20 Aug 2015 11:43:54 +0000 (13:43 +0200)]
procctl.2: Clean up a bit.

4 years agonetinet{,6}: Assert in{,6}_inithead() are only used for system routing tables.
Nuno Antunes [Wed, 19 Aug 2015 07:46:07 +0000 (15:46 +0800)]
netinet{,6}: Assert in{,6}_inithead() are only used for system routing tables.

Suggested-by: sephe
4 years agokernel/nfs: Remove old hack abusing dom_rtattach.
Nuno Antunes [Wed, 19 Aug 2015 04:55:21 +0000 (12:55 +0800)]
kernel/nfs: Remove old hack abusing dom_rtattach.

* Mostly obtained from FreeBSD. Here's the relevant part of the
  original commit message.

    According to IANA RPC uaddr registry, there are no AFs
    except IPv4 and IPv6, so it's not worth being too abstract here.

    Remove ne_rtable[AF_MAX+1] and use explicit per-AF radix tries.
    Use own initialization without relying on domattach code.

    While I admit that this was one of the rare places in kernel
    networking code which really was capable of doing multi-AF
    without any AF-depended code, it is not possible anymore to
    rely on dom* code.

* Give netexports their own mask radix tree.

Reviewed-by: sephe, dillon
Tested-by: dillon
4 years agoqueue: Log 'last' ptr in addition to 'head'
Sepherosa Ziehau [Wed, 19 Aug 2015 12:53:23 +0000 (20:53 +0800)]
queue: Log 'last' ptr in addition to 'head'

4 years agosocket: Assert SS_{INCOMP,COMP} before deq/enq so_{comp,incomp}
Sepherosa Ziehau [Wed, 19 Aug 2015 12:51:43 +0000 (20:51 +0800)]
socket: Assert SS_{INCOMP,COMP} before deq/enq so_{comp,incomp}

Suggested-by: dillon@
4 years agosocket: Don't define SS_ISCLOSING same as SS_INCOMP
Sepherosa Ziehau [Wed, 19 Aug 2015 12:50:25 +0000 (20:50 +0800)]
socket: Don't define SS_ISCLOSING same as SS_INCOMP

4 years agoiasl.8: Clarify the -in option a bit better.
Sascha Wildner [Wed, 19 Aug 2015 20:25:41 +0000 (22:25 +0200)]
iasl.8: Clarify the -in option a bit better.

4 years agofdisk(8): Raise WARNS to 6 and fix warnings.
Sascha Wildner [Wed, 19 Aug 2015 20:17:40 +0000 (22:17 +0200)]
fdisk(8): Raise WARNS to 6 and fix warnings.

4 years agoboot - Fix CD booting
Matthew Dillon [Wed, 19 Aug 2015 19:23:26 +0000 (12:23 -0700)]
boot - Fix CD booting

* Recent changes to move the loader's heap to high-memory broke the
  CD I/O code due to being beyond the BIOS'es segmentation range.  The
  HDD code was already using bounce buffers, but the CD code was not.

* Adjust the CD I/O code to use bounce buffers too.

Reported-by: numerous.
Testing-by: swildner
4 years agocorepower.4: Explain what the package power usage value means.
Imre Vadász [Tue, 18 Aug 2015 20:40:02 +0000 (22:40 +0200)]
corepower.4: Explain what the package power usage value means.

4 years agopowerd: Restore backlight when powerd exits
Sepherosa Ziehau [Mon, 17 Aug 2015 12:46:10 +0000 (20:46 +0800)]
powerd: Restore backlight when powerd exits

4 years agoinet6: Limit the # of fragments in addition to the # of fragmented packets
Sepherosa Ziehau [Mon, 17 Aug 2015 12:38:59 +0000 (20:38 +0800)]
inet6: Limit the # of fragments in addition to the # of fragmented packets

Obtained-from: KAME via FreeBSD

4 years agoinet6: Send initial NS in a timely fashion.
Sepherosa Ziehau [Mon, 17 Aug 2015 12:31:01 +0000 (20:31 +0800)]
inet6: Send initial NS in a timely fashion.

The call of nd6_rtrequest() in nd6_output() sets the newly created
neighbor cache entry expire to time_uptime, which prevents the NS
output at the end of nd6_output().  Though the NS will be sent when
the neighbor cache times out, it will cause large delay (0~1s).

4 years agondp: Fix neighbor cache entry expire time logging
Sepherosa Ziehau [Mon, 17 Aug 2015 12:27:51 +0000 (20:27 +0800)]
ndp: Fix neighbor cache entry expire time logging

4 years agokernel/vmm: Use "(a & b) == 0" instead of "!(a & b)".
Sascha Wildner [Mon, 17 Aug 2015 18:58:59 +0000 (20:58 +0200)]
kernel/vmm: Use "(a & b) == 0" instead of "!(a & b)".

Poked-by: dillon
4 years agokernel/vmm: Use __func__ and adjust whitespace.
Sascha Wildner [Mon, 17 Aug 2015 18:46:03 +0000 (20:46 +0200)]
kernel/vmm: Use __func__ and adjust whitespace.

4 years agokernel/vmm: Untangle a too deeply nested if/else.
Sascha Wildner [Mon, 17 Aug 2015 17:23:18 +0000 (19:23 +0200)]
kernel/vmm: Untangle a too deeply nested if/else.

Get rid of if/goto/else cases. Check errors first and return early where

4 years ago<sys/vmm.h>: Fix include guard and adjust indent/whitespace a bit.
Sascha Wildner [Mon, 17 Aug 2015 17:02:24 +0000 (19:02 +0200)]
<sys/vmm.h>: Fix include guard and adjust indent/whitespace a bit.

4 years agokernel/hammer: Simplify an if/goto/else construct.
Sascha Wildner [Mon, 17 Aug 2015 16:45:48 +0000 (18:45 +0200)]
kernel/hammer: Simplify an if/goto/else construct.

4 years agosys/vfs/hammer: Cleanups
Tomohiro Kusumi [Sun, 16 Aug 2015 23:26:35 +0000 (08:26 +0900)]
sys/vfs/hammer: Cleanups

Remaining minor ones.

4 years agosys/vfs/hammer: Cleanup volume-add|del ioctl [3/3]
Tomohiro Kusumi [Sun, 16 Aug 2015 13:31:54 +0000 (22:31 +0900)]
sys/vfs/hammer: Cleanup volume-add|del ioctl [3/3]

This commit is 3/3 of a series of commits that extract
common procedures on updating volumes header into a function.

Add hammer_update_volumes_header().

4 years agosys/vfs/hammer: Cleanup volume-add|del ioctl [2/3]
Tomohiro Kusumi [Sun, 16 Aug 2015 13:28:48 +0000 (22:28 +0900)]
sys/vfs/hammer: Cleanup volume-add|del ioctl [2/3]

This commit is 2/3 of a series of commits that extract
common procedures on updating volumes header into a function.

Changing bigblock_stat fields to signed is ok (or even better)
since the original ondisk fields are int64_t.

4 years agosys/vfs/hammer: Cleanup volume-add|del ioctl [1/3]
Tomohiro Kusumi [Sun, 16 Aug 2015 11:30:29 +0000 (20:30 +0900)]
sys/vfs/hammer: Cleanup volume-add|del ioctl [1/3]

This commit is 1/3 of a series of commits that extract
common procedures on updating volumes header into a function.

Reordering hammer_format_freemap() and updating volume count
doesn't affect behavior of volume-add since it's independent
of each other. Also note that these all must succeed anyway
as assertions show.

4 years agosys/vfs/hammer: Remove duplicated vfs code
Tomohiro Kusumi [Sun, 16 Aug 2015 05:05:55 +0000 (14:05 +0900)]
sys/vfs/hammer: Remove duplicated vfs code

Much of the code in sys/vfs/hammer/hammer_volume.c is taken
from the existing code, and some of them could be integrated
into mainstream hammer code. This commit does that without
messing up interface or making functional changes.

This greatly reduces and simplifies code, and also gets rid
of extra (and unnecessary) vfs open/close operations that
existed only to initialize or erase volume header while in
kernel space on ioctl.

4 years agosbin/hammer: Fix hammer show output format
Tomohiro Kusumi [Sat, 15 Aug 2015 07:54:36 +0000 (16:54 +0900)]
sbin/hammer: Fix hammer show output format

Sync with formats of other fields.

4 years agohammer: Cleanups
Tomohiro Kusumi [Fri, 14 Aug 2015 03:12:59 +0000 (12:12 +0900)]
hammer: Cleanups

Unfold lines (that aren't intentionally separated
into different lines) that fit in 80 chars.

Fold lines that are way too long.

4 years agohammer: Conform to style(9)
Tomohiro Kusumi [Wed, 12 Aug 2015 10:36:39 +0000 (19:36 +0900)]
hammer: Conform to style(9)

* Remove header includes that are already included by
  common hammer headers (of either userspace or kernel).
* Add "#include <sys/vnode.h>" to sys/vfs/fifofs/fifo.h.

4 years agosys/gnu/vfs/ext2fs: Remove unused ioctl call and variables
Tomohiro Kusumi [Tue, 11 Aug 2015 23:24:22 +0000 (08:24 +0900)]
sys/gnu/vfs/ext2fs: Remove unused ioctl call and variables

In addition to 30b14d35.
(Also see r98542 and r104697 of FreeBSD)

4 years agosys/vfs/ufs: Remove unused ioctl call and variables
Tomohiro Kusumi [Tue, 11 Aug 2015 23:22:46 +0000 (08:22 +0900)]
sys/vfs/ufs: Remove unused ioctl call and variables

Similar to 30b14d35.
(Also see r98542 and r104697 of FreeBSD)

4 years agosbin/hammer: Add init_boot|mem_area_size()
Tomohiro Kusumi [Tue, 11 Aug 2015 21:00:52 +0000 (06:00 +0900)]
sbin/hammer: Add init_boot|mem_area_size()

Integrate copy-pasted code by 6f3076af into functions.

4 years agosys/vfs/hammer: Cleanup volume# iteration
Tomohiro Kusumi [Tue, 11 Aug 2015 10:24:22 +0000 (19:24 +0900)]
sys/vfs/hammer: Cleanup volume# iteration

if (volume == NULL && error == ENOENT) {...
can be removed since now that vol_no must exist.

If error==ENOENT and hits the assertion right after this,
then the code has a bug.

4 years agosys/vfs/hammer: Fix wrong function name in kprintf
Tomohiro Kusumi [Mon, 10 Aug 2015 10:27:07 +0000 (19:27 +0900)]
sys/vfs/hammer: Fix wrong function name in kprintf

It used to be "hammer_mountroot" according to 104cb849.
"hammer_mount" still isn't name of a function, but this
is what other kprintfs around here use.

4 years agosys/vfs/hammer: Fix inconsistent function prototypes
Tomohiro Kusumi [Sun, 9 Aug 2015 21:07:15 +0000 (06:07 +0900)]
sys/vfs/hammer: Fix inconsistent function prototypes

Should use either of the type name or typedef'd name
for both function prototype and the function itself.

(hammer mostly uses hammer_mount_t rather than struct
hammer_mount in this case)

4 years agosys/vfs/hammer: Avoid volume# inconsistency on mount
Tomohiro Kusumi [Sun, 9 Aug 2015 19:35:41 +0000 (04:35 +0900)]
sys/vfs/hammer: Avoid volume# inconsistency on mount

hammer_vfs_mount() should check and compare # of volumes
to mount (# of volumes in mount_hammer arg in blkdevs format)
and vol_count field in volume header.

mount_hammer should fail if they don't match even if it's
technically possible to mount at the moment after newfs.

In the following Example1, it's possible to safely mount
/dev/da1 without /dev/da2:/dev/da3 or
/dev/da1:/dev/da2 without /dev/da3 or
/dev/da1:/dev/da3 without /dev/da2 at this point because
both /dev/da2 and /dev/da3 has no data (only layer2 big-block)
right after newfs_hammer, however if filesystem has enough
data that zone2 next_offset has already reached the missing
volume before unmount, there is going to be inconsistency
between blockmap and actual mounted volumes, which results
in kernel panic. mount needs to avoid this by checking #
of volumes as the Example2 shows.

Example 1. - newfs 3 volumes and then mount 2 volumes
  # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 > /dev/null
  # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER
  # mount | grep /HAMMER
  TEST on /HAMMER (hammer, local)
  # hammer volume-blkdevs /HAMMER
  # umount /HAMMER
  # mount_hammer /dev/da1:/dev/da2 /HAMMER
  # mount | grep /HAMMER
  TEST on /HAMMER (hammer, local)
  # hammer volume-blkdevs /HAMMER

Example 2. - with this commit it fails to mount
  # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 > /dev/null
  # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER
  # mount | grep /HAMMER
  TEST on /HAMMER (hammer, local)
  # hammer volume-blkdevs /HAMMER
  # umount /HAMMER
  # mount_hammer /dev/da1:/dev/da2 /HAMMER
  mount_hammer: Unknown error: Invalid argument
  # dmesg | tail -1
  hammer_mount: volume header says 3 volumes, but 2 installed
  # mount_hammer /dev/da1 /HAMMER
  mount_hammer: Unknown error: Invalid argument
  # dmesg | tail -1
  hammer_mount: volume header says 3 volumes, but 1 installed

4 years agosys/vfs/hammer: Fix error check on mount
Tomohiro Kusumi [Sun, 9 Aug 2015 18:16:24 +0000 (03:16 +0900)]
sys/vfs/hammer: Fix error check on mount

Since it already has failed: that does the same thing,
goto failed; on each error case makes code more clear.

Remove error==0 from the first if() conditional since
error isn't 0 when hmp->rootvol==NULL.

4 years agosys/vfs/hammer: Fix comments
Tomohiro Kusumi [Mon, 17 Aug 2015 10:58:14 +0000 (19:58 +0900)]
sys/vfs/hammer: Fix comments

These functions return 1 or 0, but not TRUE or FALSE macros.
(there are also existing comments that use 1/0)

4 years agohammer: Fix unusual line break style
Tomohiro Kusumi [Sun, 9 Aug 2015 16:46:59 +0000 (01:46 +0900)]
hammer: Fix unusual line break style

4 years agosys/vfs/hammer: Fix volume-del issue with >1 pfs
Tomohiro Kusumi [Sun, 9 Aug 2015 03:29:12 +0000 (12:29 +0900)]
sys/vfs/hammer: Fix volume-del issue with >1 pfs

Since 5e1e1454 hammer reblock supports a new option that
can reblock all pfses within filesystem.

hammer volume-del needs to use this when it finds the volume
not empty and needs to reblock. Otherwise it only reblocks a
single pfs (pfs 0 in this case) and may end up ignoring data
in other pfses that should have been reblocked from that volume
(remember that pfs has nothing to do with which volume pfs
data/inodes/etc are stored in).

As the following examples show, hammer volume-del results in
failure if the above situation occurs. It fails because data
in non-pfs0 remains in that volume without being reblocked.
If one is lucky that the volume doesn't have non-pfs0 data,
then hammer volume-del won't fail even without allpfs=1 set
(of course given that the whole filesystem has enough space
for reblock to succeed).

Create filesystem that consists of 3 volumes and >1 pfses.
The root volume can't be removed, so fill up non-zero pfses
till it gets to the second volume while keeping enough space
for reblock to succeed. Then try to remove a non-root volume
that isn't empty which is /dev/da2 in this case.

  # hammer volume-blkdevs /HAMMER
  /dev/da1:/dev/da2:/dev/da3    /* /dev/da1 is root volume */
  # ls -l /HAMMER               /* data exists in pfs 1 to 12 */
  total 0
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:24 master1 -> @@-1:00001
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:31 master10 -> @@-1:00010
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:32 master11 -> @@-1:00011
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:33 master12 -> @@-1:00012
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:25 master2 -> @@-1:00002
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:26 master3 -> @@-1:00003
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:27 master4 -> @@-1:00004
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:28 master5 -> @@-1:00005
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:29 master6 -> @@-1:00006
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:29 master7 -> @@-1:00007
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:30 master8 -> @@-1:00008
  lrwxr-xr-x  1 root  wheel  10 Aug  9 13:31 master9 -> @@-1:00009
  # df -Th /HAMMER
  Filesystem  Type     Size   Used  Avail Capacity  Mounted on
  TEST        hammer   334G   118G   216G    35%    /HAMMER
  # hammer -f /dev/da1:/dev/da2:/dev/da3 blockmap | grep -A2 layer1
    layer1 4000000000000000 @2000000000800000 blocks-free 0
          4000000000000000 zone=4  app=8388608 free=0
          4000000000800000 zone=4  app=8388608 free=0
    layer1 4010000000000000 @2010000000000000 blocks-free 13449
          4010000000000000 zone=4  app=8388608 free=0
          4010000000800000 zone=10 app=8388608 free=0
    layer1 4020000000000000 @2020000000000000 blocks-free 14268
          4020000000000000 zone=4  app=8388608 free=0
          4020000000800000 zone=0  app=0       free=8388608
/* /dev/da1 is 100% used,
   /dev/da2 is partially used,
   /dev/da3 is 0% used */

Example 1. - without allpfs=1 fails in a second because
there isn't really anything it can do as there's no data
in pfs0 except for some inodes and btree nodes, etc.
  # time hammer volume-del /dev/da2 /HAMMER
  hammer volume-del ioctl: Device busy

  real    0m0.017s
  user    0m0.000s
  sys     0m0.000s
  # dmesg | tail -2
  reblock started
  Failed to free volume: Volume 1 not empty

Example 2. - this commit with allpfs=1 takes 15 min because
it reblocks all the data in all pfses (mostly from non-pfs0),
but successfully removes /dev/da2.
  # time hammer volume-del /dev/da2 /HAMMER

  real    15m7.664s
  user    0m0.000s
  sys     7m36.270s
  # hammer volume-blkdevs /HAMMER

4 years agosys/vfs/hammer: Add (missing)debug print for data reblock
Tomohiro Kusumi [Sun, 9 Aug 2015 02:34:15 +0000 (11:34 +0900)]
sys/vfs/hammer: Add (missing)debug print for data reblock

Add debug kprintf for data reblock since leaf/internal
node have it in the same format as this.

Also add "%08x",elm->base.localization to above and the
existing debug kprintfs.

4 years agocorepower(4): Sensor for Intel CPUs' power usage via the RAPL MSRs
Imre Vadász [Mon, 17 Aug 2015 07:53:19 +0000 (09:53 +0200)]
corepower(4): Sensor for Intel CPUs' power usage via the RAPL MSRs

4 years agosensors: Add SENSOR_WATTS support to sysctl(8) and systat(1)
Imre Vadász [Mon, 17 Aug 2015 07:52:47 +0000 (09:52 +0200)]
sensors: Add SENSOR_WATTS support to sysctl(8) and systat(1)

4 years agoinet: Don't accept fragments if maxfragsperpacket is 0.
Sepherosa Ziehau [Sun, 16 Aug 2015 14:26:59 +0000 (22:26 +0800)]
inet: Don't accept fragments if maxfragsperpacket is 0.

Obtained-from: FreeBSD

4 years agopowerd: Set backlight to the specified value, if AC line is unplugged.
Sepherosa Ziehau [Sun, 16 Aug 2015 13:22:35 +0000 (21:22 +0800)]
powerd: Set backlight to the specified value, if AC line is unplugged.

4 years agoUTF-8 locales: Change all to use single master CTYPE file
John Marino [Sun, 16 Aug 2015 22:58:10 +0000 (00:58 +0200)]
UTF-8 locales: Change all to use single master CTYPE file

The xx_Comm_US locale has been removed.  It's CTYPE file has moved
to en_US.UTF-8, and all other UTF-8 locales' CTYPE links to it.

The non-UTF8 locales remain essentially the same.  They have tailored
CTYPES per the CLDR definition, just as before.

4 years agolocale gen tools: Set all UTF-8 to same rollup CTYPE
John Marino [Sun, 16 Aug 2015 22:54:44 +0000 (00:54 +0200)]
locale gen tools: Set all UTF-8 to same rollup CTYPE

The CLDR CTYPE definitions are still used for non-UTF8 encodings,
but all UTF-8 locales now share a single "master" CTYPE that knows
all reasonable character sets.

4 years agolocale - Add two new API functions
Matthew Dillon [Sun, 16 Aug 2015 22:03:03 +0000 (15:03 -0700)]
locale - Add two new API functions

* Add wcrtombin() and mbintowcr(), powerful buffer-to-buffer functions
  to translate UTF8, which can also perform escaping and de-escaping,
  allow legacy parsing, and do checks with varying levels of strictness.

  NOTE: If no locale or "C" locale, these functions are 1:1 (do not do
UTF8 processing).  A UTF8 locale must be used to access these

* Add wcrtoutf8() and utf8towcr().  These work exactly the same as
  the above functions but are locale-agnostic.  They always operate in
  UTF8 and locale initialization is not necessary.

* Escaping and de-escaping for 8-bit-clean round-trips with two of the

* Can construct UTF8B from unescaped 8-bit-clean data, can deconstruct
  UTF8B (restore the original clean data), and can also be flagged
  generically to take already-escaped UTF8B or wchars as input.

* Can be used to perform strict checks.

* Very powerful incremental buffer validation and processing capabilities.
  Far more visibility to the caller rather than hiding state in a tracking
  state structure.  No tracking state structure.

* Does not do idiotic nul buffer termination.  Caller passes explicitly
  sized data, can opt to include or not include a terminator (depending
  on what is desired), and the byte buffers can contain any 8-bit code
  including 0x00.

4 years agorollup UTF-8: Manually add NO-BREAK_SPACE
John Marino [Sun, 16 Aug 2015 20:46:22 +0000 (22:46 +0200)]
rollup UTF-8: Manually add NO-BREAK_SPACE

Move this definition from cldr2def to manual UTF8 definition.
It was omitted in the first draft accidentally.

4 years agoUpdate common UTF-8 src file with generated one.
John Marino [Sun, 16 Aug 2015 19:12:59 +0000 (21:12 +0200)]
Update common UTF-8 src file with generated one.

4 years agoAdd locale tool to generate "rollup" UTF-8 src file
John Marino [Sun, 16 Aug 2015 19:06:50 +0000 (21:06 +0200)]
Add locale tool to generate "rollup" UTF-8 src file

The first version of the "common" UTF-8 file was hand-assembled by myself.
This is obviously prone to error and is very hard to maintain (the
previous incarnation was never maintained; not once after it was added).

To address these issues, create a new tool (using cldr2def as inspiration)
to create a composite UTF-8 source files using all available POSIX input
from CLDR.  What can't be generated still comes from a manual fragment
that is added to the common source file at the end.

This allows periodic maintenance when CLDR issues new releases.  We are
converging on using this composite (aka "rollup") file for all UTF-8

4 years agoutf8.c: Fix second error of two-line patch
John Marino [Sun, 16 Aug 2015 18:49:12 +0000 (20:49 +0200)]
utf8.c: Fix second error of two-line patch


4 years agokernel/iwn: Grab the WLAN serializer around ieee80211_ifdetach()
Johannes Hofmann [Sun, 16 Aug 2015 11:46:22 +0000 (13:46 +0200)]
kernel/iwn: Grab the WLAN serializer around ieee80211_ifdetach()

This fixes a panic on kldunload.

4 years agoutf8.c: Fix typo
John Marino [Sun, 16 Aug 2015 08:11:21 +0000 (10:11 +0200)]
utf8.c: Fix typo

reported-by: Yellow Rabbit

4 years agolibc/locale: limit utf8 illegal input detection to 10FF FFFF
John Marino [Sun, 16 Aug 2015 07:51:02 +0000 (09:51 +0200)]
libc/locale: limit utf8 illegal input detection to 10FF FFFF

This had been mostly done but we missed these two changes.

Discovered-by: dillon
4 years agoAdd 6 Arabic locales: AE EG JO MA QA SA
John Marino [Sat, 15 Aug 2015 15:11:11 +0000 (17:11 +0200)]
Add 6 Arabic locales: AE EG JO MA QA SA

The lack of Arabic support on BSD seems to be a glaring omission, so
lets help rectify that by adding since 6 locales:
ar_AE: United Arab Emirates
ar_EG: Egypt
ar_JO: Jordan
ar_MA: Morocco
ar_QA: Qatar
ar_SA: Saudi Arabia

There are obviously more (e.g. Iraq, Kuwait, Algeria, Libya, Tunisia,
Syria, etc.) but I selected these as being the most likely to be
used in my limited opinion.

They are UTF-8 locales only. Most of them are identical to ar_SA except
for the monetary definitions (each has a different currency)

4 years agocldr2def: Add 6 Arabic locales: AE EG JO MA QA SA
John Marino [Sat, 15 Aug 2015 14:52:20 +0000 (16:52 +0200)]
cldr2def: Add 6 Arabic locales: AE EG JO MA QA SA

The lack of Arabic support on BSD seems to be a glaring omission, so
lets help rectify that by adding since 6 locales to the cldr2def tool:
ar_AE: United Arab Emirates
ar_EG: Egypt
ar_JO: Jordan
ar_MA: Morocco
ar_QA: Qatar
ar_SA: Saudi Arabia

There are obviously more (e.g. Iraq, Kuwait, Algeria, Libya, Tunisia,
Syria, etc.) but I selected these as being the most likely to be
used in my limited opinion.

They are UTF-8 locales only.

4 years agoctypedef: Replace entire "print" sections with one element
John Marino [Sat, 15 Aug 2015 13:10:32 +0000 (15:10 +0200)]
ctypedef: Replace entire "print" sections with one element

With a recent change to localedef, the "print" section became completely
redundant.  Since it can consume several hundred thousand bytes, removing
it makes the ctype src files much smaller, usually by 33% - 50%.

However, non-breaking spaces have not been previously defined despite
being used in monetary definitions. To correct this mistake, the
non-breaking space has been introduced to ctype as a printable blank
character.  Localedef considers "blanks" as "spaces" so there is no need
to explicitly define this as a space as well.

4 years agocldr2def: Slim down ctype src files
John Marino [Sat, 15 Aug 2015 13:04:22 +0000 (15:04 +0200)]
cldr2def: Slim down ctype src files

I originally modified the tool to use "ranges" to define the CTYPE,
e.g. "<a>;...;<z>" rather than "<a>;<b>;<c> ... <z>".  This worked
great on UTF-8 but converting to other encodings is not supported
because part of the range may not exist, or the upper boundary may
come before the lower boundary in the target encoding.  Thus I had
to remove that work, but I was able to retain the removal of the now
redundant "print" section.

I confirmed that the output without "print" section was identical to
before, and then I added back "print" section with a single element:
NO-BREAK_SPACE. This character is used in quite a few monetary
defintions, but it was never mapped to CTYPE, which I believe is a
mistake.  NO-BREAK_SPACE is also defined as a blank, which is considered
a space as well by localedef tool (so there's no need to also define a
"space" section").

The net change is multibyte encodings now have non-breaking spaces
1) recognized and 2) defined as printable.

4 years agolocaledef(1): eliminate need for "print" definition
John Marino [Sat, 15 Aug 2015 12:03:22 +0000 (14:03 +0200)]
localedef(1): eliminate need for "print" definition

By having space automatically classified as "print" type, we can
eliminate the print section from ctype src files completely (they
are just "graph" plus "<space>".

4 years agoinet6: Set rtentry properly in nd6_output()
Sepherosa Ziehau [Sat, 15 Aug 2015 12:34:39 +0000 (20:34 +0800)]
inet6: Set rtentry properly in nd6_output()

4 years agoinet6/nd6: Join and leave solicited node mcast group once on cpu0
Sepherosa Ziehau [Sat, 15 Aug 2015 08:58:46 +0000 (16:58 +0800)]
inet6/nd6: Join and leave solicited node mcast group once on cpu0

4 years agoinet/arp: Announce proxied ARP once on cpu0
Sepherosa Ziehau [Sat, 15 Aug 2015 08:58:18 +0000 (16:58 +0800)]
inet/arp: Announce proxied ARP once on cpu0

4 years agoinet6: Dispatch mcast routing expire upcalls to netisr0 to run
Sepherosa Ziehau [Sat, 15 Aug 2015 08:35:46 +0000 (16:35 +0800)]
inet6: Dispatch mcast routing expire upcalls to netisr0 to run

4 years agoinet6: Dispatch route timeouts to netisr to run
Sepherosa Ziehau [Sat, 15 Aug 2015 08:03:53 +0000 (16:03 +0800)]
inet6: Dispatch route timeouts to netisr to run

While I'm here, remove unnecessary crit sections.

4 years agoinet6: Avoid excessive calling of in6_addr2zoneid()
Sepherosa Ziehau [Sat, 15 Aug 2015 03:47:01 +0000 (11:47 +0800)]
inet6: Avoid excessive calling of in6_addr2zoneid()

Obtained-from: FreeBSD

4 years agoUpdate the pciconf(8) database.
Sascha Wildner [Sat, 15 Aug 2015 11:13:41 +0000 (13:13 +0200)]
Update the pciconf(8) database.

July 31, 2015 snapshot from http://pciids.sourceforge.net/