Skip to content

Commit

Permalink
os/FileJournal: stop aio completion thread *after* writer thread
Browse files Browse the repository at this point in the history
The writer thread may submit a new aio to update the header in its
final moments before shutting down.  Do not stop the aio thread until after
that has happened or else we may not wait for those aio completions.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Aug 30, 2014
1 parent 67c552b commit c776a89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/os/FileJournal.cc
Expand Up @@ -605,6 +605,7 @@ int FileJournal::dump(ostream& out)
void FileJournal::start_writer()
{
write_stop = false;
aio_stop = false;
write_thread.create();
#ifdef HAVE_LIBAIO
if (aio)
Expand All @@ -616,24 +617,21 @@ void FileJournal::stop_writer()
{
{
Mutex::Locker l(write_lock);
#ifdef HAVE_LIBAIO
if (aio)
aio_lock.Lock();
#endif
Mutex::Locker p(writeq_lock);
write_stop = true;
writeq_cond.Signal();
#ifdef HAVE_LIBAIO
if (aio) {
aio_cond.Signal();
write_finish_cond.Signal();
aio_lock.Unlock();
}
#endif
}
}
write_thread.join();

#ifdef HAVE_LIBAIO
// stop aio completeion thread *after* writer thread has stopped
// and has submitted all of its io
if (aio) {
aio_lock.Lock();
aio_stop = true;
aio_cond.Signal();
write_finish_cond.Signal();
aio_lock.Unlock();
write_finish_thread.join();
}
#endif
Expand Down Expand Up @@ -1341,7 +1339,7 @@ void FileJournal::write_finish_thread_entry()
{
Mutex::Locker locker(aio_lock);
if (aio_queue.empty()) {
if (write_stop)
if (aio_stop)
break;
dout(20) << "write_finish_thread_entry sleeping" << dendl;
write_finish_cond.Wait(aio_lock);
Expand Down
2 changes: 2 additions & 0 deletions src/os/FileJournal.h
Expand Up @@ -287,6 +287,7 @@ class FileJournal : public Journal {
// write thread
Mutex write_lock;
bool write_stop;
bool aio_stop;

Cond commit_cond;

Expand Down Expand Up @@ -378,6 +379,7 @@ class FileJournal : public Journal {
throttle_bytes(g_ceph_context, "filestore_bytes"),
write_lock("FileJournal::write_lock", false, true, false, g_ceph_context),
write_stop(false),
aio_stop(false),
write_thread(this),
write_finish_thread(this) { }
~FileJournal() {
Expand Down

0 comments on commit c776a89

Please sign in to comment.