mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add prefetch property
ZFS prefetch is currently governed by the zfs_prefetch_disable tunable. However, this is a module-wide settings - if a specific dataset benefits from prefetch, while others have issue with it, an optimal solution does not exists. This commit introduce the "prefetch" tri-state property, which enable granular control (at dataset/volume level) for prefetching. This patch does not remove the zfs_prefetch_disable, which remains a system-wide switch for enable/disable prefetch. However, to avoid duplication, it would be preferable to deprecate and then remove the module tunable. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ameer Hamza <ahamza@ixsystems.com> Signed-off-by: Gionatan Danti <g.danti@assyoma.it> Co-authored-by: Gionatan Danti <g.danti@assyoma.it> Closes #15237 Closes #15436
This commit is contained in:
@@ -263,6 +263,19 @@ secondary_cache_changed_cb(void *arg, uint64_t newval)
|
||||
os->os_secondary_cache = newval;
|
||||
}
|
||||
|
||||
static void
|
||||
prefetch_changed_cb(void *arg, uint64_t newval)
|
||||
{
|
||||
objset_t *os = arg;
|
||||
|
||||
/*
|
||||
* Inheritance should have been done by now.
|
||||
*/
|
||||
ASSERT(newval == ZFS_PREFETCH_ALL || newval == ZFS_PREFETCH_NONE ||
|
||||
newval == ZFS_PREFETCH_METADATA);
|
||||
os->os_prefetch = newval;
|
||||
}
|
||||
|
||||
static void
|
||||
sync_changed_cb(void *arg, uint64_t newval)
|
||||
{
|
||||
@@ -562,6 +575,11 @@ dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
|
||||
zfs_prop_to_name(ZFS_PROP_SECONDARYCACHE),
|
||||
secondary_cache_changed_cb, os);
|
||||
}
|
||||
if (err == 0) {
|
||||
err = dsl_prop_register(ds,
|
||||
zfs_prop_to_name(ZFS_PROP_PREFETCH),
|
||||
prefetch_changed_cb, os);
|
||||
}
|
||||
if (!ds->ds_is_snapshot) {
|
||||
if (err == 0) {
|
||||
err = dsl_prop_register(ds,
|
||||
@@ -635,6 +653,7 @@ dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
|
||||
os->os_primary_cache = ZFS_CACHE_ALL;
|
||||
os->os_secondary_cache = ZFS_CACHE_ALL;
|
||||
os->os_dnodesize = DNODE_MIN_SIZE;
|
||||
os->os_prefetch = ZFS_PREFETCH_ALL;
|
||||
}
|
||||
|
||||
if (ds == NULL || !ds->ds_is_snapshot)
|
||||
|
||||
@@ -329,9 +329,14 @@ dmu_zfetch_prepare(zfetch_t *zf, uint64_t blkid, uint64_t nblks,
|
||||
{
|
||||
zstream_t *zs;
|
||||
spa_t *spa = zf->zf_dnode->dn_objset->os_spa;
|
||||
zfs_prefetch_type_t os_prefetch = zf->zf_dnode->dn_objset->os_prefetch;
|
||||
|
||||
if (zfs_prefetch_disable)
|
||||
if (zfs_prefetch_disable || os_prefetch == ZFS_PREFETCH_NONE)
|
||||
return (NULL);
|
||||
|
||||
if (os_prefetch == ZFS_PREFETCH_METADATA)
|
||||
fetch_data = B_FALSE;
|
||||
|
||||
/*
|
||||
* If we haven't yet loaded the indirect vdevs' mappings, we
|
||||
* can only read from blocks that we carefully ensure are on
|
||||
|
||||
Reference in New Issue
Block a user