Move zap_attribute_t to the heap in dsl_deadlist_merge

In the case of a regular compilation, the compiler
raises a warning for a dsl_deadlist_merge function, that
the stack size is to large. In debug build this can
generate an error.

Move large structures to heap.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mariusz Zaborski <mariusz.zaborski@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Closes #14524
This commit is contained in:
Mariusz Zaborski 2023-02-27 23:27:58 +01:00 committed by GitHub
parent 000985fc15
commit 3b9309aabe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -860,7 +860,7 @@ void
dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx) dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
{ {
zap_cursor_t zc, pzc; zap_cursor_t zc, pzc;
zap_attribute_t za, pza; zap_attribute_t *za, *pza;
dmu_buf_t *bonus; dmu_buf_t *bonus;
dsl_deadlist_phys_t *dlp; dsl_deadlist_phys_t *dlp;
dmu_object_info_t doi; dmu_object_info_t doi;
@ -875,28 +875,31 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
return; return;
} }
za = kmem_alloc(sizeof (*za), KM_SLEEP);
pza = kmem_alloc(sizeof (*pza), KM_SLEEP);
mutex_enter(&dl->dl_lock); mutex_enter(&dl->dl_lock);
/* /*
* Prefetch up to 128 deadlists first and then more as we progress. * Prefetch up to 128 deadlists first and then more as we progress.
* The limit is a balance between ARC use and diminishing returns. * The limit is a balance between ARC use and diminishing returns.
*/ */
for (zap_cursor_init(&pzc, dl->dl_os, obj), i = 0; for (zap_cursor_init(&pzc, dl->dl_os, obj), i = 0;
(perror = zap_cursor_retrieve(&pzc, &pza)) == 0 && i < 128; (perror = zap_cursor_retrieve(&pzc, pza)) == 0 && i < 128;
zap_cursor_advance(&pzc), i++) { zap_cursor_advance(&pzc), i++) {
dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer, dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer,
zfs_strtonum(pza.za_name, NULL)); zfs_strtonum(pza->za_name, NULL));
} }
for (zap_cursor_init(&zc, dl->dl_os, obj); for (zap_cursor_init(&zc, dl->dl_os, obj);
(error = zap_cursor_retrieve(&zc, &za)) == 0; (error = zap_cursor_retrieve(&zc, za)) == 0;
zap_cursor_advance(&zc)) { zap_cursor_advance(&zc)) {
uint64_t mintxg = zfs_strtonum(za.za_name, NULL); uint64_t mintxg = zfs_strtonum(za->za_name, NULL);
dsl_deadlist_insert_bpobj(dl, za.za_first_integer, mintxg, tx); dsl_deadlist_insert_bpobj(dl, za->za_first_integer, mintxg, tx);
VERIFY0(zap_remove_int(dl->dl_os, obj, mintxg, tx)); VERIFY0(zap_remove_int(dl->dl_os, obj, mintxg, tx));
if (perror == 0) { if (perror == 0) {
dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer, dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer,
zfs_strtonum(pza.za_name, NULL)); zfs_strtonum(pza->za_name, NULL));
zap_cursor_advance(&pzc); zap_cursor_advance(&pzc);
perror = zap_cursor_retrieve(&pzc, &pza); perror = zap_cursor_retrieve(&pzc, pza);
} }
} }
VERIFY3U(error, ==, ENOENT); VERIFY3U(error, ==, ENOENT);
@ -909,6 +912,9 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
memset(dlp, 0, sizeof (*dlp)); memset(dlp, 0, sizeof (*dlp));
dmu_buf_rele(bonus, FTAG); dmu_buf_rele(bonus, FTAG);
mutex_exit(&dl->dl_lock); mutex_exit(&dl->dl_lock);
kmem_free(za, sizeof (*za));
kmem_free(pza, sizeof (*pza));
} }
/* /*