Skip to content

Relax zfs_vnops_read_chunk_size limitations #17415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025
Merged
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
2 changes: 1 addition & 1 deletion man/man4/zfs.4
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ Disable QAT hardware acceleration for AES-GCM encryption.
May be unset after the ZFS modules have been loaded to initialize the QAT
hardware as long as support is compiled in and the QAT driver is present.
.
.It Sy zfs_vnops_read_chunk_size Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq u64
.It Sy zfs_vnops_read_chunk_size Ns = Ns Sy 33554432 Ns B Po 32 MiB Pc Pq u64
Bytes to read per chunk.
.
.It Sy zfs_read_history Ns = Ns Sy 0 Pq uint
Expand Down
12 changes: 10 additions & 2 deletions module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ static int zfs_dio_strict = 0;
/*
* Maximum bytes to read per chunk in zfs_read().
*/
#ifdef _ILP32
static uint64_t zfs_vnops_read_chunk_size = 1024 * 1024;
#else
static uint64_t zfs_vnops_read_chunk_size = DMU_MAX_ACCESS / 2;
#endif

int
zfs_fsync(znode_t *zp, int syncflag, cred_t *cr)
Expand Down Expand Up @@ -401,7 +405,8 @@ zfs_read(struct znode *zp, zfs_uio_t *uio, int ioflag, cred_t *cr)
#if defined(__linux__)
ssize_t start_offset = zfs_uio_offset(uio);
#endif
ssize_t chunk_size = zfs_vnops_read_chunk_size;
uint_t blksz = zp->z_blksz;
ssize_t chunk_size;
ssize_t n = MIN(zfs_uio_resid(uio), zp->z_size - zfs_uio_offset(uio));
ssize_t start_resid = n;
ssize_t dio_remaining_resid = 0;
Expand Down Expand Up @@ -432,11 +437,14 @@ zfs_read(struct znode *zp, zfs_uio_t *uio, int ioflag, cred_t *cr)
if (dio_remaining_resid != 0)
n -= dio_remaining_resid;
dflags |= DMU_DIRECTIO;
} else {
chunk_size = MIN(MAX(zfs_vnops_read_chunk_size, blksz),
DMU_MAX_ACCESS / 2);
}

while (n > 0) {
ssize_t nbytes = MIN(n, chunk_size -
P2PHASE(zfs_uio_offset(uio), chunk_size));
P2PHASE(zfs_uio_offset(uio), blksz));
#ifdef UIO_NOCOPY
if (zfs_uio_segflg(uio) == UIO_NOCOPY)
error = mappedread_sf(zp, nbytes, uio);
Expand Down