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-05-28 20:45:14 +00:00
|
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2024-03-29 19:15:56 +00:00
|
|
|
* Copyright (c) 2011, 2024 by Delphix. All rights reserved.
|
2011-11-11 22:07:54 +00:00
|
|
|
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
2015-04-02 03:44:32 +00:00
|
|
|
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
2016-06-15 22:47:05 +00:00
|
|
|
* Copyright 2013 Saso Kiselkov. All rights reserved.
|
2017-05-30 18:39:17 +00:00
|
|
|
* Copyright (c) 2014 Integros [integros.com]
|
|
|
|
* Copyright 2017 Joyent, Inc.
|
2018-09-06 01:33:36 +00:00
|
|
|
* Copyright (c) 2017, Intel Corporation.
|
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
|
|
|
* Copyright (c) 2019, Allan Jude
|
|
|
|
* Copyright (c) 2019, Klara Inc.
|
2022-07-28 22:52:46 +00:00
|
|
|
* Copyright (c) 2019, Datto Inc.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_SPA_H
|
|
|
|
#define _SYS_SPA_H
|
|
|
|
|
|
|
|
#include <sys/zfs_context.h>
|
2024-07-17 20:54:11 +00:00
|
|
|
#include <sys/avl.h>
|
2014-12-03 19:56:32 +00:00
|
|
|
#include <sys/kstat.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
#include <sys/nvpair.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/fs/zfs.h>
|
2015-12-09 23:34:16 +00:00
|
|
|
#include <sys/spa_checksum.h>
|
2016-06-13 02:47:35 +00:00
|
|
|
#include <sys/dmu.h>
|
Log Spacemap Project
= Motivation
At Delphix we've seen a lot of customer systems where fragmentation
is over 75% and random writes take a performance hit because a lot
of time is spend on I/Os that update on-disk space accounting metadata.
Specifically, we seen cases where 20% to 40% of sync time is spend
after sync pass 1 and ~30% of the I/Os on the system is spent updating
spacemaps.
The problem is that these pools have existed long enough that we've
touched almost every metaslab at least once, and random writes
scatter frees across all metaslabs every TXG, thus appending to
their spacemaps and resulting in many I/Os. To give an example,
assuming that every VDEV has 200 metaslabs and our writes fit within
a single spacemap block (generally 4K) we have 200 I/Os. Then if we
assume 2 levels of indirection, we need 400 additional I/Os and
since we are talking about metadata for which we keep 2 extra copies
for redundancy we need to triple that number, leading to a total of
1800 I/Os per VDEV every TXG.
We could try and decrease the number of metaslabs so we have less
I/Os per TXG but then each metaslab would cover a wider range on
disk and thus would take more time to be loaded in memory from disk.
In addition, after it's loaded, it's range tree would consume more
memory.
Another idea would be to just increase the spacemap block size
which would allow us to fit more entries within an I/O block
resulting in fewer I/Os per metaslab and a speedup in loading time.
The problem is still that we don't deal with the number of I/Os
going up as the number of metaslabs is increasing and the fact
is that we generally write a lot to a few metaslabs and a little
to the rest of them. Thus, just increasing the block size would
actually waste bandwidth because we won't be utilizing our bigger
block size.
= About this patch
This patch introduces the Log Spacemap project which provides the
solution to the above problem while taking into account all the
aforementioned tradeoffs. The details on how it achieves that can
be found in the references sections below and in the code (see
Big Theory Statement in spa_log_spacemap.c).
Even though the change is fairly constraint within the metaslab
and lower-level SPA codepaths, there is a side-change that is
user-facing. The change is that VDEV IDs from VDEV holes will no
longer be reused. To give some background and reasoning for this,
when a log device is removed and its VDEV structure was replaced
with a hole (or was compacted; if at the end of the vdev array),
its vdev_id could be reused by devices added after that. Now
with the pool-wide space maps recording the vdev ID, this behavior
can cause problems (e.g. is this entry referring to a segment in
the new vdev or the removed log?). Thus, to simplify things the
ID reuse behavior is gone and now vdev IDs for top-level vdevs
are truly unique within a pool.
= Testing
The illumos implementation of this feature has been used internally
for a year and has been in production for ~6 months. For this patch
specifically there don't seem to be any regressions introduced to
ZTS and I have been running zloop for a week without any related
problems.
= Performance Analysis (Linux Specific)
All performance results and analysis for illumos can be found in
the links of the references. Redoing the same experiments in Linux
gave similar results. Below are the specifics of the Linux run.
After the pool reached stable state the percentage of the time
spent in pass 1 per TXG was 64% on average for the stock bits
while the log spacemap bits stayed at 95% during the experiment
(graph: sdimitro.github.io/img/linux-lsm/PercOfSyncInPassOne.png).
Sync times per TXG were 37.6 seconds on average for the stock
bits and 22.7 seconds for the log spacemap bits (related graph:
sdimitro.github.io/img/linux-lsm/SyncTimePerTXG.png). As a result
the log spacemap bits were able to push more TXGs, which is also
the reason why all graphs quantified per TXG have more entries for
the log spacemap bits.
Another interesting aspect in terms of txg syncs is that the stock
bits had 22% of their TXGs reach sync pass 7, 55% reach sync pass 8,
and 20% reach 9. The log space map bits reached sync pass 4 in 79%
of their TXGs, sync pass 7 in 19%, and sync pass 8 at 1%. This
emphasizes the fact that not only we spend less time on metadata
but we also iterate less times to convergence in spa_sync() dirtying
objects.
[related graphs:
stock- sdimitro.github.io/img/linux-lsm/NumberOfPassesPerTXGStock.png
lsm- sdimitro.github.io/img/linux-lsm/NumberOfPassesPerTXGLSM.png]
Finally, the improvement in IOPs that the userland gains from the
change is approximately 40%. There is a consistent win in IOPS as
you can see from the graphs below but the absolute amount of
improvement that the log spacemap gives varies within each minute
interval.
sdimitro.github.io/img/linux-lsm/StockVsLog3Days.png
sdimitro.github.io/img/linux-lsm/StockVsLog10Hours.png
= Porting to Other Platforms
For people that want to port this commit to other platforms below
is a list of ZoL commits that this patch depends on:
Make zdb results for checkpoint tests consistent
db587941c5ff6dea01932bb78f70db63cf7f38ba
Update vdev_is_spacemap_addressable() for new spacemap encoding
419ba5914552c6185afbe1dd17b3ed4b0d526547
Simplify spa_sync by breaking it up to smaller functions
8dc2197b7b1e4d7ebc1420ea30e51c6541f1d834
Factor metaslab_load_wait() in metaslab_load()
b194fab0fb6caad18711abccaff3c69ad8b3f6d3
Rename range_tree_verify to range_tree_verify_not_present
df72b8bebe0ebac0b20e0750984bad182cb6564a
Change target size of metaslabs from 256GB to 16GB
c853f382db731e15a87512f4ef1101d14d778a55
zdb -L should skip leak detection altogether
21e7cf5da89f55ce98ec1115726b150e19eefe89
vs_alloc can underflow in L2ARC vdevs
7558997d2f808368867ca7e5234e5793446e8f3f
Simplify log vdev removal code
6c926f426a26ffb6d7d8e563e33fc176164175cb
Get rid of space_map_update() for ms_synced_length
425d3237ee88abc53d8522a7139c926d278b4b7f
Introduce auxiliary metaslab histograms
928e8ad47d3478a3d5d01f0dd6ae74a9371af65e
Error path in metaslab_load_impl() forgets to drop ms_sync_lock
8eef997679ba54547f7d361553d21b3291f41ae7
= References
Background, Motivation, and Internals of the Feature
- OpenZFS 2017 Presentation:
youtu.be/jj2IxRkl5bQ
- Slides:
slideshare.net/SerapheimNikolaosDim/zfs-log-spacemaps-project
Flushing Algorithm Internals & Performance Results
(Illumos Specific)
- Blogpost:
sdimitro.github.io/post/zfs-lsm-flushing/
- OpenZFS 2018 Presentation:
youtu.be/x6D2dHRjkxw
- Slides:
slideshare.net/SerapheimNikolaosDim/zfs-log-spacemap-flushing-algorithm
Upstream Delphix Issues:
DLPX-51539, DLPX-59659, DLPX-57783, DLPX-61438, DLPX-41227, DLPX-59320
DLPX-63385
Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #8442
2019-07-16 17:11:49 +00:00
|
|
|
#include <sys/space_map.h>
|
Reduce loaded range tree memory usage
This patch implements a new tree structure for ZFS, and uses it to
store range trees more efficiently.
The new structure is approximately a B-tree, though there are some
small differences from the usual characterizations. The tree has core
nodes and leaf nodes; each contain data elements, which the elements
in the core nodes acting as separators between its children. The
difference between core and leaf nodes is that the core nodes have an
array of children, while leaf nodes don't. Every node in the tree may
be only partially full; in most cases, they are all at least 50% full
(in terms of element count) except for the root node, which can be
less full. Underfull nodes will steal from their neighbors or merge to
remain full enough, while overfull nodes will split in two. The data
elements are contained in tree-controlled buffers; they are copied
into these on insertion, and overwritten on deletion. This means that
the elements are not independently allocated, which reduces overhead,
but also means they can't be shared between trees (and also that
pointers to them are only valid until a side-effectful tree operation
occurs). The overhead varies based on how dense the tree is, but is
usually on the order of about 50% of the element size; the per-node
overheads are very small, and so don't make a significant difference.
The trees can accept arbitrary records; they accept a size and a
comparator to allow them to be used for a variety of purposes.
The new trees replace the AVL trees used in the range trees today.
Currently, the range_seg_t structure contains three 8 byte integers
of payload and two 24 byte avl_tree_node_ts to handle its storage in
both an offset-sorted tree and a size-sorted tree (total size: 64
bytes). In the new model, the range seg structures are usually two 4
byte integers, but a separate one needs to exist for the size-sorted
and offset-sorted tree. Between the raw size, the 50% overhead, and
the double storage, the new btrees are expected to use 8*1.5*2 = 24
bytes per record, or 33.3% as much memory as the AVL trees (this is
for the purposes of storing metaslab range trees; for other purposes,
like scrubs, they use ~50% as much memory).
We reduced the size of the payload in the range segments by teaching
range trees about starting offsets and shifts; since metaslabs have a
fixed starting offset, and they all operate in terms of disk sectors,
we can store the ranges using 4-byte integers as long as the size of
the metaslab divided by the sector size is less than 2^32. For 512-byte
sectors, this is a 2^41 (or 2TB) metaslab, which with the default
settings corresponds to a 256PB disk. 4k sector disks can handle
metaslabs up to 2^46 bytes, or 2^63 byte disks. Since we do not
anticipate disks of this size in the near future, there should be
almost no cases where metaslabs need 64-byte integers to store their
ranges. We do still have the capability to store 64-byte integer ranges
to account for cases where we are storing per-vdev (or per-dnode) trees,
which could reasonably go above the limits discussed. We also do not
store fill information in the compact version of the node, since it
is only used for sorted scrub.
We also optimized the metaslab loading process in various other ways
to offset some inefficiencies in the btree model. While individual
operations (find, insert, remove_from) are faster for the btree than
they are for the avl tree, remove usually requires a find operation,
while in the AVL tree model the element itself suffices. Some clever
changes actually caused an overall speedup in metaslab loading; we use
approximately 40% less cpu to load metaslabs in our tests on Illumos.
Another memory and performance optimization was achieved by changing
what is stored in the size-sorted trees. When a disk is heavily
fragmented, the df algorithm used by default in ZFS will almost always
find a number of small regions in its initial cursor-based search; it
will usually only fall back to the size-sorted tree to find larger
regions. If we increase the size of the cursor-based search slightly,
and don't store segments that are smaller than a tunable size floor
in the size-sorted tree, we can further cut memory usage down to
below 20% of what the AVL trees store. This also results in further
reductions in CPU time spent loading metaslabs.
The 16KiB size floor was chosen because it results in substantial memory
usage reduction while not usually resulting in situations where we can't
find an appropriate chunk with the cursor and are forced to use an
oversized chunk from the size-sorted tree. In addition, even if we do
have to use an oversized chunk from the size-sorted tree, the chunk
would be too small to use for ZIL allocations, so it isn't as big of a
loss as it might otherwise be. And often, more small allocations will
follow the initial one, and the cursor search will now find the
remainder of the chunk we didn't use all of and use it for subsequent
allocations. Practical testing has shown little or no change in
fragmentation as a result of this change.
If the size-sorted tree becomes empty while the offset sorted one still
has entries, it will load all the entries from the offset sorted tree
and disregard the size floor until it is unloaded again. This operation
occurs rarely with the default setting, only on incredibly thoroughly
fragmented pools.
There are some other small changes to zdb to teach it to handle btrees,
but nothing major.
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed by: Sebastien Roy seb@delphix.com
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #9181
2019-10-09 17:36:03 +00:00
|
|
|
#include <sys/bitops.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Forward references that lots of things need.
|
|
|
|
*/
|
|
|
|
typedef struct spa spa_t;
|
|
|
|
typedef struct vdev vdev_t;
|
|
|
|
typedef struct metaslab metaslab_t;
|
2010-05-28 20:45:14 +00:00
|
|
|
typedef struct metaslab_group metaslab_group_t;
|
|
|
|
typedef struct metaslab_class metaslab_class_t;
|
|
|
|
typedef struct zio zio_t;
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef struct zilog zilog_t;
|
|
|
|
typedef struct spa_aux_vdev spa_aux_vdev_t;
|
2014-06-25 18:37:59 +00:00
|
|
|
typedef struct zbookmark_phys zbookmark_phys_t;
|
2023-03-28 23:51:58 +00:00
|
|
|
typedef struct zbookmark_err_phys zbookmark_err_phys_t;
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
|
2019-07-26 17:54:14 +00:00
|
|
|
struct bpobj;
|
|
|
|
struct bplist;
|
2008-11-20 20:01:55 +00:00
|
|
|
struct dsl_pool;
|
2013-08-28 11:45:09 +00:00
|
|
|
struct dsl_dataset;
|
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 dsl_crypto_params;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2017-03-29 00:21:11 +00:00
|
|
|
/*
|
|
|
|
* Alignment Shift (ashift) is an immutable, internal top-level vdev property
|
|
|
|
* which can only be set at vdev creation time. Physical writes are always done
|
|
|
|
* according to it, which makes 2^ashift the smallest possible IO on a vdev.
|
|
|
|
*
|
2017-05-03 16:31:05 +00:00
|
|
|
* We currently allow values ranging from 512 bytes (2^9 = 512) to 64 KiB
|
|
|
|
* (2^16 = 65,536).
|
2017-03-29 00:21:11 +00:00
|
|
|
*/
|
|
|
|
#define ASHIFT_MIN 9
|
2017-05-03 16:31:05 +00:00
|
|
|
#define ASHIFT_MAX 16
|
2017-03-29 00:21:11 +00:00
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
/*
|
|
|
|
* Size of block to hold the configuration data (a packed nvlist)
|
|
|
|
*/
|
2012-12-13 23:24:15 +00:00
|
|
|
#define SPA_CONFIG_BLOCKSIZE (1ULL << 14)
|
2008-12-03 20:09:06 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
|
|
|
|
* The ASIZE encoding should be at least 64 times larger (6 more bits)
|
|
|
|
* to support up to 4-way RAID-Z mirror mode with worst-case gang block
|
|
|
|
* overhead, three DVAs per bp, plus one more bit in case we do anything
|
|
|
|
* else that expands the ASIZE.
|
|
|
|
*/
|
|
|
|
#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */
|
|
|
|
#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */
|
|
|
|
#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */
|
|
|
|
|
2016-06-02 04:04:53 +00:00
|
|
|
#define SPA_COMPRESSBITS 7
|
2017-08-04 16:30:49 +00:00
|
|
|
#define SPA_VDEVBITS 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 SPA_COMPRESSMASK ((1U << SPA_COMPRESSBITS) - 1)
|
2016-06-02 04:04:53 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* All SPA data is represented by 128-bit data virtual addresses (DVAs).
|
|
|
|
* The members of the dva_t should be considered opaque outside the SPA.
|
|
|
|
*/
|
|
|
|
typedef struct dva {
|
|
|
|
uint64_t dva_word[2];
|
|
|
|
} dva_t;
|
|
|
|
|
|
|
|
|
2016-06-15 22:47:05 +00:00
|
|
|
/*
|
|
|
|
* Some checksums/hashes need a 256-bit initialization salt. This salt is kept
|
|
|
|
* secret and is suitable for use in MAC algorithms as the key.
|
|
|
|
*/
|
|
|
|
typedef struct zio_cksum_salt {
|
|
|
|
uint8_t zcs_bytes[32];
|
|
|
|
} zio_cksum_salt_t;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* Each block is described by its DVAs, time of birth, checksum, etc.
|
|
|
|
* The word-by-word, bit-by-bit layout of the blkptr is as follows:
|
|
|
|
*
|
|
|
|
* 64 56 48 40 32 24 16 8 0
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2024-03-25 22:01:54 +00:00
|
|
|
* 0 | pad | vdev1 | pad | ASIZE |
|
2008-11-20 20:01:55 +00:00
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 1 |G| offset1 |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2024-03-25 22:01:54 +00:00
|
|
|
* 2 | pad | vdev2 | pad | ASIZE |
|
2008-11-20 20:01:55 +00:00
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 3 |G| offset2 |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2024-03-25 22:01:54 +00:00
|
|
|
* 4 | pad | vdev3 | pad | ASIZE |
|
2008-11-20 20:01:55 +00:00
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 5 |G| offset3 |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2014-06-05 21:19:08 +00:00
|
|
|
* 6 |BDX|lvl| type | cksum |E| comp| PSIZE | LSIZE |
|
2008-11-20 20:01:55 +00:00
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 7 | padding |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 8 | padding |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2010-05-28 20:45:14 +00:00
|
|
|
* 9 | physical birth txg |
|
2008-11-20 20:01:55 +00:00
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2010-05-28 20:45:14 +00:00
|
|
|
* a | logical birth txg |
|
2008-11-20 20:01:55 +00:00
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* b | fill count |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* c | checksum[0] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* d | checksum[1] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* e | checksum[2] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* f | checksum[3] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
*
|
|
|
|
* Legend:
|
|
|
|
*
|
|
|
|
* vdev virtual device ID
|
|
|
|
* offset offset into virtual device
|
|
|
|
* LSIZE logical size
|
|
|
|
* PSIZE physical size (after compression)
|
|
|
|
* ASIZE allocated size (including RAID-Z parity and gang block headers)
|
|
|
|
* cksum checksum function
|
|
|
|
* comp compression function
|
|
|
|
* G gang block indicator
|
2010-05-28 20:45:14 +00:00
|
|
|
* B byteorder (endianness)
|
|
|
|
* D 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
|
|
|
* X encryption
|
2014-06-05 21:19:08 +00:00
|
|
|
* E blkptr_t contains embedded data (see below)
|
2008-11-20 20:01:55 +00:00
|
|
|
* lvl level of indirection
|
2010-05-28 20:45:14 +00:00
|
|
|
* type DMU object type
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
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.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
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: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 16:30:13 +00:00
|
|
|
* phys birth txg when dva[0] was written; zero if same as logical birth txg
|
|
|
|
* note that typically all the dva's would be written in this
|
|
|
|
* txg, but they could be different if they were moved by
|
|
|
|
* device removal.
|
2010-05-28 20:45:14 +00:00
|
|
|
* log. birth transaction group in which the block was logically born
|
2008-11-20 20:01:55 +00:00
|
|
|
* fill count number of non-zero blocks under this bp
|
|
|
|
* checksum[4] 256-bit checksum of the data this bp describes
|
|
|
|
*/
|
2014-06-05 21:19:08 +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
|
|
|
/*
|
|
|
|
* The blkptr_t's of encrypted blocks also need to store the encryption
|
|
|
|
* parameters so that the block can be decrypted. This layout is as follows:
|
|
|
|
*
|
|
|
|
* 64 56 48 40 32 24 16 8 0
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2024-03-25 22:01:54 +00:00
|
|
|
* 0 | vdev1 | pad | ASIZE |
|
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
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 1 |G| offset1 |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
2024-03-25 22:01:54 +00:00
|
|
|
* 2 | vdev2 | pad | ASIZE |
|
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
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 3 |G| offset2 |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 4 | salt |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 5 | IV1 |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 6 |BDX|lvl| type | cksum |E| comp| PSIZE | LSIZE |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 7 | padding |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 8 | padding |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 9 | physical birth txg |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* a | logical birth txg |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* b | IV2 | fill count |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* c | checksum[0] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* d | checksum[1] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* e | MAC[0] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* f | MAC[1] |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
*
|
|
|
|
* Legend:
|
|
|
|
*
|
|
|
|
* salt Salt for generating encryption keys
|
|
|
|
* IV1 First 64 bits of encryption IV
|
|
|
|
* X Block requires encryption handling (set to 1)
|
|
|
|
* E blkptr_t contains embedded data (set to 0, see below)
|
|
|
|
* fill count number of non-zero blocks under this bp (truncated to 32 bits)
|
|
|
|
* IV2 Last 32 bits of encryption IV
|
|
|
|
* checksum[2] 128-bit checksum of the data this bp describes
|
|
|
|
* MAC[2] 128-bit message authentication code for this data
|
|
|
|
*
|
|
|
|
* The X bit being set indicates that this block is one of 3 types. If this is
|
|
|
|
* a level 0 block with an encrypted object type, the block is encrypted
|
|
|
|
* (see BP_IS_ENCRYPTED()). If this is a level 0 block with an unencrypted
|
|
|
|
* object type, this block is authenticated with an HMAC (see
|
|
|
|
* BP_IS_AUTHENTICATED()). Otherwise (if level > 0), this bp will use the MAC
|
|
|
|
* words to store a checksum-of-MACs from the level below (see
|
|
|
|
* BP_HAS_INDIRECT_MAC_CKSUM()). For convenience in the code, BP_IS_PROTECTED()
|
|
|
|
* refers to both encrypted and authenticated blocks and BP_USES_CRYPT()
|
|
|
|
* refers to any of these 3 kinds of blocks.
|
|
|
|
*
|
|
|
|
* The additional encryption parameters are the salt, IV, and MAC which are
|
|
|
|
* explained in greater detail in the block comment at the top of zio_crypt.c.
|
|
|
|
* The MAC occupies half of the checksum space since it serves a very similar
|
|
|
|
* purpose: to prevent data corruption on disk. The only functional difference
|
|
|
|
* is that the checksum is used to detect on-disk corruption whether or not the
|
|
|
|
* encryption key is loaded and the MAC provides additional protection against
|
|
|
|
* malicious disk tampering. We use the 3rd DVA to store the salt and first
|
|
|
|
* 64 bits of the IV. As a result encrypted blocks can only have 2 copies
|
|
|
|
* maximum instead of the normal 3. The last 32 bits of the IV are stored in
|
|
|
|
* the upper bits of what is usually the fill count. Note that only blocks at
|
|
|
|
* level 0 or -2 are ever encrypted, which allows us to guarantee that these
|
|
|
|
* 32 bits are not trampled over by other code (see zio_crypt.c for details).
|
|
|
|
* The salt and IV are not used for authenticated bps or bps with an indirect
|
|
|
|
* MAC checksum, so these blocks can utilize all 3 DVAs and the full 64 bits
|
|
|
|
* for the fill count.
|
|
|
|
*/
|
|
|
|
|
2014-06-05 21:19:08 +00:00
|
|
|
/*
|
|
|
|
* "Embedded" blkptr_t's don't actually point to a block, instead they
|
|
|
|
* have a data payload embedded in the blkptr_t itself. See the comment
|
|
|
|
* in blkptr.c for more details.
|
|
|
|
*
|
|
|
|
* The blkptr_t is laid out as follows:
|
|
|
|
*
|
|
|
|
* 64 56 48 40 32 24 16 8 0
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 0 | payload |
|
|
|
|
* 1 | payload |
|
|
|
|
* 2 | payload |
|
|
|
|
* 3 | payload |
|
|
|
|
* 4 | payload |
|
|
|
|
* 5 | payload |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 6 |BDX|lvl| type | etype |E| comp| PSIZE| LSIZE |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* 7 | payload |
|
|
|
|
* 8 | payload |
|
|
|
|
* 9 | payload |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* a | logical birth txg |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
* b | payload |
|
|
|
|
* c | payload |
|
|
|
|
* d | payload |
|
|
|
|
* e | payload |
|
|
|
|
* f | payload |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
|
|
|
*
|
|
|
|
* Legend:
|
|
|
|
*
|
|
|
|
* payload contains the embedded data
|
|
|
|
* B (byteorder) byteorder (endianness)
|
|
|
|
* D (dedup) padding (set to zero)
|
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
|
|
|
* X encryption (set to zero)
|
2014-06-05 21:19:08 +00:00
|
|
|
* E (embedded) set to one
|
|
|
|
* lvl indirection level
|
|
|
|
* type DMU object type
|
|
|
|
* etype how to interpret embedded data (BP_EMBEDDED_TYPE_*)
|
|
|
|
* comp compression function of payload
|
|
|
|
* PSIZE size of payload after compression, in bytes
|
|
|
|
* LSIZE logical size of payload, in bytes
|
|
|
|
* note that 25 bits is enough to store the largest
|
|
|
|
* "normal" BP's LSIZE (2^16 * 2^9) in bytes
|
|
|
|
* log. birth transaction group in which the block was logically born
|
|
|
|
*
|
|
|
|
* Note that LSIZE and PSIZE are stored in bytes, whereas for non-embedded
|
|
|
|
* bp's they are stored in units of SPA_MINBLOCKSHIFT.
|
|
|
|
* Generally, the generic BP_GET_*() macros can be used on embedded BP's.
|
|
|
|
* The B, D, X, lvl, type, and comp fields are stored the same as with normal
|
|
|
|
* BP's so the BP_SET_* macros can be used with them. etype, PSIZE, LSIZE must
|
|
|
|
* be set with the BPE_SET_* macros. BP_SET_EMBEDDED() should be called before
|
|
|
|
* other macros, as they assert that they are only used on BP's of the correct
|
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
|
|
|
* "embedded-ness". Encrypted blkptr_t's cannot be embedded because they use
|
|
|
|
* the payload space for encryption parameters (see the comment above on
|
|
|
|
* how encryption parameters are stored).
|
2014-06-05 21:19:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define BPE_GET_ETYPE(bp) \
|
|
|
|
(ASSERT(BP_IS_EMBEDDED(bp)), \
|
|
|
|
BF64_GET((bp)->blk_prop, 40, 8))
|
|
|
|
#define BPE_SET_ETYPE(bp, t) do { \
|
|
|
|
ASSERT(BP_IS_EMBEDDED(bp)); \
|
|
|
|
BF64_SET((bp)->blk_prop, 40, 8, t); \
|
2021-06-05 14:02:41 +00:00
|
|
|
} while (0)
|
2014-06-05 21:19:08 +00:00
|
|
|
|
|
|
|
#define BPE_GET_LSIZE(bp) \
|
|
|
|
(ASSERT(BP_IS_EMBEDDED(bp)), \
|
|
|
|
BF64_GET_SB((bp)->blk_prop, 0, 25, 0, 1))
|
|
|
|
#define BPE_SET_LSIZE(bp, x) do { \
|
|
|
|
ASSERT(BP_IS_EMBEDDED(bp)); \
|
|
|
|
BF64_SET_SB((bp)->blk_prop, 0, 25, 0, 1, x); \
|
2021-06-05 14:02:41 +00:00
|
|
|
} while (0)
|
2014-06-05 21:19:08 +00:00
|
|
|
|
|
|
|
#define BPE_GET_PSIZE(bp) \
|
|
|
|
(ASSERT(BP_IS_EMBEDDED(bp)), \
|
|
|
|
BF64_GET_SB((bp)->blk_prop, 25, 7, 0, 1))
|
|
|
|
#define BPE_SET_PSIZE(bp, x) do { \
|
|
|
|
ASSERT(BP_IS_EMBEDDED(bp)); \
|
|
|
|
BF64_SET_SB((bp)->blk_prop, 25, 7, 0, 1, x); \
|
2021-06-05 14:02:41 +00:00
|
|
|
} while (0)
|
2014-06-05 21:19:08 +00:00
|
|
|
|
|
|
|
typedef enum bp_embedded_type {
|
|
|
|
BP_EMBEDDED_TYPE_DATA,
|
2019-06-25 01:02:17 +00:00
|
|
|
BP_EMBEDDED_TYPE_RESERVED, /* Reserved for Delphix byteswap feature. */
|
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
|
|
|
BP_EMBEDDED_TYPE_REDACTED,
|
2019-06-25 01:02:17 +00:00
|
|
|
NUM_BP_EMBEDDED_TYPES
|
2014-06-05 21:19:08 +00:00
|
|
|
} bp_embedded_type_t;
|
|
|
|
|
|
|
|
#define BPE_NUM_WORDS 14
|
|
|
|
#define BPE_PAYLOAD_SIZE (BPE_NUM_WORDS * sizeof (uint64_t))
|
|
|
|
#define BPE_IS_PAYLOADWORD(bp, wp) \
|
2024-03-25 22:01:54 +00:00
|
|
|
((wp) != &(bp)->blk_prop && (wp) != (&(bp)->blk_birth_word[1]))
|
2014-06-05 21:19:08 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */
|
|
|
|
#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */
|
OpenZFS 9075 - Improve ZFS pool import/load process and corrupted pool recovery
Some work has been done lately to improve the debugability of the ZFS pool
load (and import) process. This includes:
7638 Refactor spa_load_impl into several functions
8961 SPA load/import should tell us why it failed
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.
Porting notes (ZTS):
* Fix 'make dist' target in zpool_import
* The maximum path length allowed by tar is 99 characters. Several
of the new test cases exceeded this limit resulting in them not
being included in the tarball. Shorten the names slightly.
* Set/get tunables using accessor functions.
* Get last synced txg via the "zfs_txg_history" mechanism.
* Clear zinject handlers in cleanup for import_cache_device_replaced
and import_rewind_device_replaced in order that the zpool can be
exported if there is an error.
* Increase FILESIZE to 8G in zfs-test.sh to allow for a larger
ext4 file system to be created on ZFS_DISK2. Also, there's
no need to partition ZFS_DISK2 at all. The partitioning had
already been disabled for multipath devices. Among other things,
the partitioning steals some space from the ext4 file system,
makes it difficult to accurately calculate the paramters to
parted and can make some of the tests fail.
* Increase FS_SIZE and FILE_SIZE in the zpool_import test
configuration now that FILESIZE is larger.
* Write more data in order that device evacuation take lonnger in
a couple tests.
* Use mkdir -p to avoid errors when the directory already exists.
* Remove use of sudo in import_rewind_config_changed.
Authored by: Pavel Zakharov <pavel.zakharov@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: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://illumos.org/issues/9075
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/619c0123
Closes #7459
2016-07-22 14:39:36 +00:00
|
|
|
#define SPA_SYNC_MIN_VDEVS 3 /* min vdevs to update during sync */
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2013-12-09 18:37:51 +00:00
|
|
|
/*
|
|
|
|
* A block is a hole when it has either 1) never been written to, or
|
|
|
|
* 2) is zero-filled. In both cases, ZFS can return all zeroes for all reads
|
|
|
|
* without physically allocating disk space. Holes are represented in the
|
|
|
|
* blkptr_t structure by zeroed blk_dva. Correct checking for holes is
|
|
|
|
* done through the BP_IS_HOLE macro. For holes, the logical size, level,
|
|
|
|
* DMU object type, and birth times are all also stored for holes that
|
|
|
|
* were written to at some point (i.e. were punched after having been filled).
|
|
|
|
*/
|
2010-05-28 20:45:14 +00:00
|
|
|
typedef struct blkptr {
|
|
|
|
dva_t blk_dva[SPA_DVAS_PER_BP]; /* Data Virtual Addresses */
|
|
|
|
uint64_t blk_prop; /* size, compression, type, etc */
|
|
|
|
uint64_t blk_pad[2]; /* Extra space for the future */
|
2024-03-25 22:01:54 +00:00
|
|
|
uint64_t blk_birth_word[2];
|
2010-05-28 20:45:14 +00:00
|
|
|
uint64_t blk_fill; /* fill count */
|
|
|
|
zio_cksum_t blk_cksum; /* 256-bit checksum */
|
|
|
|
} blkptr_t;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* Macros to get and set fields in a bp or DVA.
|
|
|
|
*/
|
2021-03-26 18:19:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note, for gang blocks, DVA_GET_ASIZE() is the total space allocated for
|
|
|
|
* this gang DVA including its children BP's. The space allocated at this
|
|
|
|
* DVA's vdev/offset is vdev_gang_header_asize(vdev).
|
|
|
|
*/
|
2008-11-20 20:01:55 +00:00
|
|
|
#define DVA_GET_ASIZE(dva) \
|
2013-12-09 18:37:51 +00:00
|
|
|
BF64_GET_SB((dva)->dva_word[0], 0, SPA_ASIZEBITS, SPA_MINBLOCKSHIFT, 0)
|
2008-11-20 20:01:55 +00:00
|
|
|
#define DVA_SET_ASIZE(dva, x) \
|
2013-12-09 18:37:51 +00:00
|
|
|
BF64_SET_SB((dva)->dva_word[0], 0, SPA_ASIZEBITS, \
|
|
|
|
SPA_MINBLOCKSHIFT, 0, x)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2017-08-04 16:30:49 +00:00
|
|
|
#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, SPA_VDEVBITS)
|
|
|
|
#define DVA_SET_VDEV(dva, x) \
|
|
|
|
BF64_SET((dva)->dva_word[0], 32, SPA_VDEVBITS, x)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#define DVA_GET_OFFSET(dva) \
|
|
|
|
BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0)
|
|
|
|
#define DVA_SET_OFFSET(dva, x) \
|
|
|
|
BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x)
|
|
|
|
|
|
|
|
#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1)
|
|
|
|
#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x)
|
|
|
|
|
|
|
|
#define BP_GET_LSIZE(bp) \
|
2014-06-05 21:19:08 +00:00
|
|
|
(BP_IS_EMBEDDED(bp) ? \
|
|
|
|
(BPE_GET_ETYPE(bp) == BP_EMBEDDED_TYPE_DATA ? BPE_GET_LSIZE(bp) : 0): \
|
|
|
|
BF64_GET_SB((bp)->blk_prop, 0, SPA_LSIZEBITS, SPA_MINBLOCKSHIFT, 1))
|
|
|
|
#define BP_SET_LSIZE(bp, x) do { \
|
|
|
|
ASSERT(!BP_IS_EMBEDDED(bp)); \
|
|
|
|
BF64_SET_SB((bp)->blk_prop, \
|
|
|
|
0, SPA_LSIZEBITS, SPA_MINBLOCKSHIFT, 1, x); \
|
2021-06-05 14:02:41 +00:00
|
|
|
} while (0)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#define BP_GET_PSIZE(bp) \
|
2014-06-05 21:19:08 +00:00
|
|
|
(BP_IS_EMBEDDED(bp) ? 0 : \
|
|
|
|
BF64_GET_SB((bp)->blk_prop, 16, SPA_PSIZEBITS, SPA_MINBLOCKSHIFT, 1))
|
|
|
|
#define BP_SET_PSIZE(bp, x) do { \
|
|
|
|
ASSERT(!BP_IS_EMBEDDED(bp)); \
|
|
|
|
BF64_SET_SB((bp)->blk_prop, \
|
|
|
|
16, SPA_PSIZEBITS, SPA_MINBLOCKSHIFT, 1, x); \
|
2021-06-05 14:02:41 +00:00
|
|
|
} while (0)
|
2014-06-05 21:19:08 +00:00
|
|
|
|
2016-06-02 04:04:53 +00:00
|
|
|
#define BP_GET_COMPRESS(bp) \
|
|
|
|
BF64_GET((bp)->blk_prop, 32, SPA_COMPRESSBITS)
|
|
|
|
#define BP_SET_COMPRESS(bp, x) \
|
|
|
|
BF64_SET((bp)->blk_prop, 32, SPA_COMPRESSBITS, x)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2014-06-05 21:19:08 +00:00
|
|
|
#define BP_IS_EMBEDDED(bp) BF64_GET((bp)->blk_prop, 39, 1)
|
|
|
|
#define BP_SET_EMBEDDED(bp, x) BF64_SET((bp)->blk_prop, 39, 1, x)
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2014-06-05 21:19:08 +00:00
|
|
|
#define BP_GET_CHECKSUM(bp) \
|
|
|
|
(BP_IS_EMBEDDED(bp) ? ZIO_CHECKSUM_OFF : \
|
|
|
|
BF64_GET((bp)->blk_prop, 40, 8))
|
|
|
|
#define BP_SET_CHECKSUM(bp, x) do { \
|
|
|
|
ASSERT(!BP_IS_EMBEDDED(bp)); \
|
|
|
|
BF64_SET((bp)->blk_prop, 40, 8, x); \
|
2021-06-05 14:02:41 +00:00
|
|
|
} while (0)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8)
|
|
|
|
#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x)
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5)
|
|
|
|
#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x)
|
2008-11-20 20:01:55 +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
|
|
|
/* encrypted, authenticated, and MAC cksum bps use the same bit */
|
|
|
|
#define BP_USES_CRYPT(bp) BF64_GET((bp)->blk_prop, 61, 1)
|
|
|
|
#define BP_SET_CRYPT(bp, x) BF64_SET((bp)->blk_prop, 61, 1, x)
|
|
|
|
|
|
|
|
#define BP_IS_ENCRYPTED(bp) \
|
|
|
|
(BP_USES_CRYPT(bp) && \
|
|
|
|
BP_GET_LEVEL(bp) <= 0 && \
|
|
|
|
DMU_OT_IS_ENCRYPTED(BP_GET_TYPE(bp)))
|
|
|
|
|
|
|
|
#define BP_IS_AUTHENTICATED(bp) \
|
|
|
|
(BP_USES_CRYPT(bp) && \
|
|
|
|
BP_GET_LEVEL(bp) <= 0 && \
|
|
|
|
!DMU_OT_IS_ENCRYPTED(BP_GET_TYPE(bp)))
|
|
|
|
|
|
|
|
#define BP_HAS_INDIRECT_MAC_CKSUM(bp) \
|
|
|
|
(BP_USES_CRYPT(bp) && BP_GET_LEVEL(bp) > 0)
|
|
|
|
|
|
|
|
#define BP_IS_PROTECTED(bp) \
|
|
|
|
(BP_IS_ENCRYPTED(bp) || BP_IS_AUTHENTICATED(bp))
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
#define BP_GET_DEDUP(bp) BF64_GET((bp)->blk_prop, 62, 1)
|
|
|
|
#define BP_SET_DEDUP(bp, x) BF64_SET((bp)->blk_prop, 62, 1, x)
|
|
|
|
|
2013-12-09 18:37:51 +00:00
|
|
|
#define BP_GET_BYTEORDER(bp) BF64_GET((bp)->blk_prop, 63, 1)
|
2010-05-28 20:45:14 +00:00
|
|
|
#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x)
|
|
|
|
|
2019-07-26 17:54:14 +00:00
|
|
|
#define BP_GET_FREE(bp) BF64_GET((bp)->blk_fill, 0, 1)
|
|
|
|
#define BP_SET_FREE(bp, x) BF64_SET((bp)->blk_fill, 0, 1, x)
|
|
|
|
|
2024-03-25 22:01:54 +00:00
|
|
|
#define BP_GET_LOGICAL_BIRTH(bp) (bp)->blk_birth_word[1]
|
|
|
|
#define BP_SET_LOGICAL_BIRTH(bp, x) ((bp)->blk_birth_word[1] = (x))
|
|
|
|
|
|
|
|
#define BP_GET_PHYSICAL_BIRTH(bp) (bp)->blk_birth_word[0]
|
|
|
|
#define BP_SET_PHYSICAL_BIRTH(bp, x) ((bp)->blk_birth_word[0] = (x))
|
|
|
|
|
|
|
|
#define BP_GET_BIRTH(bp) \
|
|
|
|
(BP_IS_EMBEDDED(bp) ? 0 : \
|
|
|
|
BP_GET_PHYSICAL_BIRTH(bp) ? BP_GET_PHYSICAL_BIRTH(bp) : \
|
|
|
|
BP_GET_LOGICAL_BIRTH(bp))
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
#define BP_SET_BIRTH(bp, logical, physical) \
|
|
|
|
{ \
|
2014-06-05 21:19:08 +00:00
|
|
|
ASSERT(!BP_IS_EMBEDDED(bp)); \
|
2024-03-25 22:01:54 +00:00
|
|
|
BP_SET_LOGICAL_BIRTH(bp, logical); \
|
|
|
|
BP_SET_PHYSICAL_BIRTH(bp, \
|
|
|
|
((logical) == (physical) ? 0 : (physical))); \
|
2010-05-28 20:45:14 +00:00
|
|
|
}
|
2008-11-20 20:01:55 +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
|
|
|
#define BP_GET_FILL(bp) \
|
|
|
|
((BP_IS_ENCRYPTED(bp)) ? BF64_GET((bp)->blk_fill, 0, 32) : \
|
|
|
|
((BP_IS_EMBEDDED(bp)) ? 1 : (bp)->blk_fill))
|
|
|
|
|
|
|
|
#define BP_SET_FILL(bp, fill) \
|
|
|
|
{ \
|
|
|
|
if (BP_IS_ENCRYPTED(bp)) \
|
|
|
|
BF64_SET((bp)->blk_fill, 0, 32, fill); \
|
|
|
|
else \
|
|
|
|
(bp)->blk_fill = fill; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BP_GET_IV2(bp) \
|
|
|
|
(ASSERT(BP_IS_ENCRYPTED(bp)), \
|
|
|
|
BF64_GET((bp)->blk_fill, 32, 32))
|
|
|
|
#define BP_SET_IV2(bp, iv2) \
|
|
|
|
{ \
|
|
|
|
ASSERT(BP_IS_ENCRYPTED(bp)); \
|
|
|
|
BF64_SET((bp)->blk_fill, 32, 32, iv2); \
|
|
|
|
}
|
2014-06-05 21:19:08 +00:00
|
|
|
|
2016-07-22 15:52:49 +00:00
|
|
|
#define BP_IS_METADATA(bp) \
|
|
|
|
(BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#define BP_GET_ASIZE(bp) \
|
2014-06-05 21:19:08 +00:00
|
|
|
(BP_IS_EMBEDDED(bp) ? 0 : \
|
|
|
|
DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
|
|
|
|
DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
|
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
|
|
|
(DVA_GET_ASIZE(&(bp)->blk_dva[2]) * !BP_IS_ENCRYPTED(bp)))
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2016-07-22 15:52:49 +00:00
|
|
|
#define BP_GET_UCSIZE(bp) \
|
|
|
|
(BP_IS_METADATA(bp) ? BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp))
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#define BP_GET_NDVAS(bp) \
|
2014-06-05 21:19:08 +00:00
|
|
|
(BP_IS_EMBEDDED(bp) ? 0 : \
|
|
|
|
!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
|
2008-11-20 20:01:55 +00:00
|
|
|
!!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
|
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
|
|
|
(!!DVA_GET_ASIZE(&(bp)->blk_dva[2]) * !BP_IS_ENCRYPTED(bp)))
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#define BP_COUNT_GANG(bp) \
|
2014-06-05 21:19:08 +00:00
|
|
|
(BP_IS_EMBEDDED(bp) ? 0 : \
|
2008-11-20 20:01:55 +00:00
|
|
|
(DVA_GET_GANG(&(bp)->blk_dva[0]) + \
|
|
|
|
DVA_GET_GANG(&(bp)->blk_dva[1]) + \
|
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
|
|
|
(DVA_GET_GANG(&(bp)->blk_dva[2]) * !BP_IS_ENCRYPTED(bp))))
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#define DVA_EQUAL(dva1, dva2) \
|
|
|
|
((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
|
|
|
|
(dva1)->dva_word[0] == (dva2)->dva_word[0])
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
#define BP_EQUAL(bp1, bp2) \
|
2024-03-25 22:01:54 +00:00
|
|
|
(BP_GET_BIRTH(bp1) == BP_GET_BIRTH(bp2) && \
|
|
|
|
BP_GET_LOGICAL_BIRTH(bp1) == BP_GET_LOGICAL_BIRTH(bp2) && \
|
2010-05-28 20:45:14 +00:00
|
|
|
DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) && \
|
|
|
|
DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) && \
|
|
|
|
DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
|
|
|
|
|
2015-07-06 03:20:31 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0)
|
|
|
|
|
2014-06-05 21:19:08 +00:00
|
|
|
#define BP_IDENTITY(bp) (ASSERT(!BP_IS_EMBEDDED(bp)), &(bp)->blk_dva[0])
|
|
|
|
#define BP_IS_GANG(bp) \
|
|
|
|
(BP_IS_EMBEDDED(bp) ? B_FALSE : DVA_GET_GANG(BP_IDENTITY(bp)))
|
2013-12-09 18:37:51 +00:00
|
|
|
#define DVA_IS_EMPTY(dva) ((dva)->dva_word[0] == 0ULL && \
|
|
|
|
(dva)->dva_word[1] == 0ULL)
|
2014-06-05 21:19:08 +00:00
|
|
|
#define BP_IS_HOLE(bp) \
|
|
|
|
(!BP_IS_EMBEDDED(bp) && DVA_IS_EMPTY(BP_IDENTITY(bp)))
|
2010-05-28 20:45:14 +00:00
|
|
|
|
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 BP_SET_REDACTED(bp) \
|
|
|
|
{ \
|
|
|
|
BP_SET_EMBEDDED(bp, B_TRUE); \
|
|
|
|
BPE_SET_ETYPE(bp, BP_EMBEDDED_TYPE_REDACTED); \
|
|
|
|
}
|
|
|
|
#define BP_IS_REDACTED(bp) \
|
|
|
|
(BP_IS_EMBEDDED(bp) && BPE_GET_ETYPE(bp) == BP_EMBEDDED_TYPE_REDACTED)
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/* BP_IS_RAIDZ(bp) assumes no block compression */
|
|
|
|
#define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
|
|
|
|
BP_GET_PSIZE(bp))
|
2008-11-20 20:01:55 +00:00
|
|
|
|
ddt: add "flat phys" feature
Traditional dedup keeps a separate ddt_phys_t "type" for each possible
count of DVAs (that is, copies=) parameter. Each of these are tracked
independently of each other, and have their own set of DVAs. This leads
to an (admittedly rare) situation where you can create as many as six
copies of the data, by changing the copies= parameter between copying.
This is both a waste of storage on disk, but also a waste of space in
the stored DDT entries, since there never needs to be more than three
DVAs to handle all possible values of copies=.
This commit adds a new FDT feature, DDT_FLAG_FLAT. When active, only the
first ddt_phys_t is used. Each time a block is written with the dedup
bit set, this single phys is checked to see if it has enough DVAs to
fulfill the request. If it does, the block is filled with the saved DVAs
as normal. If not, an adjusted write is issued to create as many extra
copies as are needed to fulfill the request, which are then saved into
the entry too.
Because a single phys is no longer an all-or-nothing, but can be
transitioning from fewer to more DVAs, the write path now has to keep a
copy of the previous "known good" DVA set so we can revert to it in case
an error occurs. zio_ddt_write() has been restructured and heavily
commented to make it much easier to see what's happening.
Backwards compatibility is maintained simply by allocating four
ddt_phys_t when the DDT_FLAG_FLAT flag is not set, and updating the phys
selection macros to check the flag. In the old arrangement, each number
of copies gets a whole phys, so it will always have either zero or all
necessary DVAs filled, with no in-between, so the old behaviour
naturally falls out of the new code.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: iXsystems, Inc.
Closes #15893
2023-06-20 01:09:48 +00:00
|
|
|
#define BP_ZERO_DVAS(bp) \
|
2008-11-20 20:01:55 +00:00
|
|
|
{ \
|
|
|
|
(bp)->blk_dva[0].dva_word[0] = 0; \
|
|
|
|
(bp)->blk_dva[0].dva_word[1] = 0; \
|
|
|
|
(bp)->blk_dva[1].dva_word[0] = 0; \
|
|
|
|
(bp)->blk_dva[1].dva_word[1] = 0; \
|
|
|
|
(bp)->blk_dva[2].dva_word[0] = 0; \
|
|
|
|
(bp)->blk_dva[2].dva_word[1] = 0; \
|
ddt: add "flat phys" feature
Traditional dedup keeps a separate ddt_phys_t "type" for each possible
count of DVAs (that is, copies=) parameter. Each of these are tracked
independently of each other, and have their own set of DVAs. This leads
to an (admittedly rare) situation where you can create as many as six
copies of the data, by changing the copies= parameter between copying.
This is both a waste of storage on disk, but also a waste of space in
the stored DDT entries, since there never needs to be more than three
DVAs to handle all possible values of copies=.
This commit adds a new FDT feature, DDT_FLAG_FLAT. When active, only the
first ddt_phys_t is used. Each time a block is written with the dedup
bit set, this single phys is checked to see if it has enough DVAs to
fulfill the request. If it does, the block is filled with the saved DVAs
as normal. If not, an adjusted write is issued to create as many extra
copies as are needed to fulfill the request, which are then saved into
the entry too.
Because a single phys is no longer an all-or-nothing, but can be
transitioning from fewer to more DVAs, the write path now has to keep a
copy of the previous "known good" DVA set so we can revert to it in case
an error occurs. zio_ddt_write() has been restructured and heavily
commented to make it much easier to see what's happening.
Backwards compatibility is maintained simply by allocating four
ddt_phys_t when the DDT_FLAG_FLAT flag is not set, and updating the phys
selection macros to check the flag. In the old arrangement, each number
of copies gets a whole phys, so it will always have either zero or all
necessary DVAs filled, with no in-between, so the old behaviour
naturally falls out of the new code.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: iXsystems, Inc.
Closes #15893
2023-06-20 01:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define BP_ZERO(bp) \
|
|
|
|
{ \
|
|
|
|
BP_ZERO_DVAS(bp); \
|
2008-11-20 20:01:55 +00:00
|
|
|
(bp)->blk_prop = 0; \
|
|
|
|
(bp)->blk_pad[0] = 0; \
|
|
|
|
(bp)->blk_pad[1] = 0; \
|
2024-03-25 22:01:54 +00:00
|
|
|
(bp)->blk_birth_word[0] = 0; \
|
|
|
|
(bp)->blk_birth_word[1] = 0; \
|
2008-11-20 20:01:55 +00:00
|
|
|
(bp)->blk_fill = 0; \
|
|
|
|
ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \
|
|
|
|
}
|
|
|
|
|
2020-07-28 20:02:49 +00:00
|
|
|
#ifdef _ZFS_BIG_ENDIAN
|
2008-11-20 20:01:55 +00:00
|
|
|
#define ZFS_HOST_BYTEORDER (0ULL)
|
|
|
|
#else
|
2013-12-09 18:37:51 +00:00
|
|
|
#define ZFS_HOST_BYTEORDER (1ULL)
|
2008-11-20 20:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BP_SHOULD_BYTESWAP(bp) (BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER)
|
|
|
|
|
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 BP_SPRINTF_LEN 400
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/*
|
|
|
|
* This macro allows code sharing between zfs, libzpool, and mdb.
|
Introduce kmem_scnprintf()
`snprintf()` is meant to protect against buffer overflows, but operating
on the buffer using its return value, possibly by calling it again, can
cause a buffer overflow, because it will return how many characters it
would have written if it had enough space even when it did not. In a
number of places, we repeatedly call snprintf() by successively
incrementing a buffer offset and decrementing a buffer length, by its
return value. This is a potentially unsafe usage of `snprintf()`
whenever the buffer length is reached. CodeQL complained about this.
To fix this, we introduce `kmem_scnprintf()`, which will return 0 when
the buffer is zero or the number of written characters, minus 1 to
exclude the NULL character, when the buffer was too small. In all other
cases, it behaves like snprintf(). The name is inspired by the Linux and
XNU kernels' `scnprintf()`. The implementation was written before I
thought to look at `scnprintf()` and had a good name for it, but it
turned out to have identical semantics to the Linux kernel version.
That lead to the name, `kmem_scnprintf()`.
CodeQL only catches this issue in loops, so repeated use of snprintf()
outside of a loop was not caught. As a result, a thorough audit of the
codebase was done to examine all instances of `snprintf()` usage for
potential problems and a few were caught. Fixes for them are included in
this patch.
Unfortunately, ZED is one of the places where `snprintf()` is
potentially used incorrectly. Since using `kmem_scnprintf()` in it would
require changing how it is linked, we modify its usage to make it safe,
no matter what buffer length is used. In addition, there was a bug in
the use of the return value where the NULL format character was not
being written by pwrite(). That has been fixed.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14098
2022-10-27 18:16:04 +00:00
|
|
|
* 'func' is either kmem_scnprintf() or mdb_snprintf().
|
2010-05-28 20:45:14 +00:00
|
|
|
* 'ws' (whitespace) can be ' ' for single-line format, '\n' for multi-line.
|
|
|
|
*/
|
2019-07-26 17:54:14 +00:00
|
|
|
|
2018-04-06 20:30:26 +00:00
|
|
|
#define SNPRINTF_BLKPTR(func, ws, buf, size, bp, type, checksum, compress) \
|
2010-05-28 20:45:14 +00:00
|
|
|
{ \
|
2022-04-19 18:38:30 +00:00
|
|
|
static const char *const copyname[] = \
|
2010-05-28 20:45:14 +00:00
|
|
|
{ "zero", "single", "double", "triple" }; \
|
|
|
|
int len = 0; \
|
|
|
|
int copies = 0; \
|
2018-04-06 20:30:26 +00:00
|
|
|
const char *crypt_type; \
|
|
|
|
if (bp != NULL) { \
|
|
|
|
if (BP_IS_ENCRYPTED(bp)) { \
|
|
|
|
crypt_type = "encrypted"; \
|
|
|
|
/* LINTED E_SUSPICIOUS_COMPARISON */ \
|
|
|
|
} else if (BP_IS_AUTHENTICATED(bp)) { \
|
|
|
|
crypt_type = "authenticated"; \
|
|
|
|
} else if (BP_HAS_INDIRECT_MAC_CKSUM(bp)) { \
|
|
|
|
crypt_type = "indirect-MAC"; \
|
|
|
|
} else { \
|
|
|
|
crypt_type = "unencrypted"; \
|
|
|
|
} \
|
|
|
|
} \
|
2010-05-28 20:45:14 +00:00
|
|
|
if (bp == NULL) { \
|
2013-12-09 18:37:51 +00:00
|
|
|
len += func(buf + len, size - len, "<NULL>"); \
|
2010-05-28 20:45:14 +00:00
|
|
|
} else if (BP_IS_HOLE(bp)) { \
|
2015-03-27 02:03:22 +00:00
|
|
|
len += func(buf + len, size - len, \
|
|
|
|
"HOLE [L%llu %s] " \
|
|
|
|
"size=%llxL birth=%lluL", \
|
|
|
|
(u_longlong_t)BP_GET_LEVEL(bp), \
|
|
|
|
type, \
|
|
|
|
(u_longlong_t)BP_GET_LSIZE(bp), \
|
2024-03-25 22:01:54 +00:00
|
|
|
(u_longlong_t)BP_GET_LOGICAL_BIRTH(bp)); \
|
2014-06-05 21:19:08 +00:00
|
|
|
} else if (BP_IS_EMBEDDED(bp)) { \
|
|
|
|
len = func(buf + len, size - len, \
|
|
|
|
"EMBEDDED [L%llu %s] et=%u %s " \
|
|
|
|
"size=%llxL/%llxP birth=%lluL", \
|
|
|
|
(u_longlong_t)BP_GET_LEVEL(bp), \
|
|
|
|
type, \
|
|
|
|
(int)BPE_GET_ETYPE(bp), \
|
|
|
|
compress, \
|
|
|
|
(u_longlong_t)BPE_GET_LSIZE(bp), \
|
|
|
|
(u_longlong_t)BPE_GET_PSIZE(bp), \
|
2024-03-25 22:01:54 +00:00
|
|
|
(u_longlong_t)BP_GET_LOGICAL_BIRTH(bp)); \
|
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
|
|
|
} else if (BP_IS_REDACTED(bp)) { \
|
|
|
|
len += func(buf + len, size - len, \
|
|
|
|
"REDACTED [L%llu %s] size=%llxL birth=%lluL", \
|
|
|
|
(u_longlong_t)BP_GET_LEVEL(bp), \
|
|
|
|
type, \
|
|
|
|
(u_longlong_t)BP_GET_LSIZE(bp), \
|
2024-03-25 22:01:54 +00:00
|
|
|
(u_longlong_t)BP_GET_LOGICAL_BIRTH(bp)); \
|
2010-05-28 20:45:14 +00:00
|
|
|
} else { \
|
2017-11-04 20:25:13 +00:00
|
|
|
for (int d = 0; d < BP_GET_NDVAS(bp); d++) { \
|
2010-05-28 20:45:14 +00:00
|
|
|
const dva_t *dva = &bp->blk_dva[d]; \
|
|
|
|
if (DVA_IS_VALID(dva)) \
|
|
|
|
copies++; \
|
|
|
|
len += func(buf + len, size - len, \
|
|
|
|
"DVA[%d]=<%llu:%llx:%llx>%c", d, \
|
|
|
|
(u_longlong_t)DVA_GET_VDEV(dva), \
|
|
|
|
(u_longlong_t)DVA_GET_OFFSET(dva), \
|
|
|
|
(u_longlong_t)DVA_GET_ASIZE(dva), \
|
|
|
|
ws); \
|
|
|
|
} \
|
2023-03-04 02:15:28 +00:00
|
|
|
ASSERT3S(copies, >, 0); \
|
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
|
|
|
if (BP_IS_ENCRYPTED(bp)) { \
|
|
|
|
len += func(buf + len, size - len, \
|
|
|
|
"salt=%llx iv=%llx:%llx%c", \
|
|
|
|
(u_longlong_t)bp->blk_dva[2].dva_word[0], \
|
|
|
|
(u_longlong_t)bp->blk_dva[2].dva_word[1], \
|
|
|
|
(u_longlong_t)BP_GET_IV2(bp), \
|
|
|
|
ws); \
|
|
|
|
} \
|
2010-05-28 20:45:14 +00:00
|
|
|
if (BP_IS_GANG(bp) && \
|
|
|
|
DVA_GET_ASIZE(&bp->blk_dva[2]) <= \
|
|
|
|
DVA_GET_ASIZE(&bp->blk_dva[1]) / 2) \
|
|
|
|
copies--; \
|
|
|
|
len += func(buf + len, size - len, \
|
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
|
|
|
"[L%llu %s] %s %s %s %s %s %s %s%c" \
|
2010-05-28 20:45:14 +00:00
|
|
|
"size=%llxL/%llxP birth=%lluL/%lluP fill=%llu%c" \
|
2023-02-15 17:06:29 +00:00
|
|
|
"cksum=%016llx:%016llx:%016llx:%016llx", \
|
2010-05-28 20:45:14 +00:00
|
|
|
(u_longlong_t)BP_GET_LEVEL(bp), \
|
|
|
|
type, \
|
|
|
|
checksum, \
|
|
|
|
compress, \
|
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
|
|
|
crypt_type, \
|
2010-05-28 20:45:14 +00:00
|
|
|
BP_GET_BYTEORDER(bp) == 0 ? "BE" : "LE", \
|
|
|
|
BP_IS_GANG(bp) ? "gang" : "contiguous", \
|
|
|
|
BP_GET_DEDUP(bp) ? "dedup" : "unique", \
|
|
|
|
copyname[copies], \
|
|
|
|
ws, \
|
|
|
|
(u_longlong_t)BP_GET_LSIZE(bp), \
|
|
|
|
(u_longlong_t)BP_GET_PSIZE(bp), \
|
2024-03-25 22:01:54 +00:00
|
|
|
(u_longlong_t)BP_GET_LOGICAL_BIRTH(bp), \
|
|
|
|
(u_longlong_t)BP_GET_BIRTH(bp), \
|
2014-06-05 21:19:08 +00:00
|
|
|
(u_longlong_t)BP_GET_FILL(bp), \
|
2010-05-28 20:45:14 +00:00
|
|
|
ws, \
|
|
|
|
(u_longlong_t)bp->blk_cksum.zc_word[0], \
|
|
|
|
(u_longlong_t)bp->blk_cksum.zc_word[1], \
|
|
|
|
(u_longlong_t)bp->blk_cksum.zc_word[2], \
|
|
|
|
(u_longlong_t)bp->blk_cksum.zc_word[3]); \
|
|
|
|
} \
|
|
|
|
ASSERT(len < size); \
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#define BP_GET_BUFC_TYPE(bp) \
|
2016-07-22 15:52:49 +00:00
|
|
|
(BP_IS_METADATA(bp) ? ARC_BUFC_METADATA : ARC_BUFC_DATA)
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
typedef enum spa_import_type {
|
|
|
|
SPA_IMPORT_EXISTING,
|
|
|
|
SPA_IMPORT_ASSEMBLE
|
|
|
|
} spa_import_type_t;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2019-11-21 17:32:57 +00:00
|
|
|
typedef enum spa_mode {
|
|
|
|
SPA_MODE_UNINIT = 0,
|
|
|
|
SPA_MODE_READ = 1,
|
|
|
|
SPA_MODE_WRITE = 2,
|
|
|
|
} spa_mode_t;
|
|
|
|
|
2019-03-29 16:13:20 +00:00
|
|
|
/*
|
|
|
|
* Send TRIM commands in-line during normal pool operation while deleting.
|
|
|
|
* OFF: no
|
|
|
|
* ON: yes
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
SPA_AUTOTRIM_OFF = 0, /* default */
|
2020-08-18 16:52:30 +00:00
|
|
|
SPA_AUTOTRIM_ON,
|
2019-03-29 16:13:20 +00:00
|
|
|
} spa_autotrim_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reason TRIM command was issued, used internally for accounting purposes.
|
|
|
|
*/
|
|
|
|
typedef enum trim_type {
|
|
|
|
TRIM_TYPE_MANUAL = 0,
|
|
|
|
TRIM_TYPE_AUTO = 1,
|
2020-06-09 17:15:08 +00:00
|
|
|
TRIM_TYPE_SIMPLE = 2
|
2019-03-29 16:13:20 +00:00
|
|
|
} trim_type_t;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/* state manipulation functions */
|
2022-04-19 18:38:30 +00:00
|
|
|
extern int spa_open(const char *pool, spa_t **, const void *tag);
|
|
|
|
extern int spa_open_rewind(const char *pool, spa_t **, const void *tag,
|
2010-05-28 20:45:14 +00:00
|
|
|
nvlist_t *policy, nvlist_t **config);
|
2012-12-13 23:24:15 +00:00
|
|
|
extern int spa_get_stats(const char *pool, nvlist_t **config, char *altroot,
|
|
|
|
size_t buflen);
|
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
|
|
|
extern int spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
|
|
|
|
nvlist_t *zplprops, struct dsl_crypto_params *dcp);
|
2013-09-04 12:00:57 +00:00
|
|
|
extern int spa_import(char *pool, nvlist_t *config, nvlist_t *props,
|
2010-08-26 21:24:34 +00:00
|
|
|
uint64_t flags);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
|
2020-10-03 00:44:10 +00:00
|
|
|
extern int spa_destroy(const char *pool);
|
2016-12-16 22:11:29 +00:00
|
|
|
extern int spa_checkpoint(const char *pool);
|
|
|
|
extern int spa_checkpoint_discard(const char *pool);
|
2020-10-03 00:44:10 +00:00
|
|
|
extern int spa_export(const char *pool, nvlist_t **oldconfig, boolean_t force,
|
2009-01-15 21:59:39 +00:00
|
|
|
boolean_t hardforce);
|
2020-10-03 00:44:10 +00:00
|
|
|
extern int spa_reset(const char *pool);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_async_request(spa_t *spa, int flag);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern void spa_async_unrequest(spa_t *spa, int flag);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_async_suspend(spa_t *spa);
|
|
|
|
extern void spa_async_resume(spa_t *spa);
|
2019-11-27 18:15:01 +00:00
|
|
|
extern int spa_async_tasks(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern spa_t *spa_inject_addref(char *pool);
|
|
|
|
extern void spa_inject_delref(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern void spa_scan_stat_init(spa_t *spa);
|
|
|
|
extern int spa_scan_get_stats(spa_t *spa, pool_scan_stat_t *ps);
|
2019-07-26 17:54:14 +00:00
|
|
|
extern int bpobj_enqueue_alloc_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
|
|
|
|
extern int bpobj_enqueue_free_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2019-03-29 16:13:20 +00:00
|
|
|
#define SPA_ASYNC_CONFIG_UPDATE 0x01
|
|
|
|
#define SPA_ASYNC_REMOVE 0x02
|
2024-04-29 21:35:53 +00:00
|
|
|
#define SPA_ASYNC_FAULT_VDEV 0x04
|
2019-03-29 16:13:20 +00:00
|
|
|
#define SPA_ASYNC_RESILVER_DONE 0x08
|
|
|
|
#define SPA_ASYNC_RESILVER 0x10
|
|
|
|
#define SPA_ASYNC_AUTOEXPAND 0x20
|
|
|
|
#define SPA_ASYNC_REMOVE_DONE 0x40
|
|
|
|
#define SPA_ASYNC_REMOVE_STOP 0x80
|
|
|
|
#define SPA_ASYNC_INITIALIZE_RESTART 0x100
|
|
|
|
#define SPA_ASYNC_TRIM_RESTART 0x200
|
|
|
|
#define SPA_ASYNC_AUTOTRIM_RESTART 0x400
|
2020-04-10 17:33:35 +00:00
|
|
|
#define SPA_ASYNC_L2CACHE_REBUILD 0x800
|
2020-06-09 17:15:08 +00:00
|
|
|
#define SPA_ASYNC_L2CACHE_TRIM 0x1000
|
2020-07-03 18:05:50 +00:00
|
|
|
#define SPA_ASYNC_REBUILD_DONE 0x2000
|
2023-04-19 16:04:32 +00:00
|
|
|
#define SPA_ASYNC_DETACH_SPARE 0x4000
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* device manipulation */
|
2024-03-29 19:15:56 +00:00
|
|
|
extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot, boolean_t ashift_check);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot,
|
2020-07-03 18:05:50 +00:00
|
|
|
int replacing, int rebuild);
|
2009-01-15 21:59:39 +00:00
|
|
|
extern int spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid,
|
|
|
|
int replace_done);
|
2021-11-30 14:46:25 +00:00
|
|
|
extern int spa_vdev_alloc(spa_t *spa, uint64_t guid);
|
|
|
|
extern int spa_vdev_noalloc(spa_t *spa, uint64_t guid);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern boolean_t spa_vdev_remove_active(spa_t *spa);
|
2018-12-19 16:20:39 +00:00
|
|
|
extern int spa_vdev_initialize(spa_t *spa, nvlist_t *nv, uint64_t cmd_type,
|
|
|
|
nvlist_t *vdev_errlist);
|
2019-03-29 16:13:20 +00:00
|
|
|
extern int spa_vdev_trim(spa_t *spa, nvlist_t *nv, uint64_t cmd_type,
|
|
|
|
uint64_t rate, boolean_t partial, boolean_t secure, nvlist_t *vdev_errlist);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern int spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath);
|
2009-07-02 22:44:48 +00:00
|
|
|
extern int spa_vdev_setfru(spa_t *spa, uint64_t guid, const char *newfru);
|
2022-04-19 18:38:30 +00:00
|
|
|
extern int spa_vdev_split_mirror(spa_t *spa, const char *newname,
|
|
|
|
nvlist_t *config, nvlist_t *props, boolean_t exp);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* spare state (which is global across all pools) */
|
|
|
|
extern void spa_spare_add(vdev_t *vd);
|
|
|
|
extern void spa_spare_remove(vdev_t *vd);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern boolean_t spa_spare_exists(uint64_t guid, uint64_t *pool, int *refcnt);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_spare_activate(vdev_t *vd);
|
|
|
|
|
|
|
|
/* L2ARC state (which is global across all pools) */
|
|
|
|
extern void spa_l2cache_add(vdev_t *vd);
|
|
|
|
extern void spa_l2cache_remove(vdev_t *vd);
|
|
|
|
extern boolean_t spa_l2cache_exists(uint64_t guid, uint64_t *pool);
|
|
|
|
extern void spa_l2cache_activate(vdev_t *vd);
|
|
|
|
extern void spa_l2cache_drop(spa_t *spa);
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/* scanning */
|
|
|
|
extern int spa_scan(spa_t *spa, pool_scan_func_t func);
|
|
|
|
extern int spa_scan_stop(spa_t *spa);
|
2017-07-07 05:16:13 +00:00
|
|
|
extern int spa_scrub_pause_resume(spa_t *spa, pool_scrub_cmd_t flag);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* spa syncing */
|
|
|
|
extern void spa_sync(spa_t *spa, uint64_t txg); /* only for DMU use */
|
|
|
|
extern void spa_sync_allpools(void);
|
|
|
|
|
Cleanup: Specify unsignedness on things that should not be signed
In #13871, zfs_vdev_aggregation_limit_non_rotating and
zfs_vdev_aggregation_limit being signed was pointed out as a possible
reason not to eliminate an unnecessary MAX(unsigned, 0) since the
unsigned value was assigned from them.
There is no reason for these module parameters to be signed and upon
inspection, it was found that there are a number of other module
parameters that are signed, but should not be, so we make them unsigned.
Making them unsigned made it clear that some other variables in the code
should also be unsigned, so we also make those unsigned. This prevents
users from setting negative values that could potentially cause bad
behaviors. It also makes the code slightly easier to understand.
Mostly module parameters that deal with timeouts, limits, bitshifts and
percentages are made unsigned by this. Any that are boolean are left
signed, since whether booleans should be considered signed or unsigned
does not matter.
Making zfs_arc_lotsfree_percent unsigned caused a
`zfs_arc_lotsfree_percent >= 0` check to become redundant, so it was
removed. Removing the check was also necessary to prevent a compiler
error from -Werror=type-limits.
Several end of line comments had to be moved to their own lines because
replacing int with uint_t caused us to exceed the 80 character limit
enforced by cstyle.pl.
The following were kept signed because they are passed to
taskq_create(), which expects signed values and modifying the
OpenSolaris/Illumos DDI is out of scope of this patch:
* metaslab_load_pct
* zfs_sync_taskq_batch_pct
* zfs_zil_clean_taskq_nthr_pct
* zfs_zil_clean_taskq_minalloc
* zfs_zil_clean_taskq_maxalloc
* zfs_arc_prune_task_threads
Also, negative values in those parameters was found to be harmless.
The following were left signed because either negative values make
sense, or more analysis was needed to determine whether negative values
should be disallowed:
* zfs_metaslab_switch_threshold
* zfs_pd_bytes_max
* zfs_livelist_min_percent_shared
zfs_multihost_history was made static to be consistent with other
parameters.
A number of module parameters were marked as signed, but in reality
referenced unsigned variables. upgrade_errlog_limit is one of the
numerous examples. In the case of zfs_vdev_async_read_max_active, it was
already uint32_t, but zdb had an extern int declaration for it.
Interestingly, the documentation in zfs.4 was right for
upgrade_errlog_limit despite the module parameter being wrongly marked,
while the documentation for zfs_vdev_async_read_max_active (and friends)
was wrong. It was also wrong for zstd_abort_size, which was unsigned,
but was documented as signed.
Also, the documentation in zfs.4 incorrectly described the following
parameters as ulong when they were int:
* zfs_arc_meta_adjust_restarts
* zfs_override_estimate_recordsize
They are now uint_t as of this patch and thus the man page has been
updated to describe them as uint.
dbuf_state_index was left alone since it does nothing and perhaps should
be removed in another patch.
If any module parameters were missed, they were not found by `grep -r
'ZFS_MODULE_PARAM' | grep ', INT'`. I did find a few that grep missed,
but only because they were in files that had hits.
This patch intentionally did not attempt to address whether some of
these module parameters should be elevated to 64-bit parameters, because
the length of a long on 32-bit is 32-bit.
Lastly, it was pointed out during review that uint_t is a better match
for these variables than uint32_t because FreeBSD kernel parameter
definitions are designed for uint_t, whose bit width can change in
future memory models. As a result, we change the existing parameters
that are uint32_t to use uint_t.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13875
2022-09-27 23:42:41 +00:00
|
|
|
extern uint_t zfs_sync_pass_deferred_free;
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2023-11-06 18:38:42 +00:00
|
|
|
/* spa sync taskqueues */
|
|
|
|
taskq_t *spa_sync_tq_create(spa_t *spa, const char *name);
|
|
|
|
void spa_sync_tq_destroy(spa_t *spa);
|
2024-05-01 18:07:20 +00:00
|
|
|
uint_t spa_acq_allocator(spa_t *spa);
|
|
|
|
void spa_rel_allocator(spa_t *spa, uint_t allocator);
|
2023-11-06 18:38:42 +00:00
|
|
|
void spa_select_allocator(zio_t *zio);
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
/* spa namespace global mutex */
|
|
|
|
extern kmutex_t spa_namespace_lock;
|
2024-04-22 16:42:38 +00:00
|
|
|
extern avl_tree_t spa_namespace_avl;
|
|
|
|
extern kcondvar_t spa_namespace_cv;
|
2008-12-03 20:09:06 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* SPA configuration functions in spa_config.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SPA_CONFIG_UPDATE_POOL 0
|
|
|
|
#define SPA_CONFIG_UPDATE_VDEVS 1
|
|
|
|
|
2022-09-28 16:48:46 +00:00
|
|
|
extern void spa_write_cachefile(spa_t *, boolean_t, boolean_t, boolean_t);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_config_load(void);
|
2023-10-26 16:17:40 +00:00
|
|
|
extern int spa_all_configs(uint64_t *generation, nvlist_t **pools);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_config_set(spa_t *spa, nvlist_t *config);
|
|
|
|
extern nvlist_t *spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg,
|
|
|
|
int getstats);
|
|
|
|
extern void spa_config_update(spa_t *spa, int what);
|
2019-10-28 16:51:53 +00:00
|
|
|
extern int spa_config_parse(spa_t *spa, vdev_t **vdp, nvlist_t *nv,
|
|
|
|
vdev_t *parent, uint_t id, int atype);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Miscellaneous SPA routines in spa_misc.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Namespace manipulation */
|
|
|
|
extern spa_t *spa_lookup(const char *name);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern spa_t *spa_add(const char *name, nvlist_t *config, const char *altroot);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_remove(spa_t *spa);
|
|
|
|
extern spa_t *spa_next(spa_t *prev);
|
|
|
|
|
|
|
|
/* Refcount functions */
|
2022-04-19 18:38:30 +00:00
|
|
|
extern void spa_open_ref(spa_t *spa, const void *tag);
|
|
|
|
extern void spa_close(spa_t *spa, const void *tag);
|
|
|
|
extern void spa_async_close(spa_t *spa, const void *tag);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern boolean_t spa_refcount_zero(spa_t *spa);
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
#define SCL_NONE 0x00
|
2008-12-03 20:09:06 +00:00
|
|
|
#define SCL_CONFIG 0x01
|
|
|
|
#define SCL_STATE 0x02
|
|
|
|
#define SCL_L2ARC 0x04 /* hack until L2ARC 2.0 */
|
|
|
|
#define SCL_ALLOC 0x08
|
|
|
|
#define SCL_ZIO 0x10
|
|
|
|
#define SCL_FREE 0x20
|
|
|
|
#define SCL_VDEV 0x40
|
|
|
|
#define SCL_LOCKS 7
|
|
|
|
#define SCL_ALL ((1 << SCL_LOCKS) - 1)
|
|
|
|
#define SCL_STATE_ALL (SCL_STATE | SCL_L2ARC | SCL_ZIO)
|
|
|
|
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
/* Historical pool statistics */
|
2018-09-26 18:08:12 +00:00
|
|
|
typedef struct spa_history_kstat {
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
kmutex_t lock;
|
|
|
|
uint64_t count;
|
|
|
|
uint64_t size;
|
|
|
|
kstat_t *kstat;
|
2020-06-06 19:54:04 +00:00
|
|
|
void *priv;
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
list_t list;
|
2018-09-26 18:08:12 +00:00
|
|
|
} spa_history_kstat_t;
|
|
|
|
|
|
|
|
typedef struct spa_history_list {
|
|
|
|
uint64_t size;
|
|
|
|
procfs_list_t procfs_list;
|
|
|
|
} spa_history_list_t;
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
|
|
|
|
typedef struct spa_stats {
|
2018-09-26 18:08:12 +00:00
|
|
|
spa_history_list_t read_history;
|
|
|
|
spa_history_list_t txg_history;
|
|
|
|
spa_history_kstat_t tx_assign_histogram;
|
|
|
|
spa_history_list_t mmp_history;
|
|
|
|
spa_history_kstat_t state; /* pool state */
|
2022-05-18 17:25:33 +00:00
|
|
|
spa_history_kstat_t guid; /* pool guid */
|
2019-03-29 16:13:20 +00:00
|
|
|
spa_history_kstat_t iostats;
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
} spa_stats_t;
|
|
|
|
|
2013-10-01 16:50:50 +00:00
|
|
|
typedef enum txg_state {
|
|
|
|
TXG_STATE_BIRTH = 0,
|
|
|
|
TXG_STATE_OPEN = 1,
|
|
|
|
TXG_STATE_QUIESCED = 2,
|
2014-01-16 09:41:27 +00:00
|
|
|
TXG_STATE_WAIT_FOR_SYNC = 3,
|
|
|
|
TXG_STATE_SYNCED = 4,
|
|
|
|
TXG_STATE_COMMITTED = 5,
|
2013-10-01 16:50:50 +00:00
|
|
|
} txg_state_t;
|
|
|
|
|
2016-12-02 23:57:49 +00:00
|
|
|
typedef struct txg_stat {
|
|
|
|
vdev_stat_t vs1;
|
|
|
|
vdev_stat_t vs2;
|
|
|
|
uint64_t txg;
|
|
|
|
uint64_t ndirty;
|
|
|
|
} txg_stat_t;
|
|
|
|
|
2019-03-29 16:13:20 +00:00
|
|
|
/* Assorted pool IO kstats */
|
|
|
|
typedef struct spa_iostats {
|
|
|
|
kstat_named_t trim_extents_written;
|
|
|
|
kstat_named_t trim_bytes_written;
|
|
|
|
kstat_named_t trim_extents_skipped;
|
|
|
|
kstat_named_t trim_bytes_skipped;
|
|
|
|
kstat_named_t trim_extents_failed;
|
|
|
|
kstat_named_t trim_bytes_failed;
|
|
|
|
kstat_named_t autotrim_extents_written;
|
|
|
|
kstat_named_t autotrim_bytes_written;
|
|
|
|
kstat_named_t autotrim_extents_skipped;
|
|
|
|
kstat_named_t autotrim_bytes_skipped;
|
|
|
|
kstat_named_t autotrim_extents_failed;
|
|
|
|
kstat_named_t autotrim_bytes_failed;
|
2020-06-09 17:15:08 +00:00
|
|
|
kstat_named_t simple_trim_extents_written;
|
|
|
|
kstat_named_t simple_trim_bytes_written;
|
|
|
|
kstat_named_t simple_trim_extents_skipped;
|
|
|
|
kstat_named_t simple_trim_bytes_skipped;
|
|
|
|
kstat_named_t simple_trim_extents_failed;
|
|
|
|
kstat_named_t simple_trim_bytes_failed;
|
2019-03-29 16:13:20 +00:00
|
|
|
} spa_iostats_t;
|
|
|
|
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
extern void spa_stats_init(spa_t *spa);
|
|
|
|
extern void spa_stats_destroy(spa_t *spa);
|
2014-06-25 18:37:59 +00:00
|
|
|
extern void spa_read_history_add(spa_t *spa, const zbookmark_phys_t *zb,
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
uint32_t aflags);
|
2014-01-15 09:26:12 +00:00
|
|
|
extern void spa_txg_history_add(spa_t *spa, uint64_t txg, hrtime_t birth_time);
|
2013-10-01 16:50:50 +00:00
|
|
|
extern int spa_txg_history_set(spa_t *spa, uint64_t txg,
|
|
|
|
txg_state_t completed_state, hrtime_t completed_time);
|
2016-12-02 23:57:49 +00:00
|
|
|
extern txg_stat_t *spa_txg_history_init_io(spa_t *, uint64_t,
|
|
|
|
struct dsl_pool *);
|
|
|
|
extern void spa_txg_history_fini_io(spa_t *, txg_stat_t *);
|
2013-10-02 18:43:52 +00:00
|
|
|
extern void spa_tx_assign_add_nsecs(spa_t *spa, uint64_t nsecs);
|
2018-02-27 01:32:49 +00:00
|
|
|
extern int spa_mmp_history_set_skip(spa_t *spa, uint64_t mmp_kstat_id);
|
2018-02-22 23:34:34 +00:00
|
|
|
extern int spa_mmp_history_set(spa_t *spa, uint64_t mmp_kstat_id, int io_error,
|
|
|
|
hrtime_t duration);
|
2018-09-26 18:08:12 +00:00
|
|
|
extern void spa_mmp_history_add(spa_t *spa, uint64_t txg, uint64_t timestamp,
|
2018-02-27 01:32:49 +00:00
|
|
|
uint64_t mmp_delay, vdev_t *vd, int label, uint64_t mmp_kstat_id,
|
|
|
|
int error);
|
2019-03-29 16:13:20 +00:00
|
|
|
extern void spa_iostats_trim_add(spa_t *spa, trim_type_t type,
|
|
|
|
uint64_t extents_written, uint64_t bytes_written,
|
|
|
|
uint64_t extents_skipped, uint64_t bytes_skipped,
|
|
|
|
uint64_t extents_failed, uint64_t bytes_failed);
|
zpool import progress kstat
When an import requires a long MMP activity check, or when the user
requests pool recovery, the import make take a long time. The user may
not know why, or be able to tell whether the import is progressing or is
hung.
Add a kstat which lists all imports currently being processed by the
kernel (currently only one at a time is possible, but the kstat allows
for more than one). The kstat is /proc/spl/kstat/zfs/import_progress.
The kstat contents are as follows:
pool_guid load_state multihost_secs max_txg pool_name
16667015954387398 3 15 0 tank3
load_state: the value of spa_load_state
multihost_secs: seconds until the end of the multihost activity
check; if over, or none required, this is 0
max_txg: current spa_load_max_txg, if rewind is occurring
This could be used by outside tools, such as a pacemaker resource agent,
to report import progress, or as a part of manual troubleshooting. The
zpool import subcommand could also be modified to report this
information.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #8696
2019-05-09 17:08:05 +00:00
|
|
|
extern void spa_import_progress_add(spa_t *spa);
|
|
|
|
extern void spa_import_progress_remove(uint64_t spa_guid);
|
|
|
|
extern int spa_import_progress_set_mmp_check(uint64_t pool_guid,
|
|
|
|
uint64_t mmp_sec_remaining);
|
|
|
|
extern int spa_import_progress_set_max_txg(uint64_t pool_guid,
|
|
|
|
uint64_t max_txg);
|
|
|
|
extern int spa_import_progress_set_state(uint64_t pool_guid,
|
|
|
|
spa_load_state_t spa_load_state);
|
2023-12-05 22:27:56 +00:00
|
|
|
extern void spa_import_progress_set_notes(spa_t *spa,
|
|
|
|
const char *fmt, ...) __printflike(2, 3);
|
|
|
|
extern void spa_import_progress_set_notes_nolog(spa_t *spa,
|
|
|
|
const char *fmt, ...) __printflike(2, 3);
|
Add visibility in to arc_read
This change is an attempt to add visibility into the arc_read calls
occurring on a system, in real time. To do this, a list was added to the
in memory SPA data structure for a pool, with each element on the list
corresponding to a call to arc_read. These entries are then exported
through the kstat interface, which can then be interpreted in userspace.
For each arc_read call, the following information is exported:
* A unique identifier (uint64_t)
* The time the entry was added to the list (hrtime_t)
(*not* wall clock time; relative to the other entries on the list)
* The objset ID (uint64_t)
* The object number (uint64_t)
* The indirection level (uint64_t)
* The block ID (uint64_t)
* The name of the function originating the arc_read call (char[24])
* The arc_flags from the arc_read call (uint32_t)
* The PID of the reading thread (pid_t)
* The command or name of thread originating read (char[16])
From this exported information one can see, in real time, exactly what
is being read, what function is generating the read, and whether or not
the read was found to be already cached.
There is still some work to be done, but this should serve as a good
starting point.
Specifically, dbuf_read's are not accounted for in the currently
exported information. Thus, a follow up patch should probably be added
to export these calls that never call into arc_read (they only hit the
dbuf hash table). In addition, it might be nice to create a utility
similar to "arcstat.py" to digest the exported information and display
it in a more readable format. Or perhaps, log the information and allow
for it to be "replayed" at a later time.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2013-09-06 23:09:05 +00:00
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
/* Pool configuration locks */
|
2022-04-19 18:38:30 +00:00
|
|
|
extern int spa_config_tryenter(spa_t *spa, int locks, const void *tag,
|
|
|
|
krw_t rw);
|
2019-08-14 03:24:43 +00:00
|
|
|
extern void spa_config_enter(spa_t *spa, int locks, const void *tag, krw_t rw);
|
2023-04-19 20:22:59 +00:00
|
|
|
extern void spa_config_enter_mmp(spa_t *spa, int locks, const void *tag,
|
|
|
|
krw_t rw);
|
2019-08-14 03:24:43 +00:00
|
|
|
extern void spa_config_exit(spa_t *spa, int locks, const void *tag);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern int spa_config_held(spa_t *spa, int locks, krw_t rw);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* Pool vdev add/remove lock */
|
|
|
|
extern uint64_t spa_vdev_enter(spa_t *spa);
|
2020-07-03 18:05:50 +00:00
|
|
|
extern uint64_t spa_vdev_detach_enter(spa_t *spa, uint64_t guid);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern uint64_t spa_vdev_config_enter(spa_t *spa);
|
|
|
|
extern void spa_vdev_config_exit(spa_t *spa, vdev_t *vd, uint64_t txg,
|
2022-04-19 18:49:30 +00:00
|
|
|
int error, const char *tag);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern int spa_vdev_exit(spa_t *spa, vdev_t *vd, uint64_t txg, int error);
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
/* Pool vdev state change lock */
|
2010-05-28 20:45:14 +00:00
|
|
|
extern void spa_vdev_state_enter(spa_t *spa, int oplock);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern int spa_vdev_state_exit(spa_t *spa, vdev_t *vd, int error);
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/* Log state */
|
|
|
|
typedef enum spa_log_state {
|
|
|
|
SPA_LOG_UNKNOWN = 0, /* unknown log state */
|
|
|
|
SPA_LOG_MISSING, /* missing log(s) */
|
|
|
|
SPA_LOG_CLEAR, /* clear the log(s) */
|
|
|
|
SPA_LOG_GOOD, /* log(s) are good */
|
|
|
|
} spa_log_state_t;
|
|
|
|
|
|
|
|
extern spa_log_state_t spa_get_log_state(spa_t *spa);
|
|
|
|
extern void spa_set_log_state(spa_t *spa, spa_log_state_t state);
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
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.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
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: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 16:30:13 +00:00
|
|
|
extern int spa_reset_logs(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
/* Log claim callback */
|
|
|
|
extern void spa_claim_notify(zio_t *zio);
|
2013-04-29 22:49:23 +00:00
|
|
|
extern void spa_deadman(void *);
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/* Accessor functions */
|
2008-12-03 20:09:06 +00:00
|
|
|
extern boolean_t spa_shutting_down(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern struct dsl_pool *spa_get_dsl(spa_t *spa);
|
2012-12-13 23:24:15 +00:00
|
|
|
extern boolean_t spa_is_initializing(spa_t *spa);
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
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.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
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: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 16:30:13 +00:00
|
|
|
extern boolean_t spa_indirect_vdevs_loaded(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern blkptr_t *spa_get_rootblkptr(spa_t *spa);
|
|
|
|
extern void spa_set_rootblkptr(spa_t *spa, const blkptr_t *bp);
|
|
|
|
extern void spa_altroot(spa_t *, char *, size_t);
|
Cleanup: Specify unsignedness on things that should not be signed
In #13871, zfs_vdev_aggregation_limit_non_rotating and
zfs_vdev_aggregation_limit being signed was pointed out as a possible
reason not to eliminate an unnecessary MAX(unsigned, 0) since the
unsigned value was assigned from them.
There is no reason for these module parameters to be signed and upon
inspection, it was found that there are a number of other module
parameters that are signed, but should not be, so we make them unsigned.
Making them unsigned made it clear that some other variables in the code
should also be unsigned, so we also make those unsigned. This prevents
users from setting negative values that could potentially cause bad
behaviors. It also makes the code slightly easier to understand.
Mostly module parameters that deal with timeouts, limits, bitshifts and
percentages are made unsigned by this. Any that are boolean are left
signed, since whether booleans should be considered signed or unsigned
does not matter.
Making zfs_arc_lotsfree_percent unsigned caused a
`zfs_arc_lotsfree_percent >= 0` check to become redundant, so it was
removed. Removing the check was also necessary to prevent a compiler
error from -Werror=type-limits.
Several end of line comments had to be moved to their own lines because
replacing int with uint_t caused us to exceed the 80 character limit
enforced by cstyle.pl.
The following were kept signed because they are passed to
taskq_create(), which expects signed values and modifying the
OpenSolaris/Illumos DDI is out of scope of this patch:
* metaslab_load_pct
* zfs_sync_taskq_batch_pct
* zfs_zil_clean_taskq_nthr_pct
* zfs_zil_clean_taskq_minalloc
* zfs_zil_clean_taskq_maxalloc
* zfs_arc_prune_task_threads
Also, negative values in those parameters was found to be harmless.
The following were left signed because either negative values make
sense, or more analysis was needed to determine whether negative values
should be disallowed:
* zfs_metaslab_switch_threshold
* zfs_pd_bytes_max
* zfs_livelist_min_percent_shared
zfs_multihost_history was made static to be consistent with other
parameters.
A number of module parameters were marked as signed, but in reality
referenced unsigned variables. upgrade_errlog_limit is one of the
numerous examples. In the case of zfs_vdev_async_read_max_active, it was
already uint32_t, but zdb had an extern int declaration for it.
Interestingly, the documentation in zfs.4 was right for
upgrade_errlog_limit despite the module parameter being wrongly marked,
while the documentation for zfs_vdev_async_read_max_active (and friends)
was wrong. It was also wrong for zstd_abort_size, which was unsigned,
but was documented as signed.
Also, the documentation in zfs.4 incorrectly described the following
parameters as ulong when they were int:
* zfs_arc_meta_adjust_restarts
* zfs_override_estimate_recordsize
They are now uint_t as of this patch and thus the man page has been
updated to describe them as uint.
dbuf_state_index was left alone since it does nothing and perhaps should
be removed in another patch.
If any module parameters were missed, they were not found by `grep -r
'ZFS_MODULE_PARAM' | grep ', INT'`. I did find a few that grep missed,
but only because they were in files that had hits.
This patch intentionally did not attempt to address whether some of
these module parameters should be elevated to 64-bit parameters, because
the length of a long on 32-bit is 32-bit.
Lastly, it was pointed out during review that uint_t is a better match
for these variables than uint32_t because FreeBSD kernel parameter
definitions are designed for uint_t, whose bit width can change in
future memory models. As a result, we change the existing parameters
that are uint32_t to use uint_t.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13875
2022-09-27 23:42:41 +00:00
|
|
|
extern uint32_t spa_sync_pass(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern char *spa_name(spa_t *spa);
|
|
|
|
extern uint64_t spa_guid(spa_t *spa);
|
2011-11-11 22:07:54 +00:00
|
|
|
extern uint64_t spa_load_guid(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern uint64_t spa_last_synced_txg(spa_t *spa);
|
|
|
|
extern uint64_t spa_first_txg(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern uint64_t spa_syncing_txg(spa_t *spa);
|
2017-04-07 20:50:18 +00:00
|
|
|
extern uint64_t spa_final_dirty_txg(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern uint64_t spa_version(spa_t *spa);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern pool_state_t spa_state(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern spa_load_state_t spa_load_state(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern uint64_t spa_freeze_txg(spa_t *spa);
|
OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space
Reviewed by: Steve Gonczi <steve.gonczi@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Background information: This assertion about tx_space_* verifies that we
are not dirtying more stuff than we thought we would. We “need” to know
how much we will dirty so that we can check if we should fail this
transaction with ENOSPC/EDQUOT, in dmu_tx_assign(). While the
transaction is open (i.e. between dmu_tx_assign() and dmu_tx_commit() —
typically less than a millisecond), we call dbuf_dirty() on the exact
blocks that will be modified. Once this happens, the temporary
accounting in tx_space_* is unnecessary, because we know exactly what
blocks are newly dirtied; we call dnode_willuse_space() to track this
more exact accounting.
The fundamental problem causing this bug is that dmu_tx_hold_*() relies
on the current state in the DMU (e.g. dn_nlevels) to predict how much
will be dirtied by this transaction, but this state can change before we
actually perform the transaction (i.e. call dbuf_dirty()).
This bug will be fixed by removing the assertion that the tx_space_*
accounting is perfectly accurate (i.e. we never dirty more than was
predicted by dmu_tx_hold_*()). By removing the requirement that this
accounting be perfectly accurate, we can also vastly simplify it, e.g.
removing most of the logic in dmu_tx_count_*().
The new tx space accounting will be very approximate, and may be more or
less than what is actually dirtied. It will still be used to determine
if this transaction will put us over quota. Transactions that are marked
by dmu_tx_mark_netfree() will be excepted from this check. We won’t make
an attempt to determine how much space will be freed by the transaction
— this was rarely accurate enough to determine if a transaction should
be permitted when we are over quota, which is why dmu_tx_mark_netfree()
was introduced in 2014.
We also won’t attempt to give “credit” when overwriting existing blocks,
if those blocks may be freed. This allows us to remove the
do_free_accounting logic in dbuf_dirty(), and associated routines. This
logic attempted to predict what will be on disk when this txg syncs, to
know if the overwritten block will be freed (i.e. exists, and has no
snapshots).
OpenZFS-issue: https://www.illumos.org/issues/7793
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/3704e0a
Upstream bugs: DLPX-32883a
Closes #5804
Porting notes:
- DNODE_SIZE replaced with DNODE_MIN_SIZE in dmu_tx_count_dnode(),
Using the default dnode size would be slightly better.
- DEBUG_DMU_TX wrappers and configure option removed.
- Resolved _by_dnode() conflicts these changes have not yet been
applied to OpenZFS.
2017-03-07 17:51:59 +00:00
|
|
|
extern uint64_t spa_get_worst_case_asize(spa_t *spa, uint64_t lsize);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern uint64_t spa_get_dspace(spa_t *spa);
|
2016-12-16 22:11:29 +00:00
|
|
|
extern uint64_t spa_get_checkpoint_space(spa_t *spa);
|
2014-11-04 17:35:37 +00:00
|
|
|
extern uint64_t spa_get_slop_space(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern void spa_update_dspace(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern uint64_t spa_version(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern boolean_t spa_deflate(spa_t *spa);
|
|
|
|
extern metaslab_class_t *spa_normal_class(spa_t *spa);
|
|
|
|
extern metaslab_class_t *spa_log_class(spa_t *spa);
|
Set aside a metaslab for ZIL blocks
Mixing ZIL and normal allocations has several problems:
1. The ZIL allocations are allocated, written to disk, and then a few
seconds later freed. This leaves behind holes (free segments) where the
ZIL blocks used to be, which increases fragmentation, which negatively
impacts performance.
2. When under moderate load, ZIL allocations are of 128KB. If the pool
is fairly fragmented, there may not be many free chunks of that size.
This causes ZFS to load more metaslabs to locate free segments of 128KB
or more. The loading happens synchronously (from zil_commit()), and can
take around a second even if the metaslab's spacemap is cached in the
ARC. All concurrent synchronous operations on this filesystem must wait
while the metaslab is loading. This can cause a significant performance
impact.
3. If the pool is very fragmented, there may be zero free chunks of
128KB or more. In this case, the ZIL falls back to txg_wait_synced(),
which has an enormous performance impact.
These problems can be eliminated by using a dedicated log device
("slog"), even one with the same performance characteristics as the
normal devices.
This change sets aside one metaslab from each top-level vdev that is
preferentially used for ZIL allocations (vdev_log_mg,
spa_embedded_log_class). From an allocation perspective, this is
similar to having a dedicated log device, and it eliminates the
above-mentioned performance problems.
Log (ZIL) blocks can be allocated from the following locations. Each
one is tried in order until the allocation succeeds:
1. dedicated log vdevs, aka "slog" (spa_log_class)
2. embedded slog metaslabs (spa_embedded_log_class)
3. other metaslabs in normal vdevs (spa_normal_class)
The space required for the embedded slog metaslabs is usually between
0.5% and 1.0% of the pool, and comes out of the existing 3.2% of "slop"
space that is not available for user data.
On an all-ssd system with 4TB storage, 87% fragmentation, 60% capacity,
and recordsize=8k, testing shows a ~50% performance increase on random
8k sync writes. On even more fragmented systems (which hit problem #3
above and call txg_wait_synced()), the performance improvement can be
arbitrarily large (>100x).
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #11389
2021-01-21 23:12:54 +00:00
|
|
|
extern metaslab_class_t *spa_embedded_log_class(spa_t *spa);
|
2018-09-06 01:33:36 +00:00
|
|
|
extern metaslab_class_t *spa_special_class(spa_t *spa);
|
|
|
|
extern metaslab_class_t *spa_dedup_class(spa_t *spa);
|
2023-06-27 01:03:29 +00:00
|
|
|
extern metaslab_class_t *spa_preferred_class(spa_t *spa, const zio_t *zio);
|
ddt: dedup table quota enforcement
This adds two new pool properties:
- dedup_table_size, the total size of all DDTs on the pool; and
- dedup_table_quota, the maximum possible size of all DDTs in the pool
When set, quota will be enforced by checking when a new entry is about
to be created. If the pool is over its dedup quota, the entry won't be
created, and the corresponding write will be converted to a regular
non-dedup write. Note that existing entries can be updated (ie their
refcounts changed), as that reuses the space rather than requiring more.
dedup_table_quota can be set to 'auto', which will set it based on the
size of the devices backing the "dedup" allocation device. This makes it
possible to limit the DDTs to the size of a dedup vdev only, such that
when the device fills, no new blocks are deduplicated.
Sponsored-by: iXsystems, Inc.
Sponsored-By: Klara Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Rob Wing <rob.wing@klarasystems.com>
Co-authored-by: Sean Eric Fagan <sean.fagan@klarasystems.com>
Closes #15889
2024-07-25 16:47:36 +00:00
|
|
|
extern boolean_t spa_special_has_ddt(spa_t *spa);
|
2018-09-06 01:33:36 +00:00
|
|
|
|
2015-04-02 03:44:32 +00:00
|
|
|
extern void spa_evicting_os_register(spa_t *, objset_t *os);
|
|
|
|
extern void spa_evicting_os_deregister(spa_t *, objset_t *os);
|
|
|
|
extern void spa_evicting_os_wait(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern int spa_max_replication(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern int spa_prev_software_version(spa_t *spa);
|
2017-12-18 22:06:07 +00:00
|
|
|
extern uint64_t spa_get_failmode(spa_t *spa);
|
|
|
|
extern uint64_t spa_get_deadman_failmode(spa_t *spa);
|
|
|
|
extern void spa_set_deadman_failmode(spa_t *spa, const char *failmode);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern boolean_t spa_suspended(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern uint64_t spa_bootfs(spa_t *spa);
|
|
|
|
extern uint64_t spa_delegation(spa_t *spa);
|
|
|
|
extern objset_t *spa_meta_objset(spa_t *spa);
|
Log Spacemap Project
= Motivation
At Delphix we've seen a lot of customer systems where fragmentation
is over 75% and random writes take a performance hit because a lot
of time is spend on I/Os that update on-disk space accounting metadata.
Specifically, we seen cases where 20% to 40% of sync time is spend
after sync pass 1 and ~30% of the I/Os on the system is spent updating
spacemaps.
The problem is that these pools have existed long enough that we've
touched almost every metaslab at least once, and random writes
scatter frees across all metaslabs every TXG, thus appending to
their spacemaps and resulting in many I/Os. To give an example,
assuming that every VDEV has 200 metaslabs and our writes fit within
a single spacemap block (generally 4K) we have 200 I/Os. Then if we
assume 2 levels of indirection, we need 400 additional I/Os and
since we are talking about metadata for which we keep 2 extra copies
for redundancy we need to triple that number, leading to a total of
1800 I/Os per VDEV every TXG.
We could try and decrease the number of metaslabs so we have less
I/Os per TXG but then each metaslab would cover a wider range on
disk and thus would take more time to be loaded in memory from disk.
In addition, after it's loaded, it's range tree would consume more
memory.
Another idea would be to just increase the spacemap block size
which would allow us to fit more entries within an I/O block
resulting in fewer I/Os per metaslab and a speedup in loading time.
The problem is still that we don't deal with the number of I/Os
going up as the number of metaslabs is increasing and the fact
is that we generally write a lot to a few metaslabs and a little
to the rest of them. Thus, just increasing the block size would
actually waste bandwidth because we won't be utilizing our bigger
block size.
= About this patch
This patch introduces the Log Spacemap project which provides the
solution to the above problem while taking into account all the
aforementioned tradeoffs. The details on how it achieves that can
be found in the references sections below and in the code (see
Big Theory Statement in spa_log_spacemap.c).
Even though the change is fairly constraint within the metaslab
and lower-level SPA codepaths, there is a side-change that is
user-facing. The change is that VDEV IDs from VDEV holes will no
longer be reused. To give some background and reasoning for this,
when a log device is removed and its VDEV structure was replaced
with a hole (or was compacted; if at the end of the vdev array),
its vdev_id could be reused by devices added after that. Now
with the pool-wide space maps recording the vdev ID, this behavior
can cause problems (e.g. is this entry referring to a segment in
the new vdev or the removed log?). Thus, to simplify things the
ID reuse behavior is gone and now vdev IDs for top-level vdevs
are truly unique within a pool.
= Testing
The illumos implementation of this feature has been used internally
for a year and has been in production for ~6 months. For this patch
specifically there don't seem to be any regressions introduced to
ZTS and I have been running zloop for a week without any related
problems.
= Performance Analysis (Linux Specific)
All performance results and analysis for illumos can be found in
the links of the references. Redoing the same experiments in Linux
gave similar results. Below are the specifics of the Linux run.
After the pool reached stable state the percentage of the time
spent in pass 1 per TXG was 64% on average for the stock bits
while the log spacemap bits stayed at 95% during the experiment
(graph: sdimitro.github.io/img/linux-lsm/PercOfSyncInPassOne.png).
Sync times per TXG were 37.6 seconds on average for the stock
bits and 22.7 seconds for the log spacemap bits (related graph:
sdimitro.github.io/img/linux-lsm/SyncTimePerTXG.png). As a result
the log spacemap bits were able to push more TXGs, which is also
the reason why all graphs quantified per TXG have more entries for
the log spacemap bits.
Another interesting aspect in terms of txg syncs is that the stock
bits had 22% of their TXGs reach sync pass 7, 55% reach sync pass 8,
and 20% reach 9. The log space map bits reached sync pass 4 in 79%
of their TXGs, sync pass 7 in 19%, and sync pass 8 at 1%. This
emphasizes the fact that not only we spend less time on metadata
but we also iterate less times to convergence in spa_sync() dirtying
objects.
[related graphs:
stock- sdimitro.github.io/img/linux-lsm/NumberOfPassesPerTXGStock.png
lsm- sdimitro.github.io/img/linux-lsm/NumberOfPassesPerTXGLSM.png]
Finally, the improvement in IOPs that the userland gains from the
change is approximately 40%. There is a consistent win in IOPS as
you can see from the graphs below but the absolute amount of
improvement that the log spacemap gives varies within each minute
interval.
sdimitro.github.io/img/linux-lsm/StockVsLog3Days.png
sdimitro.github.io/img/linux-lsm/StockVsLog10Hours.png
= Porting to Other Platforms
For people that want to port this commit to other platforms below
is a list of ZoL commits that this patch depends on:
Make zdb results for checkpoint tests consistent
db587941c5ff6dea01932bb78f70db63cf7f38ba
Update vdev_is_spacemap_addressable() for new spacemap encoding
419ba5914552c6185afbe1dd17b3ed4b0d526547
Simplify spa_sync by breaking it up to smaller functions
8dc2197b7b1e4d7ebc1420ea30e51c6541f1d834
Factor metaslab_load_wait() in metaslab_load()
b194fab0fb6caad18711abccaff3c69ad8b3f6d3
Rename range_tree_verify to range_tree_verify_not_present
df72b8bebe0ebac0b20e0750984bad182cb6564a
Change target size of metaslabs from 256GB to 16GB
c853f382db731e15a87512f4ef1101d14d778a55
zdb -L should skip leak detection altogether
21e7cf5da89f55ce98ec1115726b150e19eefe89
vs_alloc can underflow in L2ARC vdevs
7558997d2f808368867ca7e5234e5793446e8f3f
Simplify log vdev removal code
6c926f426a26ffb6d7d8e563e33fc176164175cb
Get rid of space_map_update() for ms_synced_length
425d3237ee88abc53d8522a7139c926d278b4b7f
Introduce auxiliary metaslab histograms
928e8ad47d3478a3d5d01f0dd6ae74a9371af65e
Error path in metaslab_load_impl() forgets to drop ms_sync_lock
8eef997679ba54547f7d361553d21b3291f41ae7
= References
Background, Motivation, and Internals of the Feature
- OpenZFS 2017 Presentation:
youtu.be/jj2IxRkl5bQ
- Slides:
slideshare.net/SerapheimNikolaosDim/zfs-log-spacemaps-project
Flushing Algorithm Internals & Performance Results
(Illumos Specific)
- Blogpost:
sdimitro.github.io/post/zfs-lsm-flushing/
- OpenZFS 2018 Presentation:
youtu.be/x6D2dHRjkxw
- Slides:
slideshare.net/SerapheimNikolaosDim/zfs-log-spacemap-flushing-algorithm
Upstream Delphix Issues:
DLPX-51539, DLPX-59659, DLPX-57783, DLPX-61438, DLPX-41227, DLPX-59320
DLPX-63385
Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #8442
2019-07-16 17:11:49 +00:00
|
|
|
extern space_map_t *spa_syncing_log_sm(spa_t *spa);
|
2013-04-29 22:49:23 +00:00
|
|
|
extern uint64_t spa_deadman_synctime(spa_t *spa);
|
2017-12-18 22:06:07 +00:00
|
|
|
extern uint64_t spa_deadman_ziotime(spa_t *spa);
|
2017-09-27 01:45:19 +00:00
|
|
|
extern uint64_t spa_dirty_data(spa_t *spa);
|
2019-03-29 16:13:20 +00:00
|
|
|
extern spa_autotrim_t spa_get_autotrim(spa_t *spa);
|
2023-09-02 01:00:30 +00:00
|
|
|
extern int spa_get_allocator(spa_t *spa);
|
|
|
|
extern void spa_set_allocator(spa_t *spa, const char *allocator);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* Miscellaneous support routines */
|
2021-06-05 11:14:12 +00:00
|
|
|
extern void spa_load_failed(spa_t *spa, const char *fmt, ...)
|
|
|
|
__attribute__((format(printf, 2, 3)));
|
|
|
|
extern void spa_load_note(spa_t *spa, const char *fmt, ...)
|
|
|
|
__attribute__((format(printf, 2, 3)));
|
2013-12-09 18:37:51 +00:00
|
|
|
extern void spa_activate_mos_feature(spa_t *spa, const char *feature,
|
|
|
|
dmu_tx_t *tx);
|
2012-12-13 23:24:15 +00:00
|
|
|
extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature);
|
2010-08-26 21:24:34 +00:00
|
|
|
extern spa_t *spa_by_guid(uint64_t pool_guid, uint64_t device_guid);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern boolean_t spa_guid_exists(uint64_t pool_guid, uint64_t device_guid);
|
|
|
|
extern char *spa_strdup(const char *);
|
|
|
|
extern void spa_strfree(char *);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern uint64_t spa_generate_guid(spa_t *spa);
|
2013-12-09 18:37:51 +00:00
|
|
|
extern void snprintf_blkptr(char *buf, size_t buflen, const blkptr_t *bp);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_freeze(spa_t *spa);
|
2011-11-11 22:07:54 +00:00
|
|
|
extern int spa_change_guid(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_upgrade(spa_t *spa, uint64_t version);
|
|
|
|
extern void spa_evict_all(void);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern vdev_t *spa_lookup_by_guid(spa_t *spa, uint64_t guid,
|
|
|
|
boolean_t l2cache);
|
2021-11-11 19:54:15 +00:00
|
|
|
extern boolean_t spa_has_l2cache(spa_t *, uint64_t guid);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern boolean_t spa_has_spare(spa_t *, uint64_t guid);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern uint64_t dva_get_dsize_sync(spa_t *spa, const dva_t *dva);
|
|
|
|
extern uint64_t bp_get_dsize_sync(spa_t *spa, const blkptr_t *bp);
|
|
|
|
extern uint64_t bp_get_dsize(spa_t *spa, const blkptr_t *bp);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern boolean_t spa_has_slogs(spa_t *spa);
|
2008-12-03 20:09:06 +00:00
|
|
|
extern boolean_t spa_is_root(spa_t *spa);
|
2009-01-15 21:59:39 +00:00
|
|
|
extern boolean_t spa_writeable(spa_t *spa);
|
2014-07-18 15:08:31 +00:00
|
|
|
extern boolean_t spa_has_pending_synctask(spa_t *spa);
|
2014-11-03 20:15:08 +00:00
|
|
|
extern int spa_maxblocksize(spa_t *spa);
|
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
|
|
|
extern int spa_maxdnodesize(spa_t *spa);
|
2016-12-16 22:11:29 +00:00
|
|
|
extern boolean_t spa_has_checkpoint(spa_t *spa);
|
|
|
|
extern boolean_t spa_importing_readonly_checkpoint(spa_t *spa);
|
|
|
|
extern boolean_t spa_suspend_async_destroy(spa_t *spa);
|
|
|
|
extern uint64_t spa_min_claim_txg(spa_t *spa);
|
OpenZFS 9075 - Improve ZFS pool import/load process and corrupted pool recovery
Some work has been done lately to improve the debugability of the ZFS pool
load (and import) process. This includes:
7638 Refactor spa_load_impl into several functions
8961 SPA load/import should tell us why it failed
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.
Porting notes (ZTS):
* Fix 'make dist' target in zpool_import
* The maximum path length allowed by tar is 99 characters. Several
of the new test cases exceeded this limit resulting in them not
being included in the tarball. Shorten the names slightly.
* Set/get tunables using accessor functions.
* Get last synced txg via the "zfs_txg_history" mechanism.
* Clear zinject handlers in cleanup for import_cache_device_replaced
and import_rewind_device_replaced in order that the zpool can be
exported if there is an error.
* Increase FILESIZE to 8G in zfs-test.sh to allow for a larger
ext4 file system to be created on ZFS_DISK2. Also, there's
no need to partition ZFS_DISK2 at all. The partitioning had
already been disabled for multipath devices. Among other things,
the partitioning steals some space from the ext4 file system,
makes it difficult to accurately calculate the paramters to
parted and can make some of the tests fail.
* Increase FS_SIZE and FILE_SIZE in the zpool_import test
configuration now that FILESIZE is larger.
* Write more data in order that device evacuation take lonnger in
a couple tests.
* Use mkdir -p to avoid errors when the directory already exists.
* Remove use of sudo in import_rewind_config_changed.
Authored by: Pavel Zakharov <pavel.zakharov@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: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://illumos.org/issues/9075
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/619c0123
Closes #7459
2016-07-22 14:39:36 +00:00
|
|
|
extern boolean_t zfs_dva_valid(spa_t *spa, const dva_t *dva,
|
|
|
|
const blkptr_t *bp);
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
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.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
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: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 16:30:13 +00:00
|
|
|
typedef void (*spa_remap_cb_t)(uint64_t vdev, uint64_t offset, uint64_t size,
|
|
|
|
void *arg);
|
|
|
|
extern boolean_t spa_remap_blkptr(spa_t *spa, blkptr_t *bp,
|
|
|
|
spa_remap_cb_t callback, void *arg);
|
|
|
|
extern uint64_t spa_get_last_removal_txg(spa_t *spa);
|
OpenZFS 9075 - Improve ZFS pool import/load process and corrupted pool recovery
Some work has been done lately to improve the debugability of the ZFS pool
load (and import) process. This includes:
7638 Refactor spa_load_impl into several functions
8961 SPA load/import should tell us why it failed
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.
Porting notes (ZTS):
* Fix 'make dist' target in zpool_import
* The maximum path length allowed by tar is 99 characters. Several
of the new test cases exceeded this limit resulting in them not
being included in the tarball. Shorten the names slightly.
* Set/get tunables using accessor functions.
* Get last synced txg via the "zfs_txg_history" mechanism.
* Clear zinject handlers in cleanup for import_cache_device_replaced
and import_rewind_device_replaced in order that the zpool can be
exported if there is an error.
* Increase FILESIZE to 8G in zfs-test.sh to allow for a larger
ext4 file system to be created on ZFS_DISK2. Also, there's
no need to partition ZFS_DISK2 at all. The partitioning had
already been disabled for multipath devices. Among other things,
the partitioning steals some space from the ext4 file system,
makes it difficult to accurately calculate the paramters to
parted and can make some of the tests fail.
* Increase FS_SIZE and FILE_SIZE in the zpool_import test
configuration now that FILESIZE is larger.
* Write more data in order that device evacuation take lonnger in
a couple tests.
* Use mkdir -p to avoid errors when the directory already exists.
* Remove use of sudo in import_rewind_config_changed.
Authored by: Pavel Zakharov <pavel.zakharov@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: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://illumos.org/issues/9075
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/619c0123
Closes #7459
2016-07-22 14:39:36 +00:00
|
|
|
extern boolean_t spa_trust_config(spa_t *spa);
|
|
|
|
extern uint64_t spa_missing_tvds_allowed(spa_t *spa);
|
|
|
|
extern void spa_set_missing_tvds(spa_t *spa, uint64_t missing);
|
2016-12-16 22:11:29 +00:00
|
|
|
extern boolean_t spa_top_vdevs_spacemap_addressable(spa_t *spa);
|
Log Spacemap Project
= Motivation
At Delphix we've seen a lot of customer systems where fragmentation
is over 75% and random writes take a performance hit because a lot
of time is spend on I/Os that update on-disk space accounting metadata.
Specifically, we seen cases where 20% to 40% of sync time is spend
after sync pass 1 and ~30% of the I/Os on the system is spent updating
spacemaps.
The problem is that these pools have existed long enough that we've
touched almost every metaslab at least once, and random writes
scatter frees across all metaslabs every TXG, thus appending to
their spacemaps and resulting in many I/Os. To give an example,
assuming that every VDEV has 200 metaslabs and our writes fit within
a single spacemap block (generally 4K) we have 200 I/Os. Then if we
assume 2 levels of indirection, we need 400 additional I/Os and
since we are talking about metadata for which we keep 2 extra copies
for redundancy we need to triple that number, leading to a total of
1800 I/Os per VDEV every TXG.
We could try and decrease the number of metaslabs so we have less
I/Os per TXG but then each metaslab would cover a wider range on
disk and thus would take more time to be loaded in memory from disk.
In addition, after it's loaded, it's range tree would consume more
memory.
Another idea would be to just increase the spacemap block size
which would allow us to fit more entries within an I/O block
resulting in fewer I/Os per metaslab and a speedup in loading time.
The problem is still that we don't deal with the number of I/Os
going up as the number of metaslabs is increasing and the fact
is that we generally write a lot to a few metaslabs and a little
to the rest of them. Thus, just increasing the block size would
actually waste bandwidth because we won't be utilizing our bigger
block size.
= About this patch
This patch introduces the Log Spacemap project which provides the
solution to the above problem while taking into account all the
aforementioned tradeoffs. The details on how it achieves that can
be found in the references sections below and in the code (see
Big Theory Statement in spa_log_spacemap.c).
Even though the change is fairly constraint within the metaslab
and lower-level SPA codepaths, there is a side-change that is
user-facing. The change is that VDEV IDs from VDEV holes will no
longer be reused. To give some background and reasoning for this,
when a log device is removed and its VDEV structure was replaced
with a hole (or was compacted; if at the end of the vdev array),
its vdev_id could be reused by devices added after that. Now
with the pool-wide space maps recording the vdev ID, this behavior
can cause problems (e.g. is this entry referring to a segment in
the new vdev or the removed log?). Thus, to simplify things the
ID reuse behavior is gone and now vdev IDs for top-level vdevs
are truly unique within a pool.
= Testing
The illumos implementation of this feature has been used internally
for a year and has been in production for ~6 months. For this patch
specifically there don't seem to be any regressions introduced to
ZTS and I have been running zloop for a week without any related
problems.
= Performance Analysis (Linux Specific)
All performance results and analysis for illumos can be found in
the links of the references. Redoing the same experiments in Linux
gave similar results. Below are the specifics of the Linux run.
After the pool reached stable state the percentage of the time
spent in pass 1 per TXG was 64% on average for the stock bits
while the log spacemap bits stayed at 95% during the experiment
(graph: sdimitro.github.io/img/linux-lsm/PercOfSyncInPassOne.png).
Sync times per TXG were 37.6 seconds on average for the stock
bits and 22.7 seconds for the log spacemap bits (related graph:
sdimitro.github.io/img/linux-lsm/SyncTimePerTXG.png). As a result
the log spacemap bits were able to push more TXGs, which is also
the reason why all graphs quantified per TXG have more entries for
the log spacemap bits.
Another interesting aspect in terms of txg syncs is that the stock
bits had 22% of their TXGs reach sync pass 7, 55% reach sync pass 8,
and 20% reach 9. The log space map bits reached sync pass 4 in 79%
of their TXGs, sync pass 7 in 19%, and sync pass 8 at 1%. This
emphasizes the fact that not only we spend less time on metadata
but we also iterate less times to convergence in spa_sync() dirtying
objects.
[related graphs:
stock- sdimitro.github.io/img/linux-lsm/NumberOfPassesPerTXGStock.png
lsm- sdimitro.github.io/img/linux-lsm/NumberOfPassesPerTXGLSM.png]
Finally, the improvement in IOPs that the userland gains from the
change is approximately 40%. There is a consistent win in IOPS as
you can see from the graphs below but the absolute amount of
improvement that the log spacemap gives varies within each minute
interval.
sdimitro.github.io/img/linux-lsm/StockVsLog3Days.png
sdimitro.github.io/img/linux-lsm/StockVsLog10Hours.png
= Porting to Other Platforms
For people that want to port this commit to other platforms below
is a list of ZoL commits that this patch depends on:
Make zdb results for checkpoint tests consistent
db587941c5ff6dea01932bb78f70db63cf7f38ba
Update vdev_is_spacemap_addressable() for new spacemap encoding
419ba5914552c6185afbe1dd17b3ed4b0d526547
Simplify spa_sync by breaking it up to smaller functions
8dc2197b7b1e4d7ebc1420ea30e51c6541f1d834
Factor metaslab_load_wait() in metaslab_load()
b194fab0fb6caad18711abccaff3c69ad8b3f6d3
Rename range_tree_verify to range_tree_verify_not_present
df72b8bebe0ebac0b20e0750984bad182cb6564a
Change target size of metaslabs from 256GB to 16GB
c853f382db731e15a87512f4ef1101d14d778a55
zdb -L should skip leak detection altogether
21e7cf5da89f55ce98ec1115726b150e19eefe89
vs_alloc can underflow in L2ARC vdevs
7558997d2f808368867ca7e5234e5793446e8f3f
Simplify log vdev removal code
6c926f426a26ffb6d7d8e563e33fc176164175cb
Get rid of space_map_update() for ms_synced_length
425d3237ee88abc53d8522a7139c926d278b4b7f
Introduce auxiliary metaslab histograms
928e8ad47d3478a3d5d01f0dd6ae74a9371af65e
Error path in metaslab_load_impl() forgets to drop ms_sync_lock
8eef997679ba54547f7d361553d21b3291f41ae7
= References
Background, Motivation, and Internals of the Feature
- OpenZFS 2017 Presentation:
youtu.be/jj2IxRkl5bQ
- Slides:
slideshare.net/SerapheimNikolaosDim/zfs-log-spacemaps-project
Flushing Algorithm Internals & Performance Results
(Illumos Specific)
- Blogpost:
sdimitro.github.io/post/zfs-lsm-flushing/
- OpenZFS 2018 Presentation:
youtu.be/x6D2dHRjkxw
- Slides:
slideshare.net/SerapheimNikolaosDim/zfs-log-spacemap-flushing-algorithm
Upstream Delphix Issues:
DLPX-51539, DLPX-59659, DLPX-57783, DLPX-61438, DLPX-41227, DLPX-59320
DLPX-63385
Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #8442
2019-07-16 17:11:49 +00:00
|
|
|
extern uint64_t spa_total_metaslabs(spa_t *spa);
|
Multi-modifier protection (MMP)
Add multihost=on|off pool property to control MMP. When enabled
a new thread writes uberblocks to the last slot in each label, at a
set frequency, to indicate to other hosts the pool is actively imported.
These uberblocks are the last synced uberblock with an updated
timestamp. Property defaults to off.
During tryimport, find the "best" uberblock (newest txg and timestamp)
repeatedly, checking for change in the found uberblock. Include the
results of the activity test in the config returned by tryimport.
These results are reported to user in "zpool import".
Allow the user to control the period between MMP writes, and the
duration of the activity test on import, via a new module parameter
zfs_multihost_interval. The period is specified in milliseconds. The
activity test duration is calculated from this value, and from the
mmp_delay in the "best" uberblock found initially.
Add a kstat interface to export statistics about Multiple Modifier
Protection (MMP) updates. Include the last synced txg number, the
timestamp, the delay since the last MMP update, the VDEV GUID, the VDEV
label that received the last MMP update, and the VDEV path. Abbreviated
output below.
$ cat /proc/spl/kstat/zfs/mypool/multihost
31 0 0x01 10 880 105092382393521 105144180101111
txg timestamp mmp_delay vdev_guid vdev_label vdev_path
20468 261337 250274925 68396651780 3 /dev/sda
20468 261339 252023374 6267402363293 1 /dev/sdc
20468 261340 252000858 6698080955233 1 /dev/sdx
20468 261341 251980635 783892869810 2 /dev/sdy
20468 261342 253385953 8923255792467 3 /dev/sdd
20468 261344 253336622 042125143176 0 /dev/sdab
20468 261345 253310522 1200778101278 2 /dev/sde
20468 261346 253286429 0950576198362 2 /dev/sdt
20468 261347 253261545 96209817917 3 /dev/sds
20468 261349 253238188 8555725937673 3 /dev/sdb
Add a new tunable zfs_multihost_history to specify the number of MMP
updates to store history for. By default it is set to zero meaning that
no MMP statistics are stored.
When using ztest to generate activity, for automated tests of the MMP
function, some test functions interfere with the test. For example, the
pool is exported to run zdb and then imported again. Add a new ztest
function, "-M", to alter ztest behavior to prevent this.
Add new tests to verify the new functionality. Tests provided by
Giuseppe Di Natale.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Ned Bass <bass6@llnl.gov>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #745
Closes #6279
2017-07-08 03:20:35 +00:00
|
|
|
extern boolean_t spa_multihost(spa_t *spa);
|
2019-09-10 20:42:30 +00:00
|
|
|
extern uint32_t spa_get_hostid(spa_t *spa);
|
2018-09-06 01:33:36 +00:00
|
|
|
extern void spa_activate_allocation_classes(spa_t *, dmu_tx_t *);
|
2019-07-26 17:54:14 +00:00
|
|
|
extern boolean_t spa_livelist_delete_check(spa_t *spa);
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2024-04-29 21:35:53 +00:00
|
|
|
extern boolean_t spa_mmp_remote_host_activity(spa_t *spa);
|
|
|
|
|
2019-11-21 17:32:57 +00:00
|
|
|
extern spa_mode_t spa_mode(spa_t *spa);
|
2017-06-13 03:16:28 +00:00
|
|
|
extern uint64_t zfs_strtonum(const char *str, char **nptr);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
extern char *spa_his_ievent_table[];
|
|
|
|
|
|
|
|
extern void spa_history_create_obj(spa_t *spa, dmu_tx_t *tx);
|
|
|
|
extern int spa_history_get(spa_t *spa, uint64_t *offset, uint64_t *len_read,
|
|
|
|
char *his_buf);
|
2013-08-28 11:45:09 +00:00
|
|
|
extern int spa_history_log(spa_t *spa, const char *his_buf);
|
|
|
|
extern int spa_history_log_nvl(spa_t *spa, nvlist_t *nvl);
|
2017-10-23 16:45:59 +00:00
|
|
|
extern void spa_history_log_version(spa_t *spa, const char *operation,
|
|
|
|
dmu_tx_t *tx);
|
2013-08-28 11:45:09 +00:00
|
|
|
extern void spa_history_log_internal(spa_t *spa, const char *operation,
|
2019-09-12 20:28:26 +00:00
|
|
|
dmu_tx_t *tx, const char *fmt, ...) __printflike(4, 5);
|
2013-08-28 11:45:09 +00:00
|
|
|
extern void spa_history_log_internal_ds(struct dsl_dataset *ds, const char *op,
|
2019-09-12 20:28:26 +00:00
|
|
|
dmu_tx_t *tx, const char *fmt, ...) __printflike(4, 5);
|
2013-08-28 11:45:09 +00:00
|
|
|
extern void spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
|
2019-09-12 20:28:26 +00:00
|
|
|
dmu_tx_t *tx, const char *fmt, ...) __printflike(4, 5);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2018-06-06 16:33:54 +00:00
|
|
|
extern const char *spa_state_to_name(spa_t *spa);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/* error handling */
|
2014-06-25 18:37:59 +00:00
|
|
|
struct zbookmark_phys;
|
2023-03-28 23:51:58 +00:00
|
|
|
extern void spa_log_error(spa_t *spa, const zbookmark_phys_t *zb,
|
2024-03-25 22:01:54 +00:00
|
|
|
const uint64_t birth);
|
2023-05-09 15:53:27 +00:00
|
|
|
extern void spa_remove_error(spa_t *spa, zbookmark_phys_t *zb,
|
2024-03-25 22:01:54 +00:00
|
|
|
uint64_t birth);
|
2020-06-06 19:54:04 +00:00
|
|
|
extern int zfs_ereport_post(const char *clazz, spa_t *spa, vdev_t *vd,
|
2020-09-04 17:34:28 +00:00
|
|
|
const zbookmark_phys_t *zb, zio_t *zio, uint64_t state);
|
2020-06-06 19:54:04 +00:00
|
|
|
extern boolean_t zfs_ereport_is_valid(const char *clazz, spa_t *spa, vdev_t *vd,
|
2018-11-09 00:47:24 +00:00
|
|
|
zio_t *zio);
|
2020-09-04 17:34:28 +00:00
|
|
|
extern void zfs_ereport_taskq_fini(void);
|
2021-02-20 06:33:15 +00:00
|
|
|
extern void zfs_ereport_clear(spa_t *spa, vdev_t *vd);
|
2017-05-30 18:39:17 +00:00
|
|
|
extern nvlist_t *zfs_event_create(spa_t *spa, vdev_t *vd, const char *type,
|
|
|
|
const char *name, nvlist_t *aux);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void zfs_post_remove(spa_t *spa, vdev_t *vd);
|
2016-08-31 21:46:58 +00:00
|
|
|
extern void zfs_post_state_change(spa_t *spa, vdev_t *vd, uint64_t laststate);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void zfs_post_autoreplace(spa_t *spa, vdev_t *vd);
|
2022-12-22 19:48:49 +00:00
|
|
|
extern uint64_t spa_approx_errlog_size(spa_t *spa);
|
Improve zpool status output, list all affected datasets
Currently, determining which datasets are affected by corruption is
a manual process.
The primary difficulty in reporting the list of affected snapshots is
that since the error was initially found, the snapshot where the error
originally occurred in, may have been deleted. To solve this issue, we
add the ID of the head dataset of the original snapshot which the error
was detected in, to the stored error report. Then any time a filesystem
is deleted, the errors associated with it are deleted as well. Any time
a clone promote occurs, we modify reports associated with the original
head to refer to the new head. The stored error reports are identified
by this head ID, the birth time of the block which the error occurred
in, as well as some information about the error itself are also stored.
Once this information is stored, we can find the set of datasets
affected by an error by walking back the list of snapshots in the given
head until we find one with the appropriate birth txg, and then traverse
through the snapshots of the clone family, terminating a branch if the
block was replaced in a given snapshot. Then we report this information
back to libzfs, and to the zpool status command, where it is displayed
as follows:
pool: test
state: ONLINE
status: One or more devices has experienced an error resulting in data
corruption. Applications may be affected.
action: Restore the file in question if possible. Otherwise restore the
entire pool from backup.
see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-8A
scan: scrub repaired 0B in 00:00:00 with 800 errors on Fri Dec 3
08:27:57 2021
config:
NAME STATE READ WRITE CKSUM
test ONLINE 0 0 0
sdb ONLINE 0 0 1.58K
errors: Permanent errors have been detected in the following files:
test@1:/test.0.0
/test/test.0.0
/test/1clone/test.0.0
A new feature flag is introduced to mark the presence of this change, as
well as promotion and backwards compatibility logic. This is an updated
version of #9175. Rebase required fixing the tests, updating the ABI of
libzfs, updating the man pages, fixing bugs, fixing the error returns,
and updating the old on-disk error logs to the new format when
activating the feature.
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Co-authored-by: TulsiJain <tulsi.jain@delphix.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #9175
Closes #12812
2022-04-26 00:25:42 +00:00
|
|
|
extern int spa_get_errlog(spa_t *spa, void *uaddr, uint64_t *count);
|
2021-12-17 20:35:28 +00:00
|
|
|
extern uint64_t spa_get_last_errlog_size(spa_t *spa);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_errlog_rotate(spa_t *spa);
|
|
|
|
extern void spa_errlog_drain(spa_t *spa);
|
|
|
|
extern void spa_errlog_sync(spa_t *spa, uint64_t txg);
|
|
|
|
extern void spa_get_errlists(spa_t *spa, avl_tree_t *last, avl_tree_t *scrub);
|
Improve zpool status output, list all affected datasets
Currently, determining which datasets are affected by corruption is
a manual process.
The primary difficulty in reporting the list of affected snapshots is
that since the error was initially found, the snapshot where the error
originally occurred in, may have been deleted. To solve this issue, we
add the ID of the head dataset of the original snapshot which the error
was detected in, to the stored error report. Then any time a filesystem
is deleted, the errors associated with it are deleted as well. Any time
a clone promote occurs, we modify reports associated with the original
head to refer to the new head. The stored error reports are identified
by this head ID, the birth time of the block which the error occurred
in, as well as some information about the error itself are also stored.
Once this information is stored, we can find the set of datasets
affected by an error by walking back the list of snapshots in the given
head until we find one with the appropriate birth txg, and then traverse
through the snapshots of the clone family, terminating a branch if the
block was replaced in a given snapshot. Then we report this information
back to libzfs, and to the zpool status command, where it is displayed
as follows:
pool: test
state: ONLINE
status: One or more devices has experienced an error resulting in data
corruption. Applications may be affected.
action: Restore the file in question if possible. Otherwise restore the
entire pool from backup.
see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-8A
scan: scrub repaired 0B in 00:00:00 with 800 errors on Fri Dec 3
08:27:57 2021
config:
NAME STATE READ WRITE CKSUM
test ONLINE 0 0 0
sdb ONLINE 0 0 1.58K
errors: Permanent errors have been detected in the following files:
test@1:/test.0.0
/test/test.0.0
/test/1clone/test.0.0
A new feature flag is introduced to mark the presence of this change, as
well as promotion and backwards compatibility logic. This is an updated
version of #9175. Rebase required fixing the tests, updating the ABI of
libzfs, updating the man pages, fixing bugs, fixing the error returns,
and updating the old on-disk error logs to the new format when
activating the feature.
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Co-authored-by: TulsiJain <tulsi.jain@delphix.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #9175
Closes #12812
2022-04-26 00:25:42 +00:00
|
|
|
extern void spa_delete_dataset_errlog(spa_t *spa, uint64_t ds, dmu_tx_t *tx);
|
|
|
|
extern void spa_swap_errlog(spa_t *spa, uint64_t new_head_ds,
|
|
|
|
uint64_t old_head_ds, dmu_tx_t *tx);
|
|
|
|
extern void sync_error_list(spa_t *spa, avl_tree_t *t, uint64_t *obj,
|
|
|
|
dmu_tx_t *tx);
|
|
|
|
extern void spa_upgrade_errlog(spa_t *spa, dmu_tx_t *tx);
|
2021-12-17 20:35:28 +00:00
|
|
|
extern int find_top_affected_fs(spa_t *spa, uint64_t head_ds,
|
|
|
|
zbookmark_err_phys_t *zep, uint64_t *top_affected_fs);
|
|
|
|
extern int find_birth_txg(struct dsl_dataset *ds, zbookmark_err_phys_t *zep,
|
|
|
|
uint64_t *birth_txg);
|
|
|
|
extern void zep_to_zb(uint64_t dataset, zbookmark_err_phys_t *zep,
|
|
|
|
zbookmark_phys_t *zb);
|
|
|
|
extern void name_to_errphys(char *buf, zbookmark_err_phys_t *zep);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2017-08-04 10:23:10 +00:00
|
|
|
/* vdev mirror */
|
|
|
|
extern void vdev_mirror_stat_init(void);
|
|
|
|
extern void vdev_mirror_stat_fini(void);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/* Initialization and termination */
|
2019-11-21 17:32:57 +00:00
|
|
|
extern void spa_init(spa_mode_t mode);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_fini(void);
|
2010-08-26 16:52:41 +00:00
|
|
|
extern void spa_boot_init(void);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
extern int spa_prop_set(spa_t *spa, nvlist_t *nvp);
|
|
|
|
extern int spa_prop_get(spa_t *spa, nvlist_t **nvp);
|
2024-07-26 16:16:18 +00:00
|
|
|
extern int spa_prop_get_nvlist(spa_t *spa, char **props,
|
|
|
|
unsigned int n_props, nvlist_t **outnvl);
|
2008-11-20 20:01:55 +00:00
|
|
|
extern void spa_prop_clear_bootfs(spa_t *spa, uint64_t obj, dmu_tx_t *tx);
|
2009-02-18 20:51:31 +00:00
|
|
|
extern void spa_configfile_set(spa_t *, nvlist_t *, boolean_t);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* asynchronous event notification */
|
2017-05-30 18:39:17 +00:00
|
|
|
extern void spa_event_notify(spa_t *spa, vdev_t *vdev, nvlist_t *hist_nvl,
|
|
|
|
const char *name);
|
2021-09-09 17:44:21 +00:00
|
|
|
extern void zfs_ereport_zvol_post(const char *subclass, const char *name,
|
|
|
|
const char *device_name, const char *raw_name);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
Add subcommand to wait for background zfs activity to complete
Currently the best way to wait for the completion of a long-running
operation in a pool, like a scrub or device removal, is to poll 'zpool
status' and parse its output, which is neither efficient nor convenient.
This change adds a 'wait' subcommand to the zpool command. When invoked,
'zpool wait' will block until a specified type of background activity
completes. Currently, this subcommand can wait for any of the following:
- Scrubs or resilvers to complete
- Devices to initialized
- Devices to be replaced
- Devices to be removed
- Checkpoints to be discarded
- Background freeing to complete
For example, a scrub that is in progress could be waited for by running
zpool wait -t scrub <pool>
This also adds a -w flag to the attach, checkpoint, initialize, replace,
remove, and scrub subcommands. When used, this flag makes the operations
kicked off by these subcommands synchronous instead of asynchronous.
This functionality is implemented using a new ioctl. The type of
activity to wait for is provided as input to the ioctl, and the ioctl
blocks until all activity of that type has completed. An ioctl was used
over other methods of kernel-userspace communiction primarily for the
sake of portability.
Porting Notes:
This is ported from Delphix OS change DLPX-44432. The following changes
were made while porting:
- Added ZoL-style ioctl input declaration.
- Reorganized error handling in zpool_initialize in libzfs to integrate
better with changes made for TRIM support.
- Fixed check for whether a checkpoint discard is in progress.
Previously it also waited if the pool had a checkpoint, instead of
just if a checkpoint was being discarded.
- Exposed zfs_initialize_chunk_size as a ZoL-style tunable.
- Updated more existing tests to make use of new 'zpool wait'
functionality, tests that don't exist in Delphix OS.
- Used existing ZoL tunable zfs_scan_suspend_progress, together with
zinject, in place of a new tunable zfs_scan_max_blks_per_txg.
- Added support for a non-integral interval argument to zpool wait.
Future work:
ZoL has support for trimming devices, which Delphix OS does not. In the
future, 'zpool wait' could be extended to add the ability to wait for
trim operations to complete.
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Gallagher <john.gallagher@delphix.com>
Closes #9162
2019-09-14 01:09:06 +00:00
|
|
|
/* waiting for pool activities to complete */
|
|
|
|
extern int spa_wait(const char *pool, zpool_wait_activity_t activity,
|
|
|
|
boolean_t *waited);
|
|
|
|
extern int spa_wait_tag(const char *name, zpool_wait_activity_t activity,
|
|
|
|
uint64_t tag, boolean_t *waited);
|
|
|
|
extern void spa_notify_waiters(spa_t *spa);
|
|
|
|
extern void spa_wake_waiters(spa_t *spa);
|
|
|
|
|
2022-02-15 23:54:25 +00:00
|
|
|
extern void spa_import_os(spa_t *spa);
|
|
|
|
extern void spa_export_os(spa_t *spa);
|
|
|
|
extern void spa_activate_os(spa_t *spa);
|
|
|
|
extern void spa_deactivate_os(spa_t *spa);
|
|
|
|
|
2019-10-31 16:52:22 +00:00
|
|
|
/* module param call functions */
|
2020-04-07 17:06:22 +00:00
|
|
|
int param_set_deadman_ziotime(ZFS_MODULE_PARAM_ARGS);
|
|
|
|
int param_set_deadman_synctime(ZFS_MODULE_PARAM_ARGS);
|
|
|
|
int param_set_slop_shift(ZFS_MODULE_PARAM_ARGS);
|
|
|
|
int param_set_deadman_failmode(ZFS_MODULE_PARAM_ARGS);
|
2023-09-02 01:00:30 +00:00
|
|
|
int param_set_active_allocator(ZFS_MODULE_PARAM_ARGS);
|
2019-10-31 16:52:22 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#ifdef ZFS_DEBUG
|
2014-11-21 00:09:39 +00:00
|
|
|
#define dprintf_bp(bp, fmt, ...) do { \
|
|
|
|
if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
|
|
|
|
char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP); \
|
|
|
|
snprintf_blkptr(__blkbuf, BP_SPRINTF_LEN, (bp)); \
|
|
|
|
dprintf(fmt " %s\n", __VA_ARGS__, __blkbuf); \
|
|
|
|
kmem_free(__blkbuf, BP_SPRINTF_LEN); \
|
2008-11-20 20:01:55 +00:00
|
|
|
} \
|
2021-06-05 14:02:41 +00:00
|
|
|
} while (0)
|
2008-11-20 20:01:55 +00:00
|
|
|
#else
|
|
|
|
#define dprintf_bp(bp, fmt, ...)
|
|
|
|
#endif
|
|
|
|
|
2019-11-21 17:32:57 +00:00
|
|
|
extern spa_mode_t spa_mode_global;
|
2017-12-18 22:06:07 +00:00
|
|
|
extern int zfs_deadman_enabled;
|
Cleanup: 64-bit kernel module parameters should use fixed width types
Various module parameters such as `zfs_arc_max` were originally
`uint64_t` on OpenSolaris/Illumos, but were changed to `unsigned long`
for Linux compatibility because Linux's kernel default module parameter
implementation did not support 64-bit types on 32-bit platforms. This
caused problems when porting OpenZFS to Windows because its LLP64 memory
model made `unsigned long` a 32-bit type on 64-bit, which created the
undesireable situation that parameters that should accept 64-bit values
could not on 64-bit Windows.
Upon inspection, it turns out that the Linux kernel module parameter
interface is extensible, such that we are allowed to define our own
types. Rather than maintaining the original type change via hacks to to
continue shrinking module parameters on 32-bit Linux, we implement
support for 64-bit module parameters on Linux.
After doing a review of all 64-bit kernel parameters (found via the man
page and also proposed changes by Andrew Innes), the kernel module
parameters fell into a few groups:
Parameters that were originally 64-bit on Illumos:
* dbuf_cache_max_bytes
* dbuf_metadata_cache_max_bytes
* l2arc_feed_min_ms
* l2arc_feed_secs
* l2arc_headroom
* l2arc_headroom_boost
* l2arc_write_boost
* l2arc_write_max
* metaslab_aliquot
* metaslab_force_ganging
* zfetch_array_rd_sz
* zfs_arc_max
* zfs_arc_meta_limit
* zfs_arc_meta_min
* zfs_arc_min
* zfs_async_block_max_blocks
* zfs_condense_max_obsolete_bytes
* zfs_condense_min_mapping_bytes
* zfs_deadman_checktime_ms
* zfs_deadman_synctime_ms
* zfs_initialize_chunk_size
* zfs_initialize_value
* zfs_lua_max_instrlimit
* zfs_lua_max_memlimit
* zil_slog_bulk
Parameters that were originally 32-bit on Illumos:
* zfs_per_txg_dirty_frees_percent
Parameters that were originally `ssize_t` on Illumos:
* zfs_immediate_write_sz
Note that `ssize_t` is `int32_t` on 32-bit and `int64_t` on 64-bit. It
has been upgraded to 64-bit.
Parameters that were `long`/`unsigned long` because of Linux/FreeBSD
influence:
* l2arc_rebuild_blocks_min_l2size
* zfs_key_max_salt_uses
* zfs_max_log_walking
* zfs_max_logsm_summary_length
* zfs_metaslab_max_size_cache_sec
* zfs_min_metaslabs_to_flush
* zfs_multihost_interval
* zfs_unflushed_log_block_max
* zfs_unflushed_log_block_min
* zfs_unflushed_log_block_pct
* zfs_unflushed_max_mem_amt
* zfs_unflushed_max_mem_ppm
New parameters that do not exist in Illumos:
* l2arc_trim_ahead
* vdev_file_logical_ashift
* vdev_file_physical_ashift
* zfs_arc_dnode_limit
* zfs_arc_dnode_limit_percent
* zfs_arc_dnode_reduce_percent
* zfs_arc_meta_limit_percent
* zfs_arc_sys_free
* zfs_deadman_ziotime_ms
* zfs_delete_blocks
* zfs_history_output_max
* zfs_livelist_max_entries
* zfs_max_async_dedup_frees
* zfs_max_nvlist_src_size
* zfs_rebuild_max_segment
* zfs_rebuild_vdev_limit
* zfs_unflushed_log_txg_max
* zfs_vdev_max_auto_ashift
* zfs_vdev_min_auto_ashift
* zfs_vnops_read_chunk_size
* zvol_max_discard_blocks
Rather than clutter the lists with commentary, the module parameters
that need comments are repeated below.
A few parameters were defined in Linux/FreeBSD specific code, where the
use of ulong/long is not an issue for portability, so we leave them
alone:
* zfs_delete_blocks
* zfs_key_max_salt_uses
* zvol_max_discard_blocks
The documentation for a few parameters was found to be incorrect:
* zfs_deadman_checktime_ms - incorrectly documented as int
* zfs_delete_blocks - not documented as Linux only
* zfs_history_output_max - incorrectly documented as int
* zfs_vnops_read_chunk_size - incorrectly documented as long
* zvol_max_discard_blocks - incorrectly documented as ulong
The documentation for these has been fixed, alongside the changes to
document the switch to fixed width types.
In addition, several kernel module parameters were percentages or held
ashift values, so being 64-bit never made sense for them. They have been
downgraded to 32-bit:
* vdev_file_logical_ashift
* vdev_file_physical_ashift
* zfs_arc_dnode_limit_percent
* zfs_arc_dnode_reduce_percent
* zfs_arc_meta_limit_percent
* zfs_per_txg_dirty_frees_percent
* zfs_unflushed_log_block_pct
* zfs_vdev_max_auto_ashift
* zfs_vdev_min_auto_ashift
Of special note are `zfs_vdev_max_auto_ashift` and
`zfs_vdev_min_auto_ashift`, which were already defined as `uint64_t`,
and passed to the kernel as `ulong`. This is inherently buggy on big
endian 32-bit Linux, since the values would not be written to the
correct locations. 32-bit FreeBSD was unaffected because its sysctl code
correctly treated this as a `uint64_t`.
Lastly, a code comment suggests that `zfs_arc_sys_free` is
Linux-specific, but there is nothing to indicate to me that it is
Linux-specific. Nothing was done about that.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Original-patch-by: Andrew Innes <andrew.c12@gmail.com>
Original-patch-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13984
Closes #14004
2022-10-03 19:06:54 +00:00
|
|
|
extern uint64_t zfs_deadman_synctime_ms;
|
|
|
|
extern uint64_t zfs_deadman_ziotime_ms;
|
|
|
|
extern uint64_t zfs_deadman_checktime_ms;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2022-01-14 23:37:55 +00:00
|
|
|
extern kmem_cache_t *zio_buf_cache[];
|
|
|
|
extern kmem_cache_t *zio_data_buf_cache[];
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SYS_SPA_H */
|