openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.42k stars 1.72k forks source link

zfs redact panics in bqueue_destroy #14053

Closed lundman closed 1 year ago

lundman commented 1 year ago

https://github.com/openzfs/zfs/blob/master/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh#L221

log_must zfs redact "$DATASET@$TESTSNAP" "$TESTBM" "$DATASET@$TESTSNAP2"

1øÿÿ: mutex not m_initialised

    OpenZFS!panic+0x4e [C:\src\openzfs\module\os\windows\spl\spl-debug.c @ 32]  C/C++/ASM
    OpenZFS!spl_mutex_enter+0x3c [C:\src\openzfs\module\os\windows\spl\spl-mutex.c @ 118]   C/C++/ASM
    OpenZFS!bqueue_destroy+0x17 [C:\src\openzfs\module\zfs\bqueue.c @ 71]   C/C++/ASM
>   OpenZFS!perform_thread_merge+0x503 [C:\src\openzfs\module\zfs\dmu_redact.c @ 829]   C/C++/ASM
    OpenZFS!redact_merge_thread+0x40 [C:\src\openzfs\module\zfs\dmu_redact.c @ 850] C/C++/ASM
    nt!PspSystemThreadStartup+0x55  C/C++/ASM
    nt!KiStartSystemThread+0x28 C/C++/ASM
    avl_destroy(&start_tree);
    avl_destroy(&end_tree);
    kmem_free(redact_nodes, num_threads * sizeof (*redact_nodes));
    if (current_record != NULL)
        bqueue_enqueue(q, current_record, sizeof (*current_record));

    for (int i = 0; i < num_threads; i++) {
        struct redact_thread_arg *targ = &thread_args[i];
>>      bqueue_destroy(&targ->q);
    }
lundman commented 1 year ago

Aha, this is due to essentially "two" versions of dmu_redact.c does not call bqueue_destroy the first version I did to fix it, and the version that eventually landed in upstream, so we were calling bqueue_destroy() twice in perform_thread_merge().