2008-11-20 23:01:55 +03: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-12 00:16:13 +03:00
|
|
|
* or https://opensource.org/licenses/CDDL-1.0.
|
2008-11-20 23:01:55 +03: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
|
|
|
|
*/
|
|
|
|
/*
|
2009-07-03 02:44:48 +04:00
|
|
|
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
2008-11-20 23:01:55 +03:00
|
|
|
* Use is subject to license terms.
|
|
|
|
*/
|
|
|
|
|
2020-09-04 20:34:28 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 by Delphix. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
#ifndef _SYS_FM_FS_ZFS_H
|
|
|
|
#define _SYS_FM_FS_ZFS_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ZFS_ERROR_CLASS "fs.zfs"
|
|
|
|
|
|
|
|
#define FM_EREPORT_ZFS_CHECKSUM "checksum"
|
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 20:36:48 +03:00
|
|
|
#define FM_EREPORT_ZFS_AUTHENTICATION "authentication"
|
2008-11-20 23:01:55 +03:00
|
|
|
#define FM_EREPORT_ZFS_IO "io"
|
|
|
|
#define FM_EREPORT_ZFS_DATA "data"
|
2010-10-02 03:54:52 +04:00
|
|
|
#define FM_EREPORT_ZFS_DELAY "delay"
|
2017-12-19 01:06:07 +03:00
|
|
|
#define FM_EREPORT_ZFS_DEADMAN "deadman"
|
Adding Direct IO Support
Adding O_DIRECT support to ZFS to bypass the ARC for writes/reads.
O_DIRECT support in ZFS will always ensure there is coherency between
buffered and O_DIRECT IO requests. This ensures that all IO requests,
whether buffered or direct, will see the same file contents at all
times. Just as in other FS's , O_DIRECT does not imply O_SYNC. While
data is written directly to VDEV disks, metadata will not be synced
until the associated TXG is synced.
For both O_DIRECT read and write request the offset and request sizes,
at a minimum, must be PAGE_SIZE aligned. In the event they are not,
then EINVAL is returned unless the direct property is set to always (see
below).
For O_DIRECT writes:
The request also must be block aligned (recordsize) or the write
request will take the normal (buffered) write path. In the event that
request is block aligned and a cached copy of the buffer in the ARC,
then it will be discarded from the ARC forcing all further reads to
retrieve the data from disk.
For O_DIRECT reads:
The only alignment restrictions are PAGE_SIZE alignment. In the event
that the requested data is in buffered (in the ARC) it will just be
copied from the ARC into the user buffer.
For both O_DIRECT writes and reads the O_DIRECT flag will be ignored in
the event that file contents are mmap'ed. In this case, all requests
that are at least PAGE_SIZE aligned will just fall back to the buffered
paths. If the request however is not PAGE_SIZE aligned, EINVAL will
be returned as always regardless if the file's contents are mmap'ed.
Since O_DIRECT writes go through the normal ZIO pipeline, the
following operations are supported just as with normal buffered writes:
Checksum
Compression
Encryption
Erasure Coding
There is one caveat for the data integrity of O_DIRECT writes that is
distinct for each of the OS's supported by ZFS.
FreeBSD - FreeBSD is able to place user pages under write protection so
any data in the user buffers and written directly down to the
VDEV disks is guaranteed to not change. There is no concern
with data integrity and O_DIRECT writes.
Linux - Linux is not able to place anonymous user pages under write
protection. Because of this, if the user decides to manipulate
the page contents while the write operation is occurring, data
integrity can not be guaranteed. However, there is a module
parameter `zfs_vdev_direct_write_verify` that controls the
if a O_DIRECT writes that can occur to a top-level VDEV before
a checksum verify is run before the contents of the I/O buffer
are committed to disk. In the event of a checksum verification
failure the write will return EIO. The number of O_DIRECT write
checksum verification errors can be observed by doing
`zpool status -d`, which will list all verification errors that
have occurred on a top-level VDEV. Along with `zpool status`, a
ZED event will be issues as `dio_verify` when a checksum
verification error occurs.
ZVOLs and dedup is not currently supported with Direct I/O.
A new dataset property `direct` has been added with the following 3
allowable values:
disabled - Accepts O_DIRECT flag, but silently ignores it and treats
the request as a buffered IO request.
standard - Follows the alignment restrictions outlined above for
write/read IO requests when the O_DIRECT flag is used.
always - Treats every write/read IO request as though it passed
O_DIRECT and will do O_DIRECT if the alignment restrictions
are met otherwise will redirect through the ARC. This
property will not allow a request to fail.
There is also a module parameter zfs_dio_enabled that can be used to
force all reads and writes through the ARC. By setting this module
parameter to 0, it mimics as if the direct dataset property is set to
disabled.
Reviewed-by: Brian Behlendorf <behlendorf@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Co-authored-by: Mark Maybee <mark.maybee@delphix.com>
Co-authored-by: Matt Macy <mmacy@FreeBSD.org>
Co-authored-by: Brian Behlendorf <behlendorf@llnl.gov>
Closes #10018
2024-09-14 23:47:59 +03:00
|
|
|
#define FM_EREPORT_ZFS_DIO_VERIFY "dio_verify"
|
2008-11-20 23:01:55 +03:00
|
|
|
#define FM_EREPORT_ZFS_POOL "zpool"
|
|
|
|
#define FM_EREPORT_ZFS_DEVICE_UNKNOWN "vdev.unknown"
|
|
|
|
#define FM_EREPORT_ZFS_DEVICE_OPEN_FAILED "vdev.open_failed"
|
|
|
|
#define FM_EREPORT_ZFS_DEVICE_CORRUPT_DATA "vdev.corrupt_data"
|
|
|
|
#define FM_EREPORT_ZFS_DEVICE_NO_REPLICAS "vdev.no_replicas"
|
|
|
|
#define FM_EREPORT_ZFS_DEVICE_BAD_GUID_SUM "vdev.bad_guid_sum"
|
|
|
|
#define FM_EREPORT_ZFS_DEVICE_TOO_SMALL "vdev.too_small"
|
|
|
|
#define FM_EREPORT_ZFS_DEVICE_BAD_LABEL "vdev.bad_label"
|
2012-05-03 16:49:19 +04:00
|
|
|
#define FM_EREPORT_ZFS_DEVICE_BAD_ASHIFT "vdev.bad_ashift"
|
2008-12-03 23:09:06 +03:00
|
|
|
#define FM_EREPORT_ZFS_IO_FAILURE "io_failure"
|
|
|
|
#define FM_EREPORT_ZFS_PROBE_FAILURE "probe_failure"
|
|
|
|
#define FM_EREPORT_ZFS_LOG_REPLAY "log_replay"
|
2015-12-31 19:38:59 +03:00
|
|
|
#define FM_EREPORT_ZFS_CONFIG_CACHE_WRITE "config_cache_write"
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_POOL "pool"
|
2008-12-03 23:09:06 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE "pool_failmode"
|
2008-11-20 23:01:55 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_POOL_GUID "pool_guid"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT "pool_context"
|
2017-04-04 00:23:02 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_POOL_STATE "pool_state"
|
2008-11-20 23:01:55 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID "vdev_guid"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_TYPE "vdev_type"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH "vdev_path"
|
2016-09-01 00:46:58 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_PHYSPATH "vdev_physpath"
|
2016-10-24 20:45:59 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path"
|
2008-11-20 23:01:55 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_DEVID "vdev_devid"
|
2009-07-03 02:44:48 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_FRU "vdev_fru"
|
2010-08-26 22:42:43 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_STATE "vdev_state"
|
2016-09-01 00:46:58 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_LASTSTATE "vdev_laststate"
|
2012-05-03 16:49:19 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_ASHIFT "vdev_ashift"
|
2013-04-30 02:49:23 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_COMP_TS "vdev_complete_ts"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_DELTA_TS "vdev_delta_ts"
|
2014-01-25 03:47:46 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_SPARE_PATHS "vdev_spare_paths"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_SPARE_GUIDS "vdev_spare_guids"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_READ_ERRORS "vdev_read_errors"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_WRITE_ERRORS "vdev_write_errors"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_CKSUM_ERRORS "vdev_cksum_errors"
|
2023-01-24 00:14:25 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_CKSUM_N "vdev_cksum_n"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_CKSUM_T "vdev_cksum_t"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_IO_N "vdev_io_n"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_IO_T "vdev_io_t"
|
2024-02-08 20:19:52 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_SLOW_IO_N "vdev_slow_io_n"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_SLOW_IO_T "vdev_slow_io_t"
|
Adding Direct IO Support
Adding O_DIRECT support to ZFS to bypass the ARC for writes/reads.
O_DIRECT support in ZFS will always ensure there is coherency between
buffered and O_DIRECT IO requests. This ensures that all IO requests,
whether buffered or direct, will see the same file contents at all
times. Just as in other FS's , O_DIRECT does not imply O_SYNC. While
data is written directly to VDEV disks, metadata will not be synced
until the associated TXG is synced.
For both O_DIRECT read and write request the offset and request sizes,
at a minimum, must be PAGE_SIZE aligned. In the event they are not,
then EINVAL is returned unless the direct property is set to always (see
below).
For O_DIRECT writes:
The request also must be block aligned (recordsize) or the write
request will take the normal (buffered) write path. In the event that
request is block aligned and a cached copy of the buffer in the ARC,
then it will be discarded from the ARC forcing all further reads to
retrieve the data from disk.
For O_DIRECT reads:
The only alignment restrictions are PAGE_SIZE alignment. In the event
that the requested data is in buffered (in the ARC) it will just be
copied from the ARC into the user buffer.
For both O_DIRECT writes and reads the O_DIRECT flag will be ignored in
the event that file contents are mmap'ed. In this case, all requests
that are at least PAGE_SIZE aligned will just fall back to the buffered
paths. If the request however is not PAGE_SIZE aligned, EINVAL will
be returned as always regardless if the file's contents are mmap'ed.
Since O_DIRECT writes go through the normal ZIO pipeline, the
following operations are supported just as with normal buffered writes:
Checksum
Compression
Encryption
Erasure Coding
There is one caveat for the data integrity of O_DIRECT writes that is
distinct for each of the OS's supported by ZFS.
FreeBSD - FreeBSD is able to place user pages under write protection so
any data in the user buffers and written directly down to the
VDEV disks is guaranteed to not change. There is no concern
with data integrity and O_DIRECT writes.
Linux - Linux is not able to place anonymous user pages under write
protection. Because of this, if the user decides to manipulate
the page contents while the write operation is occurring, data
integrity can not be guaranteed. However, there is a module
parameter `zfs_vdev_direct_write_verify` that controls the
if a O_DIRECT writes that can occur to a top-level VDEV before
a checksum verify is run before the contents of the I/O buffer
are committed to disk. In the event of a checksum verification
failure the write will return EIO. The number of O_DIRECT write
checksum verification errors can be observed by doing
`zpool status -d`, which will list all verification errors that
have occurred on a top-level VDEV. Along with `zpool status`, a
ZED event will be issues as `dio_verify` when a checksum
verification error occurs.
ZVOLs and dedup is not currently supported with Direct I/O.
A new dataset property `direct` has been added with the following 3
allowable values:
disabled - Accepts O_DIRECT flag, but silently ignores it and treats
the request as a buffered IO request.
standard - Follows the alignment restrictions outlined above for
write/read IO requests when the O_DIRECT flag is used.
always - Treats every write/read IO request as though it passed
O_DIRECT and will do O_DIRECT if the alignment restrictions
are met otherwise will redirect through the ARC. This
property will not allow a request to fail.
There is also a module parameter zfs_dio_enabled that can be used to
force all reads and writes through the ARC. By setting this module
parameter to 0, it mimics as if the direct dataset property is set to
disabled.
Reviewed-by: Brian Behlendorf <behlendorf@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Co-authored-by: Mark Maybee <mark.maybee@delphix.com>
Co-authored-by: Matt Macy <mmacy@FreeBSD.org>
Co-authored-by: Brian Behlendorf <behlendorf@llnl.gov>
Closes #10018
2024-09-14 23:47:59 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_DIO_VERIFY_ERRORS "dio_verify_errors"
|
2018-11-09 03:47:24 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_DELAYS "vdev_delays"
|
2008-11-20 23:01:55 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_PARENT_GUID "parent_guid"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_PARENT_TYPE "parent_type"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_PARENT_PATH "parent_path"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_PARENT_DEVID "parent_devid"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJSET "zio_objset"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJECT "zio_object"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_LEVEL "zio_level"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_BLKID "zio_blkid"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR "zio_err"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_OFFSET "zio_offset"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_SIZE "zio_size"
|
2010-09-28 03:55:05 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_FLAGS "zio_flags"
|
2012-10-26 00:02:31 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_STAGE "zio_stage"
|
2020-09-04 20:34:28 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_PRIORITY "zio_priority"
|
2012-10-26 00:02:31 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_PIPELINE "zio_pipeline"
|
2010-10-02 03:54:52 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_DELAY "zio_delay"
|
2013-04-30 02:49:23 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_TIMESTAMP "zio_timestamp"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_ZIO_DELTA "zio_delta"
|
2008-11-20 23:01:55 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_PREV_STATE "prev_state"
|
2010-05-29 00:45:14 +04:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_CKSUM_ALGO "cksum_algorithm"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_CKSUM_BYTESWAP "cksum_byteswap"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_BAD_OFFSET_RANGES "bad_ranges"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_MIN_GAP "bad_ranges_min_gap"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_SETS "bad_range_sets"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_CLEARS "bad_range_clears"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_BAD_SET_BITS "bad_set_bits"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_BAD_CLEARED_BITS "bad_cleared_bits"
|
2021-09-09 20:44:21 +03:00
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_SNAPSHOT_NAME "snapshot_name"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_DEVICE_NAME "device_name"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_RAW_DEVICE_NAME "raw_name"
|
|
|
|
#define FM_EREPORT_PAYLOAD_ZFS_VOLUME "volume"
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2008-12-03 23:09:06 +03:00
|
|
|
#define FM_EREPORT_FAILMODE_WAIT "wait"
|
|
|
|
#define FM_EREPORT_FAILMODE_CONTINUE "continue"
|
|
|
|
#define FM_EREPORT_FAILMODE_PANIC "panic"
|
|
|
|
|
2016-07-28 01:29:15 +03:00
|
|
|
#define FM_RESOURCE_REMOVED "removed"
|
|
|
|
#define FM_RESOURCE_AUTOREPLACE "autoreplace"
|
|
|
|
#define FM_RESOURCE_STATECHANGE "statechange"
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2021-09-09 20:44:21 +03:00
|
|
|
#define FM_RESOURCE_ZFS_SNAPSHOT_MOUNT "snapshot_mount"
|
|
|
|
#define FM_RESOURCE_ZFS_SNAPSHOT_UNMOUNT "snapshot_unmount"
|
|
|
|
#define FM_RESOURCE_ZVOL_CREATE_SYMLINK "zvol_create"
|
|
|
|
#define FM_RESOURCE_ZVOL_REMOVE_SYMLINK "zvol_remove"
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SYS_FM_FS_ZFS_H */
|