dragonfly.git
8 years agolib/libc/stdlib/merge.c: add "static" to match setup prototype
John Marino [Wed, 2 Sep 2015 20:24:54 +0000 (22:24 +0200)]
lib/libc/stdlib/merge.c: add "static" to match setup prototype

8 years agohammer2 - stabilization - blogbench, others
Matthew Dillon [Wed, 2 Sep 2015 00:50:01 +0000 (17:50 -0700)]
hammer2 - stabilization - blogbench, others

* Fix some (but not all) issues with lost chains on unmount that show
  up in a kmalloc pool warning.

* Fix a bug in hammer2_chain_create_indirect() which retained a stale
  { base, count } across possible parent chain modifications, resulting
  in corruption and/or a panic.

* Track chain lock counts on a per-thread basis and add some helpful
  assertions in the XOP processing loop.  Also add
  hammer2_chain_push_shared_lock() and hammer2_chain_pull_shared_lock()
  to helpfully transfer ownership of (shared locks only) between threads.

* Add missing cpu_lfence() after fifo read index test.  Ensures that
  the memory load of the chain occurs after the write index change has
  been detected.

* Change the XOP ABI a bit.  hammer2_xop_feed() now replicates the
  shared lock, giving one to the collector and allowing the caller
  to retain its own.  This way the locking state of the chain passed
  to it does not change from the point of view of the caller.

  This also fixes one or two lost chain locks in the XOPs.

8 years agokernel - Use unused thread_t field for lock tracker.
Matthew Dillon [Wed, 2 Sep 2015 00:49:13 +0000 (17:49 -0700)]
kernel - Use unused thread_t field for lock tracker.

* Repurpose an unused struct thread field to add td_tracker.  Structure
  size does not change.  Used for debugging only.

8 years agodrm: Bring back a KNOTE() call, unbreak vblank handling
François Tigeot [Tue, 1 Sep 2015 20:07:59 +0000 (22:07 +0200)]
drm: Bring back a KNOTE() call, unbreak vblank handling

* Userland programs were no longer properly notified of vblank events

* We can't use the drm_poll() function present in Linux and its
  explicit poll_wait() call on file_priv->event_wait without introducing
  a completely new kernel infrastructure. Add back the KNOTE() call.

Noticed-by: ivadasz, many
8 years agolibc: Remove stack_protector.c from build
John Marino [Tue, 1 Sep 2015 19:53:00 +0000 (21:53 +0200)]
libc: Remove stack_protector.c from build

Both gcc47 and gcc50 use libssp for stack protection, so the stack
protector code appears to be obsolete.  On the direction of dillon,
just delist the source file in the makefile, and after a month with
some dports run experience, permanently remove stack-protector.c
from lib/libc/sys directory.

8 years agoTake II at unbreaking world
John Marino [Tue, 1 Sep 2015 18:24:04 +0000 (20:24 +0200)]
Take II at unbreaking world

8 years agoacpicall(8): Add -U option for passing UUIDs as buffers.
Sascha Wildner [Tue, 1 Sep 2015 16:21:15 +0000 (18:21 +0200)]
acpicall(8): Add -U option for passing UUIDs as buffers.

Great for _DSM's.

Tested-by: tollens
8 years agoAdd bootstrap workaround needed by ctype.h addition for localedef
John Marino [Tue, 1 Sep 2015 17:30:52 +0000 (19:30 +0200)]
Add bootstrap workaround needed by ctype.h addition for localedef

8 years agolocaledef.1: Clean up a bit.
Sascha Wildner [Tue, 1 Sep 2015 17:14:17 +0000 (19:14 +0200)]
localedef.1: Clean up a bit.

8 years agoAdd a small vmm(2) manual page for the related system calls.
Sascha Wildner [Tue, 1 Sep 2015 16:39:56 +0000 (18:39 +0200)]
Add a small vmm(2) manual page for the related system calls.

Namely, vmm_guest_ctl(2) and vmm_guest_sync_addr(2).

It is based on a manual page which Mihai Carabas submitted to me a
rather long time ago (apologies, Mihai).

8 years agoUTF8: fix a couple of number ctype definitions
John Marino [Tue, 1 Sep 2015 12:42:39 +0000 (14:42 +0200)]
UTF8: fix a couple of number ctype definitions

During testing of new number ctype, I found a typo one of the CJK number
definitions and two Roman Numeral characters that were set as numbers but
should not be (according to equivalent python check).

8 years agolibc: Redefine "number" ctype - no longer alias of "digit"
John Marino [Tue, 1 Sep 2015 11:39:38 +0000 (13:39 +0200)]
libc: Redefine "number" ctype - no longer alias of "digit"

FreeBSD extended ctypes to include numbers (e.g. isnumber()) but never
actually implemented it.  The isnumber() function was equivalent to the
isdigit() function in every case.

Now that DragonFly's ctype source files have number definitions, the
number ctype can finally be implemented.  It's given a new flag _CTYPE_N.
The isalnum() and iswalnum() functions have been changed to use this
flag rather than the _CTYPE_D digit flag.

While isalnum(), isnumber(), and their wide equivalents now return
different values in locale cases, the ishexnumber() and iswhexnumber()
functions are unchanged.  They are still aliases for isxdigit() and
iswxdigit().

Also change ctype.h for isdigit and isxdigit to use sbistype like the
other functions.

The "isnumber()" will not work until a full world build is made.  The
reason is that localedef is modified, but it's a bootstrap tool, so the
earlier version that does not support number ctype is still used in a
quickworld build.

8 years agoUTF8 locales: Fully consider "CIRCLED_" set as alphabet
John Marino [Tue, 1 Sep 2015 10:41:21 +0000 (12:41 +0200)]
UTF8 locales: Fully consider "CIRCLED_" set as alphabet

This means defining the "A"-"Z" and "a"-"z" circled versions of the
Enclosed Alphanumerics block (0x2460-24FF) as hexidecimal digits and
defining the to-upper and to-lower conversions between the upper case
and lower case circled alphabets.

8 years agoUTF-8: Multiple improvements (and detection of possible issue)
John Marino [Tue, 1 Sep 2015 09:11:41 +0000 (11:11 +0200)]
UTF-8: Multiple improvements (and detection of possible issue)

