dragonfly.git
8 years agosys/vfs/hammer: Temporary fix for kernel panic on volume-del
Tomohiro Kusumi [Sun, 20 Mar 2016 20:46:53 +0000 (05:46 +0900)]
sys/vfs/hammer: Temporary fix for kernel panic on volume-del

This is a temporary fix for a known race issue mentioned in
http://lists.dragonflybsd.org/pipermail/kernel/2015-August/175027.html

It may be replaced with a better alternative in the future.

The next commit also needs this, otherwise it's not guaranteed
that ondisk buffers are written back to the backing storage.

8 years agokernel - Fix ig4 operation for certain machines
Matthew Dillon [Mon, 21 Mar 2016 18:33:54 +0000 (11:33 -0700)]
kernel - Fix ig4 operation for certain machines

* Some machine BIOSes use the I2C bus and leave it in a state that causes
  interrupts to not work properly due to a pending interrupt having been
  latched.

* Refactor the code a bit to clear pending interrupts when I2C is enabled.
  This fixes the primary problem.

* Also fix a possible race condition in the interrupt handler where the
  interrupt was being cleared after reading the status instead of before.

8 years agoAdd -march support for CCVER=clang* (new bsd.cpu.clang.mk)
John Marino [Mon, 21 Mar 2016 17:56:50 +0000 (18:56 +0100)]
Add -march support for CCVER=clang* (new bsd.cpu.clang.mk)

8 years agokernel/pc64: Improve EFI framebuffer mapping.
Imre Vadasz [Sun, 20 Mar 2016 20:44:24 +0000 (21:44 +0100)]
kernel/pc64: Improve EFI framebuffer mapping.

* Do a proper pmap_mapdev_attr() via SYSINIT after early boot stuff is
  finished.

* Make sure the EFI framebuffer is covered by the direct map, when using
  PHYS_TO_DMAP to access the framebuffer as early as possible.
  If it isn't covered by the direct memory map, the framebuffer will later
  be properly mapped via pmap_mapdev_attr() anyway.

8 years agoImport framework to build base clang (version 3.8.0)
John Marino [Sun, 20 Mar 2016 21:07:44 +0000 (22:07 +0100)]
Import framework to build base clang (version 3.8.0)

This commit has two major components:

1) Set of tools to generate makefiles from LLVM's CMake data.
   It greatly assists upgrading base clang from release to release

2) A new directory <root>/llvm_clang that will build and install
   clang.  It is not hooked into the world build yet.

The process for building clang is described in
tools/tools/llvm_generator/README.  Basically the llvm source needs
to be symlinked to contrib/llvm after applying one patch, and then
it can be manually built and installed (and accessible via CCVER and
WORLD_CCVER).

It will not be hooked until the build until clang-built kernel modules
load properly (they load via kldload but not during boot).  This was
last tested a few months ago on an llvm-38 dev branch using the customcc
functionality.  clang-built worlds and kernels using clang 3.8.0 have
not been tested yet.  This commit is meant to facilitate testing and
resolution of any issues with clang.

It was necessary to temporarily modify objformat to enable
WORLD_CCVER=clang to build the world.  This modication will be removed
once clang officially replaces gcc47.

8 years agoSync ACPICA with Intel's version 20160318.
Sascha Wildner [Sun, 20 Mar 2016 19:07:56 +0000 (20:07 +0100)]
Sync ACPICA with Intel's version 20160318.

* Arbitrary bit length and offset support for registers defined by the
  Generic Address Structure.

* ASL's Concatenate operator now allows any ACPI object to be passed
  as an operand.

* Added "const" across the source.

* Various fixes and additions.

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

Tested-by: ivadasz, tkusumi
8 years agosys/vfs/hammer: Fix bug on erasing volume header
Tomohiro Kusumi [Sun, 20 Mar 2016 09:09:28 +0000 (18:09 +0900)]
sys/vfs/hammer: Fix bug on erasing volume header

deabdbfb in 2015 had a bug in hammer volume-del ioctl which didn't
completely erase the volume header. hammer_ioc_volume_del() needed
to declare an ondisk volume variable instead of a pointer.

Having a pointer here caused bzero against the pointer itself
(within kernel stack of hammer volume-del), and then clear ondisk
volume header using kernel stack image.

The following [A] shows the volume deleted by hammer volume-del
has kernel stack itself for sizeof(struct hammer_volume_ondisk) bytes
which is 1928 bytes. It should be like [B] where 0-1928 bytes are
zero filled. [A] actually happens to erase the filesystem signature
(HAMMER_FSBUF_VOLUME) located at the first 8 bytes of the header
since it equals pointer size in x86_64, but it needs to properly
zero clear the whole header (1928 bytes) for security reason.

  [A] Before this commit
  # newfs_hammer -L TEST /dev/da2 > /dev/null
  # mount_hammer /dev/da2 /HAMMER
  # hammer volume-add /dev/da3 /HAMMER
  # hammer volume-del /dev/da3 /HAMMER
  # od -tx1 -N 1928 /dev/da3
  0000000    00  00  00  00  00  00  00  00  40  4d  31  23  e1  ff  ff  ff
  0000020    00  00  00  00  00  00  00  00  00  44  2a  52  e0  ff  ff  ff
  0000040    40  4d  31  23  e1  ff  ff  ff  18  68  30  c4  00  00  00  00
  0000060    30  66  29  1a  e1  ff  ff  ff  18  b6  5b  22  e1  ff  ff  ff
  ...

  [B] This commit
  # newfs_hammer -L TEST /dev/da2 > /dev/null
  # mount_hammer /dev/da2 /HAMMER
  # hammer volume-add /dev/da3 /HAMMER
  # hammer volume-del /dev/da3 /HAMMER
  # od -tx1 -N 1928 /dev/da3
  0000000    00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  *
  0003600

  [C] sizeof ondisk volume header
  # cat ./sizeof.c
  #include <stdio.h>
  #include <vfs/hammer/hammer_disk.h>
  int main(void) {
          printf("%d\n", (int)sizeof(struct hammer_volume_ondisk));
          return 0;
  }
  # gcc -Wall -g ./sizeof.c
  # ./a.out
  1928

