]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFV r329799, r329800:
mav [Thu, 22 Feb 2018 03:49:06 +0000 (03:49 +0000)]
MFV r329799, r329800:
9079 race condition in starting and ending condesing thread for indirect vdevs

illumos/illumos-gate@667ec66f1b4f491d5e839644e0912cad1c9e7122

The timeline of the race condition is the following:
[1] Thread A is about to finish condesing the first vdev in spa_condense_indirect_thread(),
so it calls the spa_condense_indirect_complete_sync() sync task which sets the
spa_condensing_indirect field to NULL. Waiting for the sync task to finish, thread A
sleeps until the txg is done. When this happens, thread A will acquire spa_async_lock
and set spa_condense_thread to NULL.
[2] While thread A waits for the txg to finish, thread B which is running spa_sync() checks
whether it should condense the second vdev in vdev_indirect_should_condense() by checking
the spa_condensing_indirect field which was set to NULL by spa_condense_indirect_thread()
from thread A. So it goes on and tries to spawn a new condensing thread in
spa_condense_indirect_start_sync() and the aforementioned assertions fails because thread A
has not set spa_condense_thread to NULL (which is basically the last thing it does before
returning).

The main issue here is that we rely on both spa_condensing_indirect and spa_condense_thread to
signify whether a condensing thread is running. Ideally we would only use one throughout the
codebase. In addition, for managing spa_condense_thread we currently use spa_async_lock which
basically tights condensing to scrubing when it comes to pausing and resuming those actions
during spa export.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>

6 years agoRemove accidental vim droppings
emaste [Thu, 22 Feb 2018 03:37:01 +0000 (03:37 +0000)]
Remove accidental vim droppings

Reported by: cy

6 years agoMissed pieces of r329799.
mav [Thu, 22 Feb 2018 03:23:43 +0000 (03:23 +0000)]
Missed pieces of r329799.

6 years ago9079 race condition in starting and ending condesing thread for indirect vdevs
mav [Thu, 22 Feb 2018 03:22:27 +0000 (03:22 +0000)]
9079 race condition in starting and ending condesing thread for indirect vdevs

illumos/illumos-gate@667ec66f1b4f491d5e839644e0912cad1c9e7122

The timeline of the race condition is the following:
[1] Thread A is about to finish condesing the first vdev in spa_condense_indirect_thread(),
so it calls the spa_condense_indirect_complete_sync() sync task which sets the
spa_condensing_indirect field to NULL. Waiting for the sync task to finish, thread A
sleeps until the txg is done. When this happens, thread A will acquire spa_async_lock
and set spa_condense_thread to NULL.
[2] While thread A waits for the txg to finish, thread B which is running spa_sync() checks
whether it should condense the second vdev in vdev_indirect_should_condense() by checking
the spa_condensing_indirect field which was set to NULL by spa_condense_indirect_thread()
from thread A. So it goes on and tries to spawn a new condensing thread in
spa_condense_indirect_start_sync() and the aforementioned assertions fails because thread A
has not set spa_condense_thread to NULL (which is basically the last thing it does before
returning).

The main issue here is that we rely on both spa_condensing_indirect and spa_condense_thread to
signify whether a condensing thread is running. Ideally we would only use one throughout the
codebase. In addition, for managing spa_condense_thread we currently use spa_async_lock which
basically tights condensing to scrubing when it comes to pausing and resuming those actions
during spa export.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>

6 years agoMFV r329793, r329795:
mav [Thu, 22 Feb 2018 03:15:35 +0000 (03:15 +0000)]
MFV r329793, r329795:
9075 Improve ZFS pool import/load process and corrupted pool recovery

illumos/illumos-gate@6f7938128a2c5e23f4b970ea101137eadd1470a1

Some work has been done lately to improve the debugability of the ZFS pool
load (and import) process. This includes:

https://www.illumos.org/issues/7638: Refactor spa_load_impl into several functions
https://www.illumos.org/issues/8961: SPA load/import should tell us why it failed
https://www.illumos.org/issues/7277: zdb should be able to print zfs_dbgmsg's

To iterate on top of that, there's a few changes that were made to make the
import process more resilient and crash free. One of the first tasks during the
pool load process is to parse a config provided from userland that describes
what devices the pool is composed of. A vdev tree is generated from that config,
and then all the vdevs are opened.

The Meta Object Set (MOS) of the pool is accessed, and several metadata objects
that are necessary to load the pool are read. The exact configuration of the
pool is also stored inside the MOS. Since the configuration provided from
userland is external and might not accurately describe the vdev tree
of the pool at the txg that is being loaded, it cannot be relied upon to safely
operate the pool. For that reason, the configuration in the MOS is read early
on. In the past, the two configurations were compared together and if there was
a mismatch then the load process was aborted and an error was returned.

The latter was a good way to ensure a pool does not get corrupted, however it
made the pool load process needlessly fragile in cases where the vdev
configuration changed or the userland configuration was outdated. Since the MOS
is stored in 3 copies, the configuration provided by userland doesn't have to be
perfect in order to read its contents. Hence, a new approach has been adopted:
The pool is first opened with the untrusted userland configuration just so that
the real configuration can be read from the MOS. The trusted MOS configuration
is then used to generate a new vdev tree and the pool is re-opened.

When the pool is opened with an untrusted configuration, writes are disabled
to avoid accidentally damaging it. During reads, some sanity checks are
performed on block pointers to see if each DVA points to a known vdev;
when the configuration is untrusted, instead of panicking the system if those
checks fail we simply avoid issuing reads to the invalid DVAs.

This new two-step pool load process now allows rewinding pools accross
vdev tree changes such as device replacement, addition, etc. Loading a pool
from an external config file in a clustering environment also becomes much
safer now since the pool will import even if the config is outdated and didn't,
for instance, register a recent device addition.

With this code in place, it became relatively easy to implement a
long-sought-after feature: the ability to import a pool with missing top level
(i.e. non-redundant) devices. Note that since this almost guarantees some loss
Of data, this feature is for now restricted to a read-only import.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoAvoid grabbing locks when grabbing the vt(4) console for DDB.
jhb [Thu, 22 Feb 2018 02:26:29 +0000 (02:26 +0000)]
Avoid grabbing locks when grabbing the vt(4) console for DDB.

Trying to grab locks during cngrab() when entering the debugger is
deadlock prone as all other CPUs are already halted (and thus unable
to release locks) when cngrab() is invoked.  One could instead use
try-locks.  However, the case that the try-lock fails still has to
be handled.  In addition, if the try-lock works it doesn't provide
any greater ordering guarantees than is already provided by entering
and exiting DDB.  It is simpler to define a simpler path for the
case that the try-lock would fail and always use that when entering
DDB.  Messing with timers, etc. when entering DDB is dubious even if
the try-lock succeeds.

This patch attempts to use the smallest possible set of operations to
grab the vt(4) console when entering DDB without using any locks.

Reviewed by: emaste
Tested by: Matthew Macy
MFC after: 1 week

6 years agor329793 | mav | 2018-02-22 04:21:03 +0200 (чт, 22 февр. 2018) | 58 lines
mav [Thu, 22 Feb 2018 02:25:09 +0000 (02:25 +0000)]
r329793 | mav | 2018-02-22 04:21:03 +0200 (чт, 22 февр. 2018) | 58 lines

9075 Improve ZFS pool import/load process and corrupted pool recovery

illumos/illumos-gate@6f7938128a2c5e23f4b970ea101137eadd1470a1

Some work has been done lately to improve the debugability of the ZFS pool
load (and import) process. This includes:

https://www.illumos.org/issues/7638: Refactor spa_load_impl into several functions
https://www.illumos.org/issues/8961: SPA load/import should tell us why it failed
https://www.illumos.org/issues/7277: zdb should be able to print zfs_dbgmsg's

To iterate on top of that, there's a few changes that were made to make the
import process more resilient and crash free. One of the first tasks during the
pool load process is to parse a config provided from userland that describes
what devices the pool is composed of. A vdev tree is generated from that config,
and then all the vdevs are opened.

The Meta Object Set (MOS) of the pool is accessed, and several metadata objects
that are necessary to load the pool are read. The exact configuration of the
pool is also stored inside the MOS. Since the configuration provided from
userland is external and might not accurately describe the vdev tree
of the pool at the txg that is being loaded, it cannot be relied upon to safely
operate the pool. For that reason, the configuration in the MOS is read early
on. In the past, the two configurations were compared together and if there was
a mismatch then the load process was aborted and an error was returned.

The latter was a good way to ensure a pool does not get corrupted, however it
made the pool load process needlessly fragile in cases where the vdev
configuration changed or the userland configuration was outdated. Since the MOS
is stored in 3 copies, the configuration provided by userland doesn't have to be
perfect in order to read its contents. Hence, a new approach has been adopted:
The pool is first opened with the untrusted userland configuration just so that
the real configuration can be read from the MOS. The trusted MOS configuration
is then used to generate a new vdev tree and the pool is re-opened.

When the pool is opened with an untrusted configuration, writes are disabled
to avoid accidentally damaging it. During reads, some sanity checks are
performed on block pointers to see if each DVA points to a known vdev;
when the configuration is untrusted, instead of panicking the system if those
checks fail we simply avoid issuing reads to the invalid DVAs.

This new two-step pool load process now allows rewinding pools accross
vdev tree changes such as device replacement, addition, etc. Loading a pool
from an external config file in a clustering environment also becomes much
safer now since the pool will import even if the config is outdated and didn't,
for instance, register a recent device addition.

With this code in place, it became relatively easy to implement a
long-sought-after feature: the ability to import a pool with missing top level
(i.e. non-redundant) devices. Note that since this almost guarantees some loss
Of data, this feature is for now restricted to a read-only import.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoCorrect proper nouns in the Linuxulator
emaste [Thu, 22 Feb 2018 02:24:17 +0000 (02:24 +0000)]
Correct proper nouns in the Linuxulator

- Capitalize Linux
- Spell FreeBSD out in full
- Address some style(9) on changed lines

Sponsored by: Turing Robotic Industries Inc.

6 years agoBring in additional constants and message fields for TLS-related messages.
jhb [Thu, 22 Feb 2018 02:02:31 +0000 (02:02 +0000)]
Bring in additional constants and message fields for TLS-related messages.

Sponsored by: Chelsio Communications

6 years agoUse 'const int *' for sysentvec errno translation table
emaste [Thu, 22 Feb 2018 01:59:59 +0000 (01:59 +0000)]
Use 'const int *' for sysentvec errno translation table

This allows an sv_errtbl to be read-only .rodata.

Sponsored by: Turing Robotic Industries Inc.

6 years agolualoader: Attach cli command functions to cli module
kevans [Thu, 22 Feb 2018 01:57:38 +0000 (01:57 +0000)]
lualoader: Attach cli command functions to cli module

Instead of the global namespace, let's attach these to the cli module. Other
users, including the "local" module, can attach functions to the cli module
at will to add other cli commands and things will still Just Work.

This distills down the candidates for functions that may be invoked via the
cli to a minimal set (boot, autoboot, arguments), rather than any function
that happens to live in the global lua namespace.

6 years agoMove DDP PCB state into a helper structure.
jhb [Thu, 22 Feb 2018 01:50:30 +0000 (01:50 +0000)]
Move DDP PCB state into a helper structure.

This consolidates all of the DDP state in one place.  Also, the code has
now been fixed to ensure that DDP state is only accessed for DDP
connections.  This should not be a functional change but makes it cleaner
and easier to add state for other TOE socket modes in the future.

MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agolualoader: Pull argument extraction for cli functions into cli.arguments
kevans [Thu, 22 Feb 2018 01:44:30 +0000 (01:44 +0000)]
lualoader: Pull argument extraction for cli functions into cli.arguments

This will be the translation layer for varargs -> cmd_name, argv for cli
commands. We reserve the right to break exactly what the varargs inclulde,
but this gives us a stable way to pull the arguments out of varargs.

6 years ago8942 zfs promote .../%recv should be an error
mav [Thu, 22 Feb 2018 01:42:13 +0000 (01:42 +0000)]
8942 zfs promote .../%recv should be an error

illumos/illumos-gate@add927f8c8d101e16c23eb9cd270be4fd7edf7d5

Reported on the ZFSonLinux https://github.com/zfsonlinux/zfs/issues/4843,
fixed by https://github.com/zfsonlinux/zfs/pull/6339:

If we are in the middle of an incremental zfs receive, the child .../%recv
will exist. If you concurrently run zfs promote .../%recv, it will "work",
but then zfs gets confused. For example, there's no obvious way to destroy
the containing filesystem (because it is now a clone of its invisible child).

Attempting to do this promote should be an error. We could fix this by
having zfs_ioc_promote() check if zc_name contains a %, similar to
zfs_ioc_rename().

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years agolualoader: Unbreak 'boot [kernel]' by including config
kevans [Thu, 22 Feb 2018 01:31:05 +0000 (01:31 +0000)]
lualoader: Unbreak 'boot [kernel]' by including config

6 years ago8942 zfs promote .../%recv should be an error
mav [Thu, 22 Feb 2018 01:30:03 +0000 (01:30 +0000)]
8942 zfs promote .../%recv should be an error

illumos/illumos-gate@add927f8c8d101e16c23eb9cd270be4fd7edf7d5

Reported on the ZFSonLinux https://github.com/zfsonlinux/zfs/issues/4843,
fixed by https://github.com/zfsonlinux/zfs/pull/6339:

If we are in the middle of an incremental zfs receive, the child .../%recv
will exist. If you concurrently run zfs promote .../%recv, it will "work",
but then zfs gets confused. For example, there's no obvious way to destroy
the containing filesystem (because it is now a clone of its invisible child).

Attempting to do this promote should be an error. We could fix this by
having zfs_ioc_promote() check if zc_name contains a %, similar to
zfs_ioc_rename().

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years agolualoader: Split cli bits out into a cli module
kevans [Thu, 22 Feb 2018 01:21:39 +0000 (01:21 +0000)]
lualoader: Split cli bits out into a cli module

This module will, in the not-so-distant future, grow functionality for
reducing boilerplate in functions that implement cli commands. It will
likely also house most in-tree cli commands.

6 years agoMFV r329776: 8477 Assertion failed in vdev_state_dirty(): spa_writeable(spa)
mav [Thu, 22 Feb 2018 01:00:46 +0000 (01:00 +0000)]
MFV r329776: 8477 Assertion failed in vdev_state_dirty(): spa_writeable(spa)

illumos/illumos-gate@f4c1745bd6c9829a05ecec15759ede7757100ab5

Illumos 4080 allows "zpool clear" to work on readonly pools: i don't think
this is the intended behaviour, we shouldn't be allowed to clear readonly
pools. Probably.

A fix is already in the ZFS on Linux repository to addess this issue:
https://github.com/zfsonlinux/zfs/commit/92e43c17188d47f47b69318e4884096dec380e36

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years ago8477 Assertion failed in vdev_state_dirty(): spa_writeable(spa)
mav [Thu, 22 Feb 2018 00:59:49 +0000 (00:59 +0000)]
8477 Assertion failed in vdev_state_dirty(): spa_writeable(spa)