This commit started out intending to fix "digit" definition on unicode,
which it mostly does, but a lot more happened in the end, namely:

 * digits apparently are not part of CLDR definition.  I added a section
   in the manual portion of UTF-8 source file that defines digit classes
   for generated sections.
 * Add numbers classification for entire UTF-8.  Currently DragonFly and
   all BSDs do not support "number" type.  However, localedef understands
   it (its supported on Illumos), but currently the number flag value is
   zero, so it's a no-op.  A short term goal is to have DragonFly be the
   first BSD with proper number ctype handling.
 * Redefine "special" ctype once and for all.  There is no definitive
   agreement on what "special" characters are.  According to wiki which
   got it from unicode, it starts with 33 characters (0x20 - 0x2F, 0x3A -
   0x40, 0x5B - 0x60, 0x7B - 0x7E).  However, localedef objects to <space>
   because it sets "graph" and "print" flags, and <space> can't be graph.
   As a result, the <space> is not considered "special" here.  Moreover,
   the punctuation in Latin-1 supplement is "special".  The division and
   multiplication signs are ambiguous, so I set them to special (since
   plus and minus signs are special).  Finally, with the most doubt, the
   punctuation of "general punctuation" block is also considered special
   although I couldn't find convincing evidence either way.  Given the
   lack of definition, I don't think "special" classification is really
   used, especially not in unicode.
 * Fix NON-BREAK_SPACE classification (set as graph and space on previous
   commit)
 * the MICRO character was also warning due to being classified as both
   lower (in Greek section) and punctuation, so remove the punct. class.
 * When possible, don't define graph if digit is defined, and similarly
   with graph and punct.  Both digit and punct also set graph flag so
   having both is redundant.
 * add several new block definitions:
   - Syloti Nagri
   - Common Indic Number Forms
   - Phags-pa
   - Saurashra
   - Kayah Li
   - Rejang
   - Javanese
   - Cham
   - Tal Viet
   - Meetei Mayek & extension
 * Detection of possible bug in localedef
   The Tai Tham definition are producing the wrong code but there's
   nothing wrong with the definitions.  The 6 unused characters between
   the two digit definitions should not be graphable, but as soon as
   one "digit" is defined after the first digit range is defined, all
   the characters between are marked as graphable and digits.  There
   are similar "fill-ins" but so far only with Thai Tam.  It was
   detected while outputting all "digit" types against a python program
   that does the same and this error was reveal.  It requires further
   investigation about exactly what is causing it (and thus where the
   bug is) but right now it's either a bad definition elsewhere that
   affects Thai Tam or localedef has a bug somewhere (avl lookup?)

8 years agohammer2.8/newfs_hammer2.8: Some small fixes.
Sascha Wildner [Tue, 1 Sep 2015 08:06:26 +0000 (10:06 +0200)]
hammer2.8/newfs_hammer2.8: Some small fixes.

8 years agohammer2 - stabilization - Fix bugs found by blogbench
Matthew Dillon [Tue, 1 Sep 2015 07:28:18 +0000 (00:28 -0700)]
hammer2 - stabilization - Fix bugs found by blogbench

* Make sure that any inode without an associated vnode gets put on
  the sideq if it is dirtied, otherwise it might not ever get flushed.

* Fix a SMP race in hammer2_xop_start_except().  For asynchronous completions,
  the xop can become invalid the instant we release our spinlock if another
  thread manages to process, retire, and free it.

8 years agokernel - Improve namecache generation handling
Matthew Dillon [Tue, 1 Sep 2015 03:28:50 +0000 (20:28 -0700)]
kernel - Improve namecache generation handling

* Reduce mount->mnt_namecache_gen from 64 to 32 bits and add a dummy
  field so the structure size does not change.

* Reduce namecache->nc_namecache_gen from 64 to 32 bits and add a
  second generation number to detect cache_unlink() and cache_rename()
  calls.  Bump the counter in cache_rename() and _cache_unlink().
  Structure size did not change.

* Refactor kern_rename() to use namecache->nc_generation to detect
  a larger subset of changes to the namecache entries which can leak
  in due to the temporary unlock of fromnd->nl_nch.ncp.

8 years agohammer2 - stabilization - Fix a number of bugs revealed by fsx and fsstress.
Matthew Dillon [Tue, 1 Sep 2015 03:20:22 +0000 (20:20 -0700)]
hammer2 - stabilization - Fix a number of bugs revealed by fsx and fsstress.

* Fix block rewriting against deduped data (dedup_off != 0 in call to
  hammer2_chain_resize()).  It was hitting an assertion due to chain->bytes
  not being properly updated.

* A coarse lock is required on the pfs around any link() or rename() which
  needs to mess with hardlink targets.

* Fix an inode meta.nlinks race between the frontend and the backend.  The
  frontend tracks a master copy of the inode.  The backend must also adjust
  meta.nlinks during link and unlink operations because it reads the field
  to determine if the hardlink target should be removed or not.

  This required fixes in hammer2_xop_nlink() and hammer2_xop_nremove() and
  some functional augmentation to hammer2_xop_nlink().

* Leave the target inode locked through the whole rename sequence, the
  hardlink target shifts are just too complex (for now) to be able to rely
  on inode locks.

* Fix an incorrect shared lock in hammer2_xop_nrename() which could result
  in a parent modification being made while held shared instead of exclusive.

* Add debug output for an issue in hammer2_xop_nrename() that has not yet
  been fixed (kprintf... ENOENT).

8 years agouipc: Assert 0->1 reference count transition; it must not happen.
Sepherosa Ziehau [Mon, 31 Aug 2015 13:08:44 +0000 (21:08 +0800)]
uipc: Assert 0->1 reference count transition; it must not happen.

8 years agouipc: Check unp_conn again after unp_connect().
Sepherosa Ziehau [Mon, 31 Aug 2015 13:08:11 +0000 (21:08 +0800)]
uipc: Check unp_conn again after unp_connect().

Since the current unp's token could be released after unp_conn
assignment, we need to check unp_conn again even if unp_connect()
returns no error.

8 years agoacpicall(8): Style fixes.
Sascha Wildner [Mon, 31 Aug 2015 21:32:54 +0000 (23:32 +0200)]
acpicall(8): Style fixes.

8 years agodrm: Update drm_irq.c...
François Tigeot [Mon, 31 Aug 2015 19:35:34 +0000 (21:35 +0200)]
drm: Update drm_irq.c...

... to commit 56cc279b29c7b204fe7d0943509ae209b8b128db from Linux 3.18
drm: Fix deadlock between event_lock and vbl_lock/vblank_time_lock

Imre Vadász noticed a deadlock in the drm code handling vblank irqs.
Fortunately, this was also noticed by the Linux drm developers and fixing
the issue was just a matter of updating drm_irq.c

