diff --git a/module/zfs/dmu_redact.c b/module/zfs/dmu_redact.c index 1c5f1bd248..b091df9257 100644 --- a/module/zfs/dmu_redact.c +++ b/module/zfs/dmu_redact.c @@ -1006,10 +1006,14 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, objset_t *os; struct redact_thread_arg *args = NULL; redaction_list_t *new_rl = NULL; + char *newredactbook; if ((err = dsl_pool_hold(snapname, FTAG, &dp)) != 0) return (err); + newredactbook = kmem_zalloc(sizeof (char) * ZFS_MAX_DATASET_NAME_LEN, + KM_SLEEP); + if ((err = dsl_dataset_hold_flags(dp, snapname, DS_HOLD_FLAG_DECRYPT, FTAG, &ds)) != 0) { goto out; @@ -1063,7 +1067,6 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, goto out; boolean_t resuming = B_FALSE; - char newredactbook[ZFS_MAX_DATASET_NAME_LEN]; zfs_bookmark_phys_t bookmark; (void) strlcpy(newredactbook, snapname, ZFS_MAX_DATASET_NAME_LEN); @@ -1073,6 +1076,8 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, "#%s", redactbook); if (n >= ZFS_MAX_DATASET_NAME_LEN - (c - newredactbook)) { dsl_pool_rele(dp, FTAG); + kmem_free(newredactbook, + sizeof (char) * ZFS_MAX_DATASET_NAME_LEN); return (SET_ERROR(ENAMETOOLONG)); } err = dsl_bookmark_lookup(dp, newredactbook, NULL, &bookmark); @@ -1145,16 +1150,23 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, (void) thread_create(NULL, 0, redact_traverse_thread, rta, 0, curproc, TS_RUN, minclsyspri); } - struct redact_merge_thread_arg rmta = { { {0} } }; - (void) bqueue_init(&rmta.q, zfs_redact_queue_ff, + + struct redact_merge_thread_arg *rmta; + rmta = kmem_zalloc(sizeof (struct redact_merge_thread_arg), KM_SLEEP); + + (void) bqueue_init(&rmta->q, zfs_redact_queue_ff, zfs_redact_queue_length, offsetof(struct redact_record, ln)); - rmta.numsnaps = numsnaps; - rmta.spa = os->os_spa; - rmta.thr_args = args; - (void) thread_create(NULL, 0, redact_merge_thread, &rmta, 0, curproc, + rmta->numsnaps = numsnaps; + rmta->spa = os->os_spa; + rmta->thr_args = args; + (void) thread_create(NULL, 0, redact_merge_thread, rmta, 0, curproc, TS_RUN, minclsyspri); - err = perform_redaction(os, new_rl, &rmta); + err = perform_redaction(os, new_rl, rmta); + kmem_free(rmta, sizeof (struct redact_merge_thread_arg)); + out: + kmem_free(newredactbook, sizeof (char) * ZFS_MAX_DATASET_NAME_LEN); + if (new_rl != NULL) { dsl_redaction_list_long_rele(new_rl, FTAG); dsl_redaction_list_rele(new_rl, FTAG);