Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions config/kernel-ki_complete.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
dnl # SPDX-License-Identifier: CDDL-1.0
dnl #
dnl # 5.19 API change,
dnl # kiocb->ki_complete() reduced from 3 args to 2:
dnl # old: void (*ki_complete)(struct kiocb *, long, long)
dnl # new: void (*ki_complete)(struct kiocb *, long)
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_KIOCB_KI_COMPLETE], [
ZFS_LINUX_TEST_SRC([kiocb_ki_complete_2args], [
#include <linux/fs.h>
],[
struct kiocb *kiocb = NULL;
kiocb->ki_complete(kiocb, 0);
])
])

AC_DEFUN([ZFS_AC_KERNEL_KIOCB_KI_COMPLETE], [
AC_MSG_CHECKING([whether kiocb->ki_complete() wants 2 args])
ZFS_LINUX_TEST_RESULT([kiocb_ki_complete_2args], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_2ARGS_KI_COMPLETE, 1,
[kiocb->ki_complete() wants 2 args])
],[
AC_MSG_RESULT(no)
])
])
2 changes: 2 additions & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE
ZFS_AC_KERNEL_SRC_VFS_CLONE_FILE_RANGE
ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE
ZFS_AC_KERNEL_SRC_KIOCB_KI_COMPLETE
ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS
ZFS_AC_KERNEL_SRC_KMAP_LOCAL_PAGE
ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE
Expand Down Expand Up @@ -220,6 +221,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE
ZFS_AC_KERNEL_VFS_CLONE_FILE_RANGE
ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE
ZFS_AC_KERNEL_KIOCB_KI_COMPLETE
ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
ZFS_AC_KERNEL_KMAP_LOCAL_PAGE
ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
Expand Down
1 change: 1 addition & 0 deletions include/os/linux/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kernel_sysdir = $(kerneldir)/sys
kernel_sys_HEADERS = \
%D%/zfs/sys/abd_os.h \
%D%/zfs/sys/abd_impl_os.h \
%D%/zfs/sys/dmu_direct_os.h \
%D%/zfs/sys/policy.h \
%D%/zfs/sys/trace_acl.h \
%D%/zfs/sys/trace_arc.h \
Expand Down
63 changes: 63 additions & 0 deletions include/os/linux/zfs/sys/dmu_direct_os.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: CDDL-1.0
/*
* 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
* or https://opensource.org/licenses/CDDL-1.0.
* 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
*
* Copyright 2026, tiehexue <tiehexue@hotmail.com>. All rights reserved.
*
*/

#ifndef _SYS_DMU_OS_H
#define _SYS_DMU_OS_H

#include <sys/dmu.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
* Async Direct I/O completion callback type (shared by read and write).
*/
typedef void (dmu_abd_done_func_t)(void *arg, int error);

/*
* Async Direct I/O read. Submits reads via the ZIO pipeline and returns
* immediately. The completion callback fires from ZIO taskq context when
* all reads finish. Caller retains ownership of 'data' until callback.
*/
int dmu_read_abd_async(dnode_t *dn, uint64_t offset, uint64_t size,
abd_t *data, dmu_flags_t flags,
dmu_abd_done_func_t *done, void *done_arg);

/*
* Async Direct I/O write. Submits writes via the ZIO pipeline and returns
* immediately. The completion callback fires from ZIO taskq context when
* all writes finish. Caller retains ownership of 'data' until callback
* and must commit the transaction (tx) from the callback.
*/
int dmu_write_abd_async(dnode_t *dn, uint64_t offset, uint64_t size,
abd_t *data, dmu_flags_t flags, dmu_tx_t *tx,
dmu_abd_done_func_t *done, void *done_arg);

#ifdef __cplusplus
}
#endif

#endif /* _SYS_DMU_OS_H */
9 changes: 9 additions & 0 deletions include/os/linux/zfs/sys/zfs_vnops_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ extern int zfs_map(struct inode *ip, offset_t off, caddr_t *addrp,
size_t len, unsigned long vm_flags);
extern void zfs_zrele_async(znode_t *zp);

/* async Direct I/O */
struct kiocb;
extern int zfs_read_async(znode_t *zp, zfs_uio_t *uio, int ioflag, cred_t *cr,
struct kiocb *kiocb);
extern int zfs_write_async(znode_t *zp, zfs_uio_t *uio, int ioflag, cred_t *cr,
struct kiocb *kiocb);
extern void zfs_async_dio_init(void);
extern void zfs_async_dio_fini(void);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/sys/dmu_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ int dmu_write_direct(zio_t *, dmu_buf_impl_t *, abd_t *, dmu_tx_t *);
int dmu_read_abd(dnode_t *, uint64_t, uint64_t, abd_t *, dmu_flags_t);
int dmu_write_abd(dnode_t *, uint64_t, uint64_t, abd_t *, dmu_flags_t,
dmu_tx_t *);
abd_t *make_abd_for_dbuf(dmu_buf_impl_t *, abd_t *, uint64_t, uint64_t);
void dmu_read_abd_done(zio_t *);
#if defined(_KERNEL)
int dmu_read_uio_direct(dnode_t *, zfs_uio_t *, uint64_t, dmu_flags_t);
int dmu_write_uio_direct(dnode_t *, zfs_uio_t *, uint64_t, dmu_flags_t,
Expand Down
24 changes: 24 additions & 0 deletions include/sys/zfs_vnops.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,33 @@

extern int zfs_bclone_enabled;

/*
* Direct I/O tunables. zfs_dio_enabled can be set to 0 to force all
* I/O through the ARC; zfs_dio_strict returns EINVAL for unaligned
* DIO instead of falling back.
*/
extern int zfs_dio_enabled;
extern int zfs_dio_strict;

extern int zfs_fsync(znode_t *, int, cred_t *);
extern int zfs_read(znode_t *, zfs_uio_t *, int, cred_t *);
extern int zfs_write(znode_t *, zfs_uio_t *, int, cred_t *);

/*
* Direct I/O page-pinning setup. Pins user pages for O_DIRECT reads,
* enforces alignment, and skips DIO for mmap'd or encrypted ranges.
* Returns 0 and sets UIO_DIRECT in uio->uio_extflg on success.
*/
extern int zfs_setup_direct(struct znode *, zfs_uio_t *, zfs_uio_rw_t, int *);

/*
* Clear the SUID/SGID bits after a write by non-owner.
* Called from the async write completion path (zfs_vnops_os.c on Linux)
* as well as from the synchronous zfs_write().
*/
extern void zfs_clear_setid_bits_if_necessary(zfsvfs_t *, znode_t *, cred_t *,
uint64_t *, dmu_tx_t *);

extern int zfs_holey(znode_t *, ulong_t, loff_t *);
extern int zfs_access(znode_t *, int, int, cred_t *);
extern int zfs_clone_range(znode_t *, uint64_t *, znode_t *, uint64_t *,
Expand Down
1 change: 1 addition & 0 deletions module/Kbuild.in
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ ZFS_OBJS := \

ZFS_OBJS_OS := \
abd_os.o \
dmu_direct_os.o \
arc_os.o \
kasan_compat.o \
mmp_os.o \
Expand Down
Loading
Loading