8 years agosbin/hammer: Declare char* at the top of block scope
Tomohiro Kusumi [Sun, 20 Mar 2016 07:11:19 +0000 (16:11 +0900)]
sbin/hammer: Declare char* at the top of block scope

though gcc compiles without this.

Also change char* to const char*.
These char*s are pointers to argv[].

8 years agoacpidump(8): Use the hint.acpi.0.rsdp kenv to get at the RSDP.
Sascha Wildner [Sat, 19 Mar 2016 21:14:05 +0000 (22:14 +0100)]
acpidump(8): Use the hint.acpi.0.rsdp kenv to get at the RSDP.

Using the kernel env variable instead of the sysctl can be useful
in some circumstances, for example when ACPICA is deactivated
because a box won't run with it active, yet we want to dump the
ACPI tables to investigate the problem. The kernel env variable,
which is set by the loader, is set even if the ACPICA module
is not loaded or ACPICA has been deactivated completely.

Of course, this won't help if there is a problem with finding the
RSDP itself.

I'll submit this commit upstream to Intel.

8 years agoboot/acpi: Implement hint.acpi.0.rsdp for the legacy bootloader too.
Sascha Wildner [Sat, 19 Mar 2016 21:12:29 +0000 (22:12 +0100)]
boot/acpi: Implement hint.acpi.0.rsdp for the legacy bootloader too.

I'm leaving the kernel's own RSDP searching code (acpi_sdt.c) in for
now but it is very unlikely that it will ever be triggered again
after this commit.

8 years agoSync the kenv(1) utility with FreeBSD.
Sascha Wildner [Sat, 19 Mar 2016 20:51:42 +0000 (21:51 +0100)]
Sync the kenv(1) utility with FreeBSD.

Some new options and it uses the kenv() system call now.

8 years agoAdd a kenv(2) system call for better handling of the kernel environment.
Sascha Wildner [Sat, 19 Mar 2016 20:49:39 +0000 (21:49 +0100)]
Add a kenv(2) system call for better handling of the kernel environment.

8 years agosys/vfs/hammer: Add hammer_is_zone_xxx()
Tomohiro Kusumi [Sat, 19 Mar 2016 07:01:59 +0000 (16:01 +0900)]
sys/vfs/hammer: Add hammer_is_zone_xxx()

8 years agosys/vfs/hammer: Add HAMMER_ZONE()
Tomohiro Kusumi [Sat, 19 Mar 2016 06:59:33 +0000 (15:59 +0900)]
sys/vfs/hammer: Add HAMMER_ZONE()

8 years agosys/vfs/hammer: Rename clist to node_list
Tomohiro Kusumi [Fri, 18 Mar 2016 11:08:51 +0000 (20:08 +0900)]
sys/vfs/hammer: Rename clist to node_list

The name clist comes from 2007 when there were clist and alist.

Rename it to node_list.
General naming rule in hammer is `name`_list.
e.g. target_list, cursor_list, cache_list.

8 years agosys/vfs/hammer: Remove unused HAMMER_TRANSF_DIDIO
Tomohiro Kusumi [Fri, 18 Mar 2016 10:11:46 +0000 (19:11 +0900)]
sys/vfs/hammer: Remove unused HAMMER_TRANSF_DIDIO

This flag is no longer used after 32fcc103.

8 years agosys/vfs/hammer: Remove hammer_iterate_l1l2_entries()
Tomohiro Kusumi [Fri, 11 Mar 2016 14:53:44 +0000 (23:53 +0900)]
sys/vfs/hammer: Remove hammer_iterate_l1l2_entries()

This is no longer used.
Also see the previous commit.

8 years agosys/vfs/hammer: Fix/rewrite hammer_free_freemap()
Tomohiro Kusumi [Fri, 11 Mar 2016 14:49:15 +0000 (23:49 +0900)]
sys/vfs/hammer: Fix/rewrite hammer_free_freemap()

This commit rewrites hammer_free_freemap() used by hammer volume-del
in order to handle layer2 layout change by the previous commit.

The functional difference (other than the layout difference) is
that this commit through for-loop twice. This is to separate
counting busy layer2 and zero clearing layer1. Layer1 zero clear
should be done only when all layer2 are empty, so no ondisk change
occurs until it's ready to erase ondisk layer1. It previously had
these two in the same loop, which means if the volume consisted
of >1 layer1 it could happen to find out the volume wasn't ready
to remove after it has zero cleared layer1 entry(s).

This commit adds prototype for hammer_iterate_l1l2_entries().
This was added only to avoid compile error for not using it.
hammer_iterate_l1l2_entries() will be removed in the next commit.
(Removing it in this same commit makes default git diff without
any option unclear)

