mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 03:08:51 +03:00
Implement allocation size ranges and use for gang leaves (#17111)
When forced to resort to ganging, ZFS currently allocates three child blocks, each one third of the size of the original. This is true regardless of whether larger allocations could be made, which would allow us to have fewer gang leaves. This improves performance when fragmentation is high enough to require ganging, but not so high that all the free ranges are only just big enough to hold a third of the recordsize. This is also useful for improving the behavior of a future change to allow larger gang headers. We add the ability for the allocation codepath to allocate a range of sizes instead of a single fixed size. We then use this to pre-allocate the DVAs for the gang children. If those allocations fail, we fall back to the normal write path, which will likely re-gang. Signed-off-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Co-authored-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
+20
-2
@@ -323,6 +323,19 @@ vdev_derive_alloc_bias(const char *bias)
|
||||
return (alloc_bias);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
vdev_default_psize(vdev_t *vd, uint64_t asize, uint64_t txg)
|
||||
{
|
||||
ASSERT0(asize % (1ULL << vd->vdev_top->vdev_ashift));
|
||||
uint64_t csize, psize = asize;
|
||||
for (int c = 0; c < vd->vdev_children; c++) {
|
||||
csize = vdev_asize_to_psize_txg(vd->vdev_child[c], asize, txg);
|
||||
psize = MIN(psize, csize);
|
||||
}
|
||||
|
||||
return (psize);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default asize function: return the MAX of psize with the asize of
|
||||
* all children. This is what's used by anything other than RAID-Z.
|
||||
@@ -4135,17 +4148,22 @@ vdev_sync(vdev_t *vd, uint64_t txg)
|
||||
(void) txg_list_add(&spa->spa_vdev_txg_list, vd, TXG_CLEAN(txg));
|
||||
dmu_tx_commit(tx);
|
||||
}
|
||||
uint64_t
|
||||
vdev_asize_to_psize_txg(vdev_t *vd, uint64_t asize, uint64_t txg)
|
||||
{
|
||||
return (vd->vdev_ops->vdev_op_asize_to_psize(vd, asize, txg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the amount of space that should be (or was) allocated for the given
|
||||
* psize (compressed block size) in the given TXG. Note that for expanded
|
||||
* RAIDZ vdevs, the size allocated for older BP's may be larger. See
|
||||
* vdev_raidz_asize().
|
||||
* vdev_raidz_psize_to_asize().
|
||||
*/
|
||||
uint64_t
|
||||
vdev_psize_to_asize_txg(vdev_t *vd, uint64_t psize, uint64_t txg)
|
||||
{
|
||||
return (vd->vdev_ops->vdev_op_asize(vd, psize, txg));
|
||||
return (vd->vdev_ops->vdev_op_psize_to_asize(vd, psize, txg));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
||||
Reference in New Issue
Block a user