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>
void FileJournal::start_writer()
{
write_stop = false;
+ aio_stop = false;
write_thread.create();
#ifdef HAVE_LIBAIO
if (aio)
{
{
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
{
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);
// write thread
Mutex write_lock;
bool write_stop;
+ bool aio_stop;
Cond commit_cond;
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() {