Skip to content

Commit b439a5d

Browse files
committed
Updating based on PR Feedback(5)
1. Added new module parameter zfs_dio_enabled which allows for all reads and writes to pass through the ARC. This module parameter can be set to 0 by default in OpenZFS 2.3 release if necessary. 2. Updated ZTS direct tests to account for the new zfs_dio_enabled module parameter. 3. Updated libzfs.abi to account for changes. 4. The recently merged commit 82ff9aa added a pretty printer for ZIO pipeline stages and zio flags. I updated zfs_valstr.c to account for the added ZIO pipeline stage ZIO_STAGE_DIO_CHECKSUM_VERIFY as well as the zio flag ZIO_FLAG_DIO_CHKSUM_ERR that we added in the Direct I/O code. Signed-off-by: Brian Atkinson <[email protected]>
1 parent db97936 commit b439a5d

File tree

7 files changed

+5228
-2230
lines changed

7 files changed

+5228
-2230
lines changed

lib/libzfs/libzfs.abi

Lines changed: 5193 additions & 2228 deletions
Large diffs are not rendered by default.

man/man4/zfs.4

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ Default dnode block size as a power of 2.
291291
.It Sy zfs_default_ibs Ns = Ns Sy 17 Po 128 KiB Pc Pq int
292292
Default dnode indirect block size as a power of 2.
293293
.
294+
.It Sy zfs_dio_enabled Ns = Ns Sy 0 Ns | Ns 1 Pq int
295+
Enable Direct I/O.
296+
If this setting is 0, then all I/O requests will be directed through the ARC
297+
acting as though the dataset property
298+
.Sy direct
299+
was set to
300+
.Sy disabled .
301+
.
294302
.It Sy zfs_history_output_max Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq u64
295303
When attempting to log an output nvlist of an ioctl in the on-disk history,
296304
the output will not be stored if it is larger than this size (in bytes).

module/zcommon/zfs_valstr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ _VALSTR_BITFIELD_IMPL(zio_flag,
218218
{ '.', "NP", "NOPWRITE" },
219219
{ '.', "EX", "REEXECUTED" },
220220
{ '.', "DG", "DELEGATED" },
221+
{ '.', "DC", "DIO_CHKSUM_ERR" },
221222
)
222223
/* END CSTYLED */
223224

@@ -252,6 +253,7 @@ _VALSTR_BITFIELD_IMPL(zio_stage,
252253
{ 'V', "VD", "VDEV_IO_DONE" },
253254
{ 'V', "VA", "VDEV_IO_ASSESS" },
254255
{ 'C', "CV", "CHECKSUM_VERIFY" },
256+
{ 'C', "DC", "DIO_CHECKSUM_VERIFY" },
255257
{ 'X', "X ", "DONE" },
256258
)
257259
/* END CSTYLED */

module/zfs/zfs_vnops.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ int zfs_bclone_enabled = 1;
7474
*/
7575
static int zfs_bclone_wait_dirty = 0;
7676

77+
/*
78+
* Enable Direct I/O. If this setting is 0, then all I/O requests will be
79+
* directed through the ARC acting as though the dataset property direct was
80+
* set to disabled.
81+
*/
82+
static int zfs_dio_enabled = 1;
83+
84+
7785
/*
7886
* Maximum bytes to read per chunk in zfs_read().
7987
*/
@@ -227,7 +235,7 @@ zfs_setup_direct(struct znode *zp, zfs_uio_t *uio, zfs_uio_rw_t rw,
227235
int ioflag = *ioflagp;
228236
int error = 0;
229237

230-
if (os->os_direct == ZFS_DIRECT_DISABLED ||
238+
if (!zfs_dio_enabled || os->os_direct == ZFS_DIRECT_DISABLED ||
231239
zn_has_cached_data(zp, zfs_uio_offset(uio),
232240
zfs_uio_offset(uio) + zfs_uio_resid(uio) - 1)) {
233241
/*
@@ -1805,3 +1813,6 @@ ZFS_MODULE_PARAM(zfs, zfs_, bclone_enabled, INT, ZMOD_RW,
18051813

18061814
ZFS_MODULE_PARAM(zfs, zfs_, bclone_wait_dirty, INT, ZMOD_RW,
18071815
"Wait for dirty blocks when cloning");
1816+
1817+
ZFS_MODULE_PARAM(zfs, zfs_, dio_enabled, INT, ZMOD_RW,
1818+
"Enable Direct I/O");

tests/zfs-tests/include/tunables.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ VOL_RECURSIVE vol.recursive UNSUPPORTED
101101
VOL_USE_BLK_MQ UNSUPPORTED zvol_use_blk_mq
102102
BCLONE_ENABLED bclone_enabled zfs_bclone_enabled
103103
BCLONE_WAIT_DIRTY bclone_wait_dirty zfs_bclone_wait_dirty
104+
DIO_ENABLED dio_enabled zfs_dio_enabled
104105
XATTR_COMPAT xattr_compat zfs_xattr_compat
105106
ZEVENT_LEN_MAX zevent.len_max zfs_zevent_len_max
106107
ZEVENT_RETAIN_MAX zevent.retain_max zfs_zevent_retain_max

tests/zfs-tests/tests/functional/direct/cleanup.ksh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@
2828

2929
verify_runnable "global"
3030

31-
default_cleanup
31+
default_cleanup_noexit
32+
33+
if tunable_exists DIO_ENABLED ; then
34+
log_must restore_tunable DIO_ENABLED
35+
fi
36+
37+
log_pass

tests/zfs-tests/tests/functional/direct/setup.ksh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
. $STF_SUITE/include/libtest.shlib
2828
verify_runnable "global"
2929

30+
if tunable_exists DIO_ENABLED ; then
31+
log_must save_tunable DIO_ENABLED
32+
log_must set_tunable32 DIO_ENABLED 1
33+
fi
34+
3035
default_raidz_setup_noexit "$DISKS"
3136
log_must zfs set compression=off $TESTPOOL/$TESTFS
3237
log_pass

0 commit comments

Comments
 (0)