]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFV r316918: 7990 libzfs: snapspec_cb() does not need to call zfs_strdup()
Alexander Motin [Tue, 20 Feb 2018 20:46:27 +0000 (20:46 +0000)]
MFV r316918: 7990 libzfs: snapspec_cb() does not need to call zfs_strdup()

illumos/illumos-gate@d8584ba6fb7a5e46da1725845b99ae5fab5a4baf
https://github.com/illumos/illumos-gate/commit/d8584ba6fb7a5e46da1725845b99ae5fab5a4baf

https://www.illumos.org/issues/7990
  The snapspec_cb() callback function in libzfs does not need to call zfs_strdup().

Reviewed by: Yuri Pankov <yuri.pankov@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Author: Marcel Telka <marcel@telka.sk>

6 years agoMFV r316902: 7745 print error if lzc_* is called before libzfs_core_init
Alexander Motin [Tue, 20 Feb 2018 20:40:55 +0000 (20:40 +0000)]
MFV r316902: 7745 print error if lzc_* is called before libzfs_core_init

illumos/illumos-gate@7c13517fff71be473e47531ef4330160c042bedc
https://github.com/illumos/illumos-gate/commit/7c13517fff71be473e47531ef4330160c042bedc

https://www.illumos.org/issues/7745
  The problem is that consumers of `libZFS_Core` that forget to call
  `libzfs_core_init()` before calling any other function of the library
  are having a hard time realizing their mistake. The library's internal
  file descriptor is declared as global static, which is ok, but it is not
  initialized explicitly; therefore, it defaults to 0, which is a valid
  file descriptor. If `libzfs_core_init()`, which explicitly initializes
  the correct fd, is skipped, the ioctl functions return errors that do
  not have anything to do with `libZFS_Core`, where the problem is
  actually located.
  Even though assertions for that existed within `libZFS_Core` for debug
  builds, they were never enabled because the `-DDEBUG` flag was missing
  from the compiler flags.
  This patch applies the following changes:
  1. It adds `-DDEBUG` for debug builds of `libZFS_Core` and `libzfs`,
         to enable their assertions on debug builds.
  2. It corrects an assertion within `libzfs`, where a function had
         been spelled incorrectly (`zpool_prop_unsupported()`) and nobody
         knew because the `-DDEBUG` flag was missing, and the preprocessor
         was taking that part of the code away.
  3. The library's internal fd is initialized to `-1` and `VERIFY`
         assertions have been placed to check that the fd is not equal to
         `-1` before issuing any ioctl. It is important here to note, that
         the `VERIFY` assertions exist in both debug and non-debug builds.
  4. In `libzfs_core_fini` we make sure to never increment the
         refcount of our fd below 0, and also reset the fd to `-1` when no
         one refers to it. The reason for this, is for the rare case that
         the consumer closes all references but then calls one of the
         library's functions without using `libzfs_core_init()` first, and
         in the mean time, a previous call to `open()` decided to reuse
         our previous fd. This scenario would have passed our assertion in

Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>

6 years agomtx: add debug assertions to mtx_spin_wait_unlocked
Mateusz Guzik [Tue, 20 Feb 2018 20:39:34 +0000 (20:39 +0000)]
mtx: add debug assertions to mtx_spin_wait_unlocked

