Repository navigation
os/bluestore: fix deferred_aio deadlock - #16051
Merged
Merged
Conversation
xiexingguo
reviewed
Jul 1, 2017
We submit aios while holding deferred_lock, and we take deferred_lock in the aio completion handler (of which there is only 1). That means that if the aio queue fills up, the submitter will block with the lock while the finisher won't be able to take the lock, progress, and drain completed aios, leading to a deadlock. Fix this by submiting aios *without* deferred_lock held. Instead, demote to a deferred_submit_lock. Further, in the finisher, submit aios via a finisher (this only happens when in deferred_aggressive mode which is rare and not performance-sensitive). Signed-off-by: Sage Weil <[email protected]>
| dout(20) << __func__ << " queuing async deferred_try_submit" << dendl; | ||
| finishers[0]->queue(new FunctionContext([&](int) { | ||
| deferred_try_submit(); | ||
| })); |
Contributor
There was a problem hiding this comment.
if we use async 'deferred_try_submit' here, we actually don't need introduce 'deferred_submit_lock'? Because we'll not block in the aio completion handle.
Member
Author
|
The (other) problem is that any thread calling into deferred_submit holds deferred_lock and can block if the aio queue is full. And _deferred_aio_finish can block on that lock, preventing the aio queue from draining.
|
Contributor
|
@liewegas I understand now, thanks. What's more, seems introducing 'deferred_submit_lock' is better than throw the whole function of '_defer_aio_finisher' to a finisher queue. |
Member
Author
|
retest this please |
1 similar comment
Member
|
retest this please |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We submit aios while holding deferred_lock, and we take deferred_lock in
the aio completion handler (of which there is only 1). That means that
if the aio queue fills up, the submitter will block with the lock while
the finisher won't be able to take the lock, progress, and drain completed
aios, leading to a deadlock.
Fix this by submiting aios without deferred_lock held. Instead, demote
to a deferred_submit_lock. Further, in the finisher, submit aios
via a finisher (this only happens when in deferred_aggressive mode which
is rare and not performance-sensitive).
Signed-off-by: Sage Weil [email protected]