Skip to content

Commit 7d26967

Browse files
oshogbobehlendorf
authored andcommitted
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes openzfs#14524
1 parent 93a99c6 commit 7d26967

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

module/zfs/dsl_deadlist.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ void
859859
dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
860860
{
861861
zap_cursor_t zc, pzc;
862-
zap_attribute_t za, pza;
862+
zap_attribute_t *za, *pza;
863863
dmu_buf_t *bonus;
864864
dsl_deadlist_phys_t *dlp;
865865
dmu_object_info_t doi;
@@ -874,28 +874,31 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
874874
return;
875875
}
876876

877+
za = kmem_alloc(sizeof (*za), KM_SLEEP);
878+
pza = kmem_alloc(sizeof (*pza), KM_SLEEP);
879+
877880
mutex_enter(&dl->dl_lock);
878881
/*
879882
* Prefetch up to 128 deadlists first and then more as we progress.
880883
* The limit is a balance between ARC use and diminishing returns.
881884
*/
882885
for (zap_cursor_init(&pzc, dl->dl_os, obj), i = 0;
883-
(perror = zap_cursor_retrieve(&pzc, &pza)) == 0 && i < 128;
886+
(perror = zap_cursor_retrieve(&pzc, pza)) == 0 && i < 128;
884887
zap_cursor_advance(&pzc), i++) {
885-
dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer,
886-
zfs_strtonum(pza.za_name, NULL));
888+
dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer,
889+
zfs_strtonum(pza->za_name, NULL));
887890
}
888891
for (zap_cursor_init(&zc, dl->dl_os, obj);
889-
(error = zap_cursor_retrieve(&zc, &za)) == 0;
892+
(error = zap_cursor_retrieve(&zc, za)) == 0;
890893
zap_cursor_advance(&zc)) {
891-
uint64_t mintxg = zfs_strtonum(za.za_name, NULL);
892-
dsl_deadlist_insert_bpobj(dl, za.za_first_integer, mintxg, tx);
894+
uint64_t mintxg = zfs_strtonum(za->za_name, NULL);
895+
dsl_deadlist_insert_bpobj(dl, za->za_first_integer, mintxg, tx);
893896
VERIFY0(zap_remove_int(dl->dl_os, obj, mintxg, tx));
894897
if (perror == 0) {
895-
dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer,
896-
zfs_strtonum(pza.za_name, NULL));
898+
dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer,
899+
zfs_strtonum(pza->za_name, NULL));
897900
zap_cursor_advance(&pzc);
898-
perror = zap_cursor_retrieve(&pzc, &pza);
901+
perror = zap_cursor_retrieve(&pzc, pza);
899902
}
900903
}
901904
VERIFY3U(error, ==, ENOENT);
@@ -908,6 +911,9 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
908911
bzero(dlp, sizeof (*dlp));
909912
dmu_buf_rele(bonus, FTAG);
910913
mutex_exit(&dl->dl_lock);
914+
915+
kmem_free(za, sizeof (*za));
916+
kmem_free(pza, sizeof (*pza));
911917
}
912918

913919
/*

0 commit comments

Comments
 (0)