Reviewed-by: ivadasz
8 years agoacpicall.8: Fix backslashes in method paths.
Sascha Wildner [Mon, 31 Aug 2015 18:14:16 +0000 (20:14 +0200)]
acpicall.8: Fix backslashes in method paths.

8 years agoAdd a acpicall(8) utility for debugging and tweaking purposes.
Sascha Wildner [Mon, 31 Aug 2015 18:01:31 +0000 (20:01 +0200)]
Add a acpicall(8) utility for debugging and tweaking purposes.

It is based on ports' sysutils/acpi_call (from Maxim Ignatenko) with
a few changes by me:

* Rename acpi_call -> acpicall.

* Ioctl handling is in the main acpi.ko module.

* To enable it, the debug.acpi.allow_method_calls tunable needs to
  be set.

* In acpi_call, the mandatory -p option was used to pass the method's
  namespace path. I removed the option and made the path acpicall(8)'s
  argument.

* Wrote a manual page and cleaned up a bit.

The separate acpiio_mcall.h file was added because ACPIIO_DO_MCALL's
argument struct uses ACPICA types, so it needs acpi.h which acpiio.h
(a public header used by some ports) so far didn't need. So to avoid
any hassle, I put the ACPIIO_DO_MCALL ioctl into a separate header
(it's only used by acpicall(8) anyway).

The changes to kdump(1) and truss(1) are to include and build with
acpi.h.

Tested-by: tollens
8 years agohammer2 - bug fixes
Matthew Dillon [Mon, 31 Aug 2015 02:55:53 +0000 (19:55 -0700)]
hammer2 - bug fixes

* When a dirty inode is reclaimed meta-data changes stored in the inode
  structure could sometimes get lost.  These changes must be synchronized
  to the chains in the underlying cluster nodes.

  Repurpose the unlinkq into a more general 'sideq' that handles both
  deletion-on-reclaim and dirty-meta-data-on-reclaim.

  Add a flag to the inode to represent when it is on the sideq, preventing
  situations where it might be added twice.

* Enable the free->allocated transition in the bulkfree code.  Add
  additional statistics and an underflow/overflow check for
  hammer2_bmap_data->avail.  Also adjust the volume free space
  in both directions.  Do not update any live field if 'nofree' is
  set for the chain (~1GB granularity representing possible
  frontend/backend races).

8 years agouipc: Hold per-unp token for all unp usrreq methods
Sepherosa Ziehau [Sun, 30 Aug 2015 14:39:47 +0000 (22:39 +0800)]
uipc: Hold per-unp token for all unp usrreq methods

8 years agohammer2 - Refactor bulkfree
Matthew Dillon [Sun, 30 Aug 2015 21:17:35 +0000 (14:17 -0700)]
hammer2 - Refactor bulkfree

* Change the bulkfree scan from breadth-first to depth-first.  This
  improves disk performance significantly (~2x) and is also needed for the
  duplicate-detection feature.

* Create an 8-way set-associative hash table similar to what the live
  dedup code uses.  Record the data_off for elements we have processed
  and detect if a duplicate is encountered so we do not have to re-process
  the duplicate subtree.

  Also prioritize the table based on the aggregate bottom-up inode count
  to reduce the chance that a top-level duplicate (aka snapshot) will get
  kicked out of the hash table.

* Clean up the hammer2_chain_scan() API, making it more bref-centric
  which allows us to avoid instantiating chain structures for leaf
  entities.  This significantly improves performance and increases
  flexibility.

* Manual page adjustments for kern.maxvnodes settings suggestions.

8 years agoiswdigit(3), iswxdigit(3): Don't limit to U007F
John Marino [Sun, 30 Aug 2015 18:59:42 +0000 (20:59 +0200)]
iswdigit(3), iswxdigit(3): Don't limit to U007F

We inherited a valid range of 00 - 127 for checking wide characters for
type digit or xdigit.

This is a mistake.  The relationship between digits (iswdigit) and
numbers (iswnumber, iswalnum) is that digits are a subset of numbers.
Digits are also a subset of xdigits (iswxdigit).  Digits are limited
to radix-10.  Numeric typess, on the other hand, include factions,
Roman Numerals, circled, etc.  It should cover the entire unicode
(UTF-8) range.

Unfortunately, DragonFly doesn't support the "number" type yet.  The
iswnumber and iswalnum just use the "digit" definition.  Note that
before this commit, they used full range for "digit" type while the
iswdigit() and iswdigits() themselves were limited.

8 years agoUTF8 locales: Refine Latin supplement more
John Marino [Sun, 30 Aug 2015 15:25:58 +0000 (17:25 +0200)]
UTF8 locales: Refine Latin supplement more

The multiplication and division sign were missing, and the control
characters were not outlined.  Also set superscript 1,2,3 as digits.
There are not showing up with iswdigit() function so that requires
further investigation (iswdigit does work for '0','1',...'9' however)

8 years agoUTF8 locales: Include inverted exclamation mark too
John Marino [Sun, 30 Aug 2015 13:39:42 +0000 (15:39 +0200)]
UTF8 locales: Include inverted exclamation mark too

I was off by one character when I defined the first range on the previous
commit.  It starts with an inverted exclamation mark, not the cent sign.

8 years agoUTF8 locales: Complete implemenation of Latin-1 Supplement
John Marino [Sun, 30 Aug 2015 13:12:41 +0000 (15:12 +0200)]
UTF8 locales: Complete implemenation of Latin-1 Supplement

The Latin-1 Supplement block of UTF-8 (U0080-U00FF) was not fully
implemented.  Specifically it was missing U00A1 (inverted exclamation)
through U00BF (inverted question mark).  Some popular characters this
affected was cent sign, pound sign, Yen sign, broken bar, copyright
symbol and superscripts.  On international keyboards, AltGR + number
key wouldn't output correctly.  This addition to the manual ctype input
definitions (and subsequent regenerations) will fix these issues.

Reported by: profmakx, ivadasz
Diagnostics: YRabbit

8 years agohammer2 - live dedup, cleanup
Matthew Dillon [Sun, 30 Aug 2015 03:02:14 +0000 (20:02 -0700)]
hammer2 - live dedup, cleanup

* First attempt at a live dedup.  The H2 strategy code now caches
  {data_off, crc} info to track recently accessed data blocks.  The
  cache is checked in the strategy_write code after device-level
  block encoding.  If we get a cache hit, the disk block is compared
  against the write data and reused if it matches.

* This 'live' dedup should catch most typical 'cp' or 'cpdup' style
  commands.  There will also be a bulk dedup capable of catching
  everything.

* Note that 'df' output might be a bit confusing because the 'Used'
  field represents the topology and does not take into account dedups.
  'Avail' is calculated from the actual freemap.  To make things look
  right the total disk size is adjusted upward so it matches
  Used+Avail.  This mechanism will likely change.

  Here is an example with one copy of /usr/src and 13 copies of /usr/src.
  The first copy eats around 872MB, and a 'du' will show each copy eating
  about the same.  But because of dedup each subsequent copy actually only
  eats around 160MB as you can see from the 'Avail' field:

    test40# df -h /mnt
    Filesystem                             Size   Used  Avail Capacity
    /dev/serno/WD-WX51A82J2299.s1f@LOCAL    99G   934M    99G     1%
    Filesystem                             Size   Used  Avail Capacity
    /dev/serno/WD-WX51A82J2299.s1f@LOCAL   106G   8.5G    97G     8%

* Rename hammer2_bulkscan.c to hammer2_bulkfree.c since that is
  basically all it does.

* Move the synchronization code to its own file, hammer2_synchro.c.
  (note: This code is currently in rip-up mode and will not operate
  properly).

8 years agokernel: Use NULL for pointers in DRIVER_MODULE* calls.
Sascha Wildner [Sat, 29 Aug 2015 11:32:04 +0000 (13:32 +0200)]
kernel: Use NULL for pointers in DRIVER_MODULE* calls.

8 years agokernel: Add gnu/ to SUBDIR for MODULES_WITH_WORLD.
Sascha Wildner [Sat, 29 Aug 2015 10:44:53 +0000 (12:44 +0200)]
kernel: Add gnu/ to SUBDIR for MODULES_WITH_WORLD.

I forgot to do that in b993bb87ded5c733e1f0213efbef1be2660b2536.

8 years agohammer2 - bulkfree work, rip-up cluster sync.
Matthew Dillon [Fri, 28 Aug 2015 20:49:47 +0000 (13:49 -0700)]
hammer2 - bulkfree work, rip-up cluster sync.

* bulkfree no longer attempts to flush.  Instead it deals with races against
  live by refusing to free blocks in L1 freemap chains that have been modified
  since the last sync.  This is a temporary workaround.

* No longer propagate modify_tid during a flush.  modify_tid is now used
  as a localized but cluster-aware TID (whereas mirror_tid is only localized
  to a cluster node).

* Start work on adding an update_tid to the blockref.  This will ultimately
  be used by the cluster synchronization code instead of modify_tid.

* Adjust the DESIGN document for the new synchronization concept.

8 years agokernel: Adjust sys/conf/files for recent drm changes.
Sascha Wildner [Fri, 28 Aug 2015 13:55:24 +0000 (15:55 +0200)]
kernel: Adjust sys/conf/files for recent drm changes.

8 years agokernel/cxm: Add pcidevs.h to the Makefile (forgotten in dcb4b80).
Sascha Wildner [Fri, 28 Aug 2015 13:49:48 +0000 (15:49 +0200)]
kernel/cxm: Add pcidevs.h to the Makefile (forgotten in dcb4b80).

8 years agohammer2 - stabilization, sequencing
Matthew Dillon [Fri, 28 Aug 2015 06:15:17 +0000 (23:15 -0700)]
hammer2 - stabilization, sequencing

* Change the way XOPs are dispatched.  Instead of dispatching a XOP
  to specific service threads in the xgrp we now queue the XOP to a
  per-cluster-node xopq and allow the service threads to compete for
  work.

* Implement XOP dependency tracking.  Cluster nodes can complete execution
  of a XOP in any order and the frontend may complete early on-quorum while
  the XOP is still executing on other cluster nodes.  In this situation
  the inode lock may be released or cycled and another, dependent XOP may
  be issued, potentially executing out of order on the cluster nodes that
  have not yet finished (or possibly even started) the previous XOP.

  With the new queueing mechanism we also implement dependency tracking
  using the xop->ip1, ip2, and ip3 fields.  Dependent XOPs on (slow) cluster
  nodes will be held-back and ordering of dependent XOPS will be enforced.

  This fixes one of several cluster-related issues that will need to be
  addressed in order to free the frontend of slow backend cluster nodes.

* The strategy XOP now uses a per-XOP lock instead of an xgrp lock
  (xgrp is no longer used in the xop structure and XOPs are now
  distributed to potentially different xgrps for each cluster node).

* Normalize some structural field names.

* bulkfree now takes a snapshot of vchain, using a separate (temporary)
  chain structure which isolates the entire topology scan from the
  live filesystem.

  This required minor adjustments to base/count handling for
  HAMMER2_BREF_TYPE_VOLUME and HAMMER2_BREF_TYPE_FREEMAP.

* Debugging adjustments.

8 years agohammer2 - hide some debugging kprintfs
Matthew Dillon [Thu, 27 Aug 2015 06:31:43 +0000 (23:31 -0700)]
hammer2 - hide some debugging kprintfs

* Hide debugging kprintfs related to flushes so we do not default to
  feeding console messages back to syslogd.

8 years ago<regex.h>: REG_ENOSYS was removed in Issue 7 but up to 6 it's needed.
Sascha Wildner [Thu, 27 Aug 2015 17:09:21 +0000 (19:09 +0200)]
<regex.h>: REG_ENOSYS was removed in Issue 7 but up to 6 it's needed.

8 years agoRemove references to colldef(1) and mklocale(1) in manpages & comments.
Sascha Wildner [Thu, 27 Aug 2015 16:46:08 +0000 (18:46 +0200)]
Remove references to colldef(1) and mklocale(1) in manpages & comments.

8 years agodrm/i915: Update to Linux 3.17
François Tigeot [Thu, 27 Aug 2015 18:53:22 +0000 (20:53 +0200)]
drm/i915: Update to Linux 3.17

* With an Haswell stability fix from Linux 3.19

* Display-Port code not completely synced with Linux 3.17, this was
  breaking things as noticed by Rimvydas Jasinskas

* Broadwell and Cherryview support improvements

* Runtime power-management improvements

* Panel Self-Refresh (PSR) now enabled by default on Haswell and Broadwell,
  leading to further power savings

* Interrupt handling improvements

* backlight brightness locking fixes by Yellow Rabbit

* As usual, all sort of little fixes everywhere

8 years agoRemove colldef(1) manpage too via 'make upgrade'.
Sascha Wildner [Thu, 27 Aug 2015 16:34:55 +0000 (18:34 +0200)]
Remove colldef(1) manpage too via 'make upgrade'.

8 years agodrm: Add linux/notifier.h
François Tigeot [Thu, 27 Aug 2015 06:58:34 +0000 (08:58 +0200)]
drm: Add linux/notifier.h

Obtained-from: FreeBSD/OFED

8 years agohammer2 - cleanup
Matthew Dillon [Thu, 27 Aug 2015 05:45:37 +0000 (22:45 -0700)]
hammer2 - cleanup

* Cleanup some printfs.

8 years agomount_hammer2 - Allow serno/ relative paths
Matthew Dillon [Thu, 27 Aug 2015 05:45:21 +0000 (22:45 -0700)]
mount_hammer2 - Allow serno/ relative paths

* Allow paths to omit the /dev.

8 years agokernel - Add root mount support for hammer2
Matthew Dillon [Thu, 27 Aug 2015 05:21:21 +0000 (22:21 -0700)]
kernel - Add root mount support for hammer2

* Don't try to interpret the device string in mountroot for
  hammer2 either (it was already not being interpreted for hammer).

8 years agohammer2 - Add root mount support.
Matthew Dillon [Thu, 27 Aug 2015 05:21:00 +0000 (22:21 -0700)]
hammer2 - Add root mount support.

* Add root mount support to the hammer2 vfs.

8 years agohammer2 - Require a @label in the device path
Matthew Dillon [Thu, 27 Aug 2015 03:49:18 +0000 (20:49 -0700)]
hammer2 - Require a @label in the device path

* If the user forgets to specify an @label in a hammer2 mount, complain
  in a way that does not leave the user confused.

* newfs_hammer2 no longer creates a "BOOT" and "ROOT" PFS by default.
  It still always creates the "LOCAL" PFS which we may use later to hold
  hammer2 configuration data.

  Now hammer2 creates one additional label by default, when no -L option is
  specified, based on the partition from the device path:

  'a' - newfs_hammer2 will create a "BOOT" PFS
  'd' - newfs_hammer2 will create a "ROOT" PFS
   *  - newfs_hammer2 will create a "DATA" PFS

* When -L is specified to indicate label(s) to create, newfs_hammer2 no longer
  creates any default labels other than "LOCAL" (which must always be
  created).

* Adjust manual page.

8 years agohammer2 - Fix hammer2 probe in boot code
Matthew Dillon [Thu, 27 Aug 2015 03:45:55 +0000 (20:45 -0700)]
hammer2 - Fix hammer2 probe in boot code

* During boot2 the BIOS dskread might not be able to handle a 64KB read
  request.  Break requests up into 16KB pieces in the hammer2 read code,
  allowing DragonFly to boot from a HAMMER2 boot partition.

* Automatically dive the "BOOT" label under the superoot.

8 years agohammer2 - Add WANT_HAMMER2 to buildworld
Matthew Dillon [Thu, 27 Aug 2015 03:44:26 +0000 (20:44 -0700)]
hammer2 - Add WANT_HAMMER2 to buildworld

* Setting WANT_HAMMER=YES in /etc/make.conf will build the hammer2 pieces.

8 years agohammer2 - Fix unlink/reclaim panic, add macro for "BOOT" key
Matthew Dillon [Thu, 27 Aug 2015 03:37:04 +0000 (20:37 -0700)]
hammer2 - Fix unlink/reclaim panic, add macro for "BOOT" key

* Fix confusion where an inode would erronously be placed on the unlinkq
  even though it was not moved to the hidden directory.

* Add HAMMER2_BOOT_KEY for use by libstand.

8 years agokernel - allow '@' key at mountroot> prompt
Matthew Dillon [Thu, 27 Aug 2015 03:32:55 +0000 (20:32 -0700)]
kernel - allow '@' key at mountroot> prompt

* Allow the @ key to generate an '@' at the mountroot<> prompt
  so HAMMER2 label specifications can be typed in.

8 years agouipc: Fix lockless unp_conn accessing and uipc_detach() race.
Sepherosa Ziehau [Wed, 26 Aug 2015 12:32:03 +0000 (20:32 +0800)]
uipc: Fix lockless unp_conn accessing and uipc_detach() race.

           THREAD1                         THREAD2

  uipc_send(unp)                    uipc_detach(unp2)
  {                                 {
    lock(unp);                        unp_free(unp2)
    unp2 = unp->unp_conn;             {
      :                                 /* unp2 ref is 0 */
    unp_reference(unp2);                unp_detach(unp2); (***)
    /* unp2 ref is 1 */               }
      :                             }
    unp_free(unp2)                            :
    {                                         :
       /* unp2 ref is 0 */                    :
       unp_detach(unp2); (***)                :
    }                                         :
    unlock(unp);                              :
  }                                           :

Two calls of unp_detach() on unp2!

To fix this race, we drop all connections before calling unp_free()
on uipc_detach() and uipc_abort() path.

8 years agouipc: Assert global token is held in unp_connect_pair
Sepherosa Ziehau [Wed, 26 Aug 2015 12:31:37 +0000 (20:31 +0800)]
uipc: Assert global token is held in unp_connect_pair

8 years agoregex.3: Add LIBRARY section.
Sascha Wildner [Wed, 26 Aug 2015 16:32:01 +0000 (18:32 +0200)]
regex.3: Add LIBRARY section.

8 years agouipc: Return error from unp_connect_pair() if one of unps is not attached
Sepherosa Ziehau [Tue, 25 Aug 2015 15:12:42 +0000 (23:12 +0800)]
uipc: Return error from unp_connect_pair() if one of unps is not attached

8 years agouipc: Don't abuse unp_conn for unconnect DGRAM unix sockets.
Sepherosa Ziehau [Tue, 25 Aug 2015 14:06:57 +0000 (22:06 +0800)]
uipc: Don't abuse unp_conn for unconnect DGRAM unix sockets.

Use unp_find_lockref() to located the target unp instead.

8 years agouipc: Fix various races on unp_connect() path.
Sepherosa Ziehau [Tue, 25 Aug 2015 14:05:14 +0000 (22:05 +0800)]
uipc: Fix various races on unp_connect() path.

And factor out unp_find_lockref(), which will be used to avoid
abusing unpcb.unp_conn on uipc_send() for unconnected DGRAM
unix sockets.

8 years agokernel: Sync sys/conf/files with recent drm(4) and radeonkms(4) updates.
Sascha Wildner [Tue, 25 Aug 2015 17:38:46 +0000 (19:38 +0200)]
kernel: Sync sys/conf/files with recent drm(4) and radeonkms(4) updates.

This fixes building drm into the kernel.

8 years agodrm: Make the hlist API compatible with Linux 3.17
François Tigeot [Tue, 25 Aug 2015 11:45:44 +0000 (13:45 +0200)]
drm: Make the hlist API compatible with Linux 3.17

* Replace hlist_add_after_rcu by hlist_add_behind_rcu

* hlist_for_each_entry() now only uses 3 arguments

8 years agokernel/linux: Add hweight64()
François Tigeot [Tue, 25 Aug 2015 05:32:42 +0000 (07:32 +0200)]
kernel/linux: Add hweight64()

8 years agokernel: Add bitcount64 to sys/systm.h
François Tigeot [Tue, 25 Aug 2015 05:15:27 +0000 (07:15 +0200)]
kernel: Add bitcount64 to sys/systm.h

Obtained-from: FreeBSD

8 years agouipc: Use flag to indicate that the unpcb was detached/aborted.
Sepherosa Ziehau [Mon, 24 Aug 2015 14:02:20 +0000 (22:02 +0800)]
uipc: Use flag to indicate that the unpcb was detached/aborted.

Since unpcb detach (so->so_pcb set to NULL) could be delayed by
extra references, we use a flag to indicate that the unpcb was
detached/aborted.  And hold per-unpcb token in uipc_detach() and
uipc_abort(), since this flag is also checked in other uipc_userreq
methods, e.g. uipc_send().

This commit makes uipc_abort() reentrant.

8 years agouipc: Use atomic operation for unp_flags
Sepherosa Ziehau [Mon, 24 Aug 2015 13:52:18 +0000 (21:52 +0800)]
uipc: Use atomic operation for unp_flags

8 years agosort.1: Clean up mdoc.
Sascha Wildner [Mon, 24 Aug 2015 18:15:15 +0000 (20:15 +0200)]
sort.1: Clean up mdoc.

While here, set WITHOUT_NLS in the Makefile.

8 years agotcpdrop.8: Remove unneeded .Nm arguments.
Sascha Wildner [Mon, 24 Aug 2015 18:01:18 +0000 (20:01 +0200)]
tcpdrop.8: Remove unneeded .Nm arguments.

8 years agoSort SEE ALSO in various manual pages.
Sascha Wildner [Mon, 24 Aug 2015 16:59:03 +0000 (18:59 +0200)]
Sort SEE ALSO in various manual pages.

8 years agomdoc.local: Add 4.0 version so it can be used in manpages (procctl(2)).
Sascha Wildner [Mon, 24 Aug 2015 16:58:30 +0000 (18:58 +0200)]
mdoc.local: Add 4.0 version so it can be used in manpages (procctl(2)).

This is one of the rare cases where a new feature appeared "first" in
a release (i.e. was MFC'd).

8 years agoAdd MLINKS for 3 kernel functions documented on the led(4) manpage.
Sascha Wildner [Mon, 24 Aug 2015 16:56:46 +0000 (18:56 +0200)]
Add MLINKS for 3 kernel functions documented on the led(4) manpage.

8 years agolibusbhid: Add missing MLINK for hid_get_report_id().
Sascha Wildner [Mon, 24 Aug 2015 16:51:39 +0000 (18:51 +0200)]
libusbhid: Add missing MLINK for hid_get_report_id().

8 years agoAdd MLINKS for recently added tree(3) macros.
Sascha Wildner [Mon, 24 Aug 2015 16:48:41 +0000 (18:48 +0200)]
Add MLINKS for recently added tree(3) macros.

8 years agombintowcr.3: Further mdoc cleanup.
Sascha Wildner [Mon, 24 Aug 2015 16:30:00 +0000 (18:30 +0200)]
mbintowcr.3: Further mdoc cleanup.

8 years agombintowcr.3: Mention missing functions.
Sascha Wildner [Mon, 24 Aug 2015 16:16:34 +0000 (18:16 +0200)]
mbintowcr.3: Mention missing functions.

8 years ago<xlocale/_wchar.h>: Fix wrong prototype.
Sascha Wildner [Mon, 24 Aug 2015 15:57:37 +0000 (17:57 +0200)]
<xlocale/_wchar.h>: Fix wrong prototype.

8 years agodrm/radeon: Update temperature sensor support after update to Linux 3.17
Imre Vadász [Sun, 23 Aug 2015 21:09:43 +0000 (23:09 +0200)]
drm/radeon: Update temperature sensor support after update to Linux 3.17

We can apparently just use the rdev->pm.dpm.thermal.min_temp and
rdev->pm.dpm.thermal.min_temp values as WARN and CRIT threshholds
respectively.

8 years agouipc: Factor out unp_getsocktoken()/unp_reltoken()
Sepherosa Ziehau [Sun, 23 Aug 2015 14:44:49 +0000 (22:44 +0800)]
uipc: Factor out unp_getsocktoken()/unp_reltoken()

Streamline the code a little bit.  This also paves the way to make
uipc_abort() reentrant.

8 years agolibc: Add missing futimens(2) manual page link.
Sascha Wildner [Sun, 23 Aug 2015 23:24:51 +0000 (01:24 +0200)]
libc: Add missing futimens(2) manual page link.

8 years agodrm: Move DMI definitions to their usual Linux headers
François Tigeot [Sun, 23 Aug 2015 20:11:16 +0000 (22:11 +0200)]
drm: Move DMI definitions to their usual Linux headers

8 years agodrm/linux: Improve the workqueue subsystem
François Tigeot [Sun, 23 Aug 2015 19:52:29 +0000 (21:52 +0200)]
drm/linux: Improve the workqueue subsystem

Adding some APIs used by the drm/i915 code from Linux 3.17

8 years agosys/vfs/hammer: Don't fail to downgrade cursor
Tomohiro Kusumi [Sun, 23 Aug 2015 11:53:50 +0000 (20:53 +0900)]
sys/vfs/hammer: Don't fail to downgrade cursor

7ef2d7b should have placed end: before
hammer_cursor_downgrade(cursor);.

If hammer volume-del starts to reblock because of non-empty
volume, and first reblocks data, but skips reblock for btree
node as the node was not in that volume (data and btree node
stored in different volume which is usually a rare case),
then volume-del returns from hammer_reblock_helper() without
donwgrading upgraded lock.

This could happen only on volume-del, but not hammer reblock
command since hammer reblock command never hits goto end;.

8 years agosys/vfs/hammer: Fix wrong comment
Tomohiro Kusumi [Sun, 23 Aug 2015 11:12:49 +0000 (20:12 +0900)]
sys/vfs/hammer: Fix wrong comment

It doesn't return EDEADLK.

8 years agosys/vfs/hammer: Fix possible panic with vfs.hammer.debug_general=0x4000
Tomohiro Kusumi [Sun, 23 Aug 2015 10:53:33 +0000 (19:53 +0900)]
sys/vfs/hammer: Fix possible panic with vfs.hammer.debug_general=0x4000

bc996e6 needed to check NULL-elm case for node reblock
when (vfs.hammer.debug_general & 0x4000) != 0.

The above sysctl has 0 by default, so nothing will happen
as long as keeping a default value when reblock starts.

8 years agosys/vfs/hammer: Minor cleanups
Tomohiro Kusumi [Sun, 23 Aug 2015 05:49:33 +0000 (14:49 +0900)]
sys/vfs/hammer: Minor cleanups

Nothing changes, but this probably has better readability
(and also better for grep) as it doesn't make code looks
like it's about inode. nnode and nnode->ondisk must exist
at this point.

Also sync a comment between internal and leaf.
Also add a comment on internal and leaf reblock.

8 years agodrm/radeon: Wrong authorship in previous commit
François Tigeot [Sat, 22 Aug 2015 21:26:26 +0000 (23:26 +0200)]
drm/radeon: Wrong authorship in previous commit

The big drm/radeon update to Linux 3.17 was really made by Rimvydas
Jasinskas but pushed by myself.

I must have changed the authorship unknowingly while rebasing a
bugfix and pushed the commit without noticing :-(

8 years agodrm/radeon: Update to Linux 3.17 (v2)
François Tigeot [Sat, 22 Aug 2015 16:20:38 +0000 (18:20 +0200)]
drm/radeon: Update to Linux 3.17 (v2)

Catch up with recent updates in i915kms driver.
While there perform some cleaning in drm and drm/ttm too.

This smallish(1.2MB) diff between Linux v3.12..v3.17 brings
few improvements for radeon cards support on DragonFly BSD.

Driver is VERY experimental even if FF 720p "Hey Mamma"
looks much more pleasing to the eyes on my Xeon box.

Me being Fortran developer(who wants to run OpenCL on BSDs too)
was literally throwing diffs at the fan to see what sticks on.
After cleaning up the mess a bit, these features seems to behave:
  kms-syscons switching on R7 240 and 5770 JUNIPER;
  current DPorts Xorg;
  Xorg-next(1.17.2) + Mesa-next(glamor for radeonsi);
  2D tiling now works out of the box on OLAND;
  glxgears/cubemap/cuberender mesa demos;
  firefox youtube videos(still some blinking on overlays);
  mpv -vo vdpau --hwdec=vdpau bsd-0088.mp4 (--vo=opengl too);
  UVD (decoding limited to 1080p frame streams);
  fragging in OpenArena maxed-out(even ttys[0-8] to quickly check mail);
  hdmi audio;
  DPM (enabled by default);
  gpu temperature monitoring through hw.sensors framework;
  automatic firmware loading.

TODO:
  update drm/ttm, any help would be really appreciated;
  ww_mutex, yep still good old "homegrown" locks;
  vma, newer shrinker api;
  dma_buf/prime;
  iic/i2c rework;
  kldunload radeonkms;
  better gart sizes support;
  newer firmware format support;
  fix failing ring sync test to ring-5(UVD);
  check how driver supports X2 and IGP cards;
  better OpenCL through Clover;
  many more.

Thanks goes to:
  ftigeot@efnet for opportunity and i915 work
  YRabbit@efnet for extensive testing of hdmi A/V on TURKS
  ivadasz@efnet for temperature sensors support
  mneumann@efnet for testing on HAWAII

  AMD for investing time and effort in opensource drivers
  NetBSD and Linux gpu developers

Special thanks to:
  everyone behind freebsd-ports-graphics/opencl (keep pushing the mngt!)

  and that Sweet special girl out there.

8 years agodrm: Reintroduce drm_kms_free()
François Tigeot [Sat, 22 Aug 2015 18:21:31 +0000 (20:21 +0200)]
drm: Reintroduce drm_kms_free()

* The Linux version of kfree() is a macro with one argument.

* The real kfree() function takes two arguments.

* kfree() cannot be simply called via a function pointer from
  Linux code.

* Re-add the special purpose drm_kms_free() wrapper function
  to handle this situation. It was wrongly removed during one of the
  drm_crtc.c syncs with Linux.

Reported-by: ivadasz
8 years agodrm/radeon: Add pcie_get_readrq(), pcie_set_readrq() functions
zrj [Sat, 15 Aug 2015 07:08:52 +0000 (10:08 +0300)]
drm/radeon: Add pcie_get_readrq(), pcie_set_readrq() functions

pcie_set_readrq() needs something more clever(clear and set).

Extracted-from: drm/radeon/evergreen.c

8 years agosys/vfs/hammer: Add hammer_move_node()
Tomohiro Kusumi [Sat, 22 Aug 2015 07:59:11 +0000 (16:59 +0900)]
sys/vfs/hammer: Add hammer_move_node()

Procedures to move internal and leaf node are basically the same.

Also sync some comments between internal and leaf.

8 years agosbin/hammer: Print total bytes of reblocked nodes
Tomohiro Kusumi [Sat, 22 Aug 2015 04:01:08 +0000 (13:01 +0900)]
sbin/hammer: Print total bytes of reblocked nodes

just like it shows both "data elements" and "data bytes"
in the next two lines.

"btree bytes" is kind of obvious since btree nodes are
all 4KB, and there isn't a field for "btree bytes" in
struct hammer_ioc_reblock as well, however this isn't
obvious for users so it should print it.

8 years agosys/vfs/hammer: Change obsolete hammer_ioc_reblock fields to reserved
Tomohiro Kusumi [Sat, 22 Aug 2015 03:52:34 +0000 (12:52 +0900)]
sys/vfs/hammer: Change obsolete hammer_ioc_reblock fields to reserved

record_count and record_moves fields in
hammer_ioc_reblock are not used and not necessary.

These fields were used when there was a distinction
between data and meta reblock (see bf686dbe). Meta
reblock is now a part of data reblock, so these two
are no longer used.

8 years agosys/vfs/hammer: Don't try to reblock everything on volume-del
Tomohiro Kusumi [Fri, 21 Aug 2015 12:13:40 +0000 (21:13 +0900)]
sys/vfs/hammer: Don't try to reblock everything on volume-del

Add volume# option to reblock ioctl and use that on hammer
volume-del instead of trying to reblock every data/node that
the reblocker has faced.

This is only used internally by hammer volume-del ioctl when
it finds the volume-to-remove is not empty and needs to get
reblocked. hammer reblock command does not provide an option
to specify volume# since it shouldn't be necessary for users
in general.

This makes huge difference as it cuts extra and unnecessary
i/o from reblocking, especially when the volume to remove
only has small amount data in it. The following examples show
much of the time spent on reblocking on volume-del comes from
unnecessary i/o. Example1 spent most of the time moving data
in /dev/da1 which wasn't necessary.

Example 1 - before this commit
  # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 >/dev/null
  # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER
  # dd if=/dev/zero of=/HAMMER/out bs=1000000 count=120000 >/dev/null 2>&1
  # sync; sync; sync; sync
  # df -Th /HAMMER
  Filesystem  Type     Size   Used  Avail Capacity  Mounted on
  TEST        hammer   334G   112G   222G    34%    /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 14145
          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 */
  # hammer volume-blkdevs /HAMMER
  /dev/da1:/dev/da2:/dev/da3
  # time hammer volume-del /dev/da2 /HAMMER

  real    14m29.119s
  user    0m0.000s
  sys     7m14.388s
  # hammer volume-blkdevs /HAMMER
  /dev/da1:/dev/da3

Example 2 - with this commit
  # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 >/dev/null
  # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER
  # dd if=/dev/zero of=/HAMMER/out bs=1000000 count=120000 >/dev/null 2>&1
  # sync; sync; sync; sync
  # df -Th /HAMMER
  Filesystem  Type     Size   Used  Avail Capacity  Mounted on
  TEST        hammer   334G   112G   222G    34%    /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 14145
          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 */
  # hammer volume-blkdevs /HAMMER
  /dev/da1:/dev/da2:/dev/da3
  # time hammer volume-del /dev/da2 /HAMMER

  real    0m8.139s
  user    0m0.000s
  sys     0m4.177s
  # hammer volume-blkdevs /HAMMER
  /dev/da1:/dev/da3

8 years agosys/vfs/hammer: Remove unnecessary error check
Tomohiro Kusumi [Fri, 21 Aug 2015 12:13:05 +0000 (21:13 +0900)]
sys/vfs/hammer: Remove unnecessary error check

error is always ==0 at this point.

8 years agosys/vfs/hammer: Don't repeat layer1 blockmap check of volume-to-remove
Tomohiro Kusumi [Fri, 21 Aug 2015 12:12:06 +0000 (21:12 +0900)]
sys/vfs/hammer: Don't repeat layer1 blockmap check of volume-to-remove

hammer's blockmap allocator can simply skip the whole volume
without going through unnecessary goto;s when the allocator's
current zone2 offset is in the volume-to-remove.

This is similar to 0871ec5 except that this commit does not
need to check layer1->phys_offset because that volume is what
hammer volume-del is wanting to remove.

8 years agosys/vfs/hammer: Adjust hammer_debug_general
Tomohiro Kusumi [Thu, 20 Aug 2015 14:46:56 +0000 (23:46 +0900)]
sys/vfs/hammer: Adjust hammer_debug_general

Change hammer_debug_general in hammer_blockmap_getfree()
to 0x4000 which is the same value as those in
sys/vfs/hammer/hammer_reblock.c.

This is better since hammer_blockmap_getfree() is made
for reblock and only used by reblock (0x0800 picks up
other debug kprintfs that aren't related to reblock).

Also note that hammer_debug_general values are randomly
picked based on use cases rather than fixed value for
each file/etc.

Add some comments on the conditionals that are used to
start data/node reblock since this part is not too easy
to understand.

8 years agosbin/hammer: Move two blockmap functions to hammer/blockmap.c
Tomohiro Kusumi [Thu, 20 Aug 2015 10:55:25 +0000 (19:55 +0900)]
sbin/hammer: Move two blockmap functions to hammer/blockmap.c

from hammer/ondisk.c.
See sys/vfs/hammer/hammer_blockmap.c for details.

alloc_blockmap() should be in hammer/blockmap.c than
hammer/ondisk.c considering alloc_blockmap() is the
userspace version of hammer_blockmap_alloc() in
sys/vfs/hammer/hammer_blockmap.c which basically does
the same thing. If blockmap_lookup() is located in
hammer/blockmap.c then this one should be too.

alloc_bigblock() is the userspace only function that is
only used by newfs_hammer when newfs_hammer initially
allocates the whole 8MB chunks, however since the idea
of alloc_bigblock() is the same as alloc_blockmap()
(difference in allocation size), it makes better sense
to have this in hammer/blockmap.c as well.

(There are other blockmap related functions but those
are more of formatting initial ondisk image based on
blockmap info than blockmap handling itself, so those
should stay in hammer/ondisk.c)

8 years agosbin/hammer: Cleanup pwrite(2) wrapper
Tomohiro Kusumi [Thu, 20 Aug 2015 10:22:42 +0000 (19:22 +0900)]
sbin/hammer: Cleanup pwrite(2) wrapper

Just make writehammerbuf() return 0 or -1 instead of void,
just like readhammerbuf() returns 0 or -1.

8 years agosbin/hammer: Cleanup hammer show
Tomohiro Kusumi [Thu, 20 Aug 2015 10:22:06 +0000 (19:22 +0900)]
sbin/hammer: Cleanup hammer show

Also change "=%d" to "=B%d" on error to clearly distinct
from non-error case "=%d%%".

'B' usually represents error (bad) in hammer show.

8 years agosbin/newfs_hammer: Explicitly tell which volume is root volume
Tomohiro Kusumi [Wed, 19 Aug 2015 16:13:48 +0000 (01:13 +0900)]
sbin/newfs_hammer: Explicitly tell which volume is root volume

hammer volume-del says "Cannot remove root-volume" if one
tries to remove the root volume, however no hammer commands
actually tell which one is the root volume.

This commit makes newfs_hammer printf the root volume name,
followed by the existing undo/etc info of the root volume.
Also refer to the root volume in manpages.

(It may be helpful if other hammer commands like info or
volume-list show the root volume name just like newfs_hammer,
however it's not too trivial to do that. One reason is because
hammer seems to have been designed that way so users don't
need to care about any detail of underlying fs volumes.
This commit is trivial since newfs_hammer code knows which
one is the root volume)

8 years agosys/vfs/hammer: Minor fix on volume format on volume-add
Tomohiro Kusumi [Wed, 19 Aug 2015 14:58:05 +0000 (23:58 +0900)]
sys/vfs/hammer: Minor fix on volume format on volume-add

It's better to just copy volume relative offset from
the existing root volume than having the magic number
"HAMMER_BUFSIZE * 16" in both kernel and userspace.