Skip to content

Commit 8e945eb

Browse files
committed
Relax zfs_vnops_read_chunk_size limitations
It makes no sense to limit read size below the block size, since DMU will any way consume resources for the whole block, while the current zfs_vnops_read_chunk_size is only 1MB, which is smaller that maximum block size of 16MB. Also while there, we don't need to align reads to the chunk size, but only to a block size, which is smaller and so more forgiving. My profiles show ~4% of CPU time saving when reading 16MB blocks. Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc.
1 parent 1085623 commit 8e945eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

module/zfs/zfs_vnops.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ zfs_read(struct znode *zp, zfs_uio_t *uio, int ioflag, cred_t *cr)
401401
#if defined(__linux__)
402402
ssize_t start_offset = zfs_uio_offset(uio);
403403
#endif
404-
ssize_t chunk_size = zfs_vnops_read_chunk_size;
404+
uint_t blksz = zp->z_blksz;
405+
ssize_t chunk_size;
405406
ssize_t n = MIN(zfs_uio_resid(uio), zp->z_size - zfs_uio_offset(uio));
406407
ssize_t start_resid = n;
407408
ssize_t dio_remaining_resid = 0;
@@ -432,11 +433,14 @@ zfs_read(struct znode *zp, zfs_uio_t *uio, int ioflag, cred_t *cr)
432433
if (dio_remaining_resid != 0)
433434
n -= dio_remaining_resid;
434435
dflags |= DMU_DIRECTIO;
436+
} else {
437+
chunk_size = MIN(MAX(zfs_vnops_read_chunk_size, blksz),
438+
DMU_MAX_ACCESS / 2);
435439
}
436440

437441
while (n > 0) {
438442
ssize_t nbytes = MIN(n, chunk_size -
439-
P2PHASE(zfs_uio_offset(uio), chunk_size));
443+
P2PHASE(zfs_uio_offset(uio), blksz));
440444
#ifdef UIO_NOCOPY
441445
if (zfs_uio_segflg(uio) == UIO_NOCOPY)
442446
error = mappedread_sf(zp, nbytes, uio);

0 commit comments

Comments
 (0)