From 7d26967d4e32c335caeedeb0870a6d95d1361360 Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Mon, 27 Feb 2023 23:27:58 +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 large structures to heap. Reviewed-by: Richard Yao Reviewed-by: Brian Behlendorf Signed-off-by: Mariusz Zaborski Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #14524 --- 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 d5fe2ee568..9827eb1472 100644 --- a/module/zfs/dsl_deadlist.c +++ b/module/zfs/dsl_deadlist.c @@ -859,7 +859,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; @@ -874,28 +874,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); @@ -908,6 +911,9 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx) bzero(dlp, sizeof (*dlp)); dmu_buf_rele(bonus, FTAG); mutex_exit(&dl->dl_lock); + + kmem_free(za, sizeof (*za)); + kmem_free(pza, sizeof (*pza)); } /*