Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dmu_redact.c does not call bqueue_destroy #11684

Closed
wants to merge 1 commit into from

Conversation

lundman
Copy link
Contributor

@lundman lundman commented Mar 3, 2021

Ensure all calls to bqueue_init() has a corresponding call to bqueue_destroy().

Motivation and Context

Leaking resources, avoiding panics.

Description

Weirdest fluke of things here, the bqueue structure would not call bqueue_destroy() which means the mutex members inside are never mutex_destroy()ed either. Memory is freed and later on re-used, in my case, but entirely unrelated memory, however, by chance the new memory use happened to have a mutex in the same offset, and would then panic due to mutex already initialised.

I had to guess a bit on the locations of the bqueue_destroy() calls, so hopefully I got it right.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
@ahrens ahrens requested a review from pcd1193182 March 3, 2021 16:56
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Mar 3, 2021
@behlendorf
Copy link
Contributor

@pcd1193182 would you mind taking a look at this.

for (int i = 0; i < num_threads; i++) {
struct redact_thread_arg *targ = &thread_args[i];
bqueue_destroy(&targ->q);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like we don't need this chunk. In dmu_redact_snap()->perform_redaction() we should wait until the redact_merge_thread completes at which point we'll exit perform_redaction() and destroy the bqueue with you other addition. Though I could be mistaken, @pcd1193182 can you confirm this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work, though I would move it up into the previous for loop where we call avl_remove for each worker thread.

This is destroying the worker threads' bqueues, which are different from the queue from the merge thread to the main thread, so we do need to have a separate destroy call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcd1193182 thanks for taking a look at this. @lundman if you can refresh the patch to incorporate Paul's feedback and rebase it on master we can get this merged.

for (int i = 0; i < num_threads; i++) {
struct redact_thread_arg *targ = &thread_args[i];
bqueue_destroy(&targ->q);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work, though I would move it up into the previous for loop where we call avl_remove for each worker thread.

This is destroying the worker threads' bqueues, which are different from the queue from the merge thread to the main thread, so we do need to have a separate destroy call.

@mmaybee mmaybee added Status: Revision Needed Changes are required for the PR to be accepted and removed Status: Code Review Needed Ready for review and testing labels May 24, 2021
@mmaybee
Copy link
Contributor

mmaybee commented May 24, 2021

Could you address Paul's feedback and we can get this merged.

@lundman
Copy link
Contributor Author

lundman commented May 24, 2021

Oh yeah, we deforked. I'll have to open a new PR

@lundman
Copy link
Contributor Author

lundman commented May 25, 2021

#12118

@lundman lundman closed this May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Revision Needed Changes are required for the PR to be accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants