From: Ma Jianpeng Date: Thu, 21 Aug 2014 13:07:51 +0000 (+0800) Subject: os/FileJournal: Only using aio then alloc the related resources. X-Git-Tag: v0.86~225^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F2304%2Fhead;p=ceph.git os/FileJournal: Only using aio then alloc the related resources. If define HAVE_LIBAIO, it alloc related resouces. But itt don't check whether using aio mode. Only using aio it alloc the related resources. Signed-off-by: Ma Jianpeng --- diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 2209fa29e9f5..e54dedbed4ce 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -103,12 +103,14 @@ int FileJournal::_open(bool forwrite, bool create) goto out_fd; #ifdef HAVE_LIBAIO - aio_ctx = 0; - ret = io_setup(128, &aio_ctx); - if (ret < 0) { - ret = errno; - derr << "FileJournal::_open: unable to setup io_context " << cpp_strerror(ret) << dendl; - goto out_fd; + if (aio) { + aio_ctx = 0; + ret = io_setup(128, &aio_ctx); + if (ret < 0) { + ret = errno; + derr << "FileJournal::_open: unable to setup io_context " << cpp_strerror(ret) << dendl; + goto out_fd; + } } #endif @@ -604,7 +606,8 @@ void FileJournal::start_writer() write_stop = false; write_thread.create(); #ifdef HAVE_LIBAIO - write_finish_thread.create(); + if (aio) + write_finish_thread.create(); #endif } @@ -613,19 +616,25 @@ void FileJournal::stop_writer() { Mutex::Locker l(write_lock); #ifdef HAVE_LIBAIO - Mutex::Locker q(aio_lock); + if (aio) + aio_lock.Lock(); #endif Mutex::Locker p(writeq_lock); write_stop = true; writeq_cond.Signal(); #ifdef HAVE_LIBAIO - aio_cond.Signal(); - write_finish_cond.Signal(); + if (aio) { + aio_cond.Signal(); + write_finish_cond.Signal(); + aio_lock.Unlock(); + } #endif } write_thread.join(); #ifdef HAVE_LIBAIO - write_finish_thread.join(); + if (aio) { + write_finish_thread.join(); + } #endif }