mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
Add support for POSIX_FADV_DONTNEED
For now make it only evict the specified data from the dbuf cache. Even though dbuf cache is small, this may still reduce eviction of more useful data from there, and slightly accelerate ARC evictions by making the blocks there evictable a bit sooner. On FreeBSD this also adds support for POSIX_FADV_NOREUSE, since the kernel translates it into POSIX_FADV_DONTNEED after every read/write. This is not as efficient as it could be for ZFS, but that is the only way FreeBSD kernel allows to handle POSIX_FADV_NOREUSE now. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> Closes #18399
This commit is contained in:
committed by
Tony Hutter
parent
6f14581e1a
commit
4bb7592745
@@ -6748,10 +6748,12 @@ zfs_freebsd_advise(struct vop_advise_args *ap)
|
||||
dmu_prefetch(os, zp->z_id, 0, start, len,
|
||||
ZIO_PRIORITY_ASYNC_READ);
|
||||
break;
|
||||
case POSIX_FADV_DONTNEED:
|
||||
dmu_evict_range(os, zp->z_id, start, len);
|
||||
break;
|
||||
case POSIX_FADV_NORMAL:
|
||||
case POSIX_FADV_RANDOM:
|
||||
case POSIX_FADV_SEQUENTIAL:
|
||||
case POSIX_FADV_DONTNEED:
|
||||
case POSIX_FADV_NOREUSE:
|
||||
/* ignored for now */
|
||||
break;
|
||||
|
||||
@@ -789,11 +789,17 @@ zpl_fadvise(struct file *filp, loff_t offset, loff_t len, int advice)
|
||||
}
|
||||
}
|
||||
|
||||
zfs_exit(zfsvfs, FTAG);
|
||||
|
||||
#ifdef HAVE_GENERIC_FADVISE
|
||||
error = generic_fadvise(filp, offset, len, advice);
|
||||
#endif
|
||||
|
||||
if (error == 0 && advice == POSIX_FADV_DONTNEED) {
|
||||
loff_t rlen = len ? len : i_size_read(ip) - offset;
|
||||
dmu_evict_range(os, zp->z_id, offset, rlen);
|
||||
}
|
||||
|
||||
zfs_exit(zfsvfs, FTAG);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user