Skip to content

os/bluestore: fix deferred_aio deadlock - #16051

Merged
tchaikov merged 1 commit into
ceph:masterfrom
liewegas:wip-20381
Jul 5, 2017
Merged

tchaikov merged 1 commit into
ceph:masterfrom
liewegas:wip-20381

Conversation

@liewegas

Copy link
Copy Markdown
Member

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]

Comment thread src/os/bluestore/BlueStore.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

vector?

@xiexingguo xiexingguo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

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();
}));

@tanghaodong25 tanghaodong25 Jul 1, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@liewegas

liewegas commented Jul 1, 2017 via email

Copy link
Copy Markdown
Member Author

@tanghaodong25

Copy link
Copy Markdown
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.

@liewegas

liewegas commented Jul 3, 2017

Copy link
Copy Markdown
Member Author

retest this please

1 similar comment
@xiexingguo

Copy link
Copy Markdown
Member

retest this please

@tchaikov
tchaikov merged commit 33b68a4 into ceph:master Jul 5, 2017
@liewegas
liewegas deleted the wip-20381 branch July 7, 2017 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants