From ecff3761f3d15061a2cbf0a595ca249a4c424f4c Mon Sep 17 00:00:00 2001 From: Ma Jianpeng Date: Thu, 21 Aug 2014 15:10:46 +0800 Subject: [PATCH] os/FileJournal: For journal-aio-mode, don't use aio when closing journal. For jouranl-aio-mode when closing journal, the write_finish_thread_entry may exit before write_thread_entry. This cause no one wait last aios to complete. On some platform, after that the journal-header on journal corrupted. To avoid this, when closing jouranl we don't use aio. Fixes: 9073 Reported-by: Mark Kirkwood Tested-by: Mark Kirkwood Signed-off-by: Ma Jianpeng (cherry picked from commit e870fd09ce846e5642db268c33bbe8e2e17ffef2) --- src/os/FileJournal.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 4b7971fa40c47..da930eb936ba2 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -1125,7 +1125,9 @@ void FileJournal::write_thread_entry() } #ifdef HAVE_LIBAIO - if (aio) { + //We hope write_finish_thread_entry return until the last aios complete + //when set write_stop. But it can't. So don't use aio mode when shutdown. + if (aio && !write_stop) { Mutex::Locker locker(aio_lock); // should we back off to limit aios in flight? try to do this // adaptively so that we submit larger aios once we have lots of @@ -1176,7 +1178,7 @@ void FileJournal::write_thread_entry() } #ifdef HAVE_LIBAIO - if (aio) + if (aio && !write_stop) do_aio_write(bl); else do_write(bl); -- 2.39.5