illumos/illumos-gate@f4c1745bd6c9829a05ecec15759ede7757100ab5

Illumos 4080 allows "zpool clear" to work on readonly pools: i don't think
this is the intended behaviour, we shouldn't be allowed to clear readonly
pools. Probably.

A fix is already in the ZFS on Linux repository to addess this issue:
https://github.com/zfsonlinux/zfs/commit/92e43c17188d47f47b69318e4884096dec380e36

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years agoMFV r329774:
mav [Thu, 22 Feb 2018 00:55:25 +0000 (00:55 +0000)]
MFV r329774:
8408 dsl_props_set_sync_impl() does not handle nested nvlists correctly

illumos/illumos-gate@85723e5eec42f46dbfdb4c09b9e1ed66501d1ccf

When iterating over the input nvlist in dsl_props_set_sync_impl() when we
don't preserve the nvpair name before looking up ZPROP_VALUE, so when we
later go to process it nvpair_name() is always "value" instead of the actual
property name.

This results in a couple of bugs in the recv code:

 - received properties are not restored correctly when failing to receive
   an incremental send stream
 - received properties are not completely replaced by the new ones when
   successfully receiving an incremental send stream

This was discovered on ZFS on Linux (fixed in
https://github.com/zfsonlinux/zfs/commit/5f1346c29997dd4e02acf4c19c875d5484f33b1e)

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years ago8408 dsl_props_set_sync_impl() does not handle nested nvlists correctly
mav [Thu, 22 Feb 2018 00:53:59 +0000 (00:53 +0000)]
8408 dsl_props_set_sync_impl() does not handle nested nvlists correctly

illumos/illumos-gate@85723e5eec42f46dbfdb4c09b9e1ed66501d1ccf

When iterating over the input nvlist in dsl_props_set_sync_impl() when we
don't preserve the nvpair name before looking up ZPROP_VALUE, so when we
later go to process it nvpair_name() is always "value" instead of the actual
property name.

This results in a couple of bugs in the recv code:

 - received properties are not restored correctly when failing to receive
   an incremental send stream
 - received properties are not completely replaced by the new ones when
   successfully receiving an incremental send stream

This was discovered on ZFS on Linux (fixed in
https://github.com/zfsonlinux/zfs/commit/5f1346c29997dd4e02acf4c19c875d5484f33b1e)

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years ago9036 zfs: duplicate 'const' declaration specifier
mav [Thu, 22 Feb 2018 00:48:59 +0000 (00:48 +0000)]
9036 zfs: duplicate 'const' declaration specifier

illumos/illumos-gate@f02c28e434fb4d81d95122bab187fb43d4f19c2a

Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Toomas Soome <tsoome@me.com>

6 years agoMFV r329770: 9035 zfs: this statement may fall through
mav [Thu, 22 Feb 2018 00:47:38 +0000 (00:47 +0000)]
MFV r329770: 9035 zfs: this statement may fall through

illumos/illumos-gate@46ac8fdfc5a1f9d8240c79a6ae5b2889cbe83553

Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Toomas Soome <tsoome@me.com>

6 years ago9035 zfs: this statement may fall through
mav [Thu, 22 Feb 2018 00:46:24 +0000 (00:46 +0000)]
9035 zfs: this statement may fall through

illumos/illumos-gate@46ac8fdfc5a1f9d8240c79a6ae5b2889cbe83553

Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Toomas Soome <tsoome@me.com>

6 years agoMFV r329766: 8962 zdb should work on non-idle pools
mav [Thu, 22 Feb 2018 00:42:12 +0000 (00:42 +0000)]
MFV r329766: 8962 zdb should work on non-idle pools

illumos/illumos-gate@e144c4e6c90e7d4dccaad6db660ee42b6e7ba04f

Currently `zdb` consistently fails to examine non-idle pools as it fails
during the `spa_load()` process. The main problem seems to be that
`spa_load_verify()` fails as can be seen below:

$ sudo zdb -d -G dcenter
    zdb: can't open 'dcenter': I/O error

ZFS_DBGMSG(zdb):
    spa_open_common: opening dcenter
    spa_load(dcenter): LOADING
    disk vdev '/dev/dsk/c4t11d0s0': best uberblock found for spa dcenter. txg 40824950
    spa_load(dcenter): using uberblock with txg=40824950
    spa_load(dcenter): UNLOADING
    spa_load(dcenter): RELOADING
    spa_load(dcenter): LOADING
    disk vdev '/dev/dsk/c3t10d0s0': best uberblock found for spa dcenter. txg 40824952
    spa_load(dcenter): using uberblock with txg=40824952
    spa_load(dcenter): FAILED: spa_load_verify failed [error=5]
    spa_load(dcenter): UNLOADING

This change makes `spa_load_verify()` a dryrun when ran from `zdb`. This is
done by creating a global flag in zfs and then setting it in `zdb`.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoAdd two new ioctls to bhyve for batch register fetch/store operations.
jhb [Thu, 22 Feb 2018 00:39:25 +0000 (00:39 +0000)]
Add two new ioctls to bhyve for batch register fetch/store operations.

These are a convenience for bhyve's debug server to use a single
ioctl for 'g' and 'G' rather than a loop of individual get/set
ioctl requests.

Reviewed by: grehan
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D14074

6 years ago8962 zdb should work on non-idle pools
mav [Thu, 22 Feb 2018 00:09:15 +0000 (00:09 +0000)]
8962 zdb should work on non-idle pools

illumos/illumos-gate@e144c4e6c90e7d4dccaad6db660ee42b6e7ba04f

Currently `zdb` consistently fails to examine non-idle pools as it fails
during the `spa_load()` process. The main problem seems to be that
`spa_load_verify()` fails as can be seen below:

$ sudo zdb -d -G dcenter
    zdb: can't open 'dcenter': I/O error

ZFS_DBGMSG(zdb):
    spa_open_common: opening dcenter
    spa_load(dcenter): LOADING
    disk vdev '/dev/dsk/c4t11d0s0': best uberblock found for spa dcenter. txg 40824950
    spa_load(dcenter): using uberblock with txg=40824950
    spa_load(dcenter): UNLOADING
    spa_load(dcenter): RELOADING
    spa_load(dcenter): LOADING
    disk vdev '/dev/dsk/c3t10d0s0': best uberblock found for spa dcenter. txg 40824952
    spa_load(dcenter): using uberblock with txg=40824952
    spa_load(dcenter): FAILED: spa_load_verify failed [error=5]
    spa_load(dcenter): UNLOADING

This change makes `spa_load_verify()` a dryrun when ran from `zdb`. This is
done by creating a global flag in zfs and then setting it in `zdb`.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFV r329762: 8961 SPA load/import should tell us why it failed
mav [Thu, 22 Feb 2018 00:03:14 +0000 (00:03 +0000)]
MFV r329762: 8961 SPA load/import should tell us why it failed

illumos/illumos-gate@3ee8c80c747c4aa3f83351a6920f30c411236e1b

When we fail to open or import a storage pool, we typically don't get any
additional diagnostic information, just "no pool found" or "can not import".

While there may be no additional user-consumable information, we should at
least make this situation easier to debug/diagnose for developers and support.
For example, we could start by using `zfs_dbgmsg()` to log each thing that we
try when importing, and which things failed. E.g. "tried uberblock of txg X
from label Y of device Z". Also, we could log each of the stages that we go
through in `spa_load_impl()`.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMinor formatting nits.
imp [Wed, 21 Feb 2018 23:49:35 +0000 (23:49 +0000)]
Minor formatting nits.

6 years agoAdd LOADER_DEBUG regression test
imp [Wed, 21 Feb 2018 23:49:18 +0000 (23:49 +0000)]
Add LOADER_DEBUG regression test

6 years ago8961 SPA load/import should tell us why it failed
mav [Wed, 21 Feb 2018 23:42:30 +0000 (23:42 +0000)]
8961 SPA load/import should tell us why it failed

illumos/illumos-gate@3ee8c80c747c4aa3f83351a6920f30c411236e1b

When we fail to open or import a storage pool, we typically don't get any
additional diagnostic information, just "no pool found" or "can not import".

While there may be no additional user-consumable information, we should at
least make this situation easier to debug/diagnose for developers and support.
For example, we could start by using `zfs_dbgmsg()` to log each thing that we
try when importing, and which things failed. E.g. "tried uberblock of txg X
from label Y of device Z". Also, we could log each of the stages that we go
through in `spa_load_impl()`.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFV r329760: 7638 Refactor spa_load_impl into several functions
mav [Wed, 21 Feb 2018 23:38:30 +0000 (23:38 +0000)]
MFV r329760: 7638 Refactor spa_load_impl into several functions

illumos/illumos-gate@1fd3785ff6601d3e391378c2dcbf4c5f27e1fe32

spa_load_impl has grown out of proportions.  It is currently over 700
lines long and makes it very hard to follow or debug the import process
even for experienced ZFS developers.  The objective is to split it up
in a series of well commented functions.

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years ago7638 Refactor spa_load_impl into several functions
mav [Wed, 21 Feb 2018 23:25:11 +0000 (23:25 +0000)]
7638 Refactor spa_load_impl into several functions

illumos/illumos-gate@1fd3785ff6601d3e391378c2dcbf4c5f27e1fe32

spa_load_impl has grown out of proportions.  It is currently over 700
lines long and makes it very hard to follow or debug the import process
even for experienced ZFS developers.  The objective is to split it up
in a series of well commented functions.

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years ago9018 Replace kmem_cache_reap_now() with kmem_cache_reap_soon()
mav [Wed, 21 Feb 2018 23:15:06 +0000 (23:15 +0000)]
9018 Replace kmem_cache_reap_now() with kmem_cache_reap_soon()

illumos/illumos-gate@36a64e62848b51ac5a9a5216e894ec723cfef14e

To prevent kmem_cache reaping from blocking other system resources, turn
kmem_cache_reap_now() (which blocks) into kmem_cache_reap_soon(). Callers
to kmem_cache_reap_soon() should use kmem_cache_reap_active(), which
exploits #9017's new taskq_empty().

Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Author: Tim Kordas <tim.kordas@joyent.com>

FreeBSD does not use taskqueue for kmem caches reaping, so this change
is less dramatic then it is on Illumos, just limiting reaping to 1 time
per second.  It may possibly be improved later, if needed.

6 years agoFix compilation with LOADER_DEBUG defined after r329725.
marius [Wed, 21 Feb 2018 22:24:49 +0000 (22:24 +0000)]
Fix compilation with LOADER_DEBUG defined after r329725.

6 years ago9018 Replace kmem_cache_reap_now() with kmem_cache_reap_soon()
mav [Wed, 21 Feb 2018 22:14:19 +0000 (22:14 +0000)]
9018 Replace kmem_cache_reap_now() with kmem_cache_reap_soon()

illumos/illumos-gate@36a64e62848b51ac5a9a5216e894ec723cfef14e

To prevent kmem_cache reaping from blocking other system resources, turn
kmem_cache_reap_now() (which blocks) into kmem_cache_reap_soon(). Callers
to kmem_cache_reap_soon() should use kmem_cache_reap_active(), which
exploits #9017's new taskq_empty().

Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Author: Tim Kordas <tim.kordas@joyent.com>

6 years agolualoader: Remove nasty hack for not printing out ".0"
kevans [Wed, 21 Feb 2018 21:39:47 +0000 (21:39 +0000)]
lualoader: Remove nasty hack for not printing out ".0"

luaconf.h has a LUA_COMPAT_FLOATSTRING option that may be defined to do this
instead of needing intstring.

Reported by: Dan Nelson

6 years agoMFV r329753: 8809 libzpool should leverage work done in libfakekernel
mav [Wed, 21 Feb 2018 21:18:04 +0000 (21:18 +0000)]
MFV r329753: 8809 libzpool should leverage work done in libfakekernel

illumos/illumos-gate@f06dce2c1f0f3af78581e7574f65bfba843ddb6e

Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Andrew Stormont <astormont@racktopsystems.com>

6 years agodhclient: raise WARNS to 4
asomers [Wed, 21 Feb 2018 21:13:08 +0000 (21:13 +0000)]
dhclient: raise WARNS to 4

Mostly const-correctness fixes. There were also some variable-shadowing,
unused variable, and a couple of sockaddr type-correctness changes. I also had
trouble with cast-align warnings. I was able to prove that one of them was a
false positive. But ultimately I had to disable the warning program-wide to
deal with the others.

Reviewed by: cem
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D14460

6 years ago8809 libzpool should leverage work done in libfakekernel
mav [Wed, 21 Feb 2018 21:04:46 +0000 (21:04 +0000)]
8809 libzpool should leverage work done in libfakekernel

illumos/illumos-gate@f06dce2c1f0f3af78581e7574f65bfba843ddb6e

Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Andrew Stormont <astormont@racktopsystems.com>

6 years agolibifconfig: fix ifconfig_set_metric
asomers [Wed, 21 Feb 2018 20:45:43 +0000 (20:45 +0000)]
libifconfig: fix ifconfig_set_metric

Due to a copy/paste error, ifconfig_set_metric actually set the mtu, not the
metric.

See Also: https://github.com/Savagedlight/libifconfig/issues/48

MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

6 years agoFix a read past the end of a buffer in fsck.
mckusick [Wed, 21 Feb 2018 20:32:23 +0000 (20:32 +0000)]
Fix a read past the end of a buffer in fsck.

To minimize the time spent scanning all of the directories in pass 2
(Check Pathnames), fsck uses a search order based on the location
of their first block. Zero length directories have no first block,
so the array being used to hold the block numbers of directory
inodes was of zero length. Thus a lookup was done past the end of
the array getting at best a random value and at worst a segment
fault.  For zero length directories, this change allocates a one
element block array and initializes it to zero. The effect is that
all zero length directories are handled first in pass 2.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D14163

6 years agolualoader: Drop password length restrictions
kevans [Wed, 21 Feb 2018 20:17:08 +0000 (20:17 +0000)]
lualoader: Drop password length restrictions

This seems to have been arbitrary; bootlock_password and password don't seem
to have any documented length restrictions, and loader(8) probably shouldn't
care about whatever GELI passphrase length restrictions might exist.

Reported by: Kalle Carlbark <kalle.carlbark+freebsd@kcbark.net>

6 years agolualoader: Replace 8-space indentation with a single tab
kevans [Wed, 21 Feb 2018 19:56:34 +0000 (19:56 +0000)]
lualoader: Replace 8-space indentation with a single tab

6 years agoRefactor fix in r329600 to do its check once in readsuper() rather
mckusick [Wed, 21 Feb 2018 19:56:19 +0000 (19:56 +0000)]
Refactor fix in r329600 to do its check once in readsuper() rather
than in the two places that call readsuper().

No semantic change intended.

Reviewed by: kib

6 years agoload_elf.c: Use consistent indentation
emaste [Wed, 21 Feb 2018 19:42:54 +0000 (19:42 +0000)]
load_elf.c: Use consistent indentation

As noted in D14267 load_elf.c has a variety of indentation styles.  Move
to standard 8 column hard tab indents, 4 space second level indents.
Also includes some whitespace cleanups found by clang-format.

6 years agoFix route manpage to show correct flush syntax
rstone [Wed, 21 Feb 2018 19:13:27 +0000 (19:13 +0000)]
Fix route manpage to show correct flush syntax

The current route(8) manpage shows that "flush" is an argument to
the optional -n flag, rather than a separate subcommand.  Correct
this to properly show flush as a route subcommand.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Reviewed by: rgrimes
Differential Revision: https://reviews.freebsd.org/D14401

6 years agoAllow route change requests to not specify the gateway.
rstone [Wed, 21 Feb 2018 19:13:23 +0000 (19:13 +0000)]
Allow route change requests to not specify the gateway.

Only require a gateway to be specified on a route add request.  On
a route change request that does not specify the gateway, the
gateway will remain the same.  This allows changing other route
parameters without having to re-specifying the gateway, like in
"route change 10.0.0.0/8 -mtu 9000".

Update the route(8) manpage to explicitly call out this usage
as being supported.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Reviewed By: eugen (rtsock.c change), rgrimes
Differential Revision: https://reviews.freebsd.org/D14291

6 years agoIFLIB: Make isc_magic unsigned
shurd [Wed, 21 Feb 2018 18:57:00 +0000 (18:57 +0000)]
IFLIB: Make isc_magic unsigned

The IFLIB_MAGIC macro is > INT_MAX, so isc_magic should
be able to contain it.

Reported by: jeb
Sponsored by: Limelight  Networks

6 years agoFurther style(9) changes.
benno [Wed, 21 Feb 2018 18:32:06 +0000 (18:32 +0000)]
Further style(9) changes.

Tested by: objdump -d | md5 (both in-tree clang and lang/gcc6)

6 years agoMFV r329736: 8969 Cannot boot from RAIDZ with parity > 1
mav [Wed, 21 Feb 2018 18:12:19 +0000 (18:12 +0000)]
MFV r329736: 8969 Cannot boot from RAIDZ with parity > 1

illumos/illumos-gate@0fb055e81fd0cda5221da8ddd98b2f8d1fc6bdbe

At present it is possible to boot from a root pool that is on RAIDZ but not
one that is on RAIDZ2 or RAIDZ3.  This is because, at the time the pool
version is checked to ensure support for dual/triple parity, the uberblock
has not yet been loaded into the SPA and therefore the code determines that
the pool version is too old and returns ENOTSUP.

Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Andy Fiddaman <omnios@citrus-it.co.uk>

FreeBSD already had this fixed, so this is just a diff reduction.

6 years agoPurely whitespace changes bringing this file closer to style(9).
benno [Wed, 21 Feb 2018 18:10:50 +0000 (18:10 +0000)]
Purely whitespace changes bringing this file closer to style(9).

Curiously, changing whitespace seems to cause the md5 of the .o files to differ
these days hence the following testing strategy:

Tested by: objdump -d | md5 (both in-tree clang and lang/gcc6)

6 years ago8969 Cannot boot from RAIDZ with parity > 1
mav [Wed, 21 Feb 2018 18:09:07 +0000 (18:09 +0000)]
8969 Cannot boot from RAIDZ with parity > 1

illumos/illumos-gate@0fb055e81fd0cda5221da8ddd98b2f8d1fc6bdbe

At present it is possible to boot from a root pool that is on RAIDZ but not
one that is on RAIDZ2 or RAIDZ3.  This is because, at the time the pool
version is checked to ensure support for dual/triple parity, the uberblock
has not yet been loaded into the SPA and therefore the code determines that
the pool version is too old and returns ENOTSUP.

Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Andy Fiddaman <omnios@citrus-it.co.uk>

6 years agolualoader: Don't execute menu.autoboot() for every opened menu
kevans [Wed, 21 Feb 2018 17:33:01 +0000 (17:33 +0000)]
lualoader: Don't execute menu.autoboot() for every opened menu

Attempt to autoboot when we open the default menu, and only when we open the
default menu. This alleviates the need for checking menu.already_autoboot,
because we're not trying to autoboot every time we open a submenu.

I note that escaping to loader prompt and going back to the menu (by running
require('menu').run() at the loader prompt) will happily work and not
re-initiate the autoboot sequence since "Escape to loader prompt" disables
the autoboot_delay.

6 years agolualoader: Make kernel autodetection contingent on loader.conf(5) var
kevans [Wed, 21 Feb 2018 16:57:03 +0000 (16:57 +0000)]
lualoader: Make kernel autodetection contingent on loader.conf(5) var

Instead of based it off of whether 'kernels' was specified, base it off of a
new variable: kernels_autodetect. If set to yes, we'll run the autodetection
bits and add any detected kernels to the already existing list *after* both
'kernel' and 'kernels'.

6 years agoMFV r329502: 7614 zfs device evacuation/removal
mav [Wed, 21 Feb 2018 16:51:02 +0000 (16:51 +0000)]
MFV r329502: 7614 zfs device evacuation/removal

illumos/illumos-gate@5cabbc6b49070407fb9610cfe73d4c0e0dea3e77

https://www.illumos.org/issues/7614:
This project allows top-level vdevs to be removed from the storage pool with
“zpool remove”, reducing the total amount of storage in the pool. This
operation copies all allocated regions of the device to be removed onto other
devices, recording the mapping from old to new location. After the removal is
complete, read and free operations to the removed (now “indirect”) vdev must
be remapped and performed at the new location on disk. The indirect mapping
table is kept in memory whenever the pool is loaded, so there is minimal
performance overhead when doing operations on the indirect vdev.

The size of the in-memory mapping table will be reduced when its entries
become “obsolete” because they are no longer used by any block pointers in
the pool. An entry becomes obsolete when all the blocks that use it are
freed. An entry can also become obsolete when all the snapshots that
reference it are deleted, and the block pointers that reference it have been
“remapped” in all filesystems/zvols (and clones). Whenever an indirect block
is written, all the block pointers in it will be “remapped” to their new
(concrete) locations if possible. This process can be accelerated by using
the “zfs remap” command to proactively rewrite all indirect blocks that
reference indirect (removed) vdevs.

Note that when a device is removed, we do not verify the checksum of the data
that is copied. This makes the process much faster, but if it were used on
redundant vdevs (i.e. mirror or raidz vdevs), it would be possible to copy
the wrong data, when we have the correct data on e.g. the other side of the
mirror. Therefore, mirror and raidz devices can not be removed.

Reviewed by: Alex Reece <alex@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Author: Prashanth Sreenivasa <pks@delphix.com>

6 years agolualoader: Add boot environment support
kevans [Wed, 21 Feb 2018 16:50:41 +0000 (16:50 +0000)]
lualoader: Add boot environment support

This looks a little bit differently than the forth version for the time
being, just to get off the ground- rather than a paging system, it's
implemented as a simple carousel like the kernel selector.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D14436

6 years agoAdd required header files.
ian [Wed, 21 Feb 2018 16:36:44 +0000 (16:36 +0000)]
Add required header files.

Reported by: andreast@

6 years agoRemove some files that snuck in via cut and paste.
ian [Wed, 21 Feb 2018 16:34:04 +0000 (16:34 +0000)]
Remove some files that snuck in via cut and paste.

Having these compiled into the module causes the kobj method descriptors
to be resolved incorrectly (by the compile-time linker instead of the
kernel linker), which then leads to hours of frustrating debugging.

6 years agostand/zfs: Unbreak build, 'truct' ~= 'struct'
kevans [Wed, 21 Feb 2018 16:33:08 +0000 (16:33 +0000)]
stand/zfs: Unbreak build, 'truct' ~= 'struct'

6 years agostand/zfs: Add all bootenvs to environment
kevans [Wed, 21 Feb 2018 16:26:16 +0000 (16:26 +0000)]
stand/zfs: Add all bootenvs to environment

For the benefit of lualoader, add all bootenvs to environment when
init_zfs_bootenv is invoked. All of the boot environment logic can then be
implemented in pure lua, rather than going back and forth with C to
implement paging.

This stores all boot environments in bootenvs[idx] and the final count of
bootenvs in bootenvs_count.

While here, make a copy of currdev for init_zfs_bootenv since it will be
modifying it and the caller may not necessarily want that. Some of the logic
was shifted around so that the 'currdev' pointer remains at the beginning of
the string and 'beroot' is moved around as needed to modify it or ultimately
store it in zfs_be_root.

The original zfs_bootenv that this was copied from will be able to go away
only if/when forth eventually goes away.

Tested with: lualoader (and local changes to add boot env. support)
Tested with: forth
Reviewed by: cem (earlier version), imp
Differential Revision: https://reviews.freebsd.org/D14435

6 years agoHonor settings for including / excluding cd9660, ufs, ext2fs and msdos.
imp [Wed, 21 Feb 2018 15:58:00 +0000 (15:58 +0000)]
Honor settings for including / excluding cd9660, ufs, ext2fs and msdos.

The Makefile gives the impression that ext2fs and msdos were excluded
(they weren't) and that you could exclude cd9660 and ufs support (you
couldn't). Allow those to be excluded.

We need to look, in the future, at trimming the number of supported
filesystems, and this will make that easier.

6 years agoConsolidate three copies of ZFS commands into a central location.
imp [Wed, 21 Feb 2018 15:57:36 +0000 (15:57 +0000)]
Consolidate three copies of ZFS commands into a central location.

There's no reason to have multiple copies of lszfs and
reloadbe. Consolidate them into one location. Also ldi_get_size is the
same everywhere (except sparc64). Make it the same everywhere as the
common definition is more general and will work on spar64.

6 years agoBuild getty(8) with WARNS=6.
trasz [Wed, 21 Feb 2018 15:57:24 +0000 (15:57 +0000)]
Build getty(8) with WARNS=6.

Reviewed by: imp@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14197

6 years agoministat: disallow negative variance / nan Stddev
emaste [Wed, 21 Feb 2018 15:54:23 +0000 (15:54 +0000)]
ministat: disallow negative variance / nan Stddev

With all values identical it was possible for Var() to return a negative
value due to limited floating point precision, resulting in "nan"
reported as Stddev.

Variance cannot actually be negative, so just return 0.  We can later
investigate alternate algorithms for calculating variance to reduce the
effect of catastrophic cancellation here.

Reported by: Arshan Khanifar <arshankhanifar_gmail.com>
Approved by: phk
Sponsored by: The FreeBSD Foundation

6 years agozdb: raise WARNS from 0 to 2
asomers [Wed, 21 Feb 2018 15:51:48 +0000 (15:51 +0000)]
zdb: raise WARNS from 0 to 2

This has only been possible since r329694 and r329508

MFC after: 3 weeks
X-MFC-With: 329694
X-MFC-With: 329508
Sponsored by: Spectra Logic

6 years agoAdd definition for the PowerPC A2.
nwhitehorn [Wed, 21 Feb 2018 15:15:58 +0000 (15:15 +0000)]
Add definition for the PowerPC A2.

6 years agoAdd definitions for the new Radix MMU mode on POWER9+ CPUs.
nwhitehorn [Wed, 21 Feb 2018 15:15:31 +0000 (15:15 +0000)]
Add definitions for the new Radix MMU mode on POWER9+ CPUs.

6 years agoMFV r329718: 8520 7198 lzc_rollback_to should support rolling back to origin
avg [Wed, 21 Feb 2018 15:12:14 +0000 (15:12 +0000)]
MFV r329718: 8520 7198 lzc_rollback_to should support rolling back to origin

illumos/illumos-gate@95643f75d23914a3e332adc9661ed51749e9858d
https://github.com/illumos/illumos-gate/commit/95643f75d23914a3e332adc9661ed51749e9858d

https://www.illumos.org/issues/8520
  lzc_rollback_to() should support rolling back to a clone's origin.
  The current checks in zfs_ioc_rollback() would not allow that because the
  origin snapshot belongs to a different filesystem.
  The overly restrictive check was introduced in 7600, but it was not a
  regression as none of the existing tools provided a way to rollback to the
  origin.

https://www.illumos.org/issues/7198
  EINVAL is returned when a dataset does not have any snapshots, so there is
  nothing to roll back to.
  Although the code in zfs_do_rollback checks for that condition in advance, it's
  still possible that the snapshot(s) gets removed after the check and before the
  rollback sync task is executed.
  At the moment zfs command would crash when that happens.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>
MFC after: 2 weeks

6 years ago8520 7198 lzc_rollback_to should support rolling back to origin
avg [Wed, 21 Feb 2018 15:10:33 +0000 (15:10 +0000)]
8520 7198 lzc_rollback_to should support rolling back to origin

illumos/illumos-gate@95643f75d23914a3e332adc9661ed51749e9858d
https://github.com/illumos/illumos-gate/commit/95643f75d23914a3e332adc9661ed51749e9858d

https://www.illumos.org/issues/8520
  lzc_rollback_to() should support rolling back to a clone's origin.
  The current checks in zfs_ioc_rollback() would not allow that because the
  origin snapshot belongs to a different filesystem.
  The overly restrictive check was introduced in 7600, but it was not a
  regression as none of the existing tools provided a way to rollback to the
  origin.

https://www.illumos.org/issues/7198
  EINVAL is returned when a dataset does not have any snapshots, so there is
  nothing to roll back to.
  Although the code in zfs_do_rollback checks for that condition in advance, it's
  still possible that the snapshot(s) gets removed after the check and before the
  rollback sync task is executed.
  At the moment zfs command would crash when that happens.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>

6 years agoMFV r329715: 8997 ztest assertion failure in zil_lwb_write_issue
avg [Wed, 21 Feb 2018 15:07:49 +0000 (15:07 +0000)]
MFV r329715: 8997 ztest assertion failure in zil_lwb_write_issue

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

https://www.illumos.org/issues/8997
  When dmu_tx_assign is called from zil_lwb_write_issue, it's possible
  for either ERESTART or EIO to be returned.
  If ERESTART is returned, this will cause an assertion to fail directly
  in zil_lwb_write_issue, where the code assumes the return value is
  EIO if dmu_tx_assign returns a non-zero value. This can occur if the
  SPA is suspended when dmu_tx_assign is called, and most often occurs
  when running zloop.
  If EIO is returned, this can cause assertions to fail elsewhere in the
  ZIL code. For example, zil_commit_waiter_timeout contains the
  following logic:
    lwb_t *nlwb = zil_lwb_write_issue(zilog, lwb);
    ASSERT3S(lwb->lwb_state, !=, LWB_STATE_OPENED);
  In this case, if dmu_tx_assign returned EIO from within
  zil_lwb_write_issue, the lwb variable passed in will not be issued
  to disk. Thus, it's lwb_state field will remain LWB_STATE_OPENED and
  this assertion will fail. zil_commit_waiter_timeout assumes that after
  it calls zil_lwb_write_issue, the lwb will be issued to disk, and
  doesn't handle the case where this is not true; i.e. it doesn't handle
  the case where dmu_tx_assign returns EIO.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Prakash Surya <prakash.surya@delphix.com>
MFC after: 3 weeks

6 years agolualoader: Use the key that interrupts autoboot as a menu choice
kevans [Wed, 21 Feb 2018 14:37:49 +0000 (14:37 +0000)]
lualoader: Use the key that interrupts autoboot as a menu choice

This matches forth behavior. Hitting "6" when autobooting at the welcome
menu will now take you directly to the "Boot Options" menu.

We likely have some slight optimizations we should make, like not checking
autoboot every time we open a new menu and things of this nature. Further
work will go towards this end.

6 years ago8997 ztest assertion failure in zil_lwb_write_issue
avg [Wed, 21 Feb 2018 14:33:00 +0000 (14:33 +0000)]
8997 ztest assertion failure in zil_lwb_write_issue

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

https://www.illumos.org/issues/8997
  When dmu_tx_assign is called from zil_lwb_write_issue, it's possible
  for either ERESTART or EIO to be returned.
  If ERESTART is returned, this will cause an assertion to fail directly
  in zil_lwb_write_issue, where the code assumes the return value is
  EIO if dmu_tx_assign returns a non-zero value. This can occur if the
  SPA is suspended when dmu_tx_assign is called, and most often occurs
  when running zloop.
  If EIO is returned, this can cause assertions to fail elsewhere in the
  ZIL code. For example, zil_commit_waiter_timeout contains the
  following logic:
    lwb_t *nlwb = zil_lwb_write_issue(zilog, lwb);
    ASSERT3S(lwb->lwb_state, !=, LWB_STATE_OPENED);
  In this case, if dmu_tx_assign returned EIO from within
  zil_lwb_write_issue, the lwb variable passed in will not be issued
  to disk. Thus, it's lwb_state field will remain LWB_STATE_OPENED and
  this assertion will fail. zil_commit_waiter_timeout assumes that after
  it calls zil_lwb_write_issue, the lwb will be issued to disk, and
  doesn't handle the case where this is not true; i.e. it doesn't handle
  the case where dmu_tx_assign returns EIO.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agoMFV r329713: 8731 ASSERT3U(nui64s, <=, UINT16_MAX) fails for large blocks
avg [Wed, 21 Feb 2018 14:31:48 +0000 (14:31 +0000)]
MFV r329713: 8731 ASSERT3U(nui64s, <=, UINT16_MAX) fails for large blocks

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

https://www.illumos.org/issues/8731
  annotate_ecksum() asserts that nui64s, calculated as nui64s = size / sizeof
  (uint64_t), is not greater than UINT16_MAX.
  This restriction is needed because histograms of incorrectly set and cleared
  bits have 16 bit counters and if the buffer consists of too many 64-bit words,
  then a counter can potentially overflow producing an incorrect result.
  When the largest buffer size was 128KB the greatest value of nui64s was 16K,
  well within the limit.
  But now we have support for large buffers and for buffer sizes of 512KB and
  above the restriction is violated.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>
MFC after: 2 weeks

6 years ago8731 ASSERT3U(nui64s, <=, UINT16_MAX) fails for large blocks
avg [Wed, 21 Feb 2018 14:30:34 +0000 (14:30 +0000)]
8731 ASSERT3U(nui64s, <=, UINT16_MAX) fails for large blocks

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

https://www.illumos.org/issues/8731
  annotate_ecksum() asserts that nui64s, calculated as nui64s = size / sizeof
  (uint64_t), is not greater than UINT16_MAX.
  This restriction is needed because histograms of incorrectly set and cleared
  bits have 16 bit counters and if the buffer consists of too many 64-bit words,
  then a counter can potentially overflow producing an incorrect result.
  When the largest buffer size was 128KB the greatest value of nui64s was 16K,
  well within the limit.
  But now we have support for large buffers and for buffer sizes of 512KB and
  above the restriction is violated.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>

6 years agoPowerNV: Put processor to power-save state in idle thread
wma [Wed, 21 Feb 2018 14:28:40 +0000 (14:28 +0000)]
PowerNV: Put processor to power-save state in idle thread

When processor enters power-save state it releases resources shared with other
cpu threads which makes other cores working much faster.

This patch also implements saving and restoring registers that might get
corrupted in power-save state.

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

6 years agoMFV r329710: 8966 Source file zfs_acl.c, function zfs_aclset_common contains a use...
avg [Wed, 21 Feb 2018 14:17:07 +0000 (14:17 +0000)]
MFV r329710: 8966 Source file zfs_acl.c, function zfs_aclset_common contains a use after end of the lifetime of a local variable

illumos/illumos-gate@82693e09cc02331fa1b3b73b54b1060e73507a8d
https://github.com/illumos/illumos-gate/commit/82693e09cc02331fa1b3b73b54b1060e73507a8d
https://www.illumos.org/issues/8966

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: WHR <msl0000023508@gmail.com>
PR: 225162
Submitted by: WHR <msl0000023508@gmail.com>
Reported by: WHR <msl0000023508@gmail.com>
MFC after: 1 week

6 years ago8966 Source file zfs_acl.c, function zfs_aclset_common contains a use after end of...
avg [Wed, 21 Feb 2018 14:12:29 +0000 (14:12 +0000)]
8966 Source file zfs_acl.c, function zfs_aclset_common contains a use after end of the lifetime of a local variable

illumos/illumos-gate@82693e09cc02331fa1b3b73b54b1060e73507a8d
https://github.com/illumos/illumos-gate/commit/82693e09cc02331fa1b3b73b54b1060e73507a8d

https://www.illumos.org/issues/8966

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: WHR <msl0000023508@gmail.com>

6 years agolualoader: Don't autodetect kernels if 'kernels' is explicitly set
kevans [Wed, 21 Feb 2018 14:07:53 +0000 (14:07 +0000)]
lualoader: Don't autodetect kernels if 'kernels' is explicitly set

6 years agoUse proper buffer length (the announce_buf char pointer used to be anarray),
trasz [Wed, 21 Feb 2018 14:05:13 +0000 (14:05 +0000)]
Use proper buffer length (the announce_buf char pointer used to be anarray),
broken in r317143. This fixes those weird "cd0: Attempt" messages at boot.

PR: 222103
Reviewed by: scottl@
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14369

6 years agoAllow LinuxKPI character devices to receive mmap() calls from the Linux
hselasky [Wed, 21 Feb 2018 10:13:17 +0000 (10:13 +0000)]
Allow LinuxKPI character devices to receive mmap() calls from the Linux
binary mode user-space emulation layer. This is a regression issue after
r328436, when LinuxKPI character devices started to use DTYPE_DEV in
the "f_type" field of the associated file structure(s).

MFC after: 3 days
Found by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

6 years agoPowerNV: add missing RTC_WRITE support
wma [Wed, 21 Feb 2018 08:13:17 +0000 (08:13 +0000)]
PowerNV: add missing RTC_WRITE support

Add function which can store RTC values to OPAL.

Submitted by:          Wojciech Macek <wma@semihalf.org>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies

6 years agoCXGBE: implement prefetch on non-Intel architectures
wma [Wed, 21 Feb 2018 08:05:56 +0000 (08:05 +0000)]
CXGBE: implement prefetch on non-Intel architectures

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

6 years agolualoader: Allow carousel 'items' to be a table as well as a function
kevans [Wed, 21 Feb 2018 05:04:58 +0000 (05:04 +0000)]
lualoader: Allow carousel 'items' to be a table as well as a function

We don't have any in-tree users of this, but for a static set of carousel
options having to define a callback is excessive.

6 years agolualoader: Simplify menu definitions a little further
kevans [Wed, 21 Feb 2018 04:48:37 +0000 (04:48 +0000)]
lualoader: Simplify menu definitions a little further

Allow "name" entries to be simple strings, instead of just functions. We
know whether we support colors or not by the time any of this is setup, so
all menu names that are basically static with colors sprinkled in are good
candidates for simplification.

Also simplify "func" in many cases where it's just invoking another function
with no arguments. The downside to this simplification is that the functions
called can no longer be trivially replaced by a local module. The upside is
that it removes another layer of indirection that we likely don't need.

These can be re-evaluated later if a compelling argument is raised, on a
case-by-case basis, for replacement.

6 years agolualoader: Directly reference submenu definition with submenu key
kevans [Wed, 21 Feb 2018 04:23:13 +0000 (04:23 +0000)]
lualoader: Directly reference submenu definition with submenu key

6 years agolualoader: Drop name requirement for menu separators
kevans [Wed, 21 Feb 2018 04:14:32 +0000 (04:14 +0000)]
lualoader: Drop name requirement for menu separators

6 years agolualoader: Add "menu.default", initialized to menu.welcome
kevans [Wed, 21 Feb 2018 03:37:46 +0000 (03:37 +0000)]
lualoader: Add "menu.default", initialized to menu.welcome

The intent here is to abstract away the name of the default menu. The
default menu is still the welcome menu, but this detail doesn't need to
matter to things outside of the menu module. You may change the default
menu, but one would need to modify a specific menu.

6 years agoSplit printtrap() into generic and CPU-specific components
jhibbits [Wed, 21 Feb 2018 03:34:33 +0000 (03:34 +0000)]
Split printtrap() into generic and CPU-specific components

Summary:
This compartmentalizes the CPU-specific trap components into its own
function, rather than littering the general printtrap() with various checks.
This will let us replace a series of #ifdef's with a runtime conditional check
in the future.

Reviewed By: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D14416

6 years agoMFV r324198: 8081 Compiler warnings in zdb
mav [Wed, 21 Feb 2018 03:08:47 +0000 (03:08 +0000)]
MFV r324198: 8081 Compiler warnings in zdb

illumos/illumos-gate@3f7978d02b206a6ebc5652c91aa9f42da6fbe00c
https://github.com/illumos/illumos-gate/commit/3f7978d02b206a6ebc5652c91aa9f42da6fbe00c

https://www.illumos.org/issues/8081
  zdb(8) is full of minor problems that generate compiler warnings. On FreeBSD,
  which uses -WError, the only way to build it is to disable all compiler
  warnings. This makes it much harder to detect newly introduced bugs. We should
  cleanup all the warnings.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Alan Somers <asomers@gmail.com>

6 years agolualoader: Return only argstr if with_kernel not requested
kevans [Wed, 21 Feb 2018 03:06:36 +0000 (03:06 +0000)]
lualoader: Return only argstr if with_kernel not requested

6 years agolualoader: Bring in local.lua module if it exists
kevans [Wed, 21 Feb 2018 02:35:13 +0000 (02:35 +0000)]
lualoader: Bring in local.lua module if it exists

Provide a way for out-of-tree users of lualoader to patch into the loader
system without having to modify our distributed scripts.

Do note that we can't really offer any API compatibility guarantees at this
time due to the evolving nature of lualoader right now.

This still has some utility as local modules may add commands at the loader
prompt without relying heavily on lualoader features- this specific
functionality is less likely to change without more careful consideration.

Reviewed by: cem (earlier version)
Differential Revision: https://reviews.freebsd.org/D14439

6 years agoMFV r322231:
mav [Wed, 21 Feb 2018 02:21:22 +0000 (02:21 +0000)]
MFV r322231:
8430 dir_is_empty_readdir() doesn't properly handle error from fdopendir()

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

https://www.illumos.org/issues/8430
  we should close dirfd if fdopendir() fails.

Reviewed by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Sowrabha Gopal <sowrabha.gopal@delphix.com>

6 years agoMFV r319737: 6939 add sysevents to zfs core for commands
mav [Wed, 21 Feb 2018 02:19:42 +0000 (02:19 +0000)]
MFV r319737: 6939 add sysevents to zfs core for commands

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

https://www.illumos.org/issues/6939
  Originally created https://smartos.org/bugview/OS-4489
       sysevents should be fired in the kernel from ZFS whenever a command
       is run that is logged in zpool history.
  Example output
  Terminal 1
  root - gz sunos ~ # zfs create zones/foobar
  root - gz sunos ~ # zfs set quota=10g zones/foobar
  root - gz sunos ~ # zfs destroy zones/foobar
  Terminal 2
  root - gz sunos ~ # sysevent EC_zfs
  nvlist version: 0
      date = 2016-04-28T14:50:08.964Z
      vendor = SUNW
      publisher = zfs
      class = EC_zfs
      subclass = ESC_ZFS_history_event
      pid = 0
      data = (embedded nvlist)
      nvlist version: 0
          pool_name = zones
          pool_guid = 0x40c964e8f9a7a694
          history_record = (embedded nvlist)
          nvlist version: 0
              dsname = zones/foobar
              dsid = 0x1525
              history internal str =
              internal_name = create
              history txg = 0x4c4ef3

Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Reviewed by: Josh Wilsdon <jwilsdon@joyent.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed by: Alan Somers <asomers@gmail.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Author: Dave Eddy <dave@daveeddy.com>

6 years agolualoader: Output "Failed to parse" messages
kevans [Wed, 21 Feb 2018 01:52:42 +0000 (01:52 +0000)]
lualoader: Output "Failed to parse" messages

I can't find any good reason these aren't enabled, so enable them.

The silent runs will only return false on actual parse errors, so it's ok to
be loud about those failures.

6 years agolualoader: Don't return false for failure to open config on silent parse
kevans [Wed, 21 Feb 2018 01:50:46 +0000 (01:50 +0000)]
lualoader: Don't return false for failure to open config on silent parse

6 years agolualoader: Drop explicit boolean tests; b or not b
kevans [Wed, 21 Feb 2018 01:39:33 +0000 (01:39 +0000)]
lualoader: Drop explicit boolean tests; b or not b

6 years agostyle.lua(9): Drop notes about semicolons
kevans [Wed, 21 Feb 2018 01:37:22 +0000 (01:37 +0000)]
style.lua(9): Drop notes about semicolons

It is generally agreed upon that they are ugly and should not be used except
where needed.

6 years agolualoader: Drop excessive parenthesizing
kevans [Wed, 21 Feb 2018 01:35:19 +0000 (01:35 +0000)]
lualoader: Drop excessive parenthesizing

This was also a convenience convention (for me) that is not very lua-tic.
Drop it.

I've maintained some parentheses where I'd prefer them, for example,
'if x or y or (z and w) then', but these situations are far and few between.

6 years agolualoader: Drop terminating semicolons
kevans [Wed, 21 Feb 2018 01:10:03 +0000 (01:10 +0000)]
lualoader: Drop terminating semicolons

This was previously chosen out of convenience, as we had a mixed style and
needed to be consistent. I started learning Lua on Friday, so I switched
everything over. It is not a very lua-nic convention, though, so drop it.

Excessive parenthesizing around conditionals is next on the chopping block.