2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* CDDL HEADER START
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the terms of the
|
|
|
|
* Common Development and Distribution License (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
2022-07-11 21:16:13 +00:00
|
|
|
* or https://opensource.org/licenses/CDDL-1.0.
|
2008-11-20 20:01:55 +00:00
|
|
|
* See the License for the specific language governing permissions
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
|
|
*
|
|
|
|
* CDDL HEADER END
|
|
|
|
*/
|
|
|
|
/*
|
2010-08-26 21:24:34 +00:00
|
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2020-04-23 17:06:57 +00:00
|
|
|
* Copyright (c) 2012, 2020 by Delphix. All rights reserved.
|
2016-06-09 18:46:42 +00:00
|
|
|
* Copyright 2016 RackTop Systems.
|
2017-06-17 00:21:11 +00:00
|
|
|
* Copyright (c) 2017, Intel Corporation.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_ZFS_IOCTL_H
|
|
|
|
#define _SYS_ZFS_IOCTL_H
|
|
|
|
|
|
|
|
#include <sys/cred.h>
|
|
|
|
#include <sys/dmu.h>
|
|
|
|
#include <sys/zio.h>
|
|
|
|
#include <sys/dsl_deleg.h>
|
2010-05-28 20:45:14 +00:00
|
|
|
#include <sys/spa.h>
|
2010-08-26 21:24:34 +00:00
|
|
|
#include <sys/zfs_stat.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
#include <sys/nvpair.h>
|
|
|
|
#endif /* _KERNEL */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-08-28 11:45:09 +00:00
|
|
|
/*
|
|
|
|
* The structures in this file are passed between userland and the
|
|
|
|
* kernel. Userland may be running a 32-bit process, while the kernel
|
|
|
|
* is 64-bit. Therefore, these structures need to compile the same in
|
|
|
|
* 32-bit and 64-bit. This means not using type "long", and adding
|
|
|
|
* explicit padding so that the 32-bit structure will not be packed more
|
|
|
|
* tightly than the 64-bit structure (which requires 64-bit alignment).
|
|
|
|
*/
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* Property values for snapdir
|
|
|
|
*/
|
|
|
|
#define ZFS_SNAPDIR_HIDDEN 0
|
|
|
|
#define ZFS_SNAPDIR_VISIBLE 1
|
|
|
|
|
2013-02-13 23:11:59 +00:00
|
|
|
/*
|
|
|
|
* Property values for snapdev
|
|
|
|
*/
|
|
|
|
#define ZFS_SNAPDEV_HIDDEN 0
|
|
|
|
#define ZFS_SNAPDEV_VISIBLE 1
|
2013-10-28 16:22:15 +00:00
|
|
|
/*
|
|
|
|
* Property values for acltype
|
|
|
|
*/
|
|
|
|
#define ZFS_ACLTYPE_OFF 0
|
2020-09-16 19:26:06 +00:00
|
|
|
#define ZFS_ACLTYPE_POSIX 1
|
2020-10-14 04:25:48 +00:00
|
|
|
#define ZFS_ACLTYPE_NFSV4 2
|
2013-02-13 23:11:59 +00:00
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/*
|
|
|
|
* Field manipulation macros for the drr_versioninfo field of the
|
|
|
|
* send stream header.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Header types for zfs send streams.
|
|
|
|
*/
|
|
|
|
typedef enum drr_headertype {
|
|
|
|
DMU_SUBSTREAM = 0x1,
|
|
|
|
DMU_COMPOUNDSTREAM = 0x2
|
|
|
|
} drr_headertype_t;
|
|
|
|
|
|
|
|
#define DMU_GET_STREAM_HDRTYPE(vi) BF64_GET((vi), 0, 2)
|
|
|
|
#define DMU_SET_STREAM_HDRTYPE(vi, x) BF64_SET((vi), 0, 2, x)
|
|
|
|
|
|
|
|
#define DMU_GET_FEATUREFLAGS(vi) BF64_GET((vi), 2, 30)
|
|
|
|
#define DMU_SET_FEATUREFLAGS(vi, x) BF64_SET((vi), 2, 30, x)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Feature flags for zfs send streams (flags in drr_versioninfo)
|
|
|
|
*/
|
|
|
|
|
2016-01-06 21:22:48 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_DEDUP (1 << 0)
|
|
|
|
#define DMU_BACKUP_FEATURE_DEDUPPROPS (1 << 1)
|
|
|
|
#define DMU_BACKUP_FEATURE_SA_SPILL (1 << 2)
|
2014-06-05 21:19:08 +00:00
|
|
|
/* flags #3 - #15 are reserved for incompatible closed-source implementations */
|
2016-01-06 21:22:48 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_EMBED_DATA (1 << 16)
|
2016-07-11 17:45:52 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_LZ4 (1 << 17)
|
2014-11-03 20:15:08 +00:00
|
|
|
/* flag #18 is reserved for a Delphix feature */
|
2016-01-06 21:22:48 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_LARGE_BLOCKS (1 << 19)
|
|
|
|
#define DMU_BACKUP_FEATURE_RESUMING (1 << 20)
|
Implement Redacted Send/Receive
Redacted send/receive allows users to send subsets of their data to
a target system. One possible use case for this feature is to not
transmit sensitive information to a data warehousing, test/dev, or
analytics environment. Another is to save space by not replicating
unimportant data within a given dataset, for example in backup tools
like zrepl.
Redacted send/receive is a three-stage process. First, a clone (or
clones) is made of the snapshot to be sent to the target. In this
clone (or clones), all unnecessary or unwanted data is removed or
modified. This clone is then snapshotted to create the "redaction
snapshot" (or snapshots). Second, the new zfs redact command is used
to create a redaction bookmark. The redaction bookmark stores the
list of blocks in a snapshot that were modified by the redaction
snapshot(s). Finally, the redaction bookmark is passed as a parameter
to zfs send. When sending to the snapshot that was redacted, the
redaction bookmark is used to filter out blocks that contain sensitive
or unwanted information, and those blocks are not included in the send
stream. When sending from the redaction bookmark, the blocks it
contains are considered as candidate blocks in addition to those
blocks in the destination snapshot that were modified since the
creation_txg of the redaction bookmark. This step is necessary to
allow the target to rehydrate data in the case where some blocks are
accidentally or unnecessarily modified in the redaction snapshot.
The changes to bookmarks to enable fast space estimation involve
adding deadlists to bookmarks. There is also logic to manage the
life cycles of these deadlists.
The new size estimation process operates in cases where previously
an accurate estimate could not be provided. In those cases, a send
is performed where no data blocks are read, reducing the runtime
significantly and providing a byte-accurate size estimate.
Reviewed-by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed-by: Matt Ahrens <mahrens@delphix.com>
Reviewed-by: Prashanth Sreenivasa <pks@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: Chris Williamson <chris.williamson@delphix.com>
Reviewed-by: Pavel Zhakarov <pavel.zakharov@delphix.com>
Reviewed-by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #7958
2019-06-19 16:48:13 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_REDACTED (1 << 21)
|
2016-07-11 17:45:52 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_COMPRESSED (1 << 22)
|
2017-05-18 17:02:16 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_LARGE_DNODE (1 << 23)
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_RAW (1 << 24)
|
Add zstd support to zfs
This PR adds two new compression types, based on ZStandard:
- zstd: A basic ZStandard compression algorithm Available compression.
Levels for zstd are zstd-1 through zstd-19, where the compression
increases with every level, but speed decreases.
- zstd-fast: A faster version of the ZStandard compression algorithm
zstd-fast is basically a "negative" level of zstd. The compression
decreases with every level, but speed increases.
Available compression levels for zstd-fast:
- zstd-fast-1 through zstd-fast-10
- zstd-fast-20 through zstd-fast-100 (in increments of 10)
- zstd-fast-500 and zstd-fast-1000
For more information check the man page.
Implementation details:
Rather than treat each level of zstd as a different algorithm (as was
done historically with gzip), the block pointer `enum zio_compress`
value is simply zstd for all levels, including zstd-fast, since they all
use the same decompression function.
The compress= property (a 64bit unsigned integer) uses the lower 7 bits
to store the compression algorithm (matching the number of bits used in
a block pointer, as the 8th bit was borrowed for embedded block
pointers). The upper bits are used to store the compression level.
It is necessary to be able to determine what compression level was used
when later reading a block back, so the concept used in LZ4, where the
first 32bits of the on-disk value are the size of the compressed data
(since the allocation is rounded up to the nearest ashift), was
extended, and we store the version of ZSTD and the level as well as the
compressed size. This value is returned when decompressing a block, so
that if the block needs to be recompressed (L2ARC, nop-write, etc), that
the same parameters will be used to result in the matching checksum.
All of the internal ZFS code ( `arc_buf_hdr_t`, `objset_t`,
`zio_prop_t`, etc.) uses the separated _compress and _complevel
variables. Only the properties ZAP contains the combined/bit-shifted
value. The combined value is split when the compression_changed_cb()
callback is called, and sets both objset members (os_compress and
os_complevel).
The userspace tools all use the combined/bit-shifted value.
Additional notes:
zdb can now also decode the ZSTD compression header (flag -Z) and
inspect the size, version and compression level saved in that header.
For each record, if it is ZSTD compressed, the parameters of the decoded
compression header get printed.
ZSTD is included with all current tests and new tests are added
as-needed.
Per-dataset feature flags now get activated when the property is set.
If a compression algorithm requires a feature flag, zfs activates the
feature when the property is set, rather than waiting for the first
block to be born. This is currently only used by zstd but can be
extended as needed.
Portions-Sponsored-By: The FreeBSD Foundation
Co-authored-by: Allan Jude <allanjude@freebsd.org>
Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Co-authored-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Co-authored-by: Michael Niewöhner <foss@mniewoehner.de>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Allan Jude <allanjude@freebsd.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Closes #6247
Closes #9024
Closes #10277
Closes #10278
2020-08-18 17:10:17 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_ZSTD (1 << 25)
|
2019-02-15 20:41:38 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_HOLDS (1 << 26)
|
File incorrectly zeroed when receiving incremental stream that toggles -L
Background:
By increasing the recordsize property above the default of 128KB, a
filesystem may have "large" blocks. By default, a send stream of such a
filesystem does not contain large WRITE records, instead it decreases
objects' block sizes to 128KB and splits the large blocks into 128KB
blocks, allowing the large-block filesystem to be received by a system
that does not support the `large_blocks` feature. A send stream
generated by `zfs send -L` (or `--large-block`) preserves the large
block size on the receiving system, by using large WRITE records.
When receiving an incremental send stream for a filesystem with large
blocks, if the send stream's -L flag was toggled, a bug is encountered
in which the file's contents are incorrectly zeroed out. The contents
of any blocks that were not modified by this send stream will be lost.
"Toggled" means that the previous send used `-L`, but this incremental
does not use `-L` (-L to no-L); or that the previous send did not use
`-L`, but this incremental does use `-L` (no-L to -L).
Changes:
This commit addresses the problem with several changes to the semantics
of zfs send/receive:
1. "-L to no-L" incrementals are rejected. If the previous send used
`-L`, but this incremental does not use `-L`, the `zfs receive` will
fail with this error message:
incremental send stream requires -L (--large-block), to match
previous receive.
2. "no-L to -L" incrementals are handled correctly, preserving the
smaller (128KB) block size of any already-received files that used large
blocks on the sending system but were split by `zfs send` without the
`-L` flag.
3. A new send stream format flag is added, `SWITCH_TO_LARGE_BLOCKS`.
This feature indicates that we can correctly handle "no-L to -L"
incrementals. This flag is currently not set on any send streams. In
the future, we intend for incremental send streams of snapshots that
have large blocks to use `-L` by default, and these streams will also
have the `SWITCH_TO_LARGE_BLOCKS` feature set. This ensures that streams
from the default use of `zfs send` won't encounter the bug mentioned
above, because they can't be received by software with the bug.
Implementation notes:
To facilitate accessing the ZPL's generation number,
`zfs_space_delta_cb()` has been renamed to `zpl_get_file_info()` and
restructured to fill in a struct with ZPL-specific info including owner
and generation.
In the "no-L to -L" case, if this is a compressed send stream (from
`zfs send -cL`), large WRITE records that are being written to small
(128KB) blocksize files need to be decompressed so that they can be
written split up into multiple blocks. The zio pipeline will recompress
each smaller block individually.
A new test case, `send-L_toggle`, is added, which tests the "no-L to -L"
case and verifies that we get an error for the "-L to no-L" case.
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #6224
Closes #10383
2020-06-09 17:41:01 +00:00
|
|
|
/*
|
|
|
|
* The SWITCH_TO_LARGE_BLOCKS feature indicates that we can receive
|
|
|
|
* incremental LARGE_BLOCKS streams (those with WRITE records of >128KB) even
|
|
|
|
* if the previous send did not use LARGE_BLOCKS, and thus its large blocks
|
|
|
|
* were split into multiple 128KB WRITE records. (See
|
|
|
|
* flush_write_batch_impl() and receive_object()). Older software that does
|
|
|
|
* not support this flag may encounter a bug when switching to large blocks,
|
|
|
|
* which causes files to incorrectly be zeroed.
|
|
|
|
*
|
|
|
|
* This flag is currently not set on any send streams. In the future, we
|
|
|
|
* intend for incremental send streams of snapshots that have large blocks to
|
|
|
|
* use LARGE_BLOCKS by default, and these streams will also have the
|
|
|
|
* SWITCH_TO_LARGE_BLOCKS feature set. This ensures that streams from the
|
|
|
|
* default use of "zfs send" won't encounter the bug mentioned above.
|
|
|
|
*/
|
|
|
|
#define DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS (1 << 27)
|
2022-08-24 17:04:19 +00:00
|
|
|
/* flag #28 is reserved for a Nutanix feature */
|
|
|
|
/*
|
|
|
|
* flag #29 is the last unused bit. It is reserved to indicate a to-be-designed
|
|
|
|
* extension to the stream format which will accomodate more feature flags.
|
|
|
|
* If you need to add another feature flag, please reach out to the OpenZFS
|
|
|
|
* community, e.g., on GitHub or Slack.
|
|
|
|
*/
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mask of all supported backup features
|
|
|
|
*/
|
2020-04-23 17:06:57 +00:00
|
|
|
#define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_SA_SPILL | \
|
2016-07-11 17:45:52 +00:00
|
|
|
DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_LZ4 | \
|
2016-01-06 21:22:48 +00:00
|
|
|
DMU_BACKUP_FEATURE_RESUMING | DMU_BACKUP_FEATURE_LARGE_BLOCKS | \
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \
|
Implement Redacted Send/Receive
Redacted send/receive allows users to send subsets of their data to
a target system. One possible use case for this feature is to not
transmit sensitive information to a data warehousing, test/dev, or
analytics environment. Another is to save space by not replicating
unimportant data within a given dataset, for example in backup tools
like zrepl.
Redacted send/receive is a three-stage process. First, a clone (or
clones) is made of the snapshot to be sent to the target. In this
clone (or clones), all unnecessary or unwanted data is removed or
modified. This clone is then snapshotted to create the "redaction
snapshot" (or snapshots). Second, the new zfs redact command is used
to create a redaction bookmark. The redaction bookmark stores the
list of blocks in a snapshot that were modified by the redaction
snapshot(s). Finally, the redaction bookmark is passed as a parameter
to zfs send. When sending to the snapshot that was redacted, the
redaction bookmark is used to filter out blocks that contain sensitive
or unwanted information, and those blocks are not included in the send
stream. When sending from the redaction bookmark, the blocks it
contains are considered as candidate blocks in addition to those
blocks in the destination snapshot that were modified since the
creation_txg of the redaction bookmark. This step is necessary to
allow the target to rehydrate data in the case where some blocks are
accidentally or unnecessarily modified in the redaction snapshot.
The changes to bookmarks to enable fast space estimation involve
adding deadlists to bookmarks. There is also logic to manage the
life cycles of these deadlists.
The new size estimation process operates in cases where previously
an accurate estimate could not be provided. In those cases, a send
is performed where no data blocks are read, reducing the runtime
significantly and providing a byte-accurate size estimate.
Reviewed-by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed-by: Matt Ahrens <mahrens@delphix.com>
Reviewed-by: Prashanth Sreenivasa <pks@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: Chris Williamson <chris.williamson@delphix.com>
Reviewed-by: Pavel Zhakarov <pavel.zakharov@delphix.com>
Reviewed-by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #7958
2019-06-19 16:48:13 +00:00
|
|
|
DMU_BACKUP_FEATURE_RAW | DMU_BACKUP_FEATURE_HOLDS | \
|
Add zstd support to zfs
This PR adds two new compression types, based on ZStandard:
- zstd: A basic ZStandard compression algorithm Available compression.
Levels for zstd are zstd-1 through zstd-19, where the compression
increases with every level, but speed decreases.
- zstd-fast: A faster version of the ZStandard compression algorithm
zstd-fast is basically a "negative" level of zstd. The compression
decreases with every level, but speed increases.
Available compression levels for zstd-fast:
- zstd-fast-1 through zstd-fast-10
- zstd-fast-20 through zstd-fast-100 (in increments of 10)
- zstd-fast-500 and zstd-fast-1000
For more information check the man page.
Implementation details:
Rather than treat each level of zstd as a different algorithm (as was
done historically with gzip), the block pointer `enum zio_compress`
value is simply zstd for all levels, including zstd-fast, since they all
use the same decompression function.
The compress= property (a 64bit unsigned integer) uses the lower 7 bits
to store the compression algorithm (matching the number of bits used in
a block pointer, as the 8th bit was borrowed for embedded block
pointers). The upper bits are used to store the compression level.
It is necessary to be able to determine what compression level was used
when later reading a block back, so the concept used in LZ4, where the
first 32bits of the on-disk value are the size of the compressed data
(since the allocation is rounded up to the nearest ashift), was
extended, and we store the version of ZSTD and the level as well as the
compressed size. This value is returned when decompressing a block, so
that if the block needs to be recompressed (L2ARC, nop-write, etc), that
the same parameters will be used to result in the matching checksum.
All of the internal ZFS code ( `arc_buf_hdr_t`, `objset_t`,
`zio_prop_t`, etc.) uses the separated _compress and _complevel
variables. Only the properties ZAP contains the combined/bit-shifted
value. The combined value is split when the compression_changed_cb()
callback is called, and sets both objset members (os_compress and
os_complevel).
The userspace tools all use the combined/bit-shifted value.
Additional notes:
zdb can now also decode the ZSTD compression header (flag -Z) and
inspect the size, version and compression level saved in that header.
For each record, if it is ZSTD compressed, the parameters of the decoded
compression header get printed.
ZSTD is included with all current tests and new tests are added
as-needed.
Per-dataset feature flags now get activated when the property is set.
If a compression algorithm requires a feature flag, zfs activates the
feature when the property is set, rather than waiting for the first
block to be born. This is currently only used by zstd but can be
extended as needed.
Portions-Sponsored-By: The FreeBSD Foundation
Co-authored-by: Allan Jude <allanjude@freebsd.org>
Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Co-authored-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Co-authored-by: Michael Niewöhner <foss@mniewoehner.de>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Allan Jude <allanjude@freebsd.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Closes #6247
Closes #9024
Closes #10277
Closes #10278
2020-08-18 17:10:17 +00:00
|
|
|
DMU_BACKUP_FEATURE_REDACTED | DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS | \
|
2022-08-24 15:08:48 +00:00
|
|
|
DMU_BACKUP_FEATURE_ZSTD)
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
/* Are all features in the given flag word currently supported? */
|
|
|
|
#define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK))
|
|
|
|
|
2016-01-06 21:22:48 +00:00
|
|
|
typedef enum dmu_send_resume_token_version {
|
|
|
|
ZFS_SEND_RESUME_TOKEN_VERSION = 1
|
|
|
|
} dmu_send_resume_token_version_t;
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/*
|
|
|
|
* The drr_versioninfo field of the dmu_replay_record has the
|
|
|
|
* following layout:
|
|
|
|
*
|
|
|
|
* 64 56 48 40 32 24 16 8 0
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2019-05-07 22:18:44 +00:00
|
|
|
* | reserved | feature-flags |C|S|
|
2010-05-28 20:45:14 +00:00
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
*
|
|
|
|
* The low order two bits indicate the header type: SUBSTREAM (0x1)
|
|
|
|
* or COMPOUNDSTREAM (0x2). Using two bits for this is historical:
|
|
|
|
* this field used to be a version number, where the two version types
|
|
|
|
* were 1 and 2. Using two bits for this allows earlier versions of
|
|
|
|
* the code to be able to recognize send streams that don't use any
|
|
|
|
* of the features indicated by feature flags.
|
|
|
|
*/
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#define DMU_BACKUP_MAGIC 0x2F5bacbacULL
|
|
|
|
|
2016-06-09 18:46:42 +00:00
|
|
|
/*
|
|
|
|
* Send stream flags. Bits 24-31 are reserved for vendor-specific
|
|
|
|
* implementations and should not be used.
|
|
|
|
*/
|
2008-11-20 20:01:55 +00:00
|
|
|
#define DRR_FLAG_CLONE (1<<0)
|
|
|
|
#define DRR_FLAG_CI_DATA (1<<1)
|
2016-06-09 18:18:16 +00:00
|
|
|
/*
|
|
|
|
* This send stream, if it is a full send, includes the FREE and FREEOBJECT
|
|
|
|
* records that are created by the sending process. This means that the send
|
|
|
|
* stream can be received as a clone, even though it is not an incremental.
|
|
|
|
* This is not implemented as a feature flag, because the receiving side does
|
|
|
|
* not need to have implemented it to receive this stream; it is fully backwards
|
|
|
|
* compatible. We need a flag, though, because full send streams without it
|
|
|
|
* cannot necessarily be received as a clone correctly.
|
|
|
|
*/
|
|
|
|
#define DRR_FLAG_FREERECORDS (1<<2)
|
2019-05-07 22:18:44 +00:00
|
|
|
/*
|
|
|
|
* When DRR_FLAG_SPILL_BLOCK is set it indicates the DRR_OBJECT_SPILL
|
|
|
|
* and DRR_SPILL_UNMODIFIED flags are meaningful in the send stream.
|
|
|
|
*
|
|
|
|
* When DRR_FLAG_SPILL_BLOCK is set, DRR_OBJECT records will have
|
|
|
|
* DRR_OBJECT_SPILL set if and only if they should have a spill block
|
|
|
|
* (either an existing one, or a new one in the send stream). When clear
|
|
|
|
* the object does not have a spill block and any existing spill block
|
|
|
|
* should be freed.
|
|
|
|
*
|
|
|
|
* Similarly, when DRR_FLAG_SPILL_BLOCK is set, DRR_SPILL records will
|
|
|
|
* have DRR_SPILL_UNMODIFIED set if and only if they were included for
|
|
|
|
* backward compatibility purposes, and can be safely ignored by new versions
|
|
|
|
* of zfs receive. Previous versions of ZFS which do not understand the
|
|
|
|
* DRR_FLAG_SPILL_BLOCK will process this record and recreate any missing
|
|
|
|
* spill blocks.
|
|
|
|
*/
|
|
|
|
#define DRR_FLAG_SPILL_BLOCK (1<<3)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/*
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
* flags in the drr_flags field in the DRR_WRITE, DRR_SPILL, DRR_OBJECT,
|
|
|
|
* DRR_WRITE_BYREF, and DRR_OBJECT_RANGE blocks
|
2010-05-28 20:45:14 +00:00
|
|
|
*/
|
2019-05-07 22:18:44 +00:00
|
|
|
#define DRR_CHECKSUM_DEDUP (1<<0) /* not used for SPILL records */
|
2017-08-23 23:54:24 +00:00
|
|
|
#define DRR_RAW_BYTESWAP (1<<1)
|
2019-05-07 22:18:44 +00:00
|
|
|
#define DRR_OBJECT_SPILL (1<<2) /* OBJECT record has a spill block */
|
|
|
|
#define DRR_SPILL_UNMODIFIED (1<<2) /* SPILL record for unmodified block */
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
#define DRR_IS_DEDUP_CAPABLE(flags) ((flags) & DRR_CHECKSUM_DEDUP)
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
#define DRR_IS_RAW_BYTESWAPPED(flags) ((flags) & DRR_RAW_BYTESWAP)
|
2019-05-07 22:18:44 +00:00
|
|
|
#define DRR_OBJECT_HAS_SPILL(flags) ((flags) & DRR_OBJECT_SPILL)
|
|
|
|
#define DRR_SPILL_IS_UNMODIFIED(flags) ((flags) & DRR_SPILL_UNMODIFIED)
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2016-07-11 17:45:52 +00:00
|
|
|
/* deal with compressed drr_write replay records */
|
|
|
|
#define DRR_WRITE_COMPRESSED(drrw) ((drrw)->drr_compressiontype != 0)
|
|
|
|
#define DRR_WRITE_PAYLOAD_SIZE(drrw) \
|
|
|
|
(DRR_WRITE_COMPRESSED(drrw) ? (drrw)->drr_compressed_size : \
|
|
|
|
(drrw)->drr_logical_size)
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
#define DRR_SPILL_PAYLOAD_SIZE(drrs) \
|
2017-08-23 23:54:24 +00:00
|
|
|
((drrs)->drr_compressed_size ? \
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
(drrs)->drr_compressed_size : (drrs)->drr_length)
|
|
|
|
#define DRR_OBJECT_PAYLOAD_SIZE(drro) \
|
2017-08-23 23:54:24 +00:00
|
|
|
((drro)->drr_raw_bonuslen != 0 ? \
|
|
|
|
(drro)->drr_raw_bonuslen : P2ROUNDUP((drro)->drr_bonuslen, 8))
|
2016-07-11 17:45:52 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* zfs ioctl command structure
|
|
|
|
*/
|
2020-06-16 18:57:04 +00:00
|
|
|
|
|
|
|
/* Header is used in C++ so can't forward declare untagged struct */
|
|
|
|
struct drr_begin {
|
|
|
|
uint64_t drr_magic;
|
|
|
|
uint64_t drr_versioninfo; /* was drr_version */
|
|
|
|
uint64_t drr_creation_time;
|
|
|
|
dmu_objset_type_t drr_type;
|
|
|
|
uint32_t drr_flags;
|
|
|
|
uint64_t drr_toguid;
|
|
|
|
uint64_t drr_fromguid;
|
|
|
|
char drr_toname[MAXNAMELEN];
|
|
|
|
};
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef struct dmu_replay_record {
|
|
|
|
enum {
|
|
|
|
DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
|
2010-05-28 20:45:14 +00:00
|
|
|
DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
|
Implement Redacted Send/Receive
Redacted send/receive allows users to send subsets of their data to
a target system. One possible use case for this feature is to not
transmit sensitive information to a data warehousing, test/dev, or
analytics environment. Another is to save space by not replicating
unimportant data within a given dataset, for example in backup tools
like zrepl.
Redacted send/receive is a three-stage process. First, a clone (or
clones) is made of the snapshot to be sent to the target. In this
clone (or clones), all unnecessary or unwanted data is removed or
modified. This clone is then snapshotted to create the "redaction
snapshot" (or snapshots). Second, the new zfs redact command is used
to create a redaction bookmark. The redaction bookmark stores the
list of blocks in a snapshot that were modified by the redaction
snapshot(s). Finally, the redaction bookmark is passed as a parameter
to zfs send. When sending to the snapshot that was redacted, the
redaction bookmark is used to filter out blocks that contain sensitive
or unwanted information, and those blocks are not included in the send
stream. When sending from the redaction bookmark, the blocks it
contains are considered as candidate blocks in addition to those
blocks in the destination snapshot that were modified since the
creation_txg of the redaction bookmark. This step is necessary to
allow the target to rehydrate data in the case where some blocks are
accidentally or unnecessarily modified in the redaction snapshot.
The changes to bookmarks to enable fast space estimation involve
adding deadlists to bookmarks. There is also logic to manage the
life cycles of these deadlists.
The new size estimation process operates in cases where previously
an accurate estimate could not be provided. In those cases, a send
is performed where no data blocks are read, reducing the runtime
significantly and providing a byte-accurate size estimate.
Reviewed-by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed-by: Matt Ahrens <mahrens@delphix.com>
Reviewed-by: Prashanth Sreenivasa <pks@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: Chris Williamson <chris.williamson@delphix.com>
Reviewed-by: Pavel Zhakarov <pavel.zakharov@delphix.com>
Reviewed-by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #7958
2019-06-19 16:48:13 +00:00
|
|
|
DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_OBJECT_RANGE, DRR_REDACT,
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
DRR_NUMTYPES
|
2008-11-20 20:01:55 +00:00
|
|
|
} drr_type;
|
|
|
|
uint32_t drr_payloadlen;
|
|
|
|
union {
|
2020-06-16 18:57:04 +00:00
|
|
|
struct drr_begin drr_begin;
|
2008-11-20 20:01:55 +00:00
|
|
|
struct drr_end {
|
|
|
|
zio_cksum_t drr_checksum;
|
2010-05-28 20:45:14 +00:00
|
|
|
uint64_t drr_toguid;
|
2008-11-20 20:01:55 +00:00
|
|
|
} drr_end;
|
|
|
|
struct drr_object {
|
|
|
|
uint64_t drr_object;
|
|
|
|
dmu_object_type_t drr_type;
|
|
|
|
dmu_object_type_t drr_bonustype;
|
|
|
|
uint32_t drr_blksz;
|
|
|
|
uint32_t drr_bonuslen;
|
2010-05-28 20:45:14 +00:00
|
|
|
uint8_t drr_checksumtype;
|
2008-11-20 20:01:55 +00:00
|
|
|
uint8_t drr_compress;
|
Implement large_dnode pool feature
Justification
-------------
This feature adds support for variable length dnodes. Our motivation is
to eliminate the overhead associated with using spill blocks. Spill
blocks are used to store system attribute data (i.e. file metadata) that
does not fit in the dnode's bonus buffer. By allowing a larger bonus
buffer area the use of a spill block can be avoided. Spill blocks
potentially incur an additional read I/O for every dnode in a dnode
block. As a worst case example, reading 32 dnodes from a 16k dnode block
and all of the spill blocks could issue 33 separate reads. Now suppose
those dnodes have size 1024 and therefore don't need spill blocks. Then
the worst case number of blocks read is reduced to from 33 to two--one
per dnode block. In practice spill blocks may tend to be co-located on
disk with the dnode blocks so the reduction in I/O would not be this
drastic. In a badly fragmented pool, however, the improvement could be
significant.
ZFS-on-Linux systems that make heavy use of extended attributes would
benefit from this feature. In particular, ZFS-on-Linux supports the
xattr=sa dataset property which allows file extended attribute data
to be stored in the dnode bonus buffer as an alternative to the
traditional directory-based format. Workloads such as SELinux and the
Lustre distributed filesystem often store enough xattr data to force
spill bocks when xattr=sa is in effect. Large dnodes may therefore
provide a performance benefit to such systems.
Other use cases that may benefit from this feature include files with
large ACLs and symbolic links with long target names. Furthermore,
this feature may be desirable on other platforms in case future
applications or features are developed that could make use of a
larger bonus buffer area.
Implementation
--------------
The size of a dnode may be a multiple of 512 bytes up to the size of
a dnode block (currently 16384 bytes). A dn_extra_slots field was
added to the current on-disk dnode_phys_t structure to describe the
size of the physical dnode on disk. The 8 bits for this field were
taken from the zero filled dn_pad2 field. The field represents how
many "extra" dnode_phys_t slots a dnode consumes in its dnode block.
This convention results in a value of 0 for 512 byte dnodes which
preserves on-disk format compatibility with older software.
Similarly, the in-memory dnode_t structure has a new dn_num_slots field
to represent the total number of dnode_phys_t slots consumed on disk.
Thus dn->dn_num_slots is 1 greater than the corresponding
dnp->dn_extra_slots. This difference in convention was adopted
because, unlike on-disk structures, backward compatibility is not a
concern for in-memory objects, so we used a more natural way to
represent size for a dnode_t.
The default size for newly created dnodes is determined by the value of
a new "dnodesize" dataset property. By default the property is set to
"legacy" which is compatible with older software. Setting the property
to "auto" will allow the filesystem to choose the most suitable dnode
size. Currently this just sets the default dnode size to 1k, but future
code improvements could dynamically choose a size based on observed
workload patterns. Dnodes of varying sizes can coexist within the same
dataset and even within the same dnode block. For example, to enable
automatically-sized dnodes, run
# zfs set dnodesize=auto tank/fish
The user can also specify literal values for the dnodesize property.
These are currently limited to powers of two from 1k to 16k. The
power-of-2 limitation is only for simplicity of the user interface.
Internally the implementation can handle any multiple of 512 up to 16k,
and consumers of the DMU API can specify any legal dnode value.
The size of a new dnode is determined at object allocation time and
stored as a new field in the znode in-memory structure. New DMU
interfaces are added to allow the consumer to specify the dnode size
that a newly allocated object should use. Existing interfaces are
unchanged to avoid having to update every call site and to preserve
compatibility with external consumers such as Lustre. The new
interfaces names are given below. The versions of these functions that
don't take a dnodesize parameter now just call the _dnsize() versions
with a dnodesize of 0, which means use the legacy dnode size.
New DMU interfaces:
dmu_object_alloc_dnsize()
dmu_object_claim_dnsize()
dmu_object_reclaim_dnsize()
New ZAP interfaces:
zap_create_dnsize()
zap_create_norm_dnsize()
zap_create_flags_dnsize()
zap_create_claim_norm_dnsize()
zap_create_link_dnsize()
The constant DN_MAX_BONUSLEN is renamed to DN_OLD_MAX_BONUSLEN. The
spa_maxdnodesize() function should be used to determine the maximum
bonus length for a pool.
These are a few noteworthy changes to key functions:
* The prototype for dnode_hold_impl() now takes a "slots" parameter.
When the DNODE_MUST_BE_FREE flag is set, this parameter is used to
ensure the hole at the specified object offset is large enough to
hold the dnode being created. The slots parameter is also used
to ensure a dnode does not span multiple dnode blocks. In both of
these cases, if a failure occurs, ENOSPC is returned. Keep in mind,
these failure cases are only possible when using DNODE_MUST_BE_FREE.
If the DNODE_MUST_BE_ALLOCATED flag is set, "slots" must be 0.
dnode_hold_impl() will check if the requested dnode is already
consumed as an extra dnode slot by an large dnode, in which case
it returns ENOENT.
* The function dmu_object_alloc() advances to the next dnode block
if dnode_hold_impl() returns an error for a requested object.
This is because the beginning of the next dnode block is the only
location it can safely assume to either be a hole or a valid
starting point for a dnode.
* dnode_next_offset_level() and other functions that iterate
through dnode blocks may no longer use a simple array indexing
scheme. These now use the current dnode's dn_num_slots field to
advance to the next dnode in the block. This is to ensure we
properly skip the current dnode's bonus area and don't interpret it
as a valid dnode.
zdb
---
The zdb command was updated to display a dnode's size under the
"dnsize" column when the object is dumped.
For ZIL create log records, zdb will now display the slot count for
the object.
ztest
-----
Ztest chooses a random dnodesize for every newly created object. The
random distribution is more heavily weighted toward small dnodes to
better simulate real-world datasets.
Unused bonus buffer space is filled with non-zero values computed from
the object number, dataset id, offset, and generation number. This
helps ensure that the dnode traversal code properly skips the interior
regions of large dnodes, and that these interior regions are not
overwritten by data belonging to other dnodes. A new test visits each
object in a dataset. It verifies that the actual dnode size matches what
was stored in the ztest block tag when it was created. It also verifies
that the unused bonus buffer space is filled with the expected data
patterns.
ZFS Test Suite
--------------
Added six new large dnode-specific tests, and integrated the dnodesize
property into existing tests for zfs allow and send/recv.
Send/Receive
------------
ZFS send streams for datasets containing large dnodes cannot be received
on pools that don't support the large_dnode feature. A send stream with
large dnodes sets a DMU_BACKUP_FEATURE_LARGE_DNODE flag which will be
unrecognized by an incompatible receiving pool so that the zfs receive
will fail gracefully.
While not implemented here, it may be possible to generate a
backward-compatible send stream from a dataset containing large
dnodes. The implementation may be tricky, however, because the send
object record for a large dnode would need to be resized to a 512
byte dnode, possibly kicking in a spill block in the process. This
means we would need to construct a new SA layout and possibly
register it in the SA layout object. The SA layout is normally just
sent as an ordinary object record. But if we are constructing new
layouts while generating the send stream we'd have to build the SA
layout object dynamically and send it at the end of the stream.
For sending and receiving between pools that do support large dnodes,
the drr_object send record type is extended with a new field to store
the dnode slot count. This field was repurposed from unused padding
in the structure.
ZIL Replay
----------
The dnode slot count is stored in the uppermost 8 bits of the lr_foid
field. The bits were unused as the object id is currently capped at
48 bits.
Resizing Dnodes
---------------
It should be possible to resize a dnode when it is dirtied if the
current dnodesize dataset property differs from the dnode's size, but
this functionality is not currently implemented. Clearly a dnode can
only grow if there are sufficient contiguous unused slots in the
dnode block, but it should always be possible to shrink a dnode.
Growing dnodes may be useful to reduce fragmentation in a pool with
many spill blocks in use. Shrinking dnodes may be useful to allow
sending a dataset to a pool that doesn't support the large_dnode
feature.
Feature Reference Counting
--------------------------
The reference count for the large_dnode pool feature tracks the
number of datasets that have ever contained a dnode of size larger
than 512 bytes. The first time a large dnode is created in a dataset
the dataset is converted to an extensible dataset. This is a one-way
operation and the only way to decrement the feature count is to
destroy the dataset, even if the dataset no longer contains any large
dnodes. The complexity of reference counting on a per-dnode basis was
too high, so we chose to track it on a per-dataset basis similarly to
the large_block feature.
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3542
2016-03-17 01:25:34 +00:00
|
|
|
uint8_t drr_dn_slots;
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
uint8_t drr_flags;
|
|
|
|
uint32_t drr_raw_bonuslen;
|
2010-05-28 20:45:14 +00:00
|
|
|
uint64_t drr_toguid;
|
2017-11-08 19:12:59 +00:00
|
|
|
/* only (possibly) nonzero for raw streams */
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
uint8_t drr_indblkshift;
|
|
|
|
uint8_t drr_nlevels;
|
|
|
|
uint8_t drr_nblkptr;
|
2017-11-08 19:12:59 +00:00
|
|
|
uint8_t drr_pad[5];
|
|
|
|
uint64_t drr_maxblkid;
|
2008-11-20 20:01:55 +00:00
|
|
|
/* bonus content follows */
|
|
|
|
} drr_object;
|
|
|
|
struct drr_freeobjects {
|
|
|
|
uint64_t drr_firstobj;
|
|
|
|
uint64_t drr_numobjs;
|
2010-05-28 20:45:14 +00:00
|
|
|
uint64_t drr_toguid;
|
2008-11-20 20:01:55 +00:00
|
|
|
} drr_freeobjects;
|
|
|
|
struct drr_write {
|
|
|
|
uint64_t drr_object;
|
|
|
|
dmu_object_type_t drr_type;
|
|
|
|
uint32_t drr_pad;
|
|
|
|
uint64_t drr_offset;
|
2016-07-11 17:45:52 +00:00
|
|
|
uint64_t drr_logical_size;
|
2010-05-28 20:45:14 +00:00
|
|
|
uint64_t drr_toguid;
|
|
|
|
uint8_t drr_checksumtype;
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
uint8_t drr_flags;
|
2016-07-11 17:45:52 +00:00
|
|
|
uint8_t drr_compressiontype;
|
|
|
|
uint8_t drr_pad2[5];
|
|
|
|
/* deduplication key */
|
|
|
|
ddt_key_t drr_key;
|
|
|
|
/* only nonzero if drr_compressiontype is not 0 */
|
|
|
|
uint64_t drr_compressed_size;
|
2017-08-23 23:54:24 +00:00
|
|
|
/* only nonzero for raw streams */
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
uint8_t drr_salt[ZIO_DATA_SALT_LEN];
|
|
|
|
uint8_t drr_iv[ZIO_DATA_IV_LEN];
|
|
|
|
uint8_t drr_mac[ZIO_DATA_MAC_LEN];
|
2008-11-20 20:01:55 +00:00
|
|
|
/* content follows */
|
|
|
|
} drr_write;
|
|
|
|
struct drr_free {
|
|
|
|
uint64_t drr_object;
|
|
|
|
uint64_t drr_offset;
|
|
|
|
uint64_t drr_length;
|
2010-05-28 20:45:14 +00:00
|
|
|
uint64_t drr_toguid;
|
2008-11-20 20:01:55 +00:00
|
|
|
} drr_free;
|
2010-05-28 20:45:14 +00:00
|
|
|
struct drr_write_byref {
|
|
|
|
/* where to put the data */
|
|
|
|
uint64_t drr_object;
|
|
|
|
uint64_t drr_offset;
|
|
|
|
uint64_t drr_length;
|
|
|
|
uint64_t drr_toguid;
|
|
|
|
/* where to find the prior copy of the data */
|
|
|
|
uint64_t drr_refguid;
|
|
|
|
uint64_t drr_refobject;
|
|
|
|
uint64_t drr_refoffset;
|
|
|
|
/* properties of the data */
|
|
|
|
uint8_t drr_checksumtype;
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
uint8_t drr_flags;
|
2010-05-28 20:45:14 +00:00
|
|
|
uint8_t drr_pad2[6];
|
|
|
|
ddt_key_t drr_key; /* deduplication key */
|
|
|
|
} drr_write_byref;
|
|
|
|
struct drr_spill {
|
|
|
|
uint64_t drr_object;
|
|
|
|
uint64_t drr_length;
|
|
|
|
uint64_t drr_toguid;
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
uint8_t drr_flags;
|
|
|
|
uint8_t drr_compressiontype;
|
|
|
|
uint8_t drr_pad[6];
|
2017-08-23 23:54:24 +00:00
|
|
|
/* only nonzero for raw streams */
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
uint64_t drr_compressed_size;
|
|
|
|
uint8_t drr_salt[ZIO_DATA_SALT_LEN];
|
|
|
|
uint8_t drr_iv[ZIO_DATA_IV_LEN];
|
|
|
|
uint8_t drr_mac[ZIO_DATA_MAC_LEN];
|
|
|
|
dmu_object_type_t drr_type;
|
2010-05-28 20:45:14 +00:00
|
|
|
/* spill data follows */
|
|
|
|
} drr_spill;
|
2014-06-05 21:19:08 +00:00
|
|
|
struct drr_write_embedded {
|
|
|
|
uint64_t drr_object;
|
|
|
|
uint64_t drr_offset;
|
|
|
|
/* logical length, should equal blocksize */
|
|
|
|
uint64_t drr_length;
|
|
|
|
uint64_t drr_toguid;
|
|
|
|
uint8_t drr_compression;
|
|
|
|
uint8_t drr_etype;
|
|
|
|
uint8_t drr_pad[6];
|
|
|
|
uint32_t drr_lsize; /* uncompressed size of payload */
|
|
|
|
uint32_t drr_psize; /* compr. (real) size of payload */
|
|
|
|
/* (possibly compressed) content follows */
|
|
|
|
} drr_write_embedded;
|
Native Encryption for ZFS on Linux
This change incorporates three major pieces:
The first change is a keystore that manages wrapping
and encryption keys for encrypted datasets. These
commands mostly involve manipulating the new
DSL Crypto Key ZAP Objects that live in the MOS. Each
encrypted dataset has its own DSL Crypto Key that is
protected with a user's key. This level of indirection
allows users to change their keys without re-encrypting
their entire datasets. The change implements the new
subcommands "zfs load-key", "zfs unload-key" and
"zfs change-key" which allow the user to manage their
encryption keys and settings. In addition, several new
flags and properties have been added to allow dataset
creation and to make mounting and unmounting more
convenient.
The second piece of this patch provides the ability to
encrypt, decyrpt, and authenticate protected datasets.
Each object set maintains a Merkel tree of Message
Authentication Codes that protect the lower layers,
similarly to how checksums are maintained. This part
impacts the zio layer, which handles the actual
encryption and generation of MACs, as well as the ARC
and DMU, which need to be able to handle encrypted
buffers and protected data.
The last addition is the ability to do raw, encrypted
sends and receives. The idea here is to send raw
encrypted and compressed data and receive it exactly
as is on a backup system. This means that the dataset
on the receiving system is protected using the same
user key that is in use on the sending side. By doing
so, datasets can be efficiently backed up to an
untrusted system without fear of data being
compromised.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #494
Closes #5769
2017-08-14 17:36:48 +00:00
|
|
|
struct drr_object_range {
|
|
|
|
uint64_t drr_firstobj;
|
|
|
|
uint64_t drr_numslots;
|
|
|
|
uint64_t drr_toguid;
|
|
|
|
uint8_t drr_salt[ZIO_DATA_SALT_LEN];
|
|
|
|
uint8_t drr_iv[ZIO_DATA_IV_LEN];
|
|
|
|
uint8_t drr_mac[ZIO_DATA_MAC_LEN];
|
|
|
|
uint8_t drr_flags;
|
|
|
|
uint8_t drr_pad[3];
|
|
|
|
} drr_object_range;
|
Implement Redacted Send/Receive
Redacted send/receive allows users to send subsets of their data to
a target system. One possible use case for this feature is to not
transmit sensitive information to a data warehousing, test/dev, or
analytics environment. Another is to save space by not replicating
unimportant data within a given dataset, for example in backup tools
like zrepl.
Redacted send/receive is a three-stage process. First, a clone (or
clones) is made of the snapshot to be sent to the target. In this
clone (or clones), all unnecessary or unwanted data is removed or
modified. This clone is then snapshotted to create the "redaction
snapshot" (or snapshots). Second, the new zfs redact command is used
to create a redaction bookmark. The redaction bookmark stores the
list of blocks in a snapshot that were modified by the redaction
snapshot(s). Finally, the redaction bookmark is passed as a parameter
to zfs send. When sending to the snapshot that was redacted, the
redaction bookmark is used to filter out blocks that contain sensitive
or unwanted information, and those blocks are not included in the send
stream. When sending from the redaction bookmark, the blocks it
contains are considered as candidate blocks in addition to those
blocks in the destination snapshot that were modified since the
creation_txg of the redaction bookmark. This step is necessary to
allow the target to rehydrate data in the case where some blocks are
accidentally or unnecessarily modified in the redaction snapshot.
The changes to bookmarks to enable fast space estimation involve
adding deadlists to bookmarks. There is also logic to manage the
life cycles of these deadlists.
The new size estimation process operates in cases where previously
an accurate estimate could not be provided. In those cases, a send
is performed where no data blocks are read, reducing the runtime
significantly and providing a byte-accurate size estimate.
Reviewed-by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed-by: Matt Ahrens <mahrens@delphix.com>
Reviewed-by: Prashanth Sreenivasa <pks@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: Chris Williamson <chris.williamson@delphix.com>
Reviewed-by: Pavel Zhakarov <pavel.zakharov@delphix.com>
Reviewed-by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #7958
2019-06-19 16:48:13 +00:00
|
|
|
struct drr_redact {
|
|
|
|
uint64_t drr_object;
|
|
|
|
uint64_t drr_offset;
|
|
|
|
uint64_t drr_length;
|
|
|
|
uint64_t drr_toguid;
|
|
|
|
} drr_redact;
|
2015-07-06 03:20:31 +00:00
|
|
|
|
|
|
|
/*
|
2020-06-10 04:24:09 +00:00
|
|
|
* Note: drr_checksum is overlaid with all record types
|
2015-07-06 03:20:31 +00:00
|
|
|
* except DRR_BEGIN. Therefore its (non-pad) members
|
|
|
|
* must not overlap with members from the other structs.
|
|
|
|
* We accomplish this by putting its members at the very
|
|
|
|
* end of the struct.
|
|
|
|
*/
|
|
|
|
struct drr_checksum {
|
|
|
|
uint64_t drr_pad[34];
|
|
|
|
/*
|
|
|
|
* fletcher-4 checksum of everything preceding the
|
|
|
|
* checksum.
|
|
|
|
*/
|
|
|
|
zio_cksum_t drr_checksum;
|
|
|
|
} drr_checksum;
|
2008-11-20 20:01:55 +00:00
|
|
|
} drr_u;
|
|
|
|
} dmu_replay_record_t;
|
|
|
|
|
2010-08-26 21:24:34 +00:00
|
|
|
/* diff record range types */
|
|
|
|
typedef enum diff_type {
|
|
|
|
DDR_NONE = 0x1,
|
|
|
|
DDR_INUSE = 0x2,
|
|
|
|
DDR_FREE = 0x4
|
|
|
|
} diff_type_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The diff reports back ranges of free or in-use objects.
|
|
|
|
*/
|
|
|
|
typedef struct dmu_diff_record {
|
|
|
|
uint64_t ddr_type;
|
|
|
|
uint64_t ddr_first;
|
|
|
|
uint64_t ddr_last;
|
|
|
|
} dmu_diff_record_t;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef struct zinject_record {
|
|
|
|
uint64_t zi_objset;
|
|
|
|
uint64_t zi_object;
|
|
|
|
uint64_t zi_start;
|
|
|
|
uint64_t zi_end;
|
|
|
|
uint64_t zi_guid;
|
|
|
|
uint32_t zi_level;
|
|
|
|
uint32_t zi_error;
|
|
|
|
uint64_t zi_type;
|
|
|
|
uint32_t zi_freq;
|
2009-07-02 22:44:48 +00:00
|
|
|
uint32_t zi_failfast;
|
2010-05-28 20:45:14 +00:00
|
|
|
char zi_func[MAXNAMELEN];
|
|
|
|
uint32_t zi_iotype;
|
|
|
|
int32_t zi_duration;
|
|
|
|
uint64_t zi_timer;
|
2016-05-23 17:41:29 +00:00
|
|
|
uint64_t zi_nlanes;
|
2013-04-29 22:49:23 +00:00
|
|
|
uint32_t zi_cmd;
|
2019-03-15 21:14:31 +00:00
|
|
|
uint32_t zi_dvas;
|
2008-11-20 20:01:55 +00:00
|
|
|
} zinject_record_t;
|
|
|
|
|
|
|
|
#define ZINJECT_NULL 0x1
|
|
|
|
#define ZINJECT_FLUSH_ARC 0x2
|
|
|
|
#define ZINJECT_UNLOAD_SPA 0x4
|
2018-11-05 19:22:33 +00:00
|
|
|
#define ZINJECT_CALC_RANGE 0x8
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2014-02-12 18:30:18 +00:00
|
|
|
#define ZEVENT_NONE 0x0
|
2010-08-26 18:42:43 +00:00
|
|
|
#define ZEVENT_NONBLOCK 0x1
|
|
|
|
#define ZEVENT_SIZE 1024
|
|
|
|
|
2013-11-22 22:52:16 +00:00
|
|
|
#define ZEVENT_SEEK_START 0
|
|
|
|
#define ZEVENT_SEEK_END UINT64_MAX
|
|
|
|
|
2017-06-17 00:21:11 +00:00
|
|
|
/* scaled frequency ranges */
|
|
|
|
#define ZI_PERCENTAGE_MIN 4294UL
|
|
|
|
#define ZI_PERCENTAGE_MAX UINT32_MAX
|
|
|
|
|
2019-03-15 21:14:31 +00:00
|
|
|
#define ZI_NO_DVA (-1)
|
|
|
|
|
2013-04-29 22:49:23 +00:00
|
|
|
typedef enum zinject_type {
|
|
|
|
ZINJECT_UNINITIALIZED,
|
|
|
|
ZINJECT_DATA_FAULT,
|
|
|
|
ZINJECT_DEVICE_FAULT,
|
|
|
|
ZINJECT_LABEL_FAULT,
|
|
|
|
ZINJECT_IGNORED_WRITES,
|
|
|
|
ZINJECT_PANIC,
|
|
|
|
ZINJECT_DELAY_IO,
|
2018-05-02 22:36:20 +00:00
|
|
|
ZINJECT_DECRYPT_FAULT,
|
2013-04-29 22:49:23 +00:00
|
|
|
} zinject_type_t;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef struct zfs_share {
|
|
|
|
uint64_t z_exportdata;
|
|
|
|
uint64_t z_sharedata;
|
|
|
|
uint64_t z_sharetype; /* 0 = share, 1 = unshare */
|
|
|
|
uint64_t z_sharemax; /* max length of share string */
|
|
|
|
} zfs_share_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ZFS file systems may behave the usual, POSIX-compliant way, where
|
|
|
|
* name lookups are case-sensitive. They may also be set up so that
|
|
|
|
* all the name lookups are case-insensitive, or so that only some
|
|
|
|
* lookups, the ones that set an FIGNORECASE flag, are case-insensitive.
|
|
|
|
*/
|
|
|
|
typedef enum zfs_case {
|
|
|
|
ZFS_CASE_SENSITIVE,
|
|
|
|
ZFS_CASE_INSENSITIVE,
|
|
|
|
ZFS_CASE_MIXED
|
|
|
|
} zfs_case_t;
|
|
|
|
|
2016-01-06 21:22:48 +00:00
|
|
|
/*
|
|
|
|
* Note: this struct must have the same layout in 32-bit and 64-bit, so
|
|
|
|
* that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit
|
|
|
|
* kernel. Therefore, we add padding to it so that no "hidden" padding
|
|
|
|
* is automatically added on 64-bit (but not on 32-bit).
|
|
|
|
*/
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef struct zfs_cmd {
|
2013-08-28 11:45:09 +00:00
|
|
|
char zc_name[MAXPATHLEN]; /* name of pool or dataset */
|
|
|
|
uint64_t zc_nvlist_src; /* really (char *) */
|
|
|
|
uint64_t zc_nvlist_src_size;
|
|
|
|
uint64_t zc_nvlist_dst; /* really (char *) */
|
|
|
|
uint64_t zc_nvlist_dst_size;
|
|
|
|
boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
|
|
|
|
int zc_pad2;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following members are for legacy ioctls which haven't been
|
|
|
|
* converted to the new method.
|
|
|
|
*/
|
|
|
|
uint64_t zc_history; /* really (char *) */
|
2008-11-20 20:01:55 +00:00
|
|
|
char zc_value[MAXPATHLEN * 2];
|
|
|
|
char zc_string[MAXNAMELEN];
|
|
|
|
uint64_t zc_guid;
|
|
|
|
uint64_t zc_nvlist_conf; /* really (char *) */
|
|
|
|
uint64_t zc_nvlist_conf_size;
|
|
|
|
uint64_t zc_cookie;
|
|
|
|
uint64_t zc_objset_type;
|
|
|
|
uint64_t zc_perm_action;
|
2013-08-28 11:45:09 +00:00
|
|
|
uint64_t zc_history_len;
|
2008-11-20 20:01:55 +00:00
|
|
|
uint64_t zc_history_offset;
|
|
|
|
uint64_t zc_obj;
|
2009-07-02 22:44:48 +00:00
|
|
|
uint64_t zc_iflags; /* internal to zfs(7fs) */
|
2008-11-20 20:01:55 +00:00
|
|
|
zfs_share_t zc_share;
|
|
|
|
dmu_objset_stats_t zc_objset_stats;
|
2016-06-10 00:04:12 +00:00
|
|
|
struct drr_begin zc_begin_record;
|
2008-11-20 20:01:55 +00:00
|
|
|
zinject_record_t zc_inject_record;
|
2014-06-05 21:19:08 +00:00
|
|
|
uint32_t zc_defer_destroy;
|
|
|
|
uint32_t zc_flags;
|
2010-08-26 21:24:34 +00:00
|
|
|
uint64_t zc_action_handle;
|
|
|
|
int zc_cleanup_fd;
|
2012-05-29 17:50:50 +00:00
|
|
|
uint8_t zc_simple;
|
2016-06-10 00:04:12 +00:00
|
|
|
uint8_t zc_pad[3]; /* alignment */
|
2010-08-26 21:24:34 +00:00
|
|
|
uint64_t zc_sendobj;
|
|
|
|
uint64_t zc_fromobj;
|
|
|
|
uint64_t zc_createtxg;
|
|
|
|
zfs_stat_t zc_stat;
|
2019-11-30 23:35:54 +00:00
|
|
|
uint64_t zc_zoneid;
|
2008-11-20 20:01:55 +00:00
|
|
|
} zfs_cmd_t;
|
|
|
|
|
2009-07-02 22:44:48 +00:00
|
|
|
typedef struct zfs_useracct {
|
|
|
|
char zu_domain[256];
|
|
|
|
uid_t zu_rid;
|
|
|
|
uint32_t zu_pad;
|
|
|
|
uint64_t zu_space;
|
|
|
|
} zfs_useracct_t;
|
|
|
|
|
2010-08-26 21:24:34 +00:00
|
|
|
#define ZFSDEV_MAX_MINOR (1 << 16)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
#define ZPOOL_EXPORT_AFTER_SPLIT 0x1
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#ifdef _KERNEL
|
2018-02-08 16:16:23 +00:00
|
|
|
struct objset;
|
|
|
|
struct zfsvfs;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
typedef struct zfs_creat {
|
|
|
|
nvlist_t *zct_zplprops;
|
|
|
|
nvlist_t *zct_props;
|
|
|
|
} zfs_creat_t;
|
|
|
|
|
2018-02-08 16:16:23 +00:00
|
|
|
extern int zfs_secpolicy_snapshot_perms(const char *, cred_t *);
|
|
|
|
extern int zfs_secpolicy_rename_perms(const char *, const char *, cred_t *);
|
|
|
|
extern int zfs_secpolicy_destroy_perms(const char *, cred_t *);
|
2018-02-08 16:32:45 +00:00
|
|
|
extern void zfs_unmount_snap(const char *);
|
2013-09-04 12:00:57 +00:00
|
|
|
extern void zfs_destroy_unmount_origin(const char *);
|
2018-02-08 16:16:23 +00:00
|
|
|
extern int getzfsvfs_impl(struct objset *, struct zfsvfs **);
|
2018-02-08 16:32:45 +00:00
|
|
|
extern int getzfsvfs(const char *, struct zfsvfs **);
|
2013-12-06 22:20:22 +00:00
|
|
|
|
2010-08-26 18:44:39 +00:00
|
|
|
enum zfsdev_state_type {
|
|
|
|
ZST_ONEXIT,
|
|
|
|
ZST_ZEVENT,
|
|
|
|
ZST_ALL,
|
2010-08-26 21:24:34 +00:00
|
|
|
};
|
|
|
|
|
2014-05-08 14:51:01 +00:00
|
|
|
/*
|
|
|
|
* The zfsdev_state_t structure is managed as a singly-linked list
|
|
|
|
* from which items are never deleted. This allows for lock-free
|
|
|
|
* reading of the list so long as assignments to the zs_next and
|
|
|
|
* reads from zs_minor are performed atomically. Empty items are
|
|
|
|
* indicated by storing -1 into zs_minor.
|
|
|
|
*/
|
2010-08-26 18:44:39 +00:00
|
|
|
typedef struct zfsdev_state {
|
2014-05-08 14:51:01 +00:00
|
|
|
struct zfsdev_state *zs_next; /* next zfsdev_state_t link */
|
2010-08-26 18:44:39 +00:00
|
|
|
minor_t zs_minor; /* made up minor number */
|
|
|
|
void *zs_onexit; /* onexit data */
|
|
|
|
void *zs_zevent; /* zevent data */
|
|
|
|
} zfsdev_state_t;
|
2010-08-26 21:24:34 +00:00
|
|
|
|
2010-08-26 18:44:39 +00:00
|
|
|
extern void *zfsdev_get_state(minor_t minor, enum zfsdev_state_type which);
|
2021-07-11 01:00:37 +00:00
|
|
|
extern int zfsdev_getminor(zfs_file_t *fp, minor_t *minorp);
|
2010-08-26 21:24:34 +00:00
|
|
|
|
2019-09-27 17:46:28 +00:00
|
|
|
extern uint_t zfs_allow_log_key;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#endif /* _KERNEL */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SYS_ZFS_IOCTL_H */
|