Skip to content

Commit

Permalink
journal: don't hold future lock during assignment
Browse files Browse the repository at this point in the history
It's possible that the future raced with its owner and reaches
an empty reference count. This was resulting in the future being
destructed while its lock was still held.

Fixes: http://tracker.ceph.com/issues/18618
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Jason Dillaman committed Jan 21, 2017
1 parent af9152f commit 0f21cee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/journal/FutureImpl.cc
Expand Up @@ -39,13 +39,12 @@ void FutureImpl::flush(Context *on_safe) {
m_contexts.push_back(on_safe);
}

prev_future = prepare_flush(&flush_handlers);
prev_future = prepare_flush(&flush_handlers, m_lock);
}
}

// instruct prior futures to flush as well
while (prev_future) {
Mutex::Locker locker(prev_future->m_lock);
prev_future = prev_future->prepare_flush(&flush_handlers);
}

Expand All @@ -62,6 +61,12 @@ void FutureImpl::flush(Context *on_safe) {
}

FutureImplPtr FutureImpl::prepare_flush(FlushHandlers *flush_handlers) {
Mutex::Locker locker(m_lock);
return prepare_flush(flush_handlers, m_lock);
}

FutureImplPtr FutureImpl::prepare_flush(FlushHandlers *flush_handlers,
Mutex &lock) {
assert(m_lock.is_locked());

if (m_flush_state == FLUSH_STATE_NONE) {
Expand Down
1 change: 1 addition & 0 deletions src/journal/FutureImpl.h
Expand Up @@ -113,6 +113,7 @@ class FutureImpl : public RefCountedObject, boost::noncopyable {
Contexts m_contexts;

FutureImplPtr prepare_flush(FlushHandlers *flush_handlers);
FutureImplPtr prepare_flush(FlushHandlers *flush_handlers, Mutex &lock);

void consistent(int r);
void finish_unlock();
Expand Down

0 comments on commit 0f21cee

Please sign in to comment.