]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/FileJournal: Only using aio then alloc the related resources.
authorMa Jianpeng <jianpeng.ma@intel.com>
Thu, 21 Aug 2014 13:07:51 +0000 (21:07 +0800)
committerSage Weil <sage@redhat.com>
Tue, 21 Oct 2014 13:55:16 +0000 (06:55 -0700)
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 <jianpeng.ma@intel.com>
(cherry picked from commit a66a4931d5be9ee26c0983b3154fdbe37261a51c)

src/os/FileJournal.cc

index 387f38787ee83a59ce566dbaaf01a83baeb766ae..4b7971fa40c47a6e967c73ae6ab42a80b239e648 100644 (file)
@@ -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
 
@@ -605,7 +607,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
 }
 
@@ -614,19 +617,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
 }