From 8616e2d109936da194a56a241c8a5905a4da896e Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Fri, 24 Feb 2023 18:08:44 +0100 Subject: [PATCH] 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 Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. --- module/zfs/dsl_deadlist.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/module/zfs/dsl_deadlist.c b/module/zfs/dsl_deadlist.c index d58820701f60..25adea37fbf5 100644 --- a/module/zfs/dsl_deadlist.c +++ b/module/zfs/dsl_deadlist.c @@ -860,7 +860,7 @@ void dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx) { zap_cursor_t zc, pzc; - zap_attribute_t za, pza; + zap_attribute_t *za, *pza; dmu_buf_t *bonus; dsl_deadlist_phys_t *dlp; dmu_object_info_t doi; @@ -875,28 +875,31 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx) return; } + za = kmem_alloc(sizeof (*za), KM_SLEEP); + pza = kmem_alloc(sizeof (*pza), KM_SLEEP); + mutex_enter(&dl->dl_lock); /* * Prefetch up to 128 deadlists first and then more as we progress. * The limit is a balance between ARC use and diminishing returns. */ 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++) { - dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer, - zfs_strtonum(pza.za_name, NULL)); + dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer, + zfs_strtonum(pza->za_name, NULL)); } 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)) { - uint64_t mintxg = zfs_strtonum(za.za_name, NULL); - dsl_deadlist_insert_bpobj(dl, za.za_first_integer, mintxg, tx); + uint64_t mintxg = zfs_strtonum(za->za_name, NULL); + dsl_deadlist_insert_bpobj(dl, za->za_first_integer, mintxg, tx); VERIFY0(zap_remove_int(dl->dl_os, obj, mintxg, tx)); if (perror == 0) { - dsl_deadlist_prefetch_bpobj(dl, pza.za_first_integer, - zfs_strtonum(pza.za_name, NULL)); + dsl_deadlist_prefetch_bpobj(dl, pza->za_first_integer, + zfs_strtonum(pza->za_name, NULL)); zap_cursor_advance(&pzc); - perror = zap_cursor_retrieve(&pzc, &pza); + perror = zap_cursor_retrieve(&pzc, pza); } } 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)); dmu_buf_rele(bonus, FTAG); mutex_exit(&dl->dl_lock); + + kmem_free(za, sizeof (*za)); + kmem_free(pza, sizeof (*pza)); } /*