This commit does not affect a volume that was previously added
by hammer volume-add when removing that volume via hammer volume-del
after this commit. HAMMER reads layer2 offset from ondisk layer1
entries (and layer1 layout hasn't changed), so the change made by
the previous commit to conform to the original design doesn't
depend on the code once it's added.

8 years agosys/vfs/hammer: Fix/rewrite hammer_format_freemap()
Tomohiro Kusumi [Fri, 11 Mar 2016 14:45:16 +0000 (23:45 +0900)]
sys/vfs/hammer: Fix/rewrite hammer_format_freemap()

hammer volume-add allocates big-blocks that contain layer2 entries
in a different way from newfs_hammer.

0          8M         4T     8T     12T...
------------------|--------------------------> zone-2 address of non-root volume
L2L2L2L2.. L2L2..                           <- newfs_hammer
L2L2L2L2..            L2L2.. L2L2.. L2L2..  <- hammer volume-add

This layout difference comes from where
hammer_iterate_l1l2_entries() uses the following code for layer2
entry offset.
layer2_off = phys_off + HAMMER_BLOCKMAP_LAYER2_OFFSET(block_off);
             ^^^^^^^^ not layer1->phys_offset

Although this works, there isn't really any reason to do it in
a different way from the original design. This commit changes the
layout to the newfs_hammer way by rewriting hammer_format_freemap().

(hammer_iterate_l1l2_entries() is tightly coupled with its callback
handlers that the above layout difference can't be fixed by just
changing phys_off to layer1->phys_offset. layer1->phys_offset
doesn't hold a valid offset at this point until all layer2 entries
are filled in, while doing layer2 stuff requires layer1->phys_offset.
This commit based on the previous 3 commits rewrites hammer_format
_freemap() without using hammer_iterate_l1l2_entries().)

This commit does not affect a volume that was previously added
by hammer volume-add. Also no need to advance HAMMER volume version.

8 years agosys/vfs/hammer: Remove struct bigblock_stat
Tomohiro Kusumi [Mon, 7 Mar 2016 13:44:54 +0000 (22:44 +0900)]
sys/vfs/hammer: Remove struct bigblock_stat

Since now that struct bigblock_stat exists only to hold a temporary
counter to count available bigblocks within each layer1 while running
through l1/l2 bigblocks, it can be done using a local variable
defined in hammer_format_freemap().

This commit removes struct bigblock_stat as well as *stat argument
from hammer_format_freemap().

8 years agosys/vfs/hammer: Remove hammer_test_free_freemap()
Tomohiro Kusumi [Sat, 5 Mar 2016 16:42:11 +0000 (01:42 +0900)]
sys/vfs/hammer: Remove hammer_test_free_freemap()

hammer_count_bigblocks() added by the previous commit can
test if the volume if free or not by comparing result values,
so hammer_test_free_freemap() is no longer necessary.

8 years agosys/vfs/hammer: Separate total/free big-block counting from formatting
Tomohiro Kusumi [Sat, 5 Mar 2016 14:24:28 +0000 (23:24 +0900)]
sys/vfs/hammer: Separate total/free big-block counting from formatting

Add hammer_count_bigblocks() to separate counting total/free big-blocks
from layer1/2 formatting.

This is for the next few commits.

8 years agosbin/hammer: Remove unnecessary conditional on freemap initialization
Tomohiro Kusumi [Tue, 15 Mar 2016 22:31:02 +0000 (07:31 +0900)]
sbin/hammer: Remove unnecessary conditional on freemap initialization

if (layer2->zone == 0)
isn't necessary since this function has just zero cleared this
layer2 entry (that will be written back to the storage later).

8 years agosbin/hammer: Fix writeback against readonly fd
Tomohiro Kusumi [Wed, 9 Mar 2016 15:03:02 +0000 (00:03 +0900)]
sbin/hammer: Fix writeback against readonly fd

writehammerbuf() needs to return 0 before it attempts to write
if the fd is readonly. Without this check flush_all_volumes()
may fail before all modified volume headers are written back
to the backing storage.

The only reason this hasn't become an issue so far is because
no existing hammer command creates readonly volume_info while
there are rw volume_info that need to be written back, which
could happen depending on the purpose of commands.

8 years agosbin/hammer: Fix conditional for Hammer_FSId initialization
Tomohiro Kusumi [Wed, 9 Mar 2016 00:04:20 +0000 (09:04 +0900)]
sbin/hammer: Fix conditional for Hammer_FSId initialization

Hammer_FSId is initialized when no entry in the VolList yet,
but this becomes an issue when a new volume (that hasn't joined
the HAMMER filesystem yet) is the first created volume_info.

If the second volume_info is for the existing HAMMER volume,
it is likely that
bcmp(&Hammer_FSId, &ondisk->vol_fsid, sizeof(Hammer_FSId))
does not match and results in the following error.
"load_volume: %s: FSId does match other volumes!"

The only reason this hasn't become an issue so far is because
no existing hammer command creates volume_info in that order.

8 years agosbin/hammer: Remove unnecessary if(AssertOnFailure) conditionals
Tomohiro Kusumi [Tue, 8 Mar 2016 07:58:03 +0000 (16:58 +0900)]
sbin/hammer: Remove unnecessary if(AssertOnFailure) conditionals

If get_volume(vol_no) fails to find a volume, there is basically
no way that /sbin/hammer can proceed the rest of the process,
so if(AssertOnFailure) isn't necessary.

(buf_offset & HAMMER_OFF_ZONE_MASK) == HAMMER_ZONE_RAW_BUFFER
should be checked unconditionally.

8 years agosbin/hammer: Remove =0; for some global variables
Tomohiro Kusumi [Tue, 8 Mar 2016 06:49:06 +0000 (15:49 +0900)]
sbin/hammer: Remove =0; for some global variables

8 years agosbin/newfs_hammer: Fix wrong comment
Tomohiro Kusumi [Tue, 8 Mar 2016 09:32:22 +0000 (18:32 +0900)]
sbin/newfs_hammer: Fix wrong comment

This comment has nothing to do with the code today.
(See 7e1ba5da and 68e079b8 in 2008)

8 years agosbin/newfs_hammer: Define UndoBufferSize in newfs_hammer
Tomohiro Kusumi [Mon, 7 Mar 2016 19:07:03 +0000 (04:07 +0900)]
sbin/newfs_hammer: Define UndoBufferSize in newfs_hammer

This is only needed and usable by newfs_hammer option -u.

8 years agosbin/newfs_hammer: Define Boot|MemAreaSize in newfs_hammer
Tomohiro Kusumi [Mon, 7 Mar 2016 18:56:15 +0000 (03:56 +0900)]
sbin/newfs_hammer: Define Boot|MemAreaSize in newfs_hammer

These are only needed and usable by newfs_hammer options -b and -m.

8 years agosbin/newfs_hammer: Rename format_root() to format_root_directory()
Tomohiro Kusumi [Mon, 7 Mar 2016 16:06:47 +0000 (01:06 +0900)]
sbin/newfs_hammer: Rename format_root() to format_root_directory()

Explicitly mention what root it is.
(HAMMER has root inode/directory, root volume, root PFS)

8 years agosbin/hammer: Minor fix for format_blockmap()
Tomohiro Kusumi [Mon, 7 Mar 2016 15:34:15 +0000 (00:34 +0900)]
sbin/hammer: Minor fix for format_blockmap()

Take *vol instead of blockmap for the first argument.
Properly set modified flag to 1 (no actual change since newfs_hammer
should have already set it to 1 via format_freemap()).
Add assertion.
Locate this function right above format_freemap().

8 years agosbin/hammer: Initialize Hammer_FSType before any subcommand
Tomohiro Kusumi [Wed, 9 Mar 2016 18:20:12 +0000 (03:20 +0900)]
sbin/hammer: Initialize Hammer_FSType before any subcommand

Ondisk volume header fstype uuid is always compared with the
global variable Hammer_FSType uuid whenever volume information
is read from the existing HAMMER volume. Then Hammer_FSType
should be initialized before any hammer command starts whether
each subcommand actually reads from the HAMMER volumes or not.

8 years agosbin/hammer: Separate setup_volume() into init/load_volume()
Tomohiro Kusumi [Mon, 7 Mar 2016 09:57:25 +0000 (18:57 +0900)]
sbin/hammer: Separate setup_volume() into init/load_volume()

Separate setup_volume() into isnew == 0 and 1 case.
setup_volume() taking two args vol_no and isnew is redundant.

Use init_volume() when newly creating a HAMMER volume.
Use load_volume() when the HAMMER volume already exists.

This commit is based on functions added by the previous two commits.

8 years agosbin/hammer: Add __add_volume()
Tomohiro Kusumi [Mon, 7 Mar 2016 09:31:06 +0000 (18:31 +0900)]
sbin/hammer: Add __add_volume()

Extract volume registration code into a separate function.

8 years agosbin/hammer: Add __alloc_volume()
Tomohiro Kusumi [Mon, 7 Mar 2016 09:23:13 +0000 (18:23 +0900)]
sbin/hammer: Add __alloc_volume()

Extract volume allocation code into a separate function.

8 years agosbin/hammer: Add get_root_volume()
Tomohiro Kusumi [Sun, 6 Mar 2016 07:10:38 +0000 (16:10 +0900)]
sbin/hammer: Add get_root_volume()

Add a wrapper for get_volume(HAMMER_ROOT_VOLNO).

8 years agosbin/hammer: Update blockmap lookup error#
Tomohiro Kusumi [Sat, 19 Mar 2016 11:04:41 +0000 (20:04 +0900)]
sbin/hammer: Update blockmap lookup error#

The previous commit has removed -3, so update the existing ones.
We want to keep different numbers for each for debugging purpose
for hammer show command. hammer show prints these error codes.

Note that hammer show on the current production release (4.4)
doesn't directly print error code, but instead prints a string
(that doesn't contain the error code digit within char[]).
hammer show's output format has changed quite a bit in 4.5, and
directly showing error code is one of them. This commit doesn't
confuse 4.4 users, in other words it doesn't make hammer show
print "-3" on what was -4 in 4.4, since 4.4 doesn't print the
code itself.

8 years agosys/vfs/hammer: Add HAMMER_ROOT_VOLNO
Tomohiro Kusumi [Sat, 5 Mar 2016 17:47:55 +0000 (02:47 +0900)]
sys/vfs/hammer: Add HAMMER_ROOT_VOLNO

The root volume# is always 0, so hammer userspace can use 0
instead of having a global variable RootVolNo that needs to
be set from -1 to 0 (and only 0).

Ondisk volume header even has fields whose name start with
vol0_xxx. This implies the root volume# is designed to be 0,
but nothing else.

8 years agosbin/newfs_hammer: Cleanup
Tomohiro Kusumi [Sun, 6 Mar 2016 07:04:55 +0000 (16:04 +0900)]
sbin/newfs_hammer: Cleanup

(vol_buf_end - vol_buf_beg) is the maximum filesystem size available
for each volume, including big-blocks for layers and UNDO fifo.

8 years agommcsd(4): Fix typo in disk_create() args. Allows accessing >1 SD-/MMC-card.
Imre Vadász [Thu, 17 Mar 2016 20:25:56 +0000 (21:25 +0100)]
mmcsd(4): Fix typo in disk_create() args. Allows accessing >1 SD-/MMC-card.

* sc->unit was always 0, so only mmcsd0 was accessible.

8 years agotcp: Implement per-cpu lport cache for listen sockets.
Sepherosa Ziehau [Tue, 15 Mar 2016 12:45:36 +0000 (20:45 +0800)]
tcp: Implement per-cpu lport cache for listen sockets.

Background:
In order to guard against reincarnation of an accepted connection
after the listen socket is closed, the accepted socket is linked
on to the same global lport hash list as the listen socket.  However,
on a busy TCP server, this could cause a lot of contention on this
global lport hash list.

But think about it again: as long as the listen socket is not closed,
reincarnation of an accepted connection is _impossible_, since the
listen socket itself is on the global lport hash list.

Given the above background, this commit changes where an accepted
socket is linked to, before the listen socket is closed:
- Create a per-cpu lport cache for listen socket.
- Accepted sockets are linked to this listen socket per-cpu lport
  cache, instead of to the global lport hash list.
- Before the listen socket is closed, all of the sockets on the
  listen socket's per-cpu lport cache are merged to the global lport
  hash list to prevent reincarnation of these connections.

This greatly reduces the total contention rate on a busy TCP server:
- From 50K/s to 18K/s, if the # of NIC rings does not match the # of
  cpus.  And it gives ~7% performance improvement (420Kconn/s ->
  450Kconn/s).
- From 30K/s to 800/s, if the # of NIC rings matches the # of cpus.
  Though this does not give more performance improvement, idle cpu
  time is increased a bit.

8 years agoMark up defined values with .Dv in various manual pages.
Sascha Wildner [Wed, 16 Mar 2016 21:04:07 +0000 (22:04 +0100)]
Mark up defined values with .Dv in various manual pages.

8 years agopppd(8): Fix an apparent bug that caused GCC whining and raise WARNS to 2.
Sascha Wildner [Tue, 15 Mar 2016 22:01:48 +0000 (23:01 +0100)]
pppd(8): Fix an apparent bug that caused GCC whining and raise WARNS to 2.

Pointed-out-by: ivadasz
Discussed-with: sephe, ivadasz

8 years agosys/dev/disk/sdhci: Update to FreeBSD r296135.
Imre Vadász [Thu, 10 Mar 2016 13:12:44 +0000 (14:12 +0100)]
sys/dev/disk/sdhci: Update to FreeBSD r296135.

8 years agosys/bus/mmc: Update to FreeBSD r285678.
Imre Vadász [Thu, 10 Mar 2016 13:47:12 +0000 (14:47 +0100)]
sys/bus/mmc: Update to FreeBSD r285678.

8 years agotic.1: Various mdoc fixes/improvements.
Sascha Wildner [Tue, 15 Mar 2016 14:44:50 +0000 (15:44 +0100)]
tic.1: Various mdoc fixes/improvements.

8 years agoUpdate the pciconf(8) database.
Sascha Wildner [Tue, 15 Mar 2016 08:38:09 +0000 (09:38 +0100)]
Update the pciconf(8) database.

February 27, 2016 snapshot from http://pciids.sourceforge.net/

8 years agoDocument new local mods on contrib/ncurses
John Marino [Sun, 13 Mar 2016 12:56:16 +0000 (13:56 +0100)]
Document new local mods on contrib/ncurses

8 years agoboot/common: Fix compilation of load_elf.c and reloc_elf.c for x86_64.
Imre Vadász [Sat, 12 Mar 2016 21:40:38 +0000 (22:40 +0100)]
boot/common: Fix compilation of load_elf.c and reloc_elf.c for x86_64.

8 years agolib/libstand: Add #ifndef _STAND_H include guard to the stand.h header.
Imre Vadász [Sat, 12 Mar 2016 14:45:55 +0000 (15:45 +0100)]
lib/libstand: Add #ifndef _STAND_H include guard to the stand.h header.

8 years agolib/libstand: Remove exit declaration from stand.h.
Imre Vadász [Sat, 12 Mar 2016 13:39:02 +0000 (14:39 +0100)]
lib/libstand: Remove exit declaration from stand.h.

* Use panic instead of printf+exit in __assert().

* In the UEFI bootloader, exit will be defined as
  void exit(EFI_STATUS status);
  where EFI_STATUS is a 64bit value. So we should avoid declaring exit()
  in stand.h, since it's not used in libstand anyway.

* All exit usages in sys/boot/common and sys/boot/pc32 already declare
  their own exit() prototype.

8 years agoHack-fix buildworld after the ncurses upgrade.
Sascha Wildner [Sun, 13 Mar 2016 11:54:44 +0000 (12:54 +0100)]
Hack-fix buildworld after the ncurses upgrade.

This seems to be enough to keep it going and buildworld's tic
usage doesn't use any of these features.

8 years agoncurses: Upgrade version 5.9 (20110402) => 6.0 (20160305)
John Marino [Fri, 11 Mar 2016 19:11:40 +0000 (20:11 +0100)]
ncurses: Upgrade version 5.9 (20110402) => 6.0 (20160305)

The tic program has been updated at the same time.
The symbol maps were expanded using the vendor symbol maps so they
should be more accurate than before.  Only one new symbol came in
for the 6.0 version, but I didn't see it present in any library.

For now, the ncurses headers are still being installed.  They may
be removed later if dports will support it and it doesn't cause
problem with unix specifications.  (On DragonFly, the ncurses
base libraries are private so in theory the headers should be too).

8 years agocontrib/ncurses: Reapply local mods and revise READMEs
John Marino [Fri, 11 Mar 2016 19:04:12 +0000 (20:04 +0100)]
contrib/ncurses: Reapply local mods and revise READMEs

8 years agoMerge branch 'vendor/NCURSES'
John Marino [Fri, 11 Mar 2016 20:00:32 +0000 (21:00 +0100)]
Merge branch 'vendor/NCURSES'

8 years agoTemporarily revert contrib/ncurses local mods for upgrade
John Marino [Fri, 11 Mar 2016 18:58:00 +0000 (19:58 +0100)]
Temporarily revert contrib/ncurses local mods for upgrade

8 years agonrelease - Update to dhcp43-server
Matthew Dillon [Fri, 11 Mar 2016 18:46:00 +0000 (10:46 -0800)]
nrelease - Update to dhcp43-server

* dhcp42-server was removed from ports, use dhcp43-server now.

8 years agoUpdate ncurses from version 5.9 to 6.0 (5 MARCH 2016)
John Marino [Fri, 11 Mar 2016 18:35:17 +0000 (19:35 +0100)]
Update ncurses from version 5.9 to 6.0 (5 MARCH 2016)

8 years agonrelease: Allow to build snapshots on tmpfs.
zrj [Thu, 10 Mar 2016 08:43:31 +0000 (10:43 +0200)]
nrelease: Allow to build snapshots on tmpfs.

/usr/libexec/locate.updatedb excludes files residing on tmpfs.
That causes an empty locate db failure just before the end of
customizeiso target and leaves a dangling ${ISOROOT}/dev mount.

By permitting updatedb to fail, the requirement for ISOROOT
to be on ufs/hammer fs is lifted.

8 years agobsd.cpu.gcc(47|50).mk: Return support for CPUTYPE i386
John Marino [Wed, 9 Mar 2016 15:22:50 +0000 (16:22 +0100)]
bsd.cpu.gcc(47|50).mk: Return support for CPUTYPE i386

The /boot loader and friends are still 32-bit.  While -m32 -march=native
should be okay in most cases, let's return limited support for
CPUTYPE=i386 which is explicitly specified in the world make files
through the use of FORCE_CPUTYPE.

Since this is only to support the bases /boot functionality, only the
generic i386 cpu is supported.  It's not intended for non-base use.

suggested by: zrj

8 years agodloader: Build i386 version for the bios bootloader as libdloader32.a.
Imre Vadász [Tue, 8 Mar 2016 23:08:56 +0000 (00:08 +0100)]
dloader: Build i386 version for the bios bootloader as libdloader32.a.

* sys/boot/pc32/loader and sys/boot/pc32/loader_tftp now link against
  libdloader32.a instead of libdloader.a.

* The libdloader.a from sys/boot/dloader is now built for x86_64.

8 years agolibstand: Build libstand for x86_64, and libstand32 for the bios loader.
Imre Vadász [Sun, 6 Mar 2016 21:39:48 +0000 (22:39 +0100)]
libstand: Build libstand for x86_64, and libstand32 for the bios loader.

* lib/libstand.a is now built for the native CPU architecture. The i386
  version is now built in sys/boot/libstand32 as an INTERNALLIB for usage
  in the BIOS bootloader.

* This makes the existing BIOS bootloader (from sys/boot/loader and
  sys/boot/loader_tftp) use the separately built libstand32.a instead of
  libstand.a.

* We now install an x86_64 version of libstand.a into world.

8 years agolibstand: Use new LIBSTAND_SRC and LIBSTAND_ARCH variables in makefiles.
Imre Vadász [Sun, 6 Mar 2016 21:21:27 +0000 (22:21 +0100)]
libstand: Use new LIBSTAND_SRC and LIBSTAND_ARCH variables in makefiles.

* Make it easier to include lib/libstand/Makefile for building different
  variants of libstand. Preparation for adding sys/boot/libstand32.

8 years agosys/boot: Push down Makeflags setting into dloader and pc32 subdirectories.
Imre Vadász [Tue, 8 Mar 2016 00:50:31 +0000 (01:50 +0100)]
sys/boot: Push down Makeflags setting into dloader and pc32 subdirectories.

* We need to build both i386 and x86_64 binaries in sys/boot for UEFI
  support. For this we need to move the .Makeflags usages one level deeper
  into sys/boot/dloader/Makefile and sys/boot/pc32/Makefile respectively.

8 years agoncurses solidation: Remove all references to libtermcap
John Marino [Wed, 9 Mar 2016 16:14:56 +0000 (17:14 +0100)]
ncurses solidation: Remove all references to libtermcap

The termlib, termcap, and tinfo libraries are all symlinked to ncurses
library.  There's no reason to have four aliases for the same library
when none of them are exposed outside base.

termlib and tinfo aren't referenced anywhere, but libtermcap is.
This commit changes all the references to libtermcap to libncurses,
and removes the private aliases of ncurses.

8 years agobnx: Don't use thread template
Sepherosa Ziehau [Wed, 9 Mar 2016 12:28:07 +0000 (20:28 +0800)]
bnx: Don't use thread template

Mainly to avoid lwkt_exit and bnx_softc free race.

8 years agodports(7): Document default WRKDIRPREFIX value
François Tigeot [Tue, 8 Mar 2016 21:32:08 +0000 (22:32 +0100)]
dports(7): Document default WRKDIRPREFIX value

Reported-by: lepot on irc
8 years agokernel/sysctl: Add SYSCTL_OUT_STR()
François Tigeot [Tue, 8 Mar 2016 20:00:13 +0000 (21:00 +0100)]
kernel/sysctl: Add SYSCTL_OUT_STR()

Obtained-from: FreeBSD

8 years ago<sys/select.h>: Provide timespec structure.
zrj [Mon, 7 Mar 2016 14:32:52 +0000 (16:32 +0200)]
<sys/select.h>: Provide timespec structure.

As per POSIX specs.

8 years agoRework the CPU Makefile for GCC 4.7, too.
Sascha Wildner [Mon, 7 Mar 2016 19:18:07 +0000 (20:18 +0100)]
Rework the CPU Makefile for GCC 4.7, too.

Due to the previous version's passing of unknown CPUTYPEs just
through to -march, a buildworld with for example CPUTYPE=haswell
(which is known by 5.3.0 but not by 4.7.4) would fail for files
that are compiled with gcc47 in the buildworld.

8 years agoAdd a manual page for exec_sys_{,un}register() system calls.
Sascha Wildner [Mon, 7 Mar 2016 19:17:34 +0000 (20:17 +0100)]
Add a manual page for exec_sys_{,un}register() system calls.

8 years agoAdjust markup of defined values to .Dv in various manual pages.
Sascha Wildner [Mon, 7 Mar 2016 19:16:33 +0000 (20:16 +0100)]
Adjust markup of defined values to .Dv in various manual pages.

8 years agoUn-__P() <opie.h>, which is a public header.
Sascha Wildner [Mon, 7 Mar 2016 19:16:31 +0000 (20:16 +0100)]
Un-__P() <opie.h>, which is a public header.

8 years agokqueue: Clear sleep counter before wakeup
Sepherosa Ziehau [Mon, 7 Mar 2016 12:43:17 +0000 (20:43 +0800)]
kqueue: Clear sleep counter before wakeup

8 years agokqueue: Make sure that kqueue sleep counter will not wrap around
Sepherosa Ziehau [Mon, 7 Mar 2016 12:26:11 +0000 (20:26 +0800)]
kqueue: Make sure that kqueue sleep counter will not wrap around

8 years agosys/kern: Change "bufcache" to "buffer cache" in warning message
Tomohiro Kusumi [Sat, 5 Mar 2016 10:57:34 +0000 (19:57 +0900)]
sys/kern: Change "bufcache" to "buffer cache" in warning message

It's better with "buffer cache".
This is the only "bufcache".

 # grep "bufcache" sys/ -rI
 sys/kern/vfs_bio.c:                         "during bufcache page allocation from %s\n",
 # grep "buffer cache" sys/ -rI | wc -l
      214

8 years agosbin/hammer: Cleanup beginning part of hammer show
Tomohiro Kusumi [Sat, 5 Mar 2016 08:50:44 +0000 (17:50 +0900)]
sbin/hammer: Cleanup beginning part of hammer show

to make the format a bit more understandable compared
to the original format, since search directives for
lo:obj_id:rt:key:tid have been available for a while.
It's confusing to print these directives along with other
arguments in a single line.

8 years agosbin/hammer: Cleanup long lines with >80 chars
Tomohiro Kusumi [Sat, 5 Mar 2016 08:27:05 +0000 (17:27 +0900)]
sbin/hammer: Cleanup long lines with >80 chars

8 years agosbin/hammer: Don't access beyond 16KB of HAMMER userspace buffer
Tomohiro Kusumi [Fri, 4 Mar 2016 16:08:46 +0000 (01:08 +0900)]
sbin/hammer: Don't access beyond 16KB of HAMMER userspace buffer

HAMMER userspace only supports upto 16KB buffer size while HAMMER
filesystem itself supports both 16KB and 64KB. This means even if
a leaf node elm says the record data is >16KB, HAMMER userspace can
only retrieve the first 16KB of the record data. Anything beyond
16KB is not supported (not malloc'd in userspace).

print_record() in hammer show is passing a pointer to maximum 16KB
buffer to hexdump(3), but is also passing data_len which is taken
from elm->leaf.data_len. This becomes an issue when the file size
is >1MB where HAMMER starts to use 64KB buffer for data beyond 1MB.
elm->leaf.data_len will typically say the length is 64KB, but
the maximum HAMMER userspace can handle is still 16KB regardless
of what the leaf node elm says. hammer show needs to omit anything
beyond 16KB (for now).

 # hammer -vvvv -f /dev/da1:/dev/da2:/dev/da3 show > /dev/null
 zsh: segmentation fault (core dumped)  hammer -vvvv -f /dev/da1:/dev/da2:/dev/da3 show > /dev/null

8 years agosbin/hammer: Minor fix for hammer(8) manpage
Tomohiro Kusumi [Fri, 4 Mar 2016 13:58:30 +0000 (22:58 +0900)]
sbin/hammer: Minor fix for hammer(8) manpage

8 years agosbin/hammer: Add num_bad_rec counter to hammer show
Tomohiro Kusumi [Thu, 3 Mar 2016 17:49:50 +0000 (02:49 +0900)]
sbin/hammer: Add num_bad_rec counter to hammer show

Add a counter for CRC error and blockmap offset error for records
in addition to counters for nodes and elms. Bad records has been
checked by hammer show, but the result wasn't printed like other two.

8 years agosbin/hammer: Cleanup error string formats for records' crc error
Tomohiro Kusumi [Thu, 3 Mar 2016 16:51:03 +0000 (01:51 +0900)]
sbin/hammer: Cleanup error string formats for records' crc error

Also make it grep friendly with "error=%s" format.

8 years agosbin/hammer: Fix indentation of config data output
Tomohiro Kusumi [Thu, 3 Mar 2016 20:21:51 +0000 (05:21 +0900)]
sbin/hammer: Fix indentation of config data output

Align config data with " before and after the data.
Otherwise hammer show generates output that looks as if
each line of config data starts with two spaces "  ".

8 years agosbin/hammer: Fix trailing blank line in config data output
Tomohiro Kusumi [Thu, 3 Mar 2016 20:11:11 +0000 (05:11 +0900)]
sbin/hammer: Fix trailing blank line in config data output

hammer show needs to ignore the last string "" after strsep(3)
replaces \n at the end of config data with \0, in order not to
print an extra blank line that shouldn't be printed.

(This also ignores the real blank line, but there are usually
no blank lines in config data)

8 years agosbin/hammer: Fix wrong config data field name
Tomohiro Kusumi [Thu, 3 Mar 2016 18:19:07 +0000 (03:19 +0900)]
sbin/hammer: Fix wrong config data field name

bc5af92e changed the name of char[] field from "text" to "stext",
which was wrong. Change it back to "text".

8 years agosbin/hammer: Don't modify buffer_info for config data for no reason
Tomohiro Kusumi [Wed, 2 Mar 2016 16:32:15 +0000 (01:32 +0900)]
sbin/hammer: Don't modify buffer_info for config data for no reason

print_config() introduced by bc5af92e modifies the data part
of buffer_info via strsep(3). No other part of hammer show
modifies data read from block devices obviously because the
command is supposed to be a read-only command.

Although it's still safe to modify the data part as long as
modified flag isn't set to 1, it's just safer to strdup(3)
the data part before calling print_config(). If someone ever
sets modified flag for some reason, calling print_config()
will break the filesystem.

8 years agosbin/hammer: Cleanup and squash inode record format of hammer show
Tomohiro Kusumi [Wed, 2 Mar 2016 17:40:01 +0000 (02:40 +0900)]
sbin/hammer: Cleanup and squash inode record format of hammer show

Inode information was taking too many lines for no reason.
Squash three lines into two and also add atime= in addition to
mtime= and ctime=.

8 years agosbin/hammer: Make hammer show print record type in text
Tomohiro Kusumi [Wed, 2 Mar 2016 15:53:12 +0000 (00:53 +0900)]
sbin/hammer: Make hammer show print record type in text

hammer show prints "dir-entry" for each directory entry record.
Do the same for the rest of record types, e.g. "inode".

Add indentation for lines that show record information.

Makes the result a bit more readable for anyone who doesn't
know or memorize what rt=%02x type means.

8 years agosbin/hammer: Cleanup and squash elm format of hammer show
Tomohiro Kusumi [Tue, 1 Mar 2016 16:38:21 +0000 (01:38 +0900)]
sbin/hammer: Cleanup and squash elm format of hammer show

Fix possible trailing whitespace after object type field.

Record information was taking too many lines for no reason.
Squash three lines (ot=, dataoff=, fill=) into one.
Record type dependent part is printed from the next line.

8 years agosbin/hammer: Add obfuscate option to hammer show
Tomohiro Kusumi [Sat, 5 Mar 2016 05:44:21 +0000 (14:44 +0900)]
sbin/hammer: Add obfuscate option to hammer show

Add an option not to print directory entry name so that users
can send hammer show output to someone else if necessary
without making public their name. Most users never use hammer
show, but some users do and see errors in it.

By default hammer show printfs directory entry name like
 dir-entry ino=00000001007a933b lo=00000000 name="hammer.c"
but by using this option it would be like
 dir-entry ino=00000001007a933b lo=00000000

Note that hammer show command is a subcommand of /sbin/hammer,
so this option is not a part of getopt(3) options. It needs
to be used as follows if one does not need to filter btree.
 # hammer -f /dev/da1:/dev/da2:/dev/da3 show none none obfuscate

Also note that this option is not written in hammer(8) manpage
just like filter/nofilter option is not written.

8 years agosbin/hammer: Use sizeof(*elm)
Tomohiro Kusumi [Wed, 2 Mar 2016 13:56:28 +0000 (22:56 +0900)]
sbin/hammer: Use sizeof(*elm)

8 years agosbin/hammer: Use HAMMER_OFF_BAD
Tomohiro Kusumi [Tue, 1 Mar 2016 13:28:45 +0000 (22:28 +0900)]
sbin/hammer: Use HAMMER_OFF_BAD

8 years agosys/vfs/hammer: Add missing hammer_crc_set_btree()
Tomohiro Kusumi [Wed, 2 Mar 2016 15:08:25 +0000 (00:08 +0900)]
sys/vfs/hammer: Add missing hammer_crc_set_btree()

set_btree is the only one missing in pairs of set/test crc functions,
though other set functions are not inlined.

8 years agosys/vfs/hammer: Don't use HAMMER_CURSOR_GET_LEAF
Tomohiro Kusumi [Tue, 1 Mar 2016 17:29:09 +0000 (02:29 +0900)]
sys/vfs/hammer: Don't use HAMMER_CURSOR_GET_LEAF

HAMMER_CURSOR_GET_LEAF is not used by the current implementation
of hammer_btree_extract(), since this function will cause
cursor->leaf to point to the node element in question regardless
of the flag value. Then just don't use this flag when calling
hammer_btree_extract() when we know loading node element (leaf)
is the default behavior.

The cursor flag is already complicated enough, so simplifying
btree extract callers by either passing 0 or DATA but not LEAF
makes things a bit more clear.

8 years agosys/vfs/hammer: Add hammer_btree_extract_data() [2/2]
Tomohiro Kusumi [Sun, 28 Feb 2016 15:29:59 +0000 (00:29 +0900)]
sys/vfs/hammer: Add hammer_btree_extract_data() [2/2]

This commit replaces
hammer_btree_extract(cursor, HAMMER_CURSOR_GET_DATA)
with
hammer_btree_extract_data(&cursor)
which are the remaining ones from the previous commit.

From the way hammer_btree_extract_data() is implemented,
hammer_btree_extract(cursor, HAMMER_CURSOR_GET_DATA)
is the same as
hammer_btree_extract(cursor, HAMMER_CURSOR_GET_LEAF | HAMMER_CURSOR_GET_DATA)
and it probably should have been (LEAF | DATA) instead of just DATA,
according to the way hammer_get_inode(), hammer_update_inode() and
hammer_update_itimes() set cursor flag. It's either LEAF or
(LEAF | DATA), but not just DATA that makes sense on calling
hammer_btree_extract().

8 years agosys/vfs/hammer: Add hammer_btree_extract_data() [1/2]
Tomohiro Kusumi [Sun, 28 Feb 2016 15:25:03 +0000 (00:25 +0900)]
sys/vfs/hammer: Add hammer_btree_extract_data() [1/2]

hammer_btree_extract() reads data from block devices if flag
has HAMMER_CURSOR_GET_DATA. It doesn't really matter if the flag
is HAMMER_CURSOR_GET_DATA or (LEAF | DATA) as long as the flag
has HAMMER_CURSOR_GET_DATA. Calling this function will cause
cursor->leaf to point to the node element in question regardless
of the flag value.

This commit adds hammer_btree_extract_data() which is just a
wrapper over hammer_btree_extract(cursor, LEAF | DATA).
This commit replaces those with (LEAF | DATA).

8 years agosys/vfs/hammer: Add hammer_btree_extract_leaf()
Tomohiro Kusumi [Sun, 28 Feb 2016 15:05:10 +0000 (00:05 +0900)]
sys/vfs/hammer: Add hammer_btree_extract_leaf()

hammer_btree_extract() doesn't read data from block devices
unless flag has HAMMER_CURSOR_GET_DATA. It doesn't really matter
if the flag is HAMMER_CURSOR_GET_LEAF or not in order to just
extract the node element (without reading data) as long as the
flag doesn't have HAMMER_CURSOR_GET_DATA. Calling this function
will cause cursor->leaf to point to the node element in question
regardless of the flag value.

This commit adds hammer_btree_extract_leaf() which is just a
wrapper over hammer_btree_extract(cursor, HAMMER_CURSOR_GET_LEAF).
This hides complexity of using HAMMER_CURSOR_GET_LEAF or 0 or
anything other than HAMMER_CURSOR_GET_DATA which are all the same.

8 years agohammer - Fix coredump bug which can stall processes
Matthew Dillon [Sat, 5 Mar 2016 03:17:28 +0000 (19:17 -0800)]
hammer - Fix coredump bug which can stall processes

* Fix a coredump bug which can stall the process.  If a process > 100MB is
  in the process of being coredumped, a signal will cause the hammer_write()
  path to hit tstop() due to the core-dump being in progress.  Unfortunately
  the write might be happening from the kernel core generator itself which
  will stall the process forever with a number of locks held.

  hammer only checks for signals on very large (> 100MB) read() and write()
  calls so the issue does not effect coredumps of smaller processes.

* Use CURSIG_NOBLOCK() instead of CURSIG().

8 years agoClean up some manual pages (mainly .Dv related).
Sascha Wildner [Fri, 4 Mar 2016 18:27:44 +0000 (19:27 +0100)]
Clean up some manual pages (mainly .Dv related).