mirror_zfs/man/man8
Brian Atkinson a10e552b99
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 13:47:59 -07:00
..
.gitignore Add zfs_prepare_disk script for disk firmware install 2023-09-21 08:36:26 -07:00
fsck.zfs.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
mount.zfs.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
vdev_id.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zdb.8 Fix a mis-merge in the zdb man page (#16304) 2024-06-28 10:38:22 -07:00
zed.8.in Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs_ids_to_path.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_prepare_disk.8.in Add zfs_prepare_disk script for disk firmware install 2023-09-21 08:36:26 -07:00
zfs-allow.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs-bookmark.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-change-key.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-clone.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-create.8 zfs-create(8): ZFS for swap: caution, clarity 2023-06-02 11:25:13 -07:00
zfs-destroy.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-diff.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-get.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-groupspace.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-hold.8 Adds the -p option to zfs holds 2022-11-08 10:08:21 -08:00
zfs-inherit.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-jail.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs-list.8 JSON output support for zfs list 2024-08-06 12:46:34 -07:00
zfs-load-key.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs-mount-generator.8.in Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs-mount.8 JSON output support zfs mount 2024-08-06 12:46:40 -07:00
zfs-program.8 Add zfs.sync.snapshot_rename 2022-09-02 13:31:19 -07:00
zfs-project.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs-projectspace.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-promote.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs-receive.8 Improve tests and update man page for healing recv 2023-03-15 10:34:10 -07:00
zfs-recv.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-redact.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-release.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-rename.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-rollback.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-send.8 libzfs: sendrecv: send_progress_thread: handle SIGINFO/SIGUSR1 2023-08-08 09:35:35 -07:00
zfs-set.8 JSON output support for zfs version and zfs get 2024-08-06 12:45:45 -07:00
zfs-share.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-snapshot.8 Update zfs-snapshot.8 2024-02-08 13:06:12 -08:00
zfs-unallow.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-unjail.8 Add FreeBSD jail support hooks 2019-12-11 11:58:37 -08:00
zfs-unload-key.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-unmount.8 Reorganize zfs(8) man page into sections 2019-11-12 11:17:40 -08:00
zfs-unzone.8 Add Linux namespace delegation support 2022-06-10 09:51:46 -07:00
zfs-upgrade.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-userspace.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zfs-wait.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs-zone.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs.8 JSON output support for zfs version and zfs get 2024-08-06 12:45:45 -07:00
zgenhostid.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zinject.8 Parallel pool import 2024-04-22 09:42:38 -07:00
zpool_influxdb.8 Consistentify miscellaneous style on remaining manpages 2021-06-09 14:35:53 -07:00
zpool-add.8 Add ashift validation when adding devices to a pool 2024-03-29 13:15:56 -06:00
zpool-attach.8 RAID-Z expansion feature 2023-11-08 10:19:41 -08:00
zpool-checkpoint.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-clear.8 vdev probe to slow disk can stall mmp write checker 2024-04-29 14:35:53 -07:00
zpool-create.8 Remove unnecessary commas in zpool-create.8 2023-06-27 16:58:32 -07:00
zpool-ddtprune.8 Add DDT prune command 2024-09-04 14:17:02 -07:00
zpool-destroy.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-detach.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-events.8 Adding Direct IO Support 2024-09-14 13:47:59 -07:00
zpool-export.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zpool-get.8 JSON output support for zpool get 2024-08-06 12:47:00 -07:00
zpool-history.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-import.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-initialize.8 Add the ability to uninitialize 2023-05-18 10:02:20 -07:00
zpool-iostat.8 Update man pages to time(1) from time(2) 2024-01-29 09:44:08 -08:00
zpool-labelclear.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-list.8 JSON output support for zpool list 2024-08-06 12:47:04 -07:00
zpool-offline.8 zpool: Add slot power control, print power status 2023-12-21 10:53:16 -08:00
zpool-online.8 Reorganize zpool(8) man page into sections 2019-11-13 09:21:07 -08:00
zpool-prefetch.8 ddt: add support for prefetching tables into the ARC 2024-07-26 09:16:18 -07:00
zpool-reguid.8 zpool: Provide GUID to zpool-reguid(8) with -g (#16239) 2024-08-26 09:27:24 -07:00
zpool-remove.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zpool-reopen.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-replace.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-resilver.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zpool-scrub.8 Do not report bytes skipped by scan as issued. 2023-06-30 08:47:13 -07:00
zpool-set.8 Reorganize zpool(8) man page into sections 2019-11-13 09:21:07 -08:00
zpool-split.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zpool-status.8 Adding Direct IO Support 2024-09-14 13:47:59 -07:00
zpool-sync.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-trim.8 Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool-upgrade.8 Ubuntu 22.04 integration: mancheck 2022-11-18 11:26:41 -08:00
zpool-wait.8 Update man pages to time(1) from time(2) 2024-01-29 09:44:08 -08:00
zpool.8 Add DDT prune command 2024-09-04 14:17:02 -07:00
zstream.8 Add ability to recompress send streams with new compression algorithm 2022-11-10 15:23:46 -08:00
zstreamdump.8 zstreamdump: replace with link to zstream 2021-05-21 10:16:14 -07:00