mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 19:04:45 +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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user