Skip to content

librbd/cache/pwl/ssd: avoid dispatch_deferred_writes() vs ~AbstractWriteLog() race - #71083

Merged
idryomov merged 1 commit into
ceph:mainfrom
idryomov:wip-77894
Aug 24, 2026
Merged

idryomov merged 1 commit into
ceph:mainfrom
idryomov:wip-77894

Conversation

@idryomov

Copy link
Copy Markdown
Contributor

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

…iteLog() race

In append_op_log_entries(), dispatch_deferred_writes() is called after
append_ops() returns.  This can result in a race between AbstractWriteLog
destructor and dispatch_deferred_writes() because all I/Os may complete
and append_ctx callback may run allowing AbstractWriteLog::shut_down()
to indicate completion before dispatch_deferred_writes() is called.

This race is problematic even if there aren't any deferred writes
(i.e. m_deferred_ios list is empty): a deadlock may pop up because
m_thread_pool is stopped by the destructor under the same lock that
dispatch_deferred_writes() needs to perform the initial check on
m_deferred_ios.

Call dispatch_deferred_writes() from append_ops() before the I/O batch
is submitted, similar to what was done previously in commit d83a0f6
("librbd/cache/pwl/ssd: avoid corrupting m_first_free_entry").  Since
dispatch_deferred_writes() appears to be called to act on a decremented
m_bytes_allocated, this doesn't change anything for it.  The ops.size()
condition has always been redundant as append_op_log_entries() asserts
on it and ops list remains constant.

Fixes: https://tracker.ceph.com/issues/77894
Signed-off-by: Ilya Dryomov <[email protected]>
@idryomov

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@sunyuechi

Copy link
Copy Markdown
Contributor

This is a better fix than the commits I had in #69898, which I've now dropped. Thanks!

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.

3 participants