Skip to content

Commit 8616e2d

Browse files
committed
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 to large structores to heap. Signed-off-by: Mariusz Zaborski <[email protected]> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc.
1 parent d816bc5 commit 8616e2d

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
@@ -860,7 +860,7 @@ void
860860
dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
861861
{
862862
zap_cursor_t zc, pzc;
863-
zap_attribute_t za, pza;
863+
zap_attribute_t *za, *pza;
864864
dmu_buf_t *bonus;
865865
dsl_deadlist_phys_t *dlp;
866866
dmu_object_info_t doi;
@@ -875,28 +875,31 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
875875
return;
876876
}
877877

878+
za = kmem_alloc(sizeof (*za), KM_SLEEP);
879+
pza = kmem_alloc(sizeof (*pza), KM_SLEEP);
880+
878881
mutex_enter(&dl->dl_lock);
879882
/*
880883
* Prefetch up to 128 deadlists first and then more as we progress.
881884
* The limit is a balance between ARC use and diminishing returns.
882885
*/
883886
for (zap_cursor_init(&pzc, dl->dl_os, obj), i = 0;
884-
(perror = zap_cursor_retrieve(&pzc, &pza)) == 0 && i < 128;
887+
(perror = zap_cursor_retrieve(&pzc, pza)) == 0 && i < 128;
885888
zap_cursor_advance(&pzc), i++) {
886-
dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer,
887-
zfs_strtonum(pza.za_name, NULL));
889+
dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer,
890+
zfs_strtonum(pza->za_name, NULL));
888891
}
889892
for (zap_cursor_init(&zc, dl->dl_os, obj);
890-
(error = zap_cursor_retrieve(&zc, &za)) == 0;
893+
(error = zap_cursor_retrieve(&zc, za)) == 0;
891894
zap_cursor_advance(&zc)) {
892-
uint64_t mintxg = zfs_strtonum(za.za_name, NULL);
893-
dsl_deadlist_insert_bpobj(dl, za.za_first_integer, mintxg, tx);
895+
uint64_t mintxg = zfs_strtonum(za->za_name, NULL);
896+
dsl_deadlist_insert_bpobj(dl, za->za_first_integer, mintxg, tx);
894897
VERIFY0(zap_remove_int(dl->dl_os, obj, mintxg, tx));
895898
if (perror == 0) {
896-
dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer,
897-
zfs_strtonum(pza.za_name, NULL));
899+
dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer,
900+
zfs_strtonum(pza->za_name, NULL));
898901
zap_cursor_advance(&pzc);
899-
perror = zap_cursor_retrieve(&pzc, &pza);
902+
perror = zap_cursor_retrieve(&pzc, pza);
900903
}
901904
}
902905
VERIFY3U(error, ==, ENOENT);
@@ -909,6 +912,9 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
909912
memset(dlp, 0, sizeof (*dlp));
910913
dmu_buf_rele(bonus, FTAG);
911914
mutex_exit(&dl->dl_lock);
915+
916+
kmem_free(za, sizeof (*za));
917+
kmem_free(pza, sizeof (*pza));
912918
}
913919

914920
/*

0 commit comments

Comments
 (0)