6 years agoMFV r316901:
Alexander Motin [Tue, 20 Feb 2018 20:37:01 +0000 (20:37 +0000)]
MFV r316901:
7730 libzfs`add_config() leaks config nvl when reading spare/l2cache devices

illumos/illumos-gate@105686550ee9cbf5d033166a8a2a5a763667d436
https://github.com/illumos/illumos-gate/commit/105686550ee9cbf5d033166a8a2a5a763667d436

https://www.illumos.org/issues/7730
  antares:root:~# mdb /usr/sbin/zpool
  > ::sysbp _exit
  > ::run import
     pool: data
       id: 2093977168778024605
    state: ONLINE
   action: The pool can be imported using its name or numeric identifier.
   config:

          data        ONLINE
            c6t0d0    ONLINE
            c6t1d0    ONLINE
          cache
            c6t2d0
  mdb: stop on entry to _exit
  mdb: target stopped at:
  0xfee556ba:     nop
  mdb: You've got symbols!
  Loading modules: [ ld.so.1 libumem.so.1 libc.so.1 libtopo.so.1 libavl.so.1
  libnvpair.so.1 ]
  > ::findleaks -d
  BYTES             LEAKED VMEM_SEG CALLER
  4096                  10 fda7b000 MMAP
  8192                   1 fea8d000 MMAP
  8192                   1 fe76d000 MMAP
  8192                   1 fe66e000 MMAP
  4096                   1 fe570000 MMAP
  8192                   1 fe470000 MMAP
  4096                   1 fe372000 MMAP
  4096                   1 fe273000 MMAP

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Serapheim Dimitropoulos <serapheim@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Yuri Pankov <yuri.pankov@nexenta.com>

6 years agoMFV r316893:
Alexander Motin [Tue, 20 Feb 2018 20:34:04 +0000 (20:34 +0000)]
MFV r316893:
7604 if volblocksize property is the default, it displays as "-" rather than 8K

illumos/illumos-gate@4d86c0eab246bdfddc2dd52410ba808433bd6266
https://github.com/illumos/illumos-gate/commit/4d86c0eab246bdfddc2dd52410ba808433bd6266

https://www.illumos.org/issues/7604
  If a zvol has the default setting for the "volblocksize" property, it is
  8KB. However, it is displayed as "-" (not present), rather than "8K".
  The problem was introduced by:
  commit 25228e830e86924a41243343b1de9daf2d7dd43a
      Author: Matthew Ahrens &lt;mahrens@delphix.com&gt;
      Date:   Thu Nov 17 14:37:24 2016 -0800
  7571 non-present readonly numeric ZFS props do not have default value
  which changed changed get_numeric_property() to indicate that readonly
  default properties are not present. However, zfs_prop_readonly() returns
  TRUE for both readonly and set-once properties (e.g. volblocksize).
  Amusingly, that commit essentially reverted:
  6900484 default volblocksize is no longer being reported correctly
  from November 2009. However, that change was not correct either; the
  correct solution is to only do this check for "truly readonly" (i.e. not
  setonce) properties.
  $ zfs list -t volume -o name,volblocksize
      NAME
  VOLBLOCK
      domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
  archive            -
      domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
  datafile           -
      domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
  external           -
      rpool/dump
  128K
      rpool/swap
  4K
      rpool/swap1
  ===============================================================================

Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Matthew Ahrens <mahrens@delphix.com>

6 years agoMFV r316876: 7542 zfs_unmount failed with EZFS_UNSHARENFSFAILED
Alexander Motin [Tue, 20 Feb 2018 20:30:40 +0000 (20:30 +0000)]
MFV r316876: 7542 zfs_unmount failed with EZFS_UNSHARENFSFAILED

illumos/illumos-gate@09c9e6dc9b69d10b771bb87e01040ec320a0bfd3
https://github.com/illumos/illumos-gate/commit/09c9e6dc9b69d10b771bb87e01040ec320a0bfd3

https://www.illumos.org/issues/7542
  libshare keeps a cached copy of the sharetab listing in memory, which can
  become out of date if shares are destroyed or created while leaving a libzfs
  handle open. This results in a spurious unmounting failure when an NFS share
  exists but isn't in the stale libshare cache.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matt Amdur <matt.amdur@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Chris Williamson <chris.williamson@delphix.com>

6 years agolualoader: Replace invalid construct with valid construct
Kyle Evans [Tue, 20 Feb 2018 20:29:41 +0000 (20:29 +0000)]
lualoader: Replace invalid construct with valid construct

It only worked by coincidence, but it did work. Store varargs in a table
instead and work off of that.

6 years agoMFV r316875: 7336 vfork and O_CLOEXEC causes zfs_mount EBUSY
Alexander Motin [Tue, 20 Feb 2018 20:26:48 +0000 (20:26 +0000)]
MFV r316875: 7336 vfork and O_CLOEXEC causes zfs_mount EBUSY

illumos/illumos-gate@873c4903a52d089cd8234b79d24f5a3fc3bccc82
https://github.com/illumos/illumos-gate/commit/873c4903a52d089cd8234b79d24f5a3fc3bccc82

https://www.illumos.org/issues/7336
  We can run into a problem where we call into zfs_mount, which in turn calls
  is_dir_empty, which opens the directory to try and make sure it's empty. The
  issue with the current approach is that it holds the directory open while it
  traverses it with readdir, which, due to subtle interaction with the Java JVM,
  vfork, and exec can cause a tricky race condition resulting in zfs_mount
  failures.
  The approach to resolving the issue in this patch is to drop the usage of
  readdir altogether, and instead rely on the fact that ZFS stores the number of
  entries contained in a directory using the st_size field of the stat structure.
  Thus, if the directory in question is a ZFS directory, we can check to see if
  it's empty by calling stat() and inspecting the st_size field of structure
  returned.
  ===============================================================================
  The root cause appears to be an interesting race between vfork, exec, and
  zfs_mount's usage of O_CLOEXEC when calling openat. Here's what is going on:
  1. We call zfs_mount, and this in turn calls openat to check if the directory
  is empty, which results in opening the directory we're trying to mount onto,
  and increment v_count.
  2. As we're in the middle of reading the directory, vfork is called by the JVM
  and proceeds to exec the jspawnhelper utility. As a result of the vfork, we
  take an additional hold on the directory, which increments v_count a second
  time. The semantics of vfork mean the parent process will wait for the child
  process to exit or exec before the parent can continue; at this point the
  parent is in the middle of zfs_mount, reading the directory to determine if
  it's empty or not.
  3. The child process exec-ing jspawnhelper gets to the relvm call within
  exec_args (which is called by exec_common). relvm is the function that releases
  the parent process, allowing the parent to proceed. The problem is, at this
  point of calling relvm, the child hasn't yet called close_exec which is
  responsible for closing the file descriptors inherited from the parent process

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agoFix reaping on process fd close broken after r329449
Mateusz Guzik [Tue, 20 Feb 2018 20:19:38 +0000 (20:19 +0000)]
Fix reaping on process fd close broken after r329449

The only consumer of proc_reap other than proc_to_reap was not updated
to not PROC_SLOCK.

Reported by:    Juan Ramon Molina Menor <listjm club.fr>

6 years agoMFV r316873: 7233 dir_is_empty should open directory with CLOEXEC
Alexander Motin [Tue, 20 Feb 2018 20:17:19 +0000 (20:17 +0000)]
MFV r316873: 7233 dir_is_empty should open directory with CLOEXEC

illumos/illumos-gate@d420209d9c807f782c1d31f5683be74798142198
https://github.com/illumos/illumos-gate/commit/d420209d9c807f782c1d31f5683be74798142198

https://www.illumos.org/issues/7233
  This fixes a race where one thread is executing zfs_mount() while another
  thread forks and execs. If the fork occurs while the directory is open, the
  child process will inherit (but not necessarily close immediately) the open fd
  for the directory, preventing the mount.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Alex Reece <alex@delphix.com>

6 years agoMFV r316872: 7502 ztest should run zdb with -G (debug mode)
Alexander Motin [Tue, 20 Feb 2018 20:14:11 +0000 (20:14 +0000)]
MFV r316872: 7502 ztest should run zdb with -G (debug mode)

illumos/illumos-gate@c3c65d17f7b6689bbd6568a1a1fcc0c4a3bac127
https://github.com/illumos/illumos-gate/commit/c3c65d17f7b6689bbd6568a1a1fcc0c4a3bac127

https://www.illumos.org/issues/7502
  Right now ztest executes zdb without -G, so when it has errors, the messages
  are often not very helpful:
  Executing zdb -bccsv -d -U /rpool/tmp/zpool.cache ztest
  zdb: can't open 'ztest': Operation not supported
  ztest: '/usr/sbin/amd64/zdb -bccsv -d -U /rpool/tmp/zpool.cache ztest' exit
  code 1
  With -G, we'd have:
  /usr/sbin/amd64/zdb -bccsv -d -U /rpool/tmp/zpool.cache -G ztest
  zdb: can't open 'ztest': Operation not supported

  ZFS_DBGMSG(zdb):
  spa_open_common: opening ztest
  spa_load(ztest): LOADING
  spa_load(ztest): FAILED: unable to parse config [error=48]
  spa_load(ztest): UNLOADING
  Which indicates where the error came from

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoFix memory leaks in zdb introduced by r329508
Alan Somers [Tue, 20 Feb 2018 19:54:06 +0000 (19:54 +0000)]
Fix memory leaks in zdb introduced by r329508

Reported by: Coverity
CID: 1386185
MFC after: 3 weeks
X-MFC-With: 329508
Sponsored by: Spectra Logic Corp

6 years agoloader.lua: Expose errno table to lua
Conrad Meyer [Tue, 20 Feb 2018 19:39:48 +0000 (19:39 +0000)]
loader.lua: Expose errno table to lua

Reviewed by: kevans
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D14454

6 years agolualoader: Ignore ACPI bits on !i386
Kyle Evans [Tue, 20 Feb 2018 19:21:34 +0000 (19:21 +0000)]
lualoader: Ignore ACPI bits on !i386

6 years agoIFLIB: do not remove dmamap on buffer unload
Stephen Hurd [Tue, 20 Feb 2018 18:33:45 +0000 (18:33 +0000)]
IFLIB: do not remove dmamap on buffer unload

Dmamap is created only on IFC attach. If we remove it on
buffer release, we won't be able to do ifconfig down&up. Only destroy
when in detach.

Reported by: wma
Reviewed by: wma
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D14060

6 years agoliblua: Add loader.machine and loader.machine_arch properties
Kyle Evans [Tue, 20 Feb 2018 18:24:20 +0000 (18:24 +0000)]
liblua: Add loader.machine and loader.machine_arch properties

Provisioned from MACHINE/MACHINE_ARCH on the system, expose loader.machine
and loader.machine_arch respectively.

These may be used to hide ACPI option on non-applicable archs.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D14446

6 years agoLua lfs.attributes: Provide a more consistent error return
Conrad Meyer [Tue, 20 Feb 2018 18:21:30 +0000 (18:21 +0000)]
Lua lfs.attributes: Provide a more consistent error return

In the remaining error case, return a 3-tuple consistent with the other
error return case.

Document how to invoke lfs.attributes() and detect/decode error return in
example comments.

Reviewed by: kevans
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D14451

6 years agoReduce duplication in dynamic syscall registration code.
Brooks Davis [Tue, 20 Feb 2018 18:08:57 +0000 (18:08 +0000)]
Reduce duplication in dynamic syscall registration code.

Remove the unused syscall_(de)register() functions in favor of the
better documented and easier to use syscall_helper_(un)register(9)
functions.

The default and freebsd32 versions differed in which array of struct
sysents they used and a few missing updates to the 32-bit code as
features were added to the main code.

Reviewed by: cem
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14337

6 years agolualoader: Eliminate global namespace pollution in loader.lua
Kyle Evans [Tue, 20 Feb 2018 18:05:21 +0000 (18:05 +0000)]
lualoader: Eliminate global namespace pollution in loader.lua

6 years agolualoader: Move carousel storage out into config
Kyle Evans [Tue, 20 Feb 2018 18:04:08 +0000 (18:04 +0000)]
lualoader: Move carousel storage out into config

Carousel storage doesn't need to happen in the menu module, and indeed
storing it there introduces a circular reference between drawer and menu
that only works because of global pollution in loader.lua.

Carousel choices generally map to config entries anyways, making it as good
of place as any to store these. Move {get,set}CarouselIndex functionality
out into config so that drawer and menu may both use it. If we had more
carousel functionality, it might make sense to create a carousel module, but
this is not the case.

6 years agolualoader: Add ability to intercept cli commands
Kyle Evans [Tue, 20 Feb 2018 17:46:50 +0000 (17:46 +0000)]
lualoader: Add ability to intercept cli commands

If we failed to execute the input line as pure lua, run the command through
parse for consistent argument parsing. Pass the parsed arguments through to
a global "cli_execute" written in Lua, which is expected to either handle it
or pass it back through to interp_builtin_cmd (via loader.command).

lua-handled cli commands will then exist as globals in whatever module they
most belong in, and invocations at the loader prompt will magically dispatch
to them if they exist.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D14450

6 years agoImplement loader.command
Warner Losh [Tue, 20 Feb 2018 17:28:59 +0000 (17:28 +0000)]
Implement loader.command

This is just like loader.perform, except it takes pre-parsed arguments.

Review: https://reviews.freebsd.org/D14448

6 years agoAdjust whitespace of things added in the past couple years to match the
Ian Lepore [Tue, 20 Feb 2018 14:59:29 +0000 (14:59 +0000)]
Adjust whitespace of things added in the past couple years to match the
original style of the file.  No functional changes.

6 years agostand/lua: Consistently organize modules
Kyle Evans [Tue, 20 Feb 2018 14:45:58 +0000 (14:45 +0000)]
stand/lua: Consistently organize modules

We follow pretty closely the following structure of a module:

1. Copyright notice
2. Module requires
3. Module local declarations
4. Module local definitions
5. Module exports
6. return

Re-organize the one-offs (config/drawer) and denote the start of module
exports with a comment.

6 years agostand/lua: Consistently declare local functions at module scope
Kyle Evans [Tue, 20 Feb 2018 14:36:28 +0000 (14:36 +0000)]
stand/lua: Consistently declare local functions at module scope

Declare these adjacent to the local definitions at the top of the module,
and make sure they're actually declared local to pollute global namespace a
little bit less.

6 years agoMake killpg1 perform process validity checks without proc lock held.
Mateusz Guzik [Tue, 20 Feb 2018 10:52:07 +0000 (10:52 +0000)]
Make killpg1 perform process validity checks without proc lock held.

6 years agovm_wait() rework.
Konstantin Belousov [Tue, 20 Feb 2018 10:13:13 +0000 (10:13 +0000)]
vm_wait() rework.

Make vm_wait() take the vm_object argument which specifies the domain
set to wait for the min condition pass.  If there is no object
associated with the wait, use curthread' policy domainset.  The
mechanics of the wait in vm_wait() and vm_wait_domain() is supplied by
the new helper vm_wait_doms(), which directly takes the bitmask of the
domains to wait for passing min condition.

Eliminate pagedaemon_wait().  vm_domain_clear() handles the same
operations.

Eliminate VM_WAIT and VM_WAITPFAULT macros, the direct functions calls
are enough.

Eliminate several control state variables from vm_domain, unneeded
after the vm_wait() conversion.

Scetched and reviewed by: jeff
Tested by: pho
Sponsored by: The FreeBSD Foundation, Mellanox Technologies
Differential revision: https://reviews.freebsd.org/D14384

6 years agoPowerPC: Switch to more accurate unit to avoid division rounding
Wojciech Macek [Tue, 20 Feb 2018 07:30:57 +0000 (07:30 +0000)]
PowerPC: Switch to more accurate unit to avoid division rounding

On POWER8 architecture there is a timer with 512Mhz frequency.
It has about 1,95ns period, but it is rounded to 1ns which is not accurate.

Submitted by:          Patryk Duda <pdk@semihalf.com>
Obtained from:         Semihalf
Reviewed by:           wma
Sponsored by:          IBM, QCM Technologies
Differential revision: https://reviews.freebsd.org/D14433

6 years agoPowerNV: Send SIGILL on HEA illegal instruction exception
Wojciech Macek [Tue, 20 Feb 2018 06:38:55 +0000 (06:38 +0000)]
PowerNV: Send SIGILL on HEA illegal instruction exception

Currently Hypervisor Emulation Assistance interrupt is unhandled.
Executing an undefined instruction in userland triggers kernel panic.
Handle this the same way as Facility Unavailable Interrupt - send
SIGILL signal to userspace.

Submitted by:          Michal Stanek <mst@semihalf.com>
Obtained from:         Semihalf
Reviewed by:           nwhitehorn, pdk@semihalf.com, wma
Sponsored by:          IBM, QCM Technologies
Differential revision: https://reviews.freebsd.org/D14437

6 years agoMore verbose output.
Warner Losh [Tue, 20 Feb 2018 05:35:00 +0000 (05:35 +0000)]
More verbose output.

6 years agostyle.lua(9): Clarify local variable guideline
Kyle Evans [Tue, 20 Feb 2018 05:21:58 +0000 (05:21 +0000)]
style.lua(9): Clarify local variable guideline

The intent of this guideline is to avoid creating global variables in module
scope. Its main purpose is to serve as a reminder that variables at module
scope also need to be declared.

We want to avoid global variables in general, but this is easier to mess up
when designing things in the module scope.

6 years agostand/lua: Insert helpful comment for drawer.branddefs
Kyle Evans [Tue, 20 Feb 2018 05:12:39 +0000 (05:12 +0000)]
stand/lua: Insert helpful comment for drawer.branddefs

6 years agostand/lua: Stick a copyright notice on drawer.lua
Kyle Evans [Tue, 20 Feb 2018 05:11:17 +0000 (05:11 +0000)]
stand/lua: Stick a copyright notice on drawer.lua

6 years agostand/lua: Use 'graphic' instead of 'logo' for table depicting graphics
Kyle Evans [Tue, 20 Feb 2018 05:10:26 +0000 (05:10 +0000)]
stand/lua: Use 'graphic' instead of 'logo' for table depicting graphics

This is a more sensible name that offers less redundancy when referring to
it (vs. logodef.logo). Switch to it while the getting is good.

6 years agoMFC r316910: 7812 Remove gender specific language
Alexander Motin [Tue, 20 Feb 2018 05:07:21 +0000 (05:07 +0000)]
MFC r316910: 7812 Remove gender specific language

illumos/illumos-gate@48bbca816818409505a6e214d0911fda44e622e3
https://github.com/illumos/illumos-gate/commit/48bbca816818409505a6e214d0911fda44e622e3

https://www.illumos.org/issues/7812
  This change removes all gendered language that did not refer specifically
  to an individual person or pet. The convention taken was to use
  variations on "they" when referring to users and/or human beings, while
  using "it" when referring to code, functions, and/or libraries.
  Additionally, we took the liberty to fix up any whitespace issues that
  were found in any files that were already being modified.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Steve Gonczi <steve.gonczi@delphix.com>
Reviewed by: Chris Williamson <chris.williamson@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Daniel Hoffman <dj.hoffman@delphix.com>

6 years agostand/lua: Refactor brands into drawer.branddefs
Kyle Evans [Tue, 20 Feb 2018 05:06:11 +0000 (05:06 +0000)]
stand/lua: Refactor brands into drawer.branddefs

6 years agostand/lua: Refactor logos into drawer.logodefs table
Kyle Evans [Tue, 20 Feb 2018 04:56:03 +0000 (04:56 +0000)]
stand/lua: Refactor logos into drawer.logodefs table

This refactor makes it straightforward to add new logos for drawing and
organizes logo definitions in a logical manner.

The graphic to be drawn for each logo may again be modified outside of
drawer, but it must be done on a case-by-case basis as a modification to the
loader_logo.

6 years agoMFV r307315:
Alexander Motin [Tue, 20 Feb 2018 04:36:51 +0000 (04:36 +0000)]
MFV r307315:
7301 zpool export -f should be able to interrupt file freeing

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Author: Alek Pinchuk <alek@nexenta.com>

Closes #175

6 years agostand/lua: Reduce exposure of the drawer module
Kyle Evans [Tue, 20 Feb 2018 04:23:43 +0000 (04:23 +0000)]
stand/lua: Reduce exposure of the drawer module

As part of an effort to slowly reduce our exports overall to a set of stable
properties/functions, go ahead and reduce what drawer exposes to others.

The graphics should generally not be modified on their own, but their
position could be modified if additional grahics also need to be drawn.
Export position/shift information, but leave the actual graphic local to
the module.

The next step will be to create a 'menudef' that gets exported instead, with
each entry in the menudef table describing the graphic to be drawn along
with specific positioning information.

6 years agoMFV r302649: 7016 arc_available_memory is not 32-bit safe
Alexander Motin [Tue, 20 Feb 2018 04:14:12 +0000 (04:14 +0000)]
MFV r302649: 7016 arc_available_memory is not 32-bit safe

illumos/illumos-gate@0dd053d7d890618ea1fc697b07de364e69eb4190
https://github.com/illumos/illumos-gate/commit/0dd053d7d890618ea1fc697b07de364e69eb4190

https://www.illumos.org/issues/7016
  upstream DLPX-39446 arc_available_memory is not 32-bit safe
  https://github.com/delphix/delphix-os/commit/
  6b353ea3b8a1610be22e71e657d051743c64190b
  related to this upstream:
  DLPX-38547 delphix engine hang
  https://github.com/delphix/delphix-os/commit/
  3183a567b3e8c62a74a65885ca60c86f3d693783
  DLPX-38547 delphix engine hang (fix static global)
  https://github.com/delphix/delphix-os/commit/
  22ac551d8ef085ad66cc8f65e51ac372b12993b9
  DLPX-38882 system hung waiting on free segment
  https://github.com/delphix/delphix-os/commit/
  cdd6beef7548cd3b12f0fc0328eeb3af540079c2

Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Gordon Ross <gordon.ross@nexenta.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agostand/lua: Move drawer.menu_name_handlers further up
Kyle Evans [Tue, 20 Feb 2018 04:11:48 +0000 (04:11 +0000)]
stand/lua: Move drawer.menu_name_handlers further up

As a good candidate for modification, move this table further up in the
module to improve visibility.

6 years agostand/lua: Add and use drawer.menu_name_handlers
Kyle Evans [Tue, 20 Feb 2018 03:58:45 +0000 (03:58 +0000)]
stand/lua: Add and use drawer.menu_name_handlers

Pull out specialized naming behavior into drawer.menu_name_handlers. This is
currently only needed for the carousel entry, where naming is based on the
current choice and the menu item purposefully does not store this state.

The setup was designed so that every type can have a special name handler,
and the default action is to simply use the result of entry.name().

6 years agoAdd missing MODULE_DEPENDS().
Ian Lepore [Tue, 20 Feb 2018 03:51:09 +0000 (03:51 +0000)]
Add missing MODULE_DEPENDS().

6 years agostand/lua: Extract menu handlers out into menu.handlers table
Kyle Evans [Tue, 20 Feb 2018 03:40:16 +0000 (03:40 +0000)]
stand/lua: Extract menu handlers out into menu.handlers table

This is a bit cleaner than our former method of an if ... else chain of
handlers. Store handlers in the menu.handlers table so that they may be
added to or removed dynamically.

All handlers take the current menu and selected entry as parameters, and
their return value indicates whether the menu processor should continue or
not. An omitted return value or 'true' will indicate that we should
continue, while returning 'false' will indicate that we should exit the
current menu.

The omitted return value behavior is due to continuing the loop being the
more common situation.

6 years agoReduce contention on the proctree lock during heavy package build.
Mateusz Guzik [Tue, 20 Feb 2018 02:18:30 +0000 (02:18 +0000)]
Reduce contention on the proctree lock during heavy package build.

There is a proctree -> allproc ordering established.

Most of the time it is either xlock -> xlock or slock -> slock.

On fork however there is a slock -> xlock pair which results in
pathological wait times due to threads keeping proctree held for
reading and all waiting on allproc. Switch this to xlock -> xlock.
Longer term fix would get rid of proctree in this place to begin with.
Right now it is necessary to walk the session/process group lists to
determine which id is free. The walk can be avoided e.g. with bitmaps.

The exit path used to have one place which dealt with allproc and
then with proctree. Move the allproc acquire into the section protected
by proctree. This reduces contention against threads waiting on proctree
in the fork codepath - the fork proctree holder does not have to wait
for allproc as often.

Finally, move tidhash manipulation outside of the area protected by
either of these locks. The removal from the hash was already unprotected.
There is no legitimate reason to look up thread ids for a process still
under construction.

This results in about 50% wait time reduction during -j 128 package build.

6 years agostand/lua: Don't set ACPI off just because we can't detect it.
Kyle Evans [Tue, 20 Feb 2018 02:03:29 +0000 (02:03 +0000)]
stand/lua: Don't set ACPI off just because we can't detect it.

This should unbreak EFI/!i386 cases.

Reported by: Peter Lei <peter.lei@ieee.org>

6 years agoFurther parallelize the buffer cache.
Jeff Roberson [Tue, 20 Feb 2018 00:06:07 +0000 (00:06 +0000)]
Further parallelize the buffer cache.

Provide multiple clean queues partitioned into 'domains'.  Each domain manages
its own bufspace and has its own bufspace daemon.  Each domain has a set of
subqueues indexed by the current cpuid to reduce lock contention on the cleanq.

Refine the sleep/wakeup around the bufspace daemon to use atomics as much as
possible.

Add a B_REUSE flag that is used to requeue bufs during the scan to approximate
LRU rather than locking the queue on every use of a frequently accessed buf.

Implement bufspace_reserve with only atomic_fetchadd to avoid loop restarts.

Reviewed by: markj
Tested by: pho
Sponsored by: Netflix, Dell/EMC Isilon
Differential Revision: https://reviews.freebsd.org/D14274

6 years agostand/lua: Wrap tuple assignment earlier for readability
Kyle Evans [Mon, 19 Feb 2018 22:56:04 +0000 (22:56 +0000)]
stand/lua: Wrap tuple assignment earlier for readability

6 years agostyle.lua(9): Note that wrapping at 80-columns is not rigid
Kyle Evans [Mon, 19 Feb 2018 22:54:10 +0000 (22:54 +0000)]
style.lua(9): Note that wrapping at 80-columns is not rigid

6 years agostand/lua: Cache swapped menu, and don't create locals for swapping
Kyle Evans [Mon, 19 Feb 2018 22:29:16 +0000 (22:29 +0000)]
stand/lua: Cache swapped menu, and don't create locals for swapping

Building the swapped welcome menu (first two items swapped) is kind of a
sluggish, because it requires a full (recrusive) shallow copy of the welcome
menu. Cache the result of that and re-use it later, instead of building it
everytime.

While here, don't create temporary locals just for swapping. The following
is just as good:

x, y = y, x;

Reported by: Alexander Nasonov <alnsn@yandex.ru> (swapping)

6 years agotail: fix "tail -r" for piped input that begins with '\n'
Alan Somers [Mon, 19 Feb 2018 22:09:49 +0000 (22:09 +0000)]
tail: fix "tail -r" for piped input that begins with '\n'

A subtle logic bug, probably introduced in r311895, caused tail to print the
first two lines of piped input in forward order, if the very first character
was a newline.

PR: 222671
Reported by: Jim Long <freebsd-bugzilla@umpquanet.com>, pprocacci@gmail.com
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

6 years agoAdd more virtqueue getter methods
Bryan Venteicher [Mon, 19 Feb 2018 19:31:18 +0000 (19:31 +0000)]
Add more virtqueue getter methods

MFC after: 2 weeks

6 years agoAdd VirtIO bus config_generation method
Bryan Venteicher [Mon, 19 Feb 2018 19:28:24 +0000 (19:28 +0000)]
Add VirtIO bus config_generation method

VirtIO buses (PCI, MMIO) can provide a generation field so a driver
can ensure either a 64-bit or array read was stable.

MFC after: 2 weeks

6 years agoDo not free(9) uninitialized pointer.
Konstantin Belousov [Mon, 19 Feb 2018 19:08:25 +0000 (19:08 +0000)]
Do not free(9) uninitialized pointer.

Reported and tested by: allanjude
Reviewed by: markj
Sponsored by: The FreeBSD Foundation

6 years agotools/80211: correct array index
Eitan Adler [Mon, 19 Feb 2018 19:01:46 +0000 (19:01 +0000)]
tools/80211: correct array index

wh->i_dur is a two byte value; not a single byte set twice

Reported by: swildner@DragonFlyBSD.org

6 years agoAdd PCI methods to iterate over the PCI capabilities
Bryan Venteicher [Mon, 19 Feb 2018 18:41:56 +0000 (18:41 +0000)]
Add PCI methods to iterate over the PCI capabilities

VirtIO V1 provides configuration in multiple VENDOR capabilities so this
allows all of the configuration to be discovered.

Reviewed by: jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D14325

6 years agostand/lua: Add copyright notice in places
Kyle Evans [Mon, 19 Feb 2018 18:11:35 +0000 (18:11 +0000)]
stand/lua: Add copyright notice in places

I've made some not-insignificant changes to config, menu, and password bits
of our lua scripts. Add a copyright notice to them to reflect.

6 years agostand/lua: Re-order locals after copyright notice; require comes first
Kyle Evans [Mon, 19 Feb 2018 17:54:22 +0000 (17:54 +0000)]
stand/lua: Re-order locals after copyright notice; require comes first

6 years agostand/lua: Round up some more style.lua(9) concerns
Kyle Evans [Mon, 19 Feb 2018 17:51:33 +0000 (17:51 +0000)]
stand/lua: Round up some more style.lua(9) concerns

6 years agostand/lua: Change boot menu items' names when swapped
Kyle Evans [Mon, 19 Feb 2018 17:40:19 +0000 (17:40 +0000)]
stand/lua: Change boot menu items' names when swapped

[Enter] should be moved to the single user menu item when we swap them.

Define a non-standard menu entry function "alternate_name" to use for this
purpose for ultimate flexibility if we change our minds later. When we're
booting single user, make a shallow copy of the menu that we'd normally
display and swap the items and their name functions to use alternate_name
instead. Toggling single user in the options menu and going back to the main
menu will now correctly reflect the current boot setting with the first two
menu options and "[Enter]" will always be on the right one.

This shallow copy technique has the chance of being quite slow since it's
done on every redraw, but in my testing it does not seem to make any obvious
difference.

shallowCopyTable could likely belong better in a general-purpose utility
module, but this (and the key constnats) are the only candidates we have at
the moment so we'll drop it into our core stuff for the moment and consider
re-organization at a later date.

6 years agostand/lua: Remove inaccurate comment after r329590
Kyle Evans [Mon, 19 Feb 2018 17:09:29 +0000 (17:09 +0000)]
stand/lua: Remove inaccurate comment after r329590

lualoader does a pretty good job of reverting any environment changes now.
It will even wipe out boot_verbose if it's set explicitly in loader.conf(5)
and overwritten in the boot options menu.

Future work will likely change this, as explicit choices made in the menu
should probably override the new loader.conf(5). I don't suspect this will
cause much grief, though, so it is not a high priority until boot
environment support actually lands.

6 years agostand/lua: Restore environment upon config reload
Kyle Evans [Mon, 19 Feb 2018 17:01:21 +0000 (17:01 +0000)]
stand/lua: Restore environment upon config reload

This restores environment to whatever defaults we had coming into lualoader.

6 years agostand/lua: Track env changes that come in via loader.conf(5)
Kyle Evans [Mon, 19 Feb 2018 16:59:28 +0000 (16:59 +0000)]
stand/lua: Track env changes that come in via loader.conf(5)

This will be used when boot environment support lands to make a good-faith
effort to apply any new loader.conf(5) environment settings atop the default
configuration that we started with.

6 years agostand/lua: Re-wrap menu.lua now that I've added indentation...
Kyle Evans [Mon, 19 Feb 2018 16:42:06 +0000 (16:42 +0000)]
stand/lua: Re-wrap menu.lua now that I've added indentation...

6 years agostand/lua: Swap single-/multi- user boot entries as needed
Kyle Evans [Mon, 19 Feb 2018 16:36:29 +0000 (16:36 +0000)]
stand/lua: Swap single-/multi- user boot entries as needed

6 years agostand/lua: Call menu_entries if it's a function
Kyle Evans [Mon, 19 Feb 2018 16:35:46 +0000 (16:35 +0000)]
stand/lua: Call menu_entries if it's a function

If we've fetched menu.entries and it turns out it's a function, call it to
get the actual menu entries.

This will be used to swap multi-/single- user boot options if we're booting
single user by default (boot_single="YES" in loader.conf(5)). It can also be
used fairly easily for other non-standard situations.

6 years agostand/lua: Add core.isSingleUserBoot
Kyle Evans [Mon, 19 Feb 2018 16:34:23 +0000 (16:34 +0000)]
stand/lua: Add core.isSingleUserBoot

6 years agoImplement list_safe_reset_next() function macro in the LinuxKPI.
Hans Petter Selasky [Mon, 19 Feb 2018 16:31:19 +0000 (16:31 +0000)]
Implement list_safe_reset_next() function macro in the LinuxKPI.

MFC after: 1 week
Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

6 years agostand/lua: Store menu entries in an "entries" table
Kyle Evans [Mon, 19 Feb 2018 16:25:43 +0000 (16:25 +0000)]
stand/lua: Store menu entries in an "entries" table

Instead of directly listing them in menu.welcome and menu.boot_options,
store them at menu.welcome.entries and welcome.boot_options.entries.

This will come into play later when we need to re-order the welcome menu if
boot_single is specified.

6 years agostand/lua: Remove some unused local declarations
Kyle Evans [Mon, 19 Feb 2018 15:49:27 +0000 (15:49 +0000)]
stand/lua: Remove some unused local declarations

Menus are actually defined as entries in the 'menu' table. These local
declarations have not been used in the history of our in-tree lua scripts,
so give them the boot.

6 years agoSet internal error returns for OF_peer(), OF_child(), and OF_parent() to
Nathan Whitehorn [Mon, 19 Feb 2018 15:49:14 +0000 (15:49 +0000)]
Set internal error returns for OF_peer(), OF_child(), and OF_parent() to
zero, matching the IEEE 1275 standard. Since these internal error paths
have never, to my knowledge, been taken, behavior is unchanged.

Reported by: gonzo
MFC after: 2 weeks

6 years agostand/lua: Menu style.lua(9) nits
Kyle Evans [Mon, 19 Feb 2018 15:47:09 +0000 (15:47 +0000)]
stand/lua: Menu style.lua(9) nits

6 years agostand/lua: Rename bootserial for clarity
Kyle Evans [Mon, 19 Feb 2018 15:42:20 +0000 (15:42 +0000)]
stand/lua: Rename bootserial for clarity

6 years agostand/lua: Defer kernel/module loading until boot or menu escape
Kyle Evans [Mon, 19 Feb 2018 14:21:56 +0000 (14:21 +0000)]
stand/lua: Defer kernel/module loading until boot or menu escape

Loading the kernel and modules can be really slow. Loading before the menu
draws and every time one changes kernel/boot environment is even more
painful.

Defer loading until we either boot, auto-boot, or escape to loader prompt.
We still need to deal with configuration changes as the boot environment
changes, but this is generally much quicker.

This commit strips all ELF loading out of config.load/config.reload so that
these are purely for configuration. config.loadelf has been created to deal
with kernel/module loads. Unloading logic has been ripped out, as we won't
need to deal with it in the menu anymore.

Discussed in part with: allanjude

6 years agoRemove unused variables and sysctl declaration.
Andrey V. Elsukov [Mon, 19 Feb 2018 12:20:51 +0000 (12:20 +0000)]
Remove unused variables and sysctl declaration.

MFC after: 1 week

6 years agoCheck packet length to do not make out of bounds access. Also save ah_nxt
Andrey V. Elsukov [Mon, 19 Feb 2018 11:14:38 +0000 (11:14 +0000)]
Check packet length to do not make out of bounds access. Also save ah_nxt
value to use it later, since ah pointer can become invalid.

Reported by: Maxime Villard <max at m00nbsd dot net>
MFC after: 5 days

6 years agorelax an assert in zfsctl_snapdir_lookup to match r323578
Andriy Gapon [Mon, 19 Feb 2018 08:55:22 +0000 (08:55 +0000)]
relax an assert in zfsctl_snapdir_lookup to match r323578

Since r323578 we may remove the last reference to a covered vnode with
vrele() instead of vput().  So, v_usecount may be decremented before
the vnode is locked and zfsctl_snapdir_lookup may "catch" the vnode
with v_usecount of zero and v_holdcnt of one.

PR: 225795
Reported by: asomers
MFC after: 1 week

6 years agoWhen stepping the radix tree in the LinuxKPI make sure we
Hans Petter Selasky [Mon, 19 Feb 2018 06:11:58 +0000 (06:11 +0000)]
When stepping the radix tree in the LinuxKPI make sure we
clear the least significant bits, so that no entries are
skipped.

MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoMFV r329552: less v530.
Xin LI [Mon, 19 Feb 2018 05:10:22 +0000 (05:10 +0000)]
MFV r329552: less v530.

MFC after: 2 weeks

6 years agoVendor import of less v530.
Xin LI [Mon, 19 Feb 2018 04:47:31 +0000 (04:47 +0000)]
Vendor import of less v530.

6 years agostand/lua: reload previously loaded kernel at config-load/reload
Kyle Evans [Mon, 19 Feb 2018 03:59:26 +0000 (03:59 +0000)]
stand/lua: reload previously loaded kernel at config-load/reload

r329550 introduced config.kernel_loaded. config.load() doesn't provide a
means of overriding the kernel to load, but that likely isn't necessary as
it will not be a common case. When loading the kernel, just attempt to load
the kernel previously loaded and specified in config.kernel_loaded.

If we haven't loaded a kernel yet, config.kernel_loaded will be unset/nil
and the "default"/first kernel found will be loaded. If we've loaded a
kernel, we'll try to load that same kernel again and fallback to the default
kernel if we need to.

This in also in support of upcoming boot environment support.

6 years agostand/lua: Store the loaded kernel as config.kernel_loaded
Kyle Evans [Mon, 19 Feb 2018 03:52:02 +0000 (03:52 +0000)]
stand/lua: Store the loaded kernel as config.kernel_loaded

'nil' means the 'first kernel found in module_path', which is the same
interpretation as passing 'nil' to loadkernel.

Otherwise, it denotes the name of a kernel that we've successfully loaded.
When reloaded later, we will still need to do the full search again to
locate the actual kernel in case things have changed, so just the name is
good enough.

This is in support of upcoming boot environment support. vfs.root.mountfrom
and currdev will be changed, then we will reload configuration and attempt
to reload the currently chosen kernel unless we shouldn't.

6 years agostand/lua: Clear the screen before prompting for passwords
Kyle Evans [Mon, 19 Feb 2018 02:09:10 +0000 (02:09 +0000)]
stand/lua: Clear the screen before prompting for passwords

In the worst case scenario, we have no passwords to prompt for and we end up
just clearing the screen twice before we draw the menu or proceed with boot.

In the best case scenario, we don't try drawing password prompts amidst a
bunch of kernel/module loading.

6 years agostand/lua: Addres style.lua(9) concern
Kyle Evans [Mon, 19 Feb 2018 02:01:49 +0000 (02:01 +0000)]
stand/lua: Addres style.lua(9) concern

6 years agostand/lua: Allow menu items to be conditionally (in)visible
Kyle Evans [Mon, 19 Feb 2018 01:59:41 +0000 (01:59 +0000)]
stand/lua: Allow menu items to be conditionally (in)visible

This will be used to conditionally show/hide the boot environment menu.

6 years agoBuild at45d and mx25l SPI flash drivers as modules.
Ian Lepore [Mon, 19 Feb 2018 01:49:19 +0000 (01:49 +0000)]
Build at45d and mx25l SPI flash drivers as modules.

6 years agoAdd ofw_bus_if.h to SRCS.
Ian Lepore [Mon, 19 Feb 2018 01:39:02 +0000 (01:39 +0000)]
Add ofw_bus_if.h to SRCS.

6 years agoAdd modules/spi as a gathering point for SPI-related modules, analagous to
Ian Lepore [Mon, 19 Feb 2018 01:32:27 +0000 (01:32 +0000)]
Add modules/spi as a gathering point for SPI-related modules, analagous to
modules/i2c for i2c/iicbus modules.  Build spibus as a module.

6 years agoCreate style.lua(9)
Kyle Evans [Mon, 19 Feb 2018 01:25:52 +0000 (01:25 +0000)]
Create style.lua(9)

This covers the lua style guidelines we've generally agreed on so far. It
will be revised as work continues and we run into more scenarios that need
specified.

Discussed with: cem, jilles
Differential Revision: https://reviews.freebsd.org/D14423

6 years agoFix process exit vs reap race introduced in r329449
Mateusz Guzik [Mon, 19 Feb 2018 00:54:08 +0000 (00:54 +0000)]
Fix process exit vs reap race introduced in r329449

The race manifested itself mostly in terms of crashes with "spin lock
held too long".

Relevant parts of respective code paths:

exit: reap:
PROC_LOCK(p);
PROC_SLOCK(p);
p->p_state == PRS_ZOMBIE
PROC_UNLOCK(p);
PROC_LOCK(p);
/* exit work */
if (p->p_state == PRS_ZOMBIE) /* true */
proc_reap()
free proc
/* more exit work */
PROC_SUNLOCK(p);

Thus a still exiting process is reaped.

Prior to the change the zombie check was followed by slock/sunlock trip
which prevented the problem.

Even code prior to this commit has a bug: the proc is still accessed for
statistic collection purposes. However, the severity is rather small and
the bug may be fixed in a future commit.

Reported by: many
Tested by: allanjude

6 years agoBuild ofw_iicbus as a module if OPT_FDT is defined.
Ian Lepore [Mon, 19 Feb 2018 00:47:03 +0000 (00:47 +0000)]
Build ofw_iicbus as a module if OPT_FDT is defined.

6 years agomtx: add mtx_spin_wait_unlocked
Mateusz Guzik [Mon, 19 Feb 2018 00:38:14 +0000 (00:38 +0000)]
mtx: add mtx_spin_wait_unlocked

The primitive can be used to wait for the lock to be released. Intended
usage is for locks in structures which are about to be freed.

The benefit is the avoided interrupt enable/disable trip + atomic op to
grab the lock and shorter wait if the lock is held (since there is no
worry someone will contend on the lock, re-reads can be more aggressive).

Briefly discussed with:  kib

6 years agoProvide public declarations for ofw_spibus_driver and ofw_spibus_devclass
Ian Lepore [Sun, 18 Feb 2018 23:35:23 +0000 (23:35 +0000)]
Provide public declarations for ofw_spibus_driver and ofw_spibus_devclass
so other drivers can refer to them in DRIVER_MODULE() decls.

6 years agoPrint more info for -v runs and temp hack for usb vs uhub
Warner Losh [Sun, 18 Feb 2018 23:16:16 +0000 (23:16 +0000)]
Print more info for -v runs and temp hack for usb vs uhub

Despite best efforts to regularize, there's a few tables in the system
that still report they are for bus usb when they are really for bus
uhub (where usb devices attach). Add a temporary workaround for this
until these places have been eliminated (likely my fault).

Second, when running verbose, describe what we're doing when
searching. This output can be quite long, but says exactly what's
going on (this output is to stdout, so it's useless for scripting).

6 years agoProvide a public function to acquire a gpio pin by giving the property name
Ian Lepore [Sun, 18 Feb 2018 23:08:43 +0000 (23:08 +0000)]
Provide a public function to acquire a gpio pin by giving the property name
and index.  A private function to do exactly that already existed, so this
renames gpio_pin_get_by_ofw_impl() to gpio_pin_get_by_ofw_propidx() and
provides a declaration for it in a public header.

Previously there were functions to get a pin by property name (assuming
there would only be one pin defined for the name), or by index (asuming
the property has the standard name "gpios").  It turns out there are
devicetree bindings that describe properties with names other than "gpios"
which can describe multiple pins.  Hence the need to retrieve the Nth item
from a named property.

6 years agoAdd the MODULE_DEPEND()s needed so that the kernel linker can resolve all
Ian Lepore [Sun, 18 Feb 2018 23:01:33 +0000 (23:01 +0000)]
Add the MODULE_DEPEND()s needed so that the kernel linker can resolve all
the symbols at load time when iicbus is not compiled into the kernel.

6 years agoAdd iic_recover_bus.c, now part of iicbus. This should have been added
Ian Lepore [Sun, 18 Feb 2018 22:57:04 +0000 (22:57 +0000)]
Add iic_recover_bus.c, now part of iicbus.  This should have been added
as part of r320463.

6 years agoArrange SRCS= as 1 file per line, alphabetical, so it's easier to maintain.
Ian Lepore [Sun, 18 Feb 2018 22:54:19 +0000 (22:54 +0000)]
Arrange SRCS= as 1 file per line, alphabetical, so it's easier to maintain.
Whitespace only, no functional changes.

6 years agoexit: get rid of PROC_SLOCK when checking a process to report, take #2
Mateusz Guzik [Sun, 18 Feb 2018 21:07:15 +0000 (21:07 +0000)]
exit: get rid of PROC_SLOCK when checking a process to report, take #2

The suspension counter needs synchronisation through slock, but we don't
need it to check if inspecting the counter is necessary to begin with.
In the common case it is not, thus avoid the lock if possible.

Reviewed by: kib
Tested by: pho

6 years agoGive the imx_i2c driver its own name, set up its relationship to ofw_iicbus.
Ian Lepore [Sun, 18 Feb 2018 20:08:35 +0000 (20:08 +0000)]
Give the imx_i2c driver its own name, set up its relationship to ofw_iicbus.
Previously it called itself 'iichb' to link up with the EARLY_DRIVER_MODULE
declaration in ofw_iicbus.c.