]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: fix potential race when closing object recorder 26425/head
authorMykola Golub <mgolub@suse.com>
Thu, 14 Feb 2019 10:57:37 +0000 (12:57 +0200)
committerMykola Golub <mgolub@suse.com>
Thu, 14 Feb 2019 10:59:00 +0000 (12:59 +0200)
Calls `send_appends_aio` only if m_pending_buffers is not
empty. It was supposed it was ok to call it even for empty
buffers, because `send_appends_aio` just returned in this
case. But the problem is caused by m_aio_scheduled flag, which is
set before releasing the lock and cleared in `send_appends_aio`,
after reacquiring the lock. If during this time window `close` is
called it will return false due to m_aio_scheduled flag set, and
the caller will expect "closed" notification, which is never
fired in this case.

Fixes: https://tracker.ceph.com/issues/38315
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/journal/ObjectRecorder.cc

index f39ca981cc0c70b603edfe85bb26d26bffb34bad..c78b7130886ab3b0bfbd785602c47e49e5cd6772 100644 (file)
@@ -303,10 +303,12 @@ void ObjectRecorder::handle_append_flushed(uint64_t tid, int r) {
       // all remaining unsent appends should be redirected to new object
       m_append_buffers.splice(m_append_buffers.begin(), m_pending_buffers);
       notify_handler_unlock();
-    } else {
+    } else if (!m_pending_buffers.empty()) {
       m_aio_scheduled = true;
       m_lock->Unlock();
       send_appends_aio();
+    } else {
+      m_lock->Unlock();
     }
   } else {
     m_lock->Unlock();