mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 02:49:32 +03:00
Fix stack ddt_class_contains()
Stack usage for ddt_class_contains() reduced from 524 bytes to 68 bytes. This large stack allocation significantly contributed to the likelyhood of a stack overflow when scrubbing/resilvering dedup pools.
This commit is contained in:
parent
5b8c7bbcea
commit
e95b3bdcbb
@ -891,7 +891,7 @@ boolean_t
|
|||||||
ddt_class_contains(spa_t *spa, enum ddt_class max_class, const blkptr_t *bp)
|
ddt_class_contains(spa_t *spa, enum ddt_class max_class, const blkptr_t *bp)
|
||||||
{
|
{
|
||||||
ddt_t *ddt;
|
ddt_t *ddt;
|
||||||
ddt_entry_t dde;
|
ddt_entry_t *dde;
|
||||||
enum ddt_type type;
|
enum ddt_type type;
|
||||||
enum ddt_class class;
|
enum ddt_class class;
|
||||||
|
|
||||||
@ -902,14 +902,20 @@ ddt_class_contains(spa_t *spa, enum ddt_class max_class, const blkptr_t *bp)
|
|||||||
return (B_TRUE);
|
return (B_TRUE);
|
||||||
|
|
||||||
ddt = spa->spa_ddt[BP_GET_CHECKSUM(bp)];
|
ddt = spa->spa_ddt[BP_GET_CHECKSUM(bp)];
|
||||||
|
dde = kmem_alloc(sizeof(ddt_entry_t), KM_SLEEP);
|
||||||
|
|
||||||
ddt_key_fill(&dde.dde_key, bp);
|
ddt_key_fill(&(dde->dde_key), bp);
|
||||||
|
|
||||||
for (type = 0; type < DDT_TYPES; type++)
|
for (type = 0; type < DDT_TYPES; type++) {
|
||||||
for (class = 0; class <= max_class; class++)
|
for (class = 0; class <= max_class; class++) {
|
||||||
if (ddt_object_lookup(ddt, type, class, &dde) == 0)
|
if (ddt_object_lookup(ddt, type, class, dde) == 0) {
|
||||||
|
kmem_free(dde, sizeof(ddt_entry_t));
|
||||||
return (B_TRUE);
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kmem_free(dde, sizeof(ddt_entry_t));
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user