mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Add interface to interface spa_get_worst_case_min_alloc() function
Provide an interface to retrieve the lowest and highest minimum allocation size for the normal allocation class. This can be used by external consumers of the DMU to estimate potential wasted capacity when setting the recordsize for an object. The new "min_alloc" and "max_alloc" keys are added to the pool configuration and used by default_volblocksize() to warn when an ineffecient block size is requested. For older kmods which don't yet include the new keys fallback to the previous logic. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #17758
This commit is contained in:
@@ -372,6 +372,8 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
|
||||
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG, txg);
|
||||
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID, spa_guid(spa));
|
||||
fnvlist_add_uint64(config, ZPOOL_CONFIG_ERRATA, spa->spa_errata);
|
||||
fnvlist_add_uint64(config, ZPOOL_CONFIG_MIN_ALLOC, spa->spa_min_alloc);
|
||||
fnvlist_add_uint64(config, ZPOOL_CONFIG_MAX_ALLOC, spa->spa_max_alloc);
|
||||
if (spa->spa_comment != NULL)
|
||||
fnvlist_add_string(config, ZPOOL_CONFIG_COMMENT,
|
||||
spa->spa_comment);
|
||||
|
||||
@@ -806,6 +806,7 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
|
||||
spa->spa_min_ashift = INT_MAX;
|
||||
spa->spa_max_ashift = 0;
|
||||
spa->spa_min_alloc = INT_MAX;
|
||||
spa->spa_max_alloc = 0;
|
||||
spa->spa_gcd_alloc = INT_MAX;
|
||||
|
||||
/* Reset cached value */
|
||||
@@ -1864,6 +1865,19 @@ spa_get_worst_case_asize(spa_t *spa, uint64_t lsize)
|
||||
return (MAX(lsize, 1 << spa->spa_max_ashift) * spa_asize_inflation);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the range of minimum allocation sizes for the normal allocation
|
||||
* class. This can be used by external consumers of the DMU to estimate
|
||||
* potential wasted capacity when setting the recordsize for an object.
|
||||
* This is mainly for dRAID pools which always pad to a full stripe width.
|
||||
*/
|
||||
void
|
||||
spa_get_min_alloc_range(spa_t *spa, uint64_t *min_alloc, uint64_t *max_alloc)
|
||||
{
|
||||
*min_alloc = spa->spa_min_alloc;
|
||||
*max_alloc = spa->spa_max_alloc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the amount of slop space in bytes. It is typically 1/32 of the pool
|
||||
* (3.2%), minus the embedded log space. On very small pools, it may be
|
||||
@@ -3085,6 +3099,7 @@ EXPORT_SYMBOL(spa_version);
|
||||
EXPORT_SYMBOL(spa_state);
|
||||
EXPORT_SYMBOL(spa_load_state);
|
||||
EXPORT_SYMBOL(spa_freeze_txg);
|
||||
EXPORT_SYMBOL(spa_get_min_alloc_range); /* for Lustre */
|
||||
EXPORT_SYMBOL(spa_get_dspace);
|
||||
EXPORT_SYMBOL(spa_update_dspace);
|
||||
EXPORT_SYMBOL(spa_deflate);
|
||||
|
||||
+8
-7
@@ -1497,12 +1497,14 @@ vdev_spa_set_alloc(spa_t *spa, uint64_t min_alloc)
|
||||
{
|
||||
if (min_alloc < spa->spa_min_alloc)
|
||||
spa->spa_min_alloc = min_alloc;
|
||||
if (spa->spa_gcd_alloc == INT_MAX) {
|
||||
|
||||
if (min_alloc > spa->spa_max_alloc)
|
||||
spa->spa_max_alloc = min_alloc;
|
||||
|
||||
if (spa->spa_gcd_alloc == INT_MAX)
|
||||
spa->spa_gcd_alloc = min_alloc;
|
||||
} else {
|
||||
spa->spa_gcd_alloc = vdev_gcd(min_alloc,
|
||||
spa->spa_gcd_alloc);
|
||||
}
|
||||
else
|
||||
spa->spa_gcd_alloc = vdev_gcd(min_alloc, spa->spa_gcd_alloc);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1560,8 +1562,7 @@ vdev_metaslab_group_create(vdev_t *vd)
|
||||
if (vd->vdev_ashift < spa->spa_min_ashift)
|
||||
spa->spa_min_ashift = vd->vdev_ashift;
|
||||
|
||||
uint64_t min_alloc = vdev_get_min_alloc(vd);
|
||||
vdev_spa_set_alloc(spa, min_alloc);
|
||||
vdev_spa_set_alloc(spa, vdev_get_min_alloc(vd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,6 +511,8 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats,
|
||||
fnvlist_add_uint64(nv, ZPOOL_CONFIG_ASHIFT, vd->vdev_ashift);
|
||||
fnvlist_add_uint64(nv, ZPOOL_CONFIG_ASIZE,
|
||||
vd->vdev_asize);
|
||||
fnvlist_add_uint64(nv, ZPOOL_CONFIG_MIN_ALLOC,
|
||||
vdev_get_min_alloc(vd));
|
||||
fnvlist_add_uint64(nv, ZPOOL_CONFIG_IS_LOG, vd->vdev_islog);
|
||||
if (vd->vdev_noalloc) {
|
||||
fnvlist_add_uint64(nv, ZPOOL_CONFIG_NONALLOCATING,
|
||||
|
||||
Reference in New Issue